MuseScore/libmscore/dynamic.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

154 lines
4.2 KiB
C
Raw Normal View History

2012-05-26 14:26:10 +02:00
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2002-2011 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
#ifndef __DYNAMICS_H__
#define __DYNAMICS_H__
#include "text.h"
#include "mscore.h"
2013-05-13 18:49:17 +02:00
namespace Ms {
2012-05-26 14:26:10 +02:00
class Measure;
class Segment;
//-----------------------------------------------------------------------------
2012-07-25 11:49:34 +02:00
// @@ Dynamic
/// dynamics marker; determines midi velocity
//
// @P range enum (Dynamic.STAFF, .PART, .SYSTEM)
//-----------------------------------------------------------------------------
2012-05-26 14:26:10 +02:00
2017-12-27 11:51:00 +01:00
class Dynamic final : public TextBase
{
2019-05-28 14:52:14 +02:00
Q_GADGET
public:
enum class Type : char {
2014-05-21 15:44:16 +02:00
OTHER,
PPPPPP,
PPPPP,
PPPP,
PPP,
PP,
P,
MP,
MF,
F,
FF,
FFF,
FFFF,
FFFFF,
FFFFFF,
FP,
SF,
SFZ,
SFF,
SFFZ,
SFP,
SFPP,
RFZ,
RF,
FZ,
M,
R,
S,
Z
};
2020-05-26 15:54:26 +02:00
enum class Range : char {
STAFF, PART, SYSTEM
};
2020-05-26 15:54:26 +02:00
2018-12-22 11:43:23 +01:00
enum class Speed : char {
SLOW, NORMAL, FAST
};
2020-05-26 15:54:26 +02:00
2018-12-22 11:43:23 +01:00
struct ChangeSpeedItem {
Speed speed;
const char* name;
};
2020-05-26 15:54:26 +02:00
Q_ENUM(Type);
2020-05-26 15:54:26 +02:00
private:
Type _dynamicType;
2020-05-26 15:54:26 +02:00
2012-05-26 14:26:10 +02:00
mutable QPointF dragOffset;
int _velocity; // associated midi velocity 0-127
Range _dynRange; // STAFF, PART, SYSTEM
2020-05-26 15:54:26 +02:00
2018-12-22 11:43:23 +01:00
int _changeInVelocity { 128 };
Speed _velChangeSpeed { Speed::NORMAL };
2020-05-26 15:54:26 +02:00
2020-03-24 14:49:16 +01:00
QRectF drag(EditData&) override;
2020-05-26 15:54:26 +02:00
2012-05-26 14:26:10 +02:00
public:
Dynamic(Score*);
Dynamic(const Dynamic&);
2020-03-24 14:49:16 +01:00
Dynamic* clone() const override { return new Dynamic(*this); }
ElementType type() const override { return ElementType::DYNAMIC; }
Segment* segment() const { return (Segment*)parent(); }
Measure* measure() const { return (Measure*)parent()->parent(); }
2020-05-26 15:54:26 +02:00
void setDynamicType(Type val) { _dynamicType = val; }
void setDynamicType(const QString&);
static QString dynamicTypeName(Dynamic::Type type);
QString dynamicTypeName() const { return dynamicTypeName(_dynamicType); }
Type dynamicType() const { return _dynamicType; }
2020-03-24 14:49:16 +01:00
int subtype() const override { return static_cast<int>(_dynamicType); }
QString subtypeName() const override { return dynamicTypeName(); }
2020-05-26 15:54:26 +02:00
2020-03-24 14:49:16 +01:00
void layout() override;
void write(XmlWriter& xml) const override;
void read(XmlReader&) override;
2020-05-26 15:54:26 +02:00
2020-03-24 14:49:16 +01:00
bool isEditable() const override { return true; }
void startEdit(EditData&) override;
void endEdit(EditData&) override;
void reset() override;
2020-05-26 15:54:26 +02:00
2016-08-02 17:00:49 +02:00
void setVelocity(int v) { _velocity = v; }
2012-05-26 14:26:10 +02:00
int velocity() const;
Range dynRange() const { return _dynRange; }
void setDynRange(Range t) { _dynRange = t; }
void undoSetDynRange(Range t);
2020-05-26 15:54:26 +02:00
2018-12-22 11:43:23 +01:00
int changeInVelocity() const;
void setChangeInVelocity(int val);
Fraction velocityChangeLength() const;
bool isVelocityChangeAvailable() const;
2020-05-26 15:54:26 +02:00
2018-12-22 11:43:23 +01:00
Speed velChangeSpeed() const { return _velChangeSpeed; }
void setVelChangeSpeed(Speed val) { _velChangeSpeed = val; }
static QString speedToName(Speed speed);
static Speed nameToSpeed(QString name);
2020-05-26 15:54:26 +02:00
2020-03-24 14:49:16 +01:00
QVariant getProperty(Pid propertyId) const override;
bool setProperty(Pid propertyId, const QVariant&) override;
QVariant propertyDefault(Pid id) const override;
Pid propertyId(const QStringRef& xmlName) const override;
QString propertyUserValue(Pid) const override;
2020-05-26 15:54:26 +02:00
std::unique_ptr<ElementGroup> getDragGroup(std::function<bool(const Element*)> isDragged) override;
2020-05-26 15:54:26 +02:00
2020-03-24 14:49:16 +01:00
QString accessibleInfo() const override;
QString screenReaderInfo() const override;
2016-07-19 14:36:09 +02:00
void doAutoplace();
2020-05-26 15:54:26 +02:00
2018-12-22 11:43:23 +01:00
static const std::vector<ChangeSpeedItem> changeSpeedTable;
static int findInString(const QString& text, int& length, QString& type);
};
2013-05-13 18:49:17 +02:00
} // namespace Ms
Q_DECLARE_METATYPE(Ms::Dynamic::Range);
2012-05-26 14:26:10 +02:00
#endif