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 __ARTICULATION_H__ 14 #define __ARTICULATION_H__ 15 16 #include "element.h" 17 #include "mscore.h" 18 #include "sym.h" 19 20 namespace Ms { 21 22 class ChordRest; 23 class Segment; 24 class Measure; 25 class System; 26 class Page; 27 28 //--------------------------------------------------------- 29 // ArticulationInfo 30 // gives infos about note attributes 31 //--------------------------------------------------------- 32 33 enum class ArticulationAnchor : char { 34 TOP_STAFF, // anchor is always placed at top of staff 35 BOTTOM_STAFF, // anchor is always placed at bottom of staff 36 CHORD, // anchor depends on chord direction, away from stem 37 TOP_CHORD, // attribute is always placed at top of chord 38 BOTTOM_CHORD, // attribute is placed at bottom of chord 39 }; 40 41 // flags: 42 enum class ArticulationShowIn : char { PITCHED_STAFF = 1, TABLATURE = 2 }; 43 44 constexpr ArticulationShowIn operator| (ArticulationShowIn a1, ArticulationShowIn a2) { 45 return static_cast<ArticulationShowIn>(static_cast<unsigned char>(a1) | static_cast<unsigned char>(a2)); 46 } 47 constexpr bool operator& (ArticulationShowIn a1, ArticulationShowIn a2) { 48 return static_cast<unsigned char>(a1) & static_cast<unsigned char>(a2); 49 } 50 51 //--------------------------------------------------------- 52 // @@ Articulation 53 /// articulation marks 54 //--------------------------------------------------------- 55 56 class Articulation final : public Element { 57 SymId _symId; 58 Direction _direction; 59 QString _channelName; 60 61 ArticulationAnchor _anchor; 62 63 bool _up; 64 MScore::OrnamentStyle _ornamentStyle; // for use in ornaments such as trill 65 bool _playArticulation; 66 67 void draw(QPainter*) const; 68 69 enum class AnchorGroup { 70 ARTICULATION, 71 LUTE_FINGERING, 72 OTHER 73 }; 74 static AnchorGroup anchorGroup(SymId); 75 76 public: 77 Articulation(Score*); 78 Articulation(SymId, Score*); 79 Articulation &operator=(const Articulation&) = delete; 80 clone()81 Articulation* clone() const override { return new Articulation(*this); } type()82 ElementType type() const override { return ElementType::ARTICULATION; } 83 84 qreal mag() const override; 85 symId()86 SymId symId() const { return _symId; } 87 void setSymId(SymId id); 88 int subtype() const override; 89 QString userName() const; 90 const char* articulationName() const; // type-name of articulation; used for midi rendering 91 static const char* symId2ArticulationName(SymId symId); 92 93 void layout() override; 94 bool layoutCloseToNote() const; 95 96 void read(XmlReader&) override; 97 void write(XmlWriter& xml) const override; 98 bool readProperties(XmlReader&) override; 99 100 QVector<QLineF> dragAnchorLines() const override; 101 102 QVariant getProperty(Pid propertyId) const override; 103 bool setProperty(Pid propertyId, const QVariant&) override; 104 QVariant propertyDefault(Pid) const override; 105 void resetProperty(Pid id) override; 106 Sid getPropertyStyle(Pid id) const override; 107 108 Pid propertyId(const QStringRef& xmlName) const override; 109 up()110 bool up() const { return _up; } 111 void setUp(bool val); setDirection(Direction d)112 void setDirection(Direction d) { _direction = d; } direction()113 Direction direction() const { return _direction; } 114 115 ChordRest* chordRest() const; 116 Segment* segment() const; 117 Measure* measure() const; 118 System* system() const; 119 Page* page() const; 120 anchor()121 ArticulationAnchor anchor() const { return _anchor; } setAnchor(ArticulationAnchor v)122 void setAnchor(ArticulationAnchor v) { _anchor = v; } 123 ornamentStyle()124 MScore::OrnamentStyle ornamentStyle() const { return _ornamentStyle; } setOrnamentStyle(MScore::OrnamentStyle val)125 void setOrnamentStyle(MScore::OrnamentStyle val) { _ornamentStyle = val; } 126 playArticulation()127 bool playArticulation() const { return _playArticulation;} setPlayArticulation(bool val)128 void setPlayArticulation(bool val) { _playArticulation = val; } 129 channelName()130 QString channelName() const { return _channelName; } setChannelName(const QString & s)131 void setChannelName(const QString& s) { _channelName = s; } 132 133 QString accessibleInfo() const override; 134 135 bool isDouble() const; 136 bool isTenuto() const; 137 bool isStaccato() const; 138 bool isAccent() const; 139 bool isMarcato() const; 140 bool isLuteFingering() const; 141 bool isOrnament() const; 142 143 void doAutoplace(); 144 }; 145 146 } // namespace Ms 147 #endif 148 149