MuseScore  3.4
Music composition and notation
arpeggio.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 __ARPEGGIO_H__
14 #define __ARPEGGIO_H__
15 
16 #include "element.h"
17 
18 namespace Ms {
19 
20 class Chord;
21 
22 enum class ArpeggioType : char {
24  };
25 
26 //---------------------------------------------------------
27 // @@ Arpeggio
28 //---------------------------------------------------------
29 
30 class Arpeggio final : public Element {
32  qreal _userLen1;
33  qreal _userLen2;
34  qreal _height;
35  int _span; // spanning staves
36  std::vector<SymId> symbols;
38 
39  qreal _stretch;
40 
41  bool _hidden = false; // set in layout, will skip draw if true
42 
43  void symbolLine(SymId start, SymId fill);
44  void symbolLine2(SymId end, SymId fill);
45 
46  virtual void spatiumChanged(qreal /*oldValue*/, qreal /*newValue*/) override;
47  virtual QLineF dragAnchor() const override;
48  virtual QPointF gripAnchor(Grip) const override;
49  virtual void startEdit(EditData&) override;
50 
51  public:
52  Arpeggio(Score* s);
53  virtual Arpeggio* clone() const override { return new Arpeggio(*this); }
54  virtual ElementType type() const override { return ElementType::ARPEGGIO; }
55 
56  ArpeggioType arpeggioType() const { return _arpeggioType; }
57  void setArpeggioType(ArpeggioType v) { _arpeggioType = v; }
58 
59  Chord* chord() const { return (Chord*)parent(); }
60 
61  virtual bool acceptDrop(EditData&) const override;
62  virtual Element* drop(EditData&) override;
63  virtual void layout() override;
64  virtual void draw(QPainter*) const override;
65  virtual bool isEditable() const override { return true; }
66  virtual void editDrag(EditData&) override;
67  virtual bool edit(EditData&) override;
68 
69  virtual void read(XmlReader& e) override;
70  virtual void write(XmlWriter& xml) const override;
71  virtual void reset() override;
72 
73  int span() const { return _span; }
74  void setSpan(int val) { _span = val; }
75  void setHeight(qreal);
76 
77  qreal userLen1() const { return _userLen1; }
78  qreal userLen2() const { return _userLen2; }
79  void setUserLen1(qreal v) { _userLen1 = v; }
80  void setUserLen2(qreal v) { _userLen2 = v; }
81 
82  bool playArpeggio() { return _playArpeggio; }
83  void setPlayArpeggio(bool p) { _playArpeggio = p; }
84 
85  qreal Stretch() const { return _stretch; }
86  void setStretch(qreal val) { _stretch = val; }
87 
88  virtual QVariant getProperty(Pid propertyId) const override;
89  virtual bool setProperty(Pid propertyId, const QVariant&) override;
90  virtual QVariant propertyDefault(Pid propertyId) const override;
91  virtual Pid propertyId(const QStringRef& xmlName) const override;
92 
93  // TODO: add a grip for moving the entire arpeggio
94  EditBehavior normalModeEditBehavior() const override { return EditBehavior::Edit; }
95  int gripsCount() const override { return 2; }
96  Grip initialEditModeGrip() const override { return Grip::END; }
97  Grip defaultGrip() const override { return Grip::START; }
98  std::vector<QPointF> gripsPositions(const EditData&) const override;
99  };
100 
101 
102 } // namespace Ms
103 #endif
104 
Pid
Definition: property.h:62
Grip initialEditModeGrip() const override
Definition: arpeggio.h:96
Definition: xml.h:67
int _span
Definition: arpeggio.h:35
EditBehavior normalModeEditBehavior() const override
Definition: arpeggio.h:94
bool playArpeggio()
Definition: arpeggio.h:82
qreal _userLen2
Definition: arpeggio.h:33
SymId
Definition: sym.h:30
Base class of score layout elements.
Definition: element.h:158
qreal Stretch() const
Definition: arpeggio.h:85
void setUserLen1(qreal v)
Definition: arpeggio.h:79
Chord * chord() const
Definition: arpeggio.h:59
void setPlayArpeggio(bool p)
Definition: arpeggio.h:83
qreal userLen2() const
Definition: arpeggio.h:78
ArpeggioType arpeggioType() const
Definition: arpeggio.h:56
ArpeggioType
Definition: arpeggio.h:22
Definition: score.h:391
Definition: arpeggio.h:30
qreal userLen1() const
Definition: arpeggio.h:77
void setUserLen2(qreal v)
Definition: arpeggio.h:80
virtual Arpeggio * clone() const override
Definition: arpeggio.h:53
int gripsCount() const override
Definition: arpeggio.h:95
ArpeggioType _arpeggioType
Definition: arpeggio.h:31
qreal _height
Definition: arpeggio.h:34
Grip
Definition: element.h:43
Definition: aeolus.cpp:26
void setSpan(int val)
Definition: arpeggio.h:74
Definition: xml.h:218
void setArpeggioType(ArpeggioType v)
Definition: arpeggio.h:57
Graphic representation of a chord.
Definition: chord.h:55
qreal _userLen1
Definition: arpeggio.h:32
void setStretch(qreal val)
Definition: arpeggio.h:86
virtual ElementType type() const override
Definition: arpeggio.h:54
std::vector< SymId > symbols
Definition: arpeggio.h:36
Definition: element.h:111
qreal _stretch
Definition: arpeggio.h:39
bool _playArpeggio
Definition: arpeggio.h:37
int span() const
Definition: arpeggio.h:73
ElementType
Definition: types.h:34
Pid propertyId(const QStringRef &s)
Definition: property.cpp:347
EditBehavior
Definition: element.h:173
Grip defaultGrip() const override
Definition: arpeggio.h:97
virtual bool isEditable() const override
Definition: arpeggio.h:65