MuseScore  3.4
Music composition and notation
vibrato.h
Go to the documentation of this file.
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);
32  virtual Sid getPropertyStyle(Pid) const override;
33 
34  protected:
35  public:
37  Vibrato* vibrato() const { return toVibrato(spanner()); }
38  virtual ElementType type() const override { return ElementType::VIBRATO_SEGMENT; }
39  virtual VibratoSegment* clone() const override { return new VibratoSegment(*this); }
40  virtual void draw(QPainter*) const override;
41  virtual void layout() override;
42 
43  virtual Element* propertyDelegate(Pid) override;
44 
45  Shape shape() const override;
46  std::vector<SymId> symbols() const { return _symbols; }
47  void setSymbols(const std::vector<SymId>& s) { _symbols = s; }
48  };
49 
50 //---------------------------------------------------------
51 // Vibrato
52 //---------------------------------------------------------
53 
54 class Vibrato final : public SLine {
55 
56  virtual Sid getPropertyStyle(Pid) const override;
57 
58  public:
59  enum class Type : char {
60  GUITAR_VIBRATO, GUITAR_VIBRATO_WIDE, VIBRATO_SAWTOOTH, VIBRATO_SAWTOOTH_WIDE
61  };
62  private:
65 
66  public:
67  Vibrato(Score* s);
68  virtual ~Vibrato();
69  virtual Vibrato* clone() const override { return new Vibrato(*this); }
70  virtual ElementType type() const override { return ElementType::VIBRATO; }
71 
72  virtual void layout() override;
73  virtual LineSegment* createLineSegment() override;
74  virtual void write(XmlWriter&) const override;
75  virtual void read(XmlReader&) override;
76 
77  void setVibratoType(const QString& s);
78  void undoSetVibratoType(Type val);
79  void setVibratoType(Type tt) { _vibratoType = tt; }
80  Type vibratoType() const { return _vibratoType; }
81  void setPlayArticulation(bool val) { _playArticulation = val;}
82  bool playArticulation() const { return _playArticulation; }
83  static QString type2name(Vibrato::Type t);
84  QString vibratoTypeName() const;
85  QString vibratoTypeUserName() const;
86 
87  Segment* segment() const { return (Segment*)parent(); }
88 
89  virtual QVariant getProperty(Pid propertyId) const override;
90  virtual bool setProperty(Pid propertyId, const QVariant&) override;
91  virtual QVariant propertyDefault(Pid) const override;
92  virtual Pid propertyId(const QStringRef& xmlName) const override;
93  virtual QString accessibleInfo() const override;
94  };
95 
96 //---------------------------------------------------------
97 // VibratoTableItem
98 //---------------------------------------------------------
99 
102  const char* name;
103  QString userName;
104  };
105 
106 extern const VibratoTableItem vibratoTable[];
107 extern int vibratoTableSize();
108 
109 } // namespace Ms
110 
111 Q_DECLARE_METATYPE(Ms::Vibrato::Type);
112 
113 #endif
114 
virtual ElementType type() const override
Definition: vibrato.h:38
bool playArticulation() const
Definition: vibrato.h:82
Pid
Definition: property.h:62
void setPlayArticulation(bool val)
Definition: vibrato.h:81
Type
Definition: vibrato.h:59
Definition: xml.h:67
const VibratoTableItem vibratoTable[]
Definition: vibrato.cpp:32
Virtual base class for slurs, ties, lines etc.
Definition: spanner.h:136
virtual QString accessibleInfo() const override
Definition: spanner.cpp:305
std::vector< SymId > symbols() const
Definition: vibrato.h:46
SymId
Definition: sym.h:30
Base class of score layout elements.
Definition: element.h:158
virtual ElementType type() const override
Definition: vibrato.h:70
virtual QVariant propertyDefault(Pid id) const override
Definition: spanner.cpp:162
bool _playArticulation
Definition: vibrato.h:64
Spanner * spanner() const
Definition: spanner.h:67
void setSymbols(const std::vector< SymId > &s)
Definition: vibrato.h:47
Element * parent() const
Definition: element.h:192
virtual Element * propertyDelegate(Pid) override
Definition: vibrato.cpp:145
Virtual base class for segmented lines segments (OttavaSegment, HairpinSegment, TrillSegment...)
Definition: line.h:34
virtual void write(XmlWriter &) const
Definition: element.cpp:732
Definition: score.h:391
Shape shape() const override
Definition: vibrato.cpp:136
int vibratoTableSize()
Definition: vibrato.cpp:39
void symbolLine(SymId start, SymId fill)
Definition: vibrato.cpp:57
virtual Sid getPropertyStyle(Pid) const override
Definition: vibrato.cpp:297
virtual VibratoSegment * clone() const override
Definition: vibrato.h:39
std::vector< SymId > _symbols
Definition: vibrato.h:28
virtual Pid propertyId(const QStringRef &xmlName) const override
Definition: element.cpp:1326
virtual base class for Hairpin, Trill and TextLine
Definition: line.h:70
Vibrato::Type type
Definition: vibrato.h:101
virtual void draw(QPainter *) const override
Definition: vibrato.cpp:47
Vibrato * vibrato() const
Definition: vibrato.h:37
virtual QVariant getProperty(Pid id) const override
Definition: spanner.cpp:127
ElementFlag
Definition: element.h:66
Definition: vibrato.h:54
Definition: segment.h:50
Type vibratoType() const
Definition: vibrato.h:80
Definition: aeolus.cpp:26
virtual Vibrato * clone() const override
Definition: vibrato.h:69
Sid
Definition: style.h:33
Definition: xml.h:218
virtual void layout() override
Definition: vibrato.cpp:101
void setVibratoType(Type tt)
Definition: vibrato.h:79
virtual void read(XmlReader &) override
Definition: line.cpp:69
Type _vibratoType
Definition: vibrato.h:63
virtual bool setProperty(Pid id, const QVariant &v) override
Definition: spanner.cpp:143
Definition: shape.h:42
Segment * segment() const
Definition: vibrato.h:87
VibratoSegment(Spanner *sp, Score *s)
Definition: vibrato.h:36
ElementType
Definition: types.h:34
Definition: vibrato.h:100
const char * name
Definition: vibrato.h:102
Definition: vibrato.h:27
QString userName
Definition: vibrato.h:103