MuseScore  3.4
Music composition and notation
hairpin.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 __HAIRPIN_H__
14 #define __HAIRPIN_H__
15 
16 #include "element.h"
17 #include "dynamic.h"
18 #include "line.h"
19 #include "textlinebase.h"
20 #include "mscore.h"
21 
22 namespace Ms {
23 
24 class Score;
25 class Hairpin;
26 
27 enum class HairpinType : signed char {
28  INVALID = -1,
31  CRESC_LINE,
33  };
34 
35 enum class VeloChangeMethod : signed char {
36  NORMAL,
38  EASE_IN,
39  EASE_OUT,
40  EASE_IN_OUT // and shake it all about
41  };
42 
43 //---------------------------------------------------------
44 // @@ HairpinSegment
45 //---------------------------------------------------------
46 
47 class HairpinSegment final : public TextLineBaseSegment {
49  QPointF circledTip;
51 
52  virtual void startEditDrag(EditData&) override;
53  virtual void editDrag(EditData&) override;
54 
55  virtual void draw(QPainter*) const override;
56  virtual Sid getPropertyStyle(Pid) const override;
57 
58  bool acceptDrop(EditData&) const override;
59  Element* drop(EditData&);
60 
61  public:
62  HairpinSegment(Spanner* sp, Score* s);
63  virtual HairpinSegment* clone() const override { return new HairpinSegment(*this); }
64  virtual ElementType type() const override { return ElementType::HAIRPIN_SEGMENT; }
65 
66  Hairpin* hairpin() const { return (Hairpin*)spanner(); }
67 
68  virtual Element* propertyDelegate(Pid) override;
69 
70  virtual void layout() override;
71  virtual Shape shape() const override;
72 
73  int gripsCount() const override { return 4; }
74  std::vector<QPointF> gripsPositions(const EditData&) const override;
75  };
76 
77 //---------------------------------------------------------
78 // @@ Hairpin
79 // @P dynRange enum (Dynamic.STAFF, Dynamic.PART, Dynamic.SYSTEM)
80 // @P hairpinType enum (Hairpin.CRESCENDO, Hairpin.DECRESCENDO)
81 // @P veloChange int
82 //---------------------------------------------------------
83 
84 class Hairpin final : public TextLineBase {
91 
94 
95  virtual Sid getPropertyStyle(Pid) const override;
96 
97  struct VeloMethodItem {
99  const char* name;
100  };
101 
102  public:
103  Hairpin(Score* s);
104  virtual Hairpin* clone() const override { return new Hairpin(*this); }
105  virtual ElementType type() const override { return ElementType::HAIRPIN; }
106 
107  HairpinType hairpinType() const { return _hairpinType; }
108  void setHairpinType(HairpinType val);
109 
110  Segment* segment() const { return (Segment*)parent(); }
111  virtual void layout() override;
112  virtual LineSegment* createLineSegment() override;
113 
114  bool hairpinCircledTip() const { return _hairpinCircledTip; }
115  void setHairpinCircledTip(bool val) { _hairpinCircledTip = val; }
116 
117  int veloChange() const { return _veloChange; }
118  void setVeloChange(int v) { _veloChange = v; }
119 
120  Dynamic::Range dynRange() const { return _dynRange; }
121  void setDynRange(Dynamic::Range t) { _dynRange = t; }
122 
123  Spatium hairpinHeight() const { return _hairpinHeight; }
124  void setHairpinHeight(Spatium val) { _hairpinHeight = val; }
125 
126  Spatium hairpinContHeight() const { return _hairpinContHeight; }
127  void setHairpinContHeight(Spatium val) { _hairpinContHeight = val; }
128 
129  bool singleNoteDynamics() const { return _singleNoteDynamics; }
130  void setSingleNoteDynamics(bool val) { _singleNoteDynamics = val; }
131 
132  VeloChangeMethod veloChangeMethod() const { return _veloChangeMethod; }
133  void setVeloChangeMethod(VeloChangeMethod val) { _veloChangeMethod = val; }
134  static QString veloChangeMethodToName(VeloChangeMethod method);
135  static VeloChangeMethod nameToVeloChangeMethod(QString name);
136 
137  bool isCrescendo() const { return _hairpinType == HairpinType::CRESC_HAIRPIN || _hairpinType == HairpinType::CRESC_LINE; }
138  bool isDecrescendo() const { return _hairpinType == HairpinType::DECRESC_HAIRPIN || _hairpinType == HairpinType::DECRESC_LINE; }
139 
140  virtual void write(XmlWriter&) const override;
141  virtual void read(XmlReader&) override;
142 
143  virtual QVariant getProperty(Pid id) const override;
144  virtual bool setProperty(Pid propertyId, const QVariant&) override;
145  virtual QVariant propertyDefault(Pid id) const override;
146  virtual Pid propertyId(const QStringRef& xmlName) const override;
147 
148  virtual QString accessibleInfo() const override;
149  bool isLineType() const { return _hairpinType == HairpinType::CRESC_LINE || _hairpinType == HairpinType::DECRESC_LINE; }
150 
151  static const std::vector<VeloMethodItem> veloChangeMethodTable;
152  };
153 
154 } // namespace Ms
155 
156 Q_DECLARE_METATYPE(Ms::HairpinType);
157 
158 #endif
159 
VeloChangeMethod
Definition: hairpin.h:35
void setHairpinHeight(Spatium val)
Definition: hairpin.h:124
void setVeloChangeMethod(VeloChangeMethod val)
Definition: hairpin.h:133
HairpinType
Definition: hairpin.h:27
Definition: hairpin.h:97
Pid
Definition: property.h:62
Definition: xml.h:67
virtual HairpinSegment * clone() const override
Definition: hairpin.h:63
VeloChangeMethod veloChangeMethod() const
Definition: hairpin.h:132
Virtual base class for slurs, ties, lines etc.
Definition: spanner.h:136
bool drawCircledTip
Definition: hairpin.h:48
Range
Definition: dynamic.h:66
bool hairpinCircledTip() const
Definition: hairpin.h:114
Spatium _hairpinContHeight
Definition: hairpin.h:93
void setHairpinCircledTip(bool val)
Definition: hairpin.h:115
bool isCrescendo() const
Definition: hairpin.h:137
bool isDecrescendo() const
Definition: hairpin.h:138
Base class of score layout elements.
Definition: element.h:158
void setDynRange(Dynamic::Range t)
Definition: hairpin.h:121
int veloChange() const
Definition: hairpin.h:117
Virtual base class for segmented lines segments (OttavaSegment, HairpinSegment, TrillSegment...)
Definition: line.h:34
virtual Hairpin * clone() const override
Definition: hairpin.h:104
Definition: hairpin.h:84
void setHairpinContHeight(Spatium val)
Definition: hairpin.h:127
HairpinType hairpinType() const
Definition: hairpin.h:107
Definition: score.h:391
VeloChangeMethod _veloChangeMethod
Definition: hairpin.h:90
Dynamic::Range dynRange() const
Definition: hairpin.h:120
Segment * segment() const
Definition: hairpin.h:110
VeloChangeMethod method
Definition: hairpin.h:98
virtual ElementType type() const override
Definition: hairpin.h:64
Hairpin * hairpin() const
Definition: hairpin.h:66
bool _singleNoteDynamics
Definition: hairpin.h:89
int _veloChange
Definition: hairpin.h:86
Definition: hairpin.h:47
Definition: textlinebase.h:31
bool _hairpinCircledTip
Definition: hairpin.h:87
Definition: segment.h:50
Definition: aeolus.cpp:26
Spatium hairpinHeight() const
Definition: hairpin.h:123
Definition: spatium.h:25
static const std::vector< VeloMethodItem > veloChangeMethodTable
Definition: hairpin.h:151
Sid
Definition: style.h:33
qreal circledTipRadius
Definition: hairpin.h:50
Definition: xml.h:218
Spatium _hairpinHeight
Definition: hairpin.h:92
void setSingleNoteDynamics(bool val)
Definition: hairpin.h:130
Definition: element.h:111
Definition: textlinebase.h:70
bool isLineType() const
Definition: hairpin.h:149
QPointF circledTip
Definition: hairpin.h:49
Definition: shape.h:42
void setVeloChange(int v)
Definition: hairpin.h:118
Spatium hairpinContHeight() const
Definition: hairpin.h:126
ElementType
Definition: types.h:34
bool singleNoteDynamics() const
Definition: hairpin.h:129
Pid propertyId(const QStringRef &s)
Definition: property.cpp:347
const char * name
Definition: hairpin.h:99
int gripsCount() const override
Definition: hairpin.h:73
virtual ElementType type() const override
Definition: hairpin.h:105
Dynamic::Range _dynRange
Definition: hairpin.h:88