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 __KEYSIG_H__ 14 #define __KEYSIG_H__ 15 16 #include "key.h" 17 #include "element.h" 18 19 namespace Ms { 20 21 class Sym; 22 class Segment; 23 24 //--------------------------------------------------------------------------------------- 25 // @@ KeySig 26 /// The KeySig class represents a Key Signature on a staff 27 // 28 // @P showCourtesy bool show courtesy key signature for this sig if appropriate 29 //--------------------------------------------------------------------------------------- 30 31 class KeySig final : public Element { 32 bool _showCourtesy; 33 bool _hideNaturals; // used in layout to override score style (needed for the Continuous panel) 34 KeySigEvent _sig; 35 void addLayout(SymId sym, qreal x, int y); 36 37 public: 38 KeySig(Score* = 0); 39 KeySig(const KeySig&); 40 clone()41 KeySig* clone() const override { return new KeySig(*this); } 42 void draw(QPainter*) const override; type()43 ElementType type() const override { return ElementType::KEYSIG; } 44 bool acceptDrop(EditData&) const override; 45 Element* drop(EditData&) override; 46 void layout() override; 47 Shape shape() const override; 48 qreal mag() const override; 49 50 //@ sets the key of the key signature 51 Q_INVOKABLE void setKey(Key); 52 segment()53 Segment* segment() const { return (Segment*)parent(); } measure()54 Measure* measure() const { return parent() ? (Measure*)parent()->parent() : nullptr; } 55 void write(XmlWriter&) const override; 56 void read(XmlReader&) override; 57 //@ returns the key of the key signature (from -7 (flats) to +7 (sharps) ) key()58 Q_INVOKABLE Key key() const { return _sig.key(); } isCustom()59 bool isCustom() const { return _sig.custom(); } isAtonal()60 bool isAtonal() const { return _sig.isAtonal(); } 61 bool isChange() const; keySigEvent()62 KeySigEvent keySigEvent() const { return _sig; } 63 bool operator==(const KeySig&) const; 64 void changeKeySigEvent(const KeySigEvent&); setKeySigEvent(const KeySigEvent & e)65 void setKeySigEvent(const KeySigEvent& e) { _sig = e; } 66 showCourtesy()67 bool showCourtesy() const { return _showCourtesy; } setShowCourtesy(bool v)68 void setShowCourtesy(bool v) { _showCourtesy = v; } 69 void undoSetShowCourtesy(bool v); 70 mode()71 KeyMode mode() const { return _sig.mode(); } setMode(KeyMode v)72 void setMode(KeyMode v) { _sig.setMode(v); } 73 void undoSetMode(KeyMode v); 74 setHideNaturals(bool hide)75 void setHideNaturals(bool hide) { _hideNaturals = hide; } 76 setForInstrumentChange(bool forInstrumentChange)77 void setForInstrumentChange(bool forInstrumentChange) { _sig.setForInstrumentChange(forInstrumentChange); } forInstrumentChange()78 bool forInstrumentChange() const { return _sig.forInstrumentChange(); } 79 80 QVariant getProperty(Pid propertyId) const override; 81 bool setProperty(Pid propertyId, const QVariant&) override; 82 QVariant propertyDefault(Pid id) const override; 83 84 Element* nextSegmentElement() override; 85 Element* prevSegmentElement() override; 86 QString accessibleInfo() const override; 87 88 SymId convertFromOldId(int val) const; 89 }; 90 91 extern const char* keyNames[]; 92 93 } // namespace Ms 94 #endif 95 96