MuseScore  3.4
Music composition and notation
measurebase.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 __MEASUREBASE_H__
14 #define __MEASUREBASE_H__
15 
21 #include "element.h"
22 #include "layoutbreak.h"
23 
24 namespace Ms {
25 
26 class Score;
27 class System;
28 class Measure;
29 
30 //---------------------------------------------------------
31 // Repeat
32 //---------------------------------------------------------
33 
34 enum class Repeat : char {
35  NONE = 0,
36  END = 1,
37  START = 2,
38  MEASURE = 4,
39  JUMP = 8
40  };
41 
42 constexpr Repeat operator| (Repeat t1, Repeat t2) {
43  return static_cast<Repeat>(static_cast<int>(t1) | static_cast<int>(t2));
44  }
45 constexpr bool operator& (Repeat t1, Repeat t2) {
46  return static_cast<int>(t1) & static_cast<int>(t2);
47  }
48 
49 //---------------------------------------------------------
50 // @@ MeasureBase
52 //
53 // @P lineBreak bool true if a system break is positioned on this measure
54 // @P nextMeasure Measure the next Measure (read-only)
55 // @P nextMeasureMM Measure the next multi-measure rest Measure (read-only)
56 // @P pageBreak bool true if a page break is positioned on this measure
57 // @P prevMeasure Measure the previous Measure (read-only)
58 // @P prevMeasureMM Measure the previous multi-measure rest Measure (read-only)
59 //---------------------------------------------------------
60 
61 class MeasureBase : public Element {
62  MeasureBase* _next { 0 };
63  MeasureBase* _prev { 0 };
64 
66  Fraction _tick { Fraction(0, 1) };
68  int _no { 0 };
69  int _noOffset { 0 };
70 
71  protected:
72  Fraction _len { Fraction(0, 1) };
73  void cleanupLayoutBreaks(bool undo);
74 
75  public:
76  MeasureBase(Score* score = 0);
77  ~MeasureBase();
78  MeasureBase(const MeasureBase&);
79 
80  virtual MeasureBase* clone() const = 0;
81  virtual ElementType type() const = 0;
82 
83  virtual void setScore(Score* s) override;
84 
85  MeasureBase* next() const { return _next; }
86  MeasureBase* nextMM() const;
87  void setNext(MeasureBase* e) { _next = e; }
88  MeasureBase* prev() const { return _prev; }
89  void setPrev(MeasureBase* e) { _prev = e; }
90 
91  Ms::Measure* nextMeasure() const;
92  Ms::Measure* prevMeasure() const;
93  Ms::Measure* nextMeasureMM() const;
94  Ms::Measure* prevMeasureMM() const;
95 
96  virtual void write(XmlWriter&) const override = 0;
97  virtual void write(XmlWriter&, int, bool, bool) const = 0;
98 
99  virtual void layout();
100 
101  virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true);
102  ElementList& el() { return _el; }
103  const ElementList& el() const { return _el; }
104  System* system() const { return (System*)parent(); }
105  void setSystem(System* s) { setParent((Element*)s); }
106 
107  LayoutBreak* sectionBreakElement() const;
108 
109  void undoSetBreak(bool v, LayoutBreak::Type type);
110  void undoSetLineBreak(bool v) { undoSetBreak(v, LayoutBreak::LINE);}
111  void undoSetPageBreak(bool v) { undoSetBreak(v, LayoutBreak::PAGE);}
112  void undoSetSectionBreak(bool v) { undoSetBreak(v, LayoutBreak::SECTION);}
113  void undoSetNoBreak(bool v) { undoSetBreak(v, LayoutBreak::NOBREAK);}
114 
115  virtual void moveTicks(const Fraction& diff) { setTick(tick() + diff); }
116 
117  virtual void add(Element*) override;
118  virtual void remove(Element*) override;
119  virtual void writeProperties(XmlWriter&) const override;
120  virtual bool readProperties(XmlReader&) override;
121 
122  Fraction tick() const { return _tick; }
123  void setTick(const Fraction& f) { _tick = f; }
124 
125  Fraction ticks() const { return _len; }
126  void setTicks(const Fraction& f) { _len = f; }
127 
128  Fraction endTick() const { return _tick + _len; }
129 
130  void triggerLayout() const override;
131 
132  qreal pause() const;
133 
134  virtual QVariant getProperty(Pid) const override;
135  virtual bool setProperty(Pid, const QVariant&) override;
136  virtual QVariant propertyDefault(Pid) const override;
137 
138  void clearElements();
139  ElementList takeElements();
140 
141  int no() const { return _no; }
142  void setNo(int n) { _no = n; }
143  int noOffset() const { return _noOffset; }
144  void setNoOffset(int n) { _noOffset = n; }
145 
146  bool repeatEnd() const { return flag(ElementFlag::REPEAT_END); }
147  void setRepeatEnd(bool v) { setFlag(ElementFlag::REPEAT_END, v); }
148 
149  bool repeatStart() const { return flag(ElementFlag::REPEAT_START); }
150  void setRepeatStart(bool v) { setFlag(ElementFlag::REPEAT_START, v); }
151 
152  bool repeatJump() const { return flag(ElementFlag::REPEAT_JUMP); }
153  void setRepeatJump(bool v) { setFlag(ElementFlag::REPEAT_JUMP, v); }
154 
155  bool irregular() const { return flag(ElementFlag::IRREGULAR); }
156  void setIrregular(bool v) { setFlag(ElementFlag::IRREGULAR, v); }
157 
158  bool lineBreak() const { return flag(ElementFlag::LINE_BREAK); }
159  void setLineBreak(bool v) { setFlag(ElementFlag::LINE_BREAK, v); }
160 
161  bool pageBreak() const { return flag(ElementFlag::PAGE_BREAK); }
162  void setPageBreak(bool v) { setFlag(ElementFlag::PAGE_BREAK, v); }
163 
164  bool sectionBreak() const { return flag(ElementFlag::SECTION_BREAK); }
165  void setSectionBreak(bool v) { setFlag(ElementFlag::SECTION_BREAK, v); }
166 
167  bool noBreak() const { return flag(ElementFlag::NO_BREAK); }
168  void setNoBreak(bool v) { setFlag(ElementFlag::NO_BREAK, v); }
169 
170  bool hasCourtesyKeySig() const { return flag(ElementFlag::KEYSIG); }
171  void setHasCourtesyKeySig(int v) { setFlag(ElementFlag::KEYSIG, v); }
172 
173  virtual void computeMinWidth() { };
174 
175  int index() const;
176  int measureIndex() const;
177  };
178 
179 
180 } // namespace Ms
181 #endif
182 
symbols for line break, page break etc.
Definition: layoutbreak.h:27
Pid
Definition: property.h:62
Virtual base class for Measure, HBox and VBox.
Definition: measurebase.h:61
Definition: xml.h:67
virtual void moveTicks(const Fraction &diff)
Definition: measurebase.h:115
bool repeatEnd() const
Definition: measurebase.h:146
ElementList & el()
Definition: measurebase.h:102
one measure in a system
Definition: measure.h:65
constexpr ArticulationShowIn operator|(ArticulationShowIn a1, ArticulationShowIn a2)
Definition: articulation.h:45
void setTicks(const Fraction &f)
Definition: measurebase.h:126
void setNoOffset(int n)
Definition: measurebase.h:144
Base class of score layout elements.
Definition: element.h:158
bool hasCourtesyKeySig() const
Definition: measurebase.h:170
Definition: layoutbreak.h:32
Definition: element.h:517
void setRepeatEnd(bool v)
Definition: measurebase.h:147
void setIrregular(bool v)
Definition: measurebase.h:156
bool repeatStart() const
Definition: measurebase.h:149
bool repeatJump() const
Definition: measurebase.h:152
MeasureBase * next() const
Definition: measurebase.h:85
Definition: score.h:391
void undoSetPageBreak(bool v)
Definition: measurebase.h:111
constexpr bool operator &(ArticulationShowIn a1, ArticulationShowIn a2)
Definition: articulation.h:48
MeasureBase * prev() const
Definition: measurebase.h:88
void setRepeatStart(bool v)
Definition: measurebase.h:150
bool irregular() const
Definition: measurebase.h:155
Type
Definition: layoutbreak.h:30
ElementList _el
Measure(/tick) relative -elements: with defined start time but outside the staff. ...
Definition: measurebase.h:65
bool sectionBreak() const
Definition: measurebase.h:164
Fraction endTick() const
Definition: measurebase.h:128
void setSystem(System *s)
Definition: measurebase.h:105
void setPageBreak(bool v)
Definition: measurebase.h:162
void setNo(int n)
Definition: measurebase.h:142
bool pageBreak() const
Definition: measurebase.h:161
System * system() const
Definition: measurebase.h:104
int no() const
Definition: measurebase.h:141
void setRepeatJump(bool v)
Definition: measurebase.h:153
Definition: aeolus.cpp:26
int noOffset() const
Definition: measurebase.h:143
void setNext(MeasureBase *e)
Definition: measurebase.h:87
bool lineBreak() const
Definition: measurebase.h:158
Fraction ticks() const
Definition: measurebase.h:125
Definition: layoutbreak.h:32
void setHasCourtesyKeySig(int v)
Definition: measurebase.h:171
Definition: xml.h:218
void setPrev(MeasureBase *e)
Definition: measurebase.h:89
Definition: layoutbreak.h:32
void setLineBreak(bool v)
Definition: measurebase.h:159
bool noBreak() const
Definition: measurebase.h:167
void undoSetNoBreak(bool v)
Definition: measurebase.h:113
virtual void computeMinWidth()
Definition: measurebase.h:173
void undoSetLineBreak(bool v)
Definition: measurebase.h:110
const ElementList & el() const
Definition: measurebase.h:103
void setSectionBreak(bool v)
Definition: measurebase.h:165
void setTick(const Fraction &f)
Definition: measurebase.h:123
Repeat
Definition: measurebase.h:34
One row of measures for all instruments; a complete piece of the timeline.
Definition: system.h:79
Fraction tick() const
Definition: measurebase.h:122
Definition: fraction.h:46
void undoSetSectionBreak(bool v)
Definition: measurebase.h:112
ElementType
Definition: types.h:34
void setNoBreak(bool v)
Definition: measurebase.h:168
Definition: layoutbreak.h:32