MuseScore  3.4
Music composition and notation
trill.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 __TRILL_H__
14 #define __TRILL_H__
15 
16 #include "line.h"
17 
18 namespace Ms {
19 
20 class Trill;
21 class Accidental;
22 
23 //---------------------------------------------------------
24 // @@ TrillSegment
25 //---------------------------------------------------------
26 
27 class TrillSegment 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:
38  Trill* trill() const { return (Trill*)spanner(); }
39  virtual ElementType type() const override { return ElementType::TRILL_SEGMENT; }
40  virtual TrillSegment* clone() const override { return new TrillSegment(*this); }
41  virtual void draw(QPainter*) const override;
42  virtual bool acceptDrop(EditData&) const override;
43  virtual Element* drop(EditData&) override;
44  virtual void layout() override;
45 
46  virtual Element* propertyDelegate(Pid) override;
47 
48  virtual void add(Element*) override;
49  virtual void remove(Element*) override;
50  virtual void scanElements(void* data, void (*func)(void*, Element*), bool all) override;
51  Shape shape() const override;
52 
53  std::vector<SymId> symbols() const { return _symbols; }
54  void setSymbols(const std::vector<SymId>& s) { _symbols = s; }
55  };
56 
57 //---------------------------------------------------------
58 // @@ Trill
59 // @P trillType enum (Trill.DOWNPRALL_LINE, .PRALLPRALL_LINE, .PURE_LINE, .TRILL_LINE, .UPPRALL_LINE)
60 //---------------------------------------------------------
61 
62 class Trill final : public SLine {
63  virtual Sid getPropertyStyle(Pid) const override;
64 
65  public:
66  enum class Type : char {
67  TRILL_LINE, UPPRALL_LINE, DOWNPRALL_LINE, PRALLPRALL_LINE,
68  };
69 
70  private:
73  MScore::OrnamentStyle _ornamentStyle; // for use in ornaments such as trill
75 
76  public:
77  Trill(Score* s);
78  virtual ~Trill();
79  virtual Trill* clone() const override { return new Trill(*this); }
80  virtual ElementType type() const override { return ElementType::TRILL; }
81 
82  virtual void layout() override;
83  virtual LineSegment* createLineSegment() override;
84  virtual void add(Element*) override;
85  virtual void remove(Element*) override;
86  virtual void write(XmlWriter&) const override;
87  virtual void read(XmlReader&) override;
88 
89  void setTrillType(const QString& s);
90  void setTrillType(Type tt) { _trillType = tt; }
91  Type trillType() const { return _trillType; }
92  void setOrnamentStyle(MScore::OrnamentStyle val) { _ornamentStyle = val;}
93  MScore::OrnamentStyle ornamentStyle() const { return _ornamentStyle;}
94  void setPlayArticulation(bool val) { _playArticulation = val;}
95  bool playArticulation() const { return _playArticulation; }
96  static QString type2name(Trill::Type t);
97  QString trillTypeName() const;
98  QString trillTypeUserName() const;
99  Accidental* accidental() const { return _accidental; }
100  void setAccidental(Accidental* a) { _accidental = a; }
101 
102  Segment* segment() const { return (Segment*)parent(); }
103  virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true) override;
104 
105  virtual QVariant getProperty(Pid propertyId) const override;
106  virtual bool setProperty(Pid propertyId, const QVariant&) override;
107  virtual QVariant propertyDefault(Pid) const override;
108  virtual Pid propertyId(const QStringRef& xmlName) const override;
109 
110  virtual QString accessibleInfo() const override;
111  };
112 
115  const char* name;
116  QString userName;
117  };
118 
119 extern const TrillTableItem trillTable[];
120 extern int trillTableSize();
121 
122 } // namespace Ms
123 
124 Q_DECLARE_METATYPE(Ms::Trill::Type);
125 
126 #endif
127 
virtual Sid getPropertyStyle(Pid) const override
Definition: trill.cpp:247
Shape shape() const override
Definition: trill.cpp:181
int trillTableSize()
Definition: trill.cpp:40
bool playArticulation() const
Definition: trill.h:95
OrnamentStyle
Definition: mscore.h:298
void setOrnamentStyle(MScore::OrnamentStyle val)
Definition: trill.h:92
Pid
Definition: property.h:62
Definition: trill.h:113
Definition: xml.h:67
Segment * segment() const
Definition: trill.h:102
Virtual base class for slurs, ties, lines etc.
Definition: spanner.h:136
virtual QString accessibleInfo() const override
Definition: spanner.cpp:305
void setPlayArticulation(bool val)
Definition: trill.h:94
Trill::Type type
Definition: trill.h:114
const TrillTableItem trillTable[]
Definition: trill.cpp:33
SymId
Definition: sym.h:30
Base class of score layout elements.
Definition: element.h:158
virtual QVariant propertyDefault(Pid id) const override
Definition: spanner.cpp:162
Spanner * spanner() const
Definition: spanner.h:67
void symbolLine(SymId start, SymId fill)
Definition: trill.cpp:92
Element * parent() const
Definition: element.h:192
virtual Trill * clone() const override
Definition: trill.h:79
Virtual base class for segmented lines segments (OttavaSegment, HairpinSegment, TrillSegment...)
Definition: line.h:34
bool _playArticulation
Definition: trill.h:74
virtual void write(XmlWriter &) const
Definition: element.cpp:732
Type
Definition: trill.h:66
Definition: accidental.h:65
Definition: trill.h:62
Definition: score.h:391
Type _trillType
Definition: trill.h:71
TrillSegment(Score *s)
Definition: trill.h:37
virtual ElementType type() const override
Definition: trill.h:80
MScore::OrnamentStyle _ornamentStyle
Definition: trill.h:73
std::vector< SymId > _symbols
Definition: trill.h:28
virtual void scanElements(void *data, void(*func)(void *, Element *), bool all) override
Definition: trill.cpp:233
virtual Pid propertyId(const QStringRef &xmlName) const override
Definition: element.cpp:1326
virtual base class for Hairpin, Trill and TextLine
Definition: line.h:70
Trill * trill() const
Definition: trill.h:38
Definition: trill.h:27
virtual void layout() override
Definition: trill.cpp:136
virtual TrillSegment * clone() const override
Definition: trill.h:40
MScore::OrnamentStyle ornamentStyle() const
Definition: trill.h:93
void setTrillType(Type tt)
Definition: trill.h:90
virtual QVariant getProperty(Pid id) const override
Definition: spanner.cpp:127
ElementFlag
Definition: element.h:66
Definition: segment.h:50
const char * name
Definition: trill.h:115
Definition: aeolus.cpp:26
virtual Element * propertyDelegate(Pid) override
Definition: trill.cpp:222
Sid
Definition: style.h:33
void setSymbols(const std::vector< SymId > &s)
Definition: trill.h:54
QString userName
Definition: trill.h:116
Definition: xml.h:218
void setAccidental(Accidental *a)
Definition: trill.h:100
virtual ElementType type() const override
Definition: trill.h:39
Type trillType() const
Definition: trill.h:91
virtual bool acceptDrop(EditData &) const override
Return true if this element accepts a drop at canvas relative pos of given element type and subtype...
Definition: trill.cpp:190
virtual void read(XmlReader &) override
Definition: line.cpp:69
Definition: element.h:111
virtual void draw(QPainter *) const override
Definition: trill.cpp:57
virtual bool setProperty(Pid id, const QVariant &v) override
Definition: spanner.cpp:143
std::vector< SymId > symbols() const
Definition: trill.h:53
Definition: shape.h:42
Accidental * accidental() const
Definition: trill.h:99
ElementType
Definition: types.h:34
Accidental * _accidental
Definition: trill.h:72
TrillSegment(Spanner *sp, Score *s)
Definition: trill.h:36
virtual void add(Element *) override
Definition: trill.cpp:67
virtual Element * drop(EditData &) override
Handle a dropped element at canvas relative pos of given element type and subtype.
Definition: trill.cpp:201