1 //=============================================================================
2 //  MuseScore
3 //  Music Composition & Notation
4 //
5 //  Copyright (C) 2017 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 __VIBRATO_H__
14 #define __VIBRATO_H__
15 
16 #include "line.h"
17 
18 namespace Ms {
19 
20 class Vibrato;
21 class Accidental;
22 
23 //---------------------------------------------------------
24 //   @@ VibratoSegment
25 //---------------------------------------------------------
26 
27 class VibratoSegment final : public LineSegment {
28       std::vector<SymId> _symbols;
29 
30       void symbolLine(SymId start, SymId fill);
31       void symbolLine(SymId start, SymId fill, SymId end);
getPropertyStyle(Pid)32       virtual Sid getPropertyStyle(Pid) const override;
33 
34    protected:
35    public:
36       VibratoSegment(Spanner* sp, Score* s) : LineSegment(sp, s, ElementFlag::MOVABLE | ElementFlag::ON_STAFF)      {}
37 
type()38       ElementType type() const override      { return ElementType::VIBRATO_SEGMENT; }
clone()39       VibratoSegment* clone() const override { return new VibratoSegment(*this); }
40 
vibrato()41       Vibrato* vibrato() const               { return toVibrato(spanner()); }
42 
43       void draw(QPainter*) const override;
44       void layout() override;
45 
46       Element* propertyDelegate(Pid) override;
47 
48       Shape shape() const override;
symbols()49       std::vector<SymId> symbols() const           { return _symbols; }
setSymbols(const std::vector<SymId> & s)50       void setSymbols(const std::vector<SymId>& s) { _symbols = s; }
51       };
52 
53 //---------------------------------------------------------
54 //   Vibrato
55 //---------------------------------------------------------
56 
57 class Vibrato final : public SLine {
58 
getPropertyStyle(Pid)59       Sid getPropertyStyle(Pid) const override;
60 
61    public:
62       enum class Type : char {
63             GUITAR_VIBRATO, GUITAR_VIBRATO_WIDE, VIBRATO_SAWTOOTH, VIBRATO_SAWTOOTH_WIDE
64             };
65    private:
66       Type _vibratoType;
67       bool _playArticulation;
68 
69    public:
70       Vibrato(Score* s);
71       ~Vibrato();
72 
clone()73       Vibrato* clone() const override   { return new Vibrato(*this);   }
type()74       ElementType type() const override { return ElementType::VIBRATO; }
75 
76       void layout() override;
77       LineSegment* createLineSegment() override;
78 
79       void write(XmlWriter&) const override;
80       void read(XmlReader&) override;
81 
82       void setVibratoType(const QString& s);
83       void undoSetVibratoType(Type val);
setVibratoType(Type tt)84       void setVibratoType(Type tt)        { _vibratoType = tt; }
vibratoType()85       Type vibratoType() const              { return _vibratoType; }
setPlayArticulation(bool val)86       void setPlayArticulation(bool val)  { _playArticulation = val;}
playArticulation()87       bool playArticulation() const       { return _playArticulation; }
88       static QString type2name(Vibrato::Type t);
89       QString vibratoTypeName() const;
90       QString vibratoTypeUserName() const;
91 
segment()92       Segment* segment() const          { return (Segment*)parent(); }
93 
94       QVariant getProperty(Pid propertyId) const override;
95       bool setProperty(Pid propertyId, const QVariant&) override;
96       QVariant propertyDefault(Pid) const override;
97       Pid propertyId(const QStringRef& xmlName) const override;
98       QString accessibleInfo() const override;
99       };
100 
101 //---------------------------------------------------------
102 //   VibratoTableItem
103 //---------------------------------------------------------
104 
105 struct VibratoTableItem {
106       Vibrato::Type type;
107       const char* name;
108       QString userName;
109       };
110 
111 extern const VibratoTableItem vibratoTable[];
112 extern int vibratoTableSize();
113 
114 }     // namespace Ms
115 
116 Q_DECLARE_METATYPE(Ms::Vibrato::Type);
117 
118 #endif
119 
120