MuseScore  3.4
Music composition and notation
ottava.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 __OTTAVA_H__
14 #define __OTTAVA_H__
15 
16 #include "textlinebase.h"
17 #include "property.h"
18 
19 namespace Ms {
20 
21 //---------------------------------------------------------
22 // OttavaE
23 //---------------------------------------------------------
24 
25 struct OttavaE {
26  int offset;
27  unsigned start;
28  unsigned end;
29  };
30 
31 //---------------------------------------------------------
32 // OttavaType
33 //---------------------------------------------------------
34 
35 enum class OttavaType : char {
36  OTTAVA_8VA,
37  OTTAVA_8VB,
42  };
43 
44 //---------------------------------------------------------
45 // OttavaDefault
46 //---------------------------------------------------------
47 
48 struct OttavaDefault {
50  int shift;
51  const char* name;
52  };
53 
54 // order is important, should be the same as OttavaType
55 static const OttavaDefault ottavaDefault[] = {
56  { OttavaType::OTTAVA_8VA, 12, "8va" },
57  { OttavaType::OTTAVA_8VB, -12, "8vb" },
58  { OttavaType::OTTAVA_15MA, 24, "15ma" },
59  { OttavaType::OTTAVA_15MB, -24, "15mb" },
60  { OttavaType::OTTAVA_22MA, 36, "22ma" },
61  { OttavaType::OTTAVA_22MB, -36, "22mb" }
62  };
63 
64 
65 class Ottava;
66 
67 //---------------------------------------------------------
68 // @@ OttavaSegment
69 //---------------------------------------------------------
70 
71 class OttavaSegment final : public TextLineBaseSegment {
72  virtual void undoChangeProperty(Pid id, const QVariant&, PropertyFlags ps) override;
73  virtual Sid getPropertyStyle(Pid) const override;
74 
75  public:
77  virtual ElementType type() const override { return ElementType::OTTAVA_SEGMENT; }
78  virtual OttavaSegment* clone() const override { return new OttavaSegment(*this); }
79  Ottava* ottava() const { return (Ottava*)spanner(); }
80  virtual void layout() override;
81  virtual Element* propertyDelegate(Pid) override;
82  };
83 
84 //---------------------------------------------------------
85 // @@ Ottava
86 // @P ottavaType enum (Ottava.OTTAVA_8VA, .OTTAVA_8VB, .OTTAVA_15MA, .OTTAVA_15MB, .OTTAVA_22MA, .OTTAVA_22MB)
87 //---------------------------------------------------------
88 
89 class Ottava final : public TextLineBase {
92 
93  void updateStyledProperties();
94  virtual Sid getPropertyStyle(Pid) const override;
95  virtual void undoChangeProperty(Pid id, const QVariant&, PropertyFlags ps) override;
96 
97  protected:
98  friend class OttavaSegment;
99 
100  public:
101  Ottava(Score* s);
102  Ottava(const Ottava&);
103  virtual Ottava* clone() const override { return new Ottava(*this); }
104  virtual ElementType type() const override { return ElementType::OTTAVA; }
105 
106  void setOttavaType(OttavaType val);
107  OttavaType ottavaType() const { return _ottavaType; }
108 
109  bool numbersOnly() const { return _numbersOnly; }
110  void setNumbersOnly(bool val);
111 
112  void setPlacement(Placement);
113 
114  virtual LineSegment* createLineSegment() override;
115  int pitchShift() const;
116 
117  virtual void write(XmlWriter& xml) const override;
118  virtual void read(XmlReader& de) override;
119  bool readProperties(XmlReader& e);
120 
121  virtual QVariant getProperty(Pid propertyId) const override;
122  virtual bool setProperty(Pid propertyId, const QVariant&) override;
123  virtual QVariant propertyDefault(Pid) const override;
124  virtual Pid propertyId(const QStringRef& xmlName) const override;
125 
126  virtual QString accessibleInfo() const override;
127  static const char* ottavaTypeName(OttavaType type);
128  };
129 
130 } // namespace Ms
131 
132 #endif
133 
unsigned end
Definition: ottava.h:28
Pid
Definition: property.h:62
OttavaType type
Definition: ottava.h:49
Definition: xml.h:67
Definition: ottava.h:48
OttavaType ottavaType() const
Definition: ottava.h:107
Virtual base class for slurs, ties, lines etc.
Definition: spanner.h:136
const char * name
Definition: ottava.h:51
int shift
Definition: ottava.h:50
OttavaType
Definition: ottava.h:35
virtual OttavaSegment * clone() const override
Definition: ottava.h:78
virtual Ottava * clone() const override
Definition: ottava.h:103
Base class of score layout elements.
Definition: element.h:158
bool numbersOnly() const
Definition: ottava.h:109
Definition: ottava.h:25
Virtual base class for segmented lines segments (OttavaSegment, HairpinSegment, TrillSegment...)
Definition: line.h:34
Definition: ottava.h:89
unsigned start
Definition: ottava.h:27
Definition: score.h:391
Definition: ottava.h:71
PropertyFlags
Definition: property.h:54
Placement
Definition: types.h:312
OttavaType _ottavaType
Definition: ottava.h:90
Definition: textlinebase.h:31
ElementFlag
Definition: element.h:66
Definition: aeolus.cpp:26
Sid
Definition: style.h:33
virtual ElementType type() const override
Definition: ottava.h:77
Definition: xml.h:218
virtual ElementType type() const override
Definition: ottava.h:104
int offset
Definition: ottava.h:26
Definition: textlinebase.h:70
Ottava * ottava() const
Definition: ottava.h:79
bool _numbersOnly
Definition: ottava.h:91
ElementType
Definition: types.h:34
OttavaSegment(Spanner *sp, Score *s)
Definition: ottava.h:76
Pid propertyId(const QStringRef &s)
Definition: property.cpp:347