MuseScore  3.4
Music composition and notation
clef.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 __CLEF_H__
14 #define __CLEF_H__
15 
21 #include "element.h"
22 #include "mscore.h"
23 
24 namespace Ms {
25 
26 class XmlWriter;
27 class MuseScoreView;
28 class Segment;
29 
30 static const int NO_CLEF = -1000;
31 
32 
33 //---------------------------------------------------------
34 // ClefType
35 //---------------------------------------------------------
36 
37 enum class ClefType : signed char {
38  INVALID = -1,
39  G = 0,
40  G15_MB,
41  G8_VB,
42  G8_VA,
43  G15_MA,
44  G8_VB_O,
45  G8_VB_P,
46  G_1,
47  C1,
48  C2,
49  C3,
50  C4,
51  C5,
52  C_19C,
53  C1_F18C,
54  C3_F18C,
55  C4_F18C,
56  C3_F20C,
57  C1_F20C,
58  C4_F20C,
59  F,
60  F15_MB,
61  F8_VB,
62  F_8VA,
63  F_15MA,
64  F_B,
65  F_C,
66  F_F18C,
67  F_19C,
68  PERC,
69  PERC2,
70  TAB,
71  TAB4,
72  TAB_SERIF,
73  TAB4_SERIF,
74  MAX
75  };
76 
77 //---------------------------------------------------------
78 // ClefTypeList
79 //---------------------------------------------------------
80 
81 struct ClefTypeList {
82  ClefType _concertClef = ClefType::G;
83  ClefType _transposingClef = ClefType::G;
84 
86  ClefTypeList(ClefType a, ClefType b) : _concertClef(a), _transposingClef(b) {}
87  ClefTypeList(ClefType a) : _concertClef(a), _transposingClef(a) {}
88  bool operator==(const ClefTypeList& t) const;
89  bool operator!=(const ClefTypeList& t) const;
90  };
91 
92 //---------------------------------------------------------
93 // ClefInfo
95 //---------------------------------------------------------
96 
97 class ClefInfo {
98  public:
99  static const ClefInfo clefTable[];
100 
101  const char* _tag;
102  const char* _sign;
103  int _line;
104  int _octChng;
106  signed char _lines[14];
108  const char* _name;
110 
111  public:
112  static const char* tag(ClefType t) { return clefTable[int(t)]._tag; }
113  static const char* sign(ClefType t) { return clefTable[int(t)]._sign; }
114  static int line(ClefType t) { return clefTable[int(t)]._line; }
115  static int octChng(ClefType t) { return clefTable[int(t)]._octChng; }
116  static int pitchOffset(ClefType t) { return clefTable[int(t)]._pitchOffset; }
117  static SymId symId(ClefType t) { return clefTable[int(t)]._symId; }
118  static const signed char* lines(ClefType t) { return clefTable[int(t)]._lines; }
119  static const char* name(ClefType t) { return clefTable[int(t)]._name; }
120  static StaffGroup staffGroup(ClefType t) { return clefTable[int(t)]._staffGroup; }
121  static ClefType tag2type(const QString&);
122  };
123 
124 //---------------------------------------------------------
125 // @@ Clef
127 //
128 // @P showCourtesy bool show/hide courtesy clef when applicable
129 // @P small bool small, mid-staff clef (read only, set by layout)
130 //---------------------------------------------------------
131 
132 class Clef final : public Element {
134  bool _showCourtesy = true;
135  bool _small = false;
136 
138 
139  public:
140  Clef(Score*);
141  virtual Clef* clone() const { return new Clef(*this); }
142  virtual ElementType type() const { return ElementType::CLEF; }
143  virtual qreal mag() const;
144 
145  Segment* segment() const { return (Segment*)parent(); }
146  Measure* measure() const { return (Measure*)parent()->parent(); }
147 
148  virtual bool acceptDrop(EditData&) const override;
149  virtual Element* drop(EditData&);
150  virtual void layout();
151  virtual void draw(QPainter*) const;
152  virtual void read(XmlReader&);
153  virtual void write(XmlWriter&) const;
154 
155  virtual bool isEditable() const { return false; }
156 
157  bool small() const { return _small; }
158  void setSmall(bool val);
159 
160  bool showCourtesy() const { return _showCourtesy; }
161  void setShowCourtesy(bool v) { _showCourtesy = v; }
162  void undoSetShowCourtesy(bool v);
163  Clef* otherClef();
164 
165  static ClefType clefType(const QString& s);
166  const char* clefTypeName();
167 
168  ClefType clefType() const;
169  void setClefType(ClefType i);
170  void setClefType(const QString& s);
171 
172  ClefTypeList clefTypeList() const { return _clefTypes; }
173  ClefType concertClef() const { return _clefTypes._concertClef; }
174  ClefType transposingClef() const { return _clefTypes._transposingClef; }
175  void setConcertClef(ClefType val);
176  void setTransposingClef(ClefType val);
177  void setClefType(const ClefTypeList& ctl) { _clefTypes = ctl; }
178  virtual void spatiumChanged(qreal oldValue, qreal newValue) override;
179 
180  QVariant getProperty(Pid propertyId) const;
181  bool setProperty(Pid propertyId, const QVariant&);
182  QVariant propertyDefault(Pid id) const;
183 
184  virtual Element* nextSegmentElement() override;
185  virtual Element* prevSegmentElement() override;
186  QString accessibleInfo() const override;
187  void clear();
188  };
189 
190 } // namespace Ms
191 #endif
192 
Measure * measure() const
Definition: clef.h:146
virtual Clef * clone() const
Definition: clef.h:141
Pid
Definition: property.h:62
Definition: xml.h:67
const char * _sign
Name for musicXml.
Definition: clef.h:102
int _octChng
Octave change for musicXml.
Definition: clef.h:104
one measure in a system
Definition: measure.h:65
ClefTypeList()
Definition: clef.h:85
SymId
Definition: sym.h:30
const char * _tag
comprehensive name for instruments.xml
Definition: clef.h:101
Base class of score layout elements.
Definition: element.h:158
const char * _name
Definition: clef.h:108
StaffGroup
Definition: mscore.h:177
Graphic representation of a clef.
Definition: clef.h:132
Definition: clef.h:81
int _line
Line for musicXml and for positioning on the staff.
Definition: clef.h:103
SymId _symId
Definition: clef.h:107
Element * parent() const
Definition: element.h:192
Segment * segment() const
Definition: clef.h:145
Definition: score.h:391
virtual bool isEditable() const
Definition: clef.h:155
Info about a clef.
Definition: clef.h:97
static StaffGroup staffGroup(ClefType t)
Definition: clef.h:120
ClefTypeList(ClefType a, ClefType b)
Definition: clef.h:86
static int pitchOffset(ClefType t)
Definition: clef.h:116
void setShowCourtesy(bool v)
Definition: clef.h:161
signed char _lines[14]
Definition: clef.h:106
static const char * name(ClefType t)
Definition: clef.h:119
bool showCourtesy() const
Definition: clef.h:160
ClefTypeList clefTypeList() const
Definition: clef.h:172
Definition: segment.h:50
static const char * sign(ClefType t)
Definition: clef.h:113
Definition: aeolus.cpp:26
ClefType transposingClef() const
Definition: clef.h:174
Definition: xml.h:218
static int line(ClefType t)
Definition: clef.h:114
static SymId symId(ClefType t)
Definition: clef.h:117
int _pitchOffset
Pitch offset for line 0.
Definition: clef.h:105
Definition: xmlwriter.h:26
bool small() const
Definition: clef.h:157
ClefType concertClef() const
Definition: clef.h:173
Definition: element.h:111
ClefType
Definition: clef.h:37
ElementType
Definition: types.h:34
virtual ElementType type() const
Definition: clef.h:142
StaffGroup _staffGroup
Definition: clef.h:109
SymId symId
Definition: clef.h:133
static const signed char * lines(ClefType t)
Definition: clef.h:118
void setClefType(const ClefTypeList &ctl)
Definition: clef.h:177
ClefTypeList(ClefType a)
Definition: clef.h:87
Pid propertyId(const QStringRef &s)
Definition: property.cpp:347
static const char * tag(ClefType t)
Definition: clef.h:112
static int octChng(ClefType t)
Definition: clef.h:115