MuseScore  3.4
Music composition and notation
tremolo.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 __TREMOLO_H__
14 #define __TREMOLO_H__
15 
16 #include "durationtype.h"
17 #include "symbol.h"
18 
19 namespace Ms {
20 
21 class Chord;
22 
23 // Tremolo subtypes:
24 enum class TremoloType : signed char {
25  INVALID_TREMOLO = -1,
26  R8=0, R16, R32, R64, BUZZ_ROLL, // one note tremolo (repeat)
27  C8, C16, C32, C64 // two note tremolo (change)
28  };
29 
30 enum class TremoloPlacement : signed char {
31  DEFAULT = 0,
33  };
34 
35 //---------------------------------------------------------
36 // @@ Tremolo
37 //---------------------------------------------------------
38 
39 class Tremolo final : public Element {
44  QPainterPath path;
45 
46  int _lines; // derived from _subtype
48 
49  QPainterPath basePath() const;
50  void computeShape();
51  void layoutOneNoteTremolo(qreal x, qreal y, qreal spatium);
52  void layoutTwoNotesTremolo(qreal x, qreal y, qreal h, qreal spatium);
53 
54  public:
55  Tremolo(Score*);
56  Tremolo(const Tremolo&);
57  Tremolo &operator=(const Tremolo&) = delete;
58  virtual Tremolo* clone() const { return new Tremolo(*this); }
59  virtual ElementType type() const { return ElementType::TREMOLO; }
60  virtual int subtype() const override { return (int) _tremoloType; }
61  virtual QString subtypeName() const override;
62 
63  QString tremoloTypeName() const;
64  void setTremoloType(const QString& s);
65  static TremoloType name2Type(const QString& s);
66  static QString type2name(TremoloType t);
67 
68  Chord* chord() const { return toChord(parent()); }
69 
70  void setTremoloType(TremoloType t);
71  TremoloType tremoloType() const { return _tremoloType; }
72 
73  virtual qreal mag() const;
74  virtual void draw(QPainter*) const;
75  virtual void layout();
76  void layout2();
77  virtual void write(XmlWriter& xml) const;
78  virtual void read(XmlReader&);
79 
80  Chord* chord1() const { return _chord1; }
81  Chord* chord2() const { return _chord2; }
82 
83  TDuration durationType() const { return _durationType; }
84  void setDurationType(TDuration d) { _durationType = d; }
85 
86  void setChords(Chord* c1, Chord* c2) {
87  _chord1 = c1;
88  _chord2 = c2;
89  }
90  Fraction tremoloLen() const;
91  bool twoNotes() const { return tremoloType() >= TremoloType::C8; } // is it a two note tremolo?
92  int lines() const { return _lines; }
93 
94  bool placeMidStem() const;
95 
96  virtual void spatiumChanged(qreal oldValue, qreal newValue) override;
97  virtual void localSpatiumChanged(qreal oldValue, qreal newValue) override;
98  virtual void styleChanged() override;
99 
100  virtual QString accessibleInfo() const override;
101 
102  virtual QVariant getProperty(Pid propertyId) const override;
103  virtual bool setProperty(Pid propertyId, const QVariant&) override;
104  virtual Pid propertyId(const QStringRef& xmlName) const override;
105  virtual QString propertyUserValue(Pid) const override;
106  };
107 
108 
109 } // namespace Ms
110 #endif
111 
void setChords(Chord *c1, Chord *c2)
Definition: tremolo.h:86
Definition: durationtype.h:28
Pid
Definition: property.h:62
TDuration durationType() const
Definition: tremolo.h:83
Definition: xml.h:67
int _lines
Definition: tremolo.h:46
bool twoNotes() const
Definition: tremolo.h:91
void setDurationType(TDuration d)
Definition: tremolo.h:84
Chord * _chord1
Definition: tremolo.h:41
Definition: tremolo.h:39
int lines() const
Definition: tremolo.h:92
Base class of score layout elements.
Definition: element.h:158
Chord * _chord2
Definition: tremolo.h:42
Definition: score.h:391
Chord * chord2() const
Definition: tremolo.h:81
Chord * chord() const
Definition: tremolo.h:68
virtual int subtype() const override
Definition: tremolo.h:60
QPainterPath path
Definition: tremolo.h:44
Definition: aeolus.cpp:26
Definition: xml.h:218
TremoloType
Definition: tremolo.h:24
Graphic representation of a chord.
Definition: chord.h:55
TremoloPlacement
Definition: tremolo.h:30
Chord * chord1() const
Definition: tremolo.h:80
Definition: fraction.h:46
virtual ElementType type() const
Definition: tremolo.h:59
ElementType
Definition: types.h:34
TDuration _durationType
Definition: tremolo.h:43
TremoloType tremoloType() const
Definition: tremolo.h:71
Pid propertyId(const QStringRef &s)
Definition: property.cpp:347
TremoloType _tremoloType
Definition: tremolo.h:40
virtual Tremolo * clone() const
Definition: tremolo.h:58