MuseScore  3.4
Music composition and notation
duration.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2008-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 __DURATION_H__
14 #define __DURATION_H__
15 
16 #include "config.h"
17 #include "element.h"
18 #include "durationtype.h"
19 
20 namespace Ms {
21 
22 class Tuplet;
23 class Beam;
24 class Spanner;
25 
26 //---------------------------------------------------------
27 // @@ DurationElement
29 //
30 // @P duration Fraction duration (as written)
31 // @P globalDuration Fraction played duration
32 //---------------------------------------------------------
33 
34 class DurationElement : public Element {
37 
38 // #ifdef SCRIPT_INTERFACE
39 // void setDurationW(FractionWrapper* f) { _duration = f->fraction(); }
40 // FractionWrapper* durationW() const { return new FractionWrapper(_duration); }
41 // FractionWrapper* globalDurW() const { return new FractionWrapper(globalDuration()); }
42 // #endif
43 
44  public:
48 
49  virtual Measure* measure() const { return (Measure*)(parent()); }
50 
51  void readAddTuplet(Tuplet* t);
52  void writeTupletStart(XmlWriter& xml) const;
53  void writeTupletEnd(XmlWriter& xml) const;
54 
55  void setTuplet(Tuplet* t) { _tuplet = t; }
56  Tuplet* tuplet() const { return _tuplet; }
57  Tuplet* topTuplet() const;
58  virtual Beam* beam() const { return 0; }
59 
60  Fraction actualTicks() const;
61 
62  virtual Fraction ticks() const { return _duration; }
63  Fraction globalTicks() const;
64  void setTicks(const Fraction& f) { _duration = f; }
65 
66  virtual QVariant getProperty(Pid propertyId) const override;
67  virtual bool setProperty(Pid propertyId, const QVariant&) override;
68  };
69 
70 
71 } // namespace Ms
72 #endif
73 
~DurationElement()
Definition: duration.cpp:49
virtual Fraction ticks() const
Definition: duration.h:62
Definition: beam.h:37
Pid
Definition: property.h:62
void setTicks(const Fraction &f)
Definition: duration.h:64
QFlags< ElementFlag > ElementFlags
Definition: element.h:101
one measure in a system
Definition: measure.h:65
void writeTupletEnd(XmlWriter &xml) const
Definition: duration.cpp:119
Base class of score layout elements.
Definition: element.h:158
virtual QVariant getProperty(Pid propertyId) const override
Definition: duration.cpp:131
Tuplet * tuplet() const
Definition: duration.h:56
Element * parent() const
Definition: element.h:192
Definition: score.h:391
virtual bool setProperty(Pid propertyId, const QVariant &) override
Definition: duration.cpp:145
Example of 1/8 triplet: _baseLen = 1/8 _actualNotes = 3 _normalNotes = 2 (3 notes played in the time ...
Definition: tuplet.h:37
void writeTupletStart(XmlWriter &xml) const
Definition: duration.cpp:107
virtual Beam * beam() const
Definition: duration.h:58
virtual Pid propertyId(const QStringRef &xmlName) const override
Definition: element.cpp:1326
Definition: aeolus.cpp:26
Definition: xml.h:218
Virtual base class for Chord, Rest and Tuplet.
Definition: duration.h:34
Fraction _duration
Definition: duration.h:35
Tuplet * _tuplet
Definition: duration.h:36
void readAddTuplet(Tuplet *t)
Definition: duration.cpp:96
Tuplet * topTuplet() const
Definition: duration.cpp:61
Fraction actualTicks() const
Definition: duration.cpp:87
virtual Measure * measure() const
Definition: duration.h:49
Definition: fraction.h:46
Fraction globalTicks() const
Definition: duration.cpp:75
DurationElement(Score *=0, ElementFlags=ElementFlag::MOVABLE|ElementFlag::ON_STAFF)
Definition: duration.cpp:28
void setTuplet(Tuplet *t)
Definition: duration.h:55