MuseScore  3.4
Music composition and notation
dynamic.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2002-2011 Werner Schweer
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2
9 // as published by the Free Software Foundation and appearing in
10 // the file LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __DYNAMICS_H__
14 #define __DYNAMICS_H__
15 
16 #include "text.h"
17 #include "mscore.h"
18 
19 namespace Ms {
20 
21 class Measure;
22 class Segment;
23 
24 //-----------------------------------------------------------------------------
25 // @@ Dynamic
27 //
28 // @P range enum (Dynamic.STAFF, .PART, .SYSTEM)
29 //-----------------------------------------------------------------------------
30 
31 class Dynamic final : public TextBase {
32  Q_GADGET
33  public:
34  enum class Type : char {
35  OTHER,
36  PPPPPP,
37  PPPPP,
38  PPPP,
39  PPP,
40  PP,
41  P,
42  MP,
43  MF,
44  F,
45  FF,
46  FFF,
47  FFFF,
48  FFFFF,
49  FFFFFF,
50  FP,
51  SF,
52  SFZ,
53  SFF,
54  SFFZ,
55  SFP,
56  SFPP,
57  RFZ,
58  RF,
59  FZ,
60  M,
61  R,
62  S,
63  Z
64  };
65 
66  enum class Range : char {
67  STAFF, PART, SYSTEM
68  };
69 
70  enum class Speed : char {
71  SLOW, NORMAL, FAST
72  };
73 
74  struct ChangeSpeedItem {
76  const char* name;
77  };
78 
79  Q_ENUM(Type);
80 
81  private:
83 
84  mutable QPointF dragOffset;
85  int _velocity; // associated midi velocity 0-127
86  Range _dynRange; // STAFF, PART, SYSTEM
87 
88  int _changeInVelocity { 128 };
90 
91  virtual QRectF drag(EditData&) override;
92  virtual Sid getPropertyStyle(Pid) const override;
93 
94  public:
95  Dynamic(Score*);
96  Dynamic(const Dynamic&);
97  virtual Dynamic* clone() const override { return new Dynamic(*this); }
98  virtual ElementType type() const override { return ElementType::DYNAMIC; }
99  Segment* segment() const { return (Segment*)parent(); }
100  Measure* measure() const { return (Measure*)parent()->parent(); }
101 
102  void setDynamicType(Type val) { _dynamicType = val; }
103  void setDynamicType(const QString&);
104  static QString dynamicTypeName(Dynamic::Type type);
105  QString dynamicTypeName() const { return dynamicTypeName(_dynamicType); }
106  Type dynamicType() const { return _dynamicType; }
107  virtual int subtype() const override { return (int) _dynamicType; }
108  virtual QString subtypeName() const override { return dynamicTypeName(); }
109 
110  virtual void layout() override;
111  virtual void write(XmlWriter& xml) const override;
112  virtual void read(XmlReader&) override;
113 
114  virtual bool isEditable() const override { return true; }
115  virtual void startEdit(EditData&) override;
116  virtual void endEdit(EditData&) override;
117  virtual void reset() override;
118 
119  void setVelocity(int v) { _velocity = v; }
120  int velocity() const;
121  Range dynRange() const { return _dynRange; }
122  void setDynRange(Range t) { _dynRange = t; }
123  void undoSetDynRange(Range t);
124 
125  int changeInVelocity() const;
126  void setChangeInVelocity(int val);
128 
131  static QString speedToName(Speed speed);
132  static Speed nameToSpeed(QString name);
133 
134  virtual QVariant getProperty(Pid propertyId) const override;
135  virtual bool setProperty(Pid propertyId, const QVariant&) override;
136  virtual QVariant propertyDefault(Pid id) const override;
137  virtual Pid propertyId(const QStringRef& xmlName) const override;
138  virtual QString propertyUserValue(Pid) const override;
139 
140  virtual QString accessibleInfo() const override;
141  virtual QString screenReaderInfo() const override;
142  void doAutoplace();
143 
144  static const std::vector<ChangeSpeedItem> changeSpeedTable;
145  };
146 
147 } // namespace Ms
148 
149 Q_DECLARE_METATYPE(Ms::Dynamic::Range);
150 
151 #endif
virtual QString screenReaderInfo() const override
Definition: dynamic.cpp:555
Type dynamicType() const
Definition: dynamic.h:106
Type _dynamicType
Definition: dynamic.h:79
virtual void layout() override
Definition: dynamic.cpp:229
virtual Pid propertyId(const QStringRef &xmlName) const override
Definition: dynamic.cpp:497
static const std::vector< ChangeSpeedItem > changeSpeedTable
Definition: dynamic.h:144
Pid
Definition: property.h:62
virtual bool setProperty(Pid propertyId, const QVariant &) override
Definition: dynamic.cpp:441
Definition: xml.h:67
virtual void write(XmlWriter &xml) const override
Definition: dynamic.cpp:187
Dynamic(Score *)
Definition: dynamic.cpp:104
void doAutoplace()
Definition: dynamic.cpp:263
const char * name
Definition: dynamic.h:76
Segment * segment() const
Definition: dynamic.h:99
QPointF dragOffset
Definition: dynamic.h:84
one measure in a system
Definition: measure.h:65
Range
Definition: dynamic.h:66
virtual void startEdit(EditData &) override
Definition: dynamic.cpp:322
QString dynamicTypeName() const
Definition: dynamic.h:105
virtual Dynamic * clone() const override
Definition: dynamic.h:97
Speed speed
Definition: dynamic.h:75
Fraction velocityChangeLength() const
Definition: dynamic.cpp:160
int _changeInVelocity
Definition: dynamic.h:88
Measure * measure() const
Definition: dynamic.h:100
int changeInVelocity() const
Definition: dynamic.cpp:138
virtual QString propertyUserValue(Pid) const override
Definition: dynamic.cpp:508
void setChangeInVelocity(int val)
Definition: dynamic.cpp:147
Range _dynRange
Definition: dynamic.h:86
void setDynamicType(Type val)
Definition: dynamic.h:102
Type
Definition: dynamic.h:34
Element * parent() const
Definition: element.h:192
virtual bool isEditable() const override
Definition: dynamic.h:114
Definition: score.h:391
int _velocity
Definition: dynamic.h:85
virtual QVariant getProperty(Pid propertyId) const override
Definition: dynamic.cpp:417
virtual ElementType type() const override
Definition: dynamic.h:98
static QString speedToName(Speed speed)
Definition: dynamic.cpp:389
int velocity() const
Definition: dynamic.cpp:129
Range dynRange() const
Definition: dynamic.h:121
void undoSetDynRange(Range t)
Definition: dynamic.cpp:380
virtual void endEdit(EditData &) override
Definition: dynamic.cpp:331
virtual QString accessibleInfo() const override
Definition: dynamic.cpp:534
void setVelChangeSpeed(Speed val)
Definition: dynamic.h:130
Definition: textbase.h:217
Definition: segment.h:50
dynamics marker; determines midi velocity
Definition: dynamic.h:31
Definition: aeolus.cpp:26
Sid
Definition: style.h:33
Definition: xml.h:218
Speed velChangeSpeed() const
Definition: dynamic.h:129
virtual QRectF drag(EditData &) override
Return update Rect relative to canvas.
Definition: dynamic.cpp:351
Speed
Definition: dynamic.h:70
virtual QVariant propertyDefault(Pid id) const override
Definition: dynamic.cpp:475
Speed _velChangeSpeed
Definition: dynamic.h:89
virtual QString subtypeName() const override
Definition: dynamic.h:108
Definition: element.h:111
virtual void reset() override
Definition: dynamic.cpp:342
const char * name() const
Definition: scoreElement.cpp:787
Definition: fraction.h:46
ElementType
Definition: types.h:34
void setVelocity(int v)
Definition: dynamic.h:119
Definition: dynamic.h:74
virtual int subtype() const override
Definition: dynamic.h:107
virtual void read(XmlReader &) override
Definition: dynamic.cpp:205
virtual Sid getPropertyStyle(Pid) const override
Definition: dynamic.cpp:523
static Speed nameToSpeed(QString name)
Definition: dynamic.cpp:404
void setDynRange(Range t)
Definition: dynamic.h:122