MuseScore  3.4
Music composition and notation
rest.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 __REST_H__
14 #define __REST_H__
15 
16 #include "chordrest.h"
17 #include "notedot.h"
18 
19 namespace Ms {
20 
21 class TDuration;
22 enum class SymId;
23 
24 //---------------------------------------------------------
25 // @@ Rest
27 //---------------------------------------------------------
28 
29 class Rest : public ChordRest {
30  // values calculated by layout:
32  int dotline { -1 }; // depends on rest symbol
33  qreal _mmWidth; // width of multi measure rest
34  bool _gap { false }; // invisible and not selectable for user
35  std::vector<NoteDot*> _dots;
36 
37  virtual QRectF drag(EditData&) override;
38  virtual qreal upPos() const override;
39  virtual qreal downPos() const override;
40  virtual void setOffset(const QPointF& o) override;
41 
42 
43  public:
44  Rest(Score* s = 0);
45  Rest(Score*, const TDuration&);
46  Rest(const Rest&, bool link = false);
47  ~Rest() { qDeleteAll(_dots); }
48 
49  virtual ElementType type() const override { return ElementType::REST; }
50  Rest &operator=(const Rest&) = delete;
51 
52  virtual Rest* clone() const override { return new Rest(*this, false); }
53  virtual Element* linkedClone() { return new Rest(*this, true); }
54  virtual Measure* measure() const override { return parent() ? (Measure*)(parent()->parent()) : 0; }
55  virtual qreal mag() const override;
56  virtual void draw(QPainter*) const override;
57  virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true) override;
58  void setTrack(int val);
59 
60  virtual bool acceptDrop(EditData&) const override;
61  virtual Element* drop(EditData&) override;
62  virtual void layout() override;
63 
64  bool isGap() const { return _gap; }
65  virtual void setGap(bool v) { _gap = v; }
66 
67  virtual void reset() override;
68 
69  virtual void add(Element*);
70  virtual void remove(Element*);
71 
72  virtual void read(XmlReader&) override;
73  virtual void write(XmlWriter& xml) const override;
74 
75  void layoutMMRest(qreal val);
76  qreal mmWidth() const { return _mmWidth; }
77  SymId getSymbol(TDuration::DurationType type, int line, int lines, int* yoffset);
78 
79  void checkDots();
80  void layoutDots();
81  NoteDot* dot(int n);
82  int getDotline() const { return dotline; }
84  SymId sym() const { return _sym; }
85  bool accent();
86  void setAccent(bool flag);
87  int computeLineOffset(int lines);
88 
89  virtual int upLine() const;
90  virtual int downLine() const;
91  virtual QPointF stemPos() const;
92  virtual qreal stemPosX() const;
93  virtual QPointF stemPosBeam() const;
94 
95  virtual void localSpatiumChanged(qreal oldValue, qreal newValue) override;
96  virtual bool setProperty(Pid propertyId, const QVariant& v) override;
97  void undoChangeDotsVisible(bool v);
98  virtual QVariant getProperty(Pid propertyId) const override;
99  virtual QVariant propertyDefault(Pid) const override;
100 
101  virtual Element* nextElement() override;
102  virtual Element* prevElement() override;
103  virtual QString accessibleInfo() const override;
104  virtual QString screenReaderInfo() const override;
105  Shape shape() const override;
106  };
107 
108 } // namespace Ms
109 #endif
110 
virtual QPointF stemPosBeam() const
Definition: rest.cpp:735
virtual void localSpatiumChanged(qreal oldValue, qreal newValue) override
Definition: rest.cpp:917
void checkDots()
Definition: rest.cpp:423
virtual void write(XmlWriter &xml) const override
Definition: rest.cpp:857
virtual qreal stemPosX() const
Definition: rest.cpp:749
Definition: durationtype.h:28
void undoChangeDotsVisible(bool v)
Definition: rest.cpp:988
virtual QVariant propertyDefault(Pid) const override
Definition: rest.cpp:944
Pid
Definition: property.h:62
~Rest()
Definition: rest.h:47
Definition: xml.h:67
virtual Element * drop(EditData &) override
Handle a dropped element at canvas relative pos of given element type and subtype.
Definition: rest.cpp:215
virtual void draw(QPainter *) const override
Definition: rest.cpp:75
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: rest.cpp:172
int getDotline() const
Definition: rest.h:82
virtual qreal downPos() const override
Definition: rest.cpp:646
SymId sym() const
Definition: rest.h:84
one measure in a system
Definition: measure.h:65
virtual QPointF stemPos() const
Definition: rest.cpp:724
DurationType
Definition: durationtype.h:30
SymId _sym
Definition: rest.h:31
virtual qreal upPos() const override
Definition: rest.cpp:637
virtual void read(XmlReader &) override
Definition: rest.cpp:881
const TDuration durationType() const
Definition: chordrest.h:117
SymId getSymbol(TDuration::DurationType type, int line, int lines, int *yoffset)
Definition: rest.cpp:272
void layoutDots()
Definition: rest.cpp:406
qreal _mmWidth
Definition: rest.h:33
virtual Rest * clone() const override
Definition: rest.h:52
SymId
Definition: sym.h:30
Base class of score layout elements.
Definition: element.h:158
int line() const
Definition: chordrest.h:98
Rest(Score *s=0)
Definition: rest.cpp:39
virtual void add(Element *)
Definition: rest.cpp:813
int computeLineOffset(int lines)
Definition: rest.cpp:478
Element * parent() const
Definition: element.h:192
Definition: score.h:391
virtual ElementType type() const override
Definition: rest.h:49
virtual QString accessibleInfo() const override
Definition: rest.cpp:791
virtual void setGap(bool v)
Definition: rest.h:65
virtual Pid propertyId(const QStringRef &xmlName) const override
Definition: element.cpp:1326
void setTrack(int val)
Definition: rest.cpp:670
Rest & operator=(const Rest &)=delete
virtual int upLine() const
Definition: rest.cpp:703
virtual QString screenReaderInfo() const override
Definition: rest.cpp:801
int dotline
Definition: rest.h:32
Definition: aeolus.cpp:26
virtual bool setProperty(Pid propertyId, const QVariant &v) override
Definition: rest.cpp:958
void setAccent(bool flag)
Definition: rest.cpp:770
std::vector< NoteDot * > _dots
Definition: rest.h:35
virtual QRectF drag(EditData &) override
Return update Rect relative to canvas.
Definition: rest.cpp:149
Shape shape() const override
Definition: rest.cpp:1016
This class implements a rest.
Definition: rest.h:29
virtual Measure * measure() const override
Definition: rest.h:54
Definition: xml.h:218
virtual Element * prevElement() override
Definition: rest.cpp:1007
virtual Element * linkedClone()
Definition: rest.h:53
virtual void reset() override
Definition: rest.cpp:681
Definition: chordrest.h:48
bool accent()
Definition: rest.cpp:761
Definition: element.h:111
bool isGap() const
Definition: rest.h:64
virtual QVariant getProperty(Pid propertyId) const override
Definition: rest.cpp:930
virtual qreal mag() const override
Definition: rest.cpp:691
Definition: notedot.h:27
virtual void layout() override
Definition: rest.cpp:337
virtual Element * nextElement() override
Definition: rest.cpp:998
NoteDot * dot(int n)
Definition: rest.cpp:442
qreal mmWidth() const
Definition: rest.h:76
Definition: shape.h:42
ElementType
Definition: types.h:34
void layoutMMRest(qreal val)
Definition: rest.cpp:317
virtual void scanElements(void *data, void(*func)(void *, Element *), bool all=true) override
Definition: rest.cpp:655
virtual int downLine() const
Definition: rest.cpp:713
virtual void setOffset(const QPointF &o) override
Definition: rest.cpp:128
bool flag(ElementFlag f) const
Definition: element.h:205
bool _gap
Definition: rest.h:34