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 {
23       NORMAL, UP, DOWN, BRACKET, UP_STRAIGHT, DOWN_STRAIGHT
24       };
25 
26 //---------------------------------------------------------
27 //   @@ Arpeggio
28 //---------------------------------------------------------
29 
30 class Arpeggio final : public Element {
31       ArpeggioType _arpeggioType;
32       qreal _userLen1;
33       qreal _userLen2;
34       qreal _height;
35       int _span;              // spanning staves
36       std::vector<SymId> symbols;
37       bool _playArpeggio;
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       void spatiumChanged(qreal /*oldValue*/, qreal /*newValue*/) override;
47       QVector<QLineF> dragAnchorLines() const override;
48       QVector<QLineF> gripAnchorLines(Grip) const override;
49       void startEdit(EditData&) override;
50 
51       static const std::array<const char*, 6> arpeggioTypeNames;
52 
53    public:
54       Arpeggio(Score* s);
55 
clone()56       Arpeggio* clone() const override    { return new Arpeggio(*this); }
type()57       ElementType type() const override   { return ElementType::ARPEGGIO; }
58 
arpeggioType()59       ArpeggioType arpeggioType() const    { return _arpeggioType; }
setArpeggioType(ArpeggioType v)60       void setArpeggioType(ArpeggioType v) { _arpeggioType = v;    }
arpeggioTypeName()61       QString arpeggioTypeName()           { return qApp->translate("Palette", arpeggioTypeNames[int(_arpeggioType)]); }
62 
chord()63       Chord* chord() const                 { return (Chord*)parent(); }
64 
65       bool acceptDrop(EditData&) const override;
66       Element* drop(EditData&) override;
67       void layout() override;
68       void draw(QPainter*) const override;
isEditable()69       bool isEditable() const override { return true; }
70       void editDrag(EditData&) override;
71       bool edit(EditData&) override;
72 
73       void read(XmlReader& e) override;
74       void write(XmlWriter& xml) const override;
75       void reset() override;
76 
span()77       int span() const      { return _span; }
setSpan(int val)78       void setSpan(int val) { _span = val; }
79       void setHeight(qreal);
80 
userLen1()81       qreal userLen1() const    { return _userLen1; }
userLen2()82       qreal userLen2() const    { return _userLen2; }
setUserLen1(qreal v)83       void setUserLen1(qreal v) { _userLen1 = v; }
setUserLen2(qreal v)84       void setUserLen2(qreal v) { _userLen2 = v; }
85 
playArpeggio()86       bool playArpeggio()       { return _playArpeggio; }
setPlayArpeggio(bool p)87       void setPlayArpeggio(bool p) { _playArpeggio = p; }
88 
Stretch()89       qreal Stretch() const             { return _stretch; }
setStretch(qreal val)90       void setStretch(qreal val)        { _stretch = val;  }
91 
92       QVariant getProperty(Pid propertyId) const override;
93       bool setProperty(Pid propertyId, const QVariant&) override;
94       QVariant propertyDefault(Pid propertyId) const override;
95       Pid propertyId(const QStringRef& xmlName) const override;
96 
97       // TODO: add a grip for moving the entire arpeggio
normalModeEditBehavior()98       EditBehavior normalModeEditBehavior() const override { return EditBehavior::Edit; }
gripsCount()99       int gripsCount() const override { return 2; }
initialEditModeGrip()100       Grip initialEditModeGrip() const override { return Grip::END; }
defaultGrip()101       Grip defaultGrip() const override { return Grip::START; }
102       std::vector<QPointF> gripsPositions(const EditData& = EditData()) const override;
103       };
104 
105 
106 }     // namespace Ms
107 #endif
108 
109