MuseScore  3.4
Music composition and notation
keysig.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 __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
27 //
28 // @P showCourtesy bool show courtesy key signature for this sig if appropriate
29 //---------------------------------------------------------------------------------------
30 
31 class KeySig final : public Element {
33  bool _hideNaturals; // used in layout to override score style (needed for the Continuous panel)
35  void addLayout(SymId sym, qreal x, int y);
36 
37  public:
38  KeySig(Score* = 0);
39  KeySig(const KeySig&);
40  virtual KeySig* clone() const override { return new KeySig(*this); }
41  virtual void draw(QPainter*) const override;
42  virtual ElementType type() const override { return ElementType::KEYSIG; }
43  virtual bool acceptDrop(EditData&) const override;
44  virtual Element* drop(EditData&) override;
45  virtual void layout() override;
46  virtual Shape shape() const override;
47  virtual qreal mag() const override;
48 
49  //@ sets the key of the key signature
50  Q_INVOKABLE void setKey(Key);
51 
52  Segment* segment() const { return (Segment*)parent(); }
53  Measure* measure() const { return parent() ? (Measure*)parent()->parent() : nullptr; }
54  virtual void write(XmlWriter&) const override;
55  virtual void read(XmlReader&) override;
56  //@ returns the key of the key signature (from -7 (flats) to +7 (sharps) )
57  Q_INVOKABLE Key key() const { return _sig.key(); }
58  bool isCustom() const { return _sig.custom(); }
59  bool isAtonal() const { return _sig.isAtonal(); }
60  bool isChange() const;
61  KeySigEvent keySigEvent() const { return _sig; }
62  bool operator==(const KeySig&) const;
63  void changeKeySigEvent(const KeySigEvent&);
64  void setKeySigEvent(const KeySigEvent& e) { _sig = e; }
65 
66  bool showCourtesy() const { return _showCourtesy; }
67  void setShowCourtesy(bool v) { _showCourtesy = v; }
68  void undoSetShowCourtesy(bool v);
69 
70  KeyMode mode() const { return _sig.mode(); }
71  void setMode(KeyMode v) { _sig.setMode(v); }
72  void undoSetMode(KeyMode v);
73 
74  void setHideNaturals(bool hide) { _hideNaturals = hide; }
75 
76  QVariant getProperty(Pid propertyId) const;
77  bool setProperty(Pid propertyId, const QVariant&);
78  QVariant propertyDefault(Pid id) const;
79 
80  virtual Element* nextSegmentElement() override;
81  virtual Element* prevSegmentElement() override;
82  virtual QString accessibleInfo() const override;
83 
84  SymId convertFromOldId(int val) const;
85  };
86 
87 extern const char* keyNames[];
88 
89 } // namespace Ms
90 #endif
91 
bool operator==(const KeySig &) const
Definition: keysig.cpp:537
Pid
Definition: property.h:62
Key
Definition: key.h:28
bool isCustom() const
Definition: keysig.h:58
Definition: xml.h:67
KeyMode mode() const
Definition: keysig.h:70
void addLayout(SymId sym, qreal x, int y)
Definition: keysig.cpp:77
virtual void draw(QPainter *) const override
Definition: keysig.cpp:303
virtual void write(XmlWriter &) const override
Definition: keysig.cpp:365
one measure in a system
Definition: measure.h:65
KeyMode
Definition: key.h:55
SymId
Definition: sym.h:30
Base class of score layout elements.
Definition: element.h:158
bool _showCourtesy
Definition: keysig.h:32
Measure * measure() const
Definition: keysig.h:53
void setMode(KeyMode m)
Definition: key.h:115
virtual void read(XmlReader &) override
Definition: keysig.cpp:408
KeySigEvent _sig
Definition: keysig.h:34
virtual Element * prevSegmentElement() override
Definition: keysig.cpp:664
Element * parent() const
Definition: element.h:192
Definition: score.h:391
QVariant propertyDefault(Pid id) const
Definition: keysig.cpp:637
virtual KeySig * clone() const override
Definition: keysig.h:40
QVariant getProperty(Pid propertyId) const
Definition: keysig.cpp:587
Q_INVOKABLE void setKey(Key)
Definition: keysig.cpp:354
KeySig(Score *=0)
Definition: keysig.cpp:49
bool showCourtesy() const
Definition: keysig.h:66
bool _hideNaturals
Definition: keysig.h:33
void undoSetMode(KeyMode v)
Definition: keysig.cpp:578
KeyMode mode() const
Definition: key.h:114
virtual Pid propertyId(const QStringRef &xmlName) const override
Definition: element.cpp:1326
The KeySig class represents a Key Signature on a staff.
Definition: keysig.h:31
bool setProperty(Pid propertyId, const QVariant &)
Definition: keysig.cpp:605
Definition: key.h:95
virtual Element * drop(EditData &) override
Handle a dropped element at canvas relative pos of given element type and subtype.
Definition: keysig.cpp:328
Definition: segment.h:50
Definition: aeolus.cpp:26
virtual Element * nextSegmentElement() override
Definition: keysig.cpp:655
bool isChange() const
Definition: keysig.cpp:546
virtual void layout() override
Definition: keysig.cpp:90
void setMode(KeyMode v)
Definition: keysig.h:71
Key key() const
Definition: key.h:113
Definition: xml.h:218
const char * keyNames[]
Definition: keysig.cpp:26
KeySigEvent keySigEvent() const
Definition: keysig.h:61
virtual qreal y() const
Definition: element.h:232
virtual bool acceptDrop(EditData &) const override
Return true if this element accepts a drop at canvas relative pos of given element type and subtype...
Definition: keysig.cpp:319
virtual qreal x() const
Definition: element.h:231
Definition: element.h:111
Q_INVOKABLE Key key() const
Definition: keysig.h:57
virtual Shape shape() const override
Definition: keysig.cpp:283
void changeKeySigEvent(const KeySigEvent &)
Definition: keysig.cpp:558
void setKeySigEvent(const KeySigEvent &e)
Definition: keysig.h:64
bool custom() const
Definition: key.h:116
bool isAtonal() const
Definition: key.h:119
void setShowCourtesy(bool v)
Definition: keysig.h:67
Definition: shape.h:42
void setHideNaturals(bool hide)
Definition: keysig.h:74
ElementType
Definition: types.h:34
virtual QString accessibleInfo() const override
Definition: keysig.cpp:673
bool isAtonal() const
Definition: keysig.h:59
Segment * segment() const
Definition: keysig.h:52
SymId convertFromOldId(int val) const
Definition: keysig.cpp:495
void undoSetShowCourtesy(bool v)
Definition: keysig.cpp:569
virtual ElementType type() const override
Definition: keysig.h:42
virtual qreal mag() const override
Definition: keysig.cpp:68