MuseScore  3.4
Music composition and notation
tempotext.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 __TEMPOTEXT_H__
14 #define __TEMPOTEXT_H__
15 
16 #include "durationtype.h"
17 #include "text.h"
18 
19 namespace Ms {
20 
21 //-------------------------------------------------------------------
22 // @@ TempoText
24 //
25 // @P tempo float tempo in quarter notes (crochets) per second
26 // @P followText bool determine tempo from text
27 //-------------------------------------------------------------------
28 
29 class TempoText final : public TextBase {
30  qreal _tempo; // beats per second
31  bool _followText; // parse text to determine tempo
32  qreal _relative;
34 
35  void updateScore();
36  void updateTempo();
37  virtual void endEdit(EditData&) override;
38  virtual void undoChangeProperty(Pid id, const QVariant&, PropertyFlags ps) override;
39 
40  public:
41  TempoText(Score*);
42  virtual TempoText* clone() const override { return new TempoText(*this); }
43  virtual ElementType type() const override { return ElementType::TEMPO_TEXT; }
44 
45  virtual void write(XmlWriter& xml) const override;
46  virtual void read(XmlReader&) override;
47 
48  Segment* segment() const { return toSegment(parent()); }
49  Measure* measure() const { return toMeasure(parent()->parent()); }
50 
51  qreal tempo() const { return _tempo; }
52  void setTempo(qreal v);
53  void undoSetTempo(qreal v);
54  bool isRelative() { return _isRelative; }
55  void setRelative(qreal v) { _isRelative = true; _relative = v; }
56 
57  bool followText() const { return _followText; }
58  void setFollowText(bool v) { _followText = v; }
59  void undoSetFollowText(bool v);
60  void updateRelative();
61 
62  virtual void layout();
63 
64  static int findTempoDuration(const QString& s, int& len, TDuration& dur);
65  static QString duration2tempoTextString(const TDuration dur);
66  static QString duration2userName(const TDuration t);
67 
68  QVariant getProperty(Pid propertyId) const override;
69  bool setProperty(Pid propertyId, const QVariant&) override;
70  QVariant propertyDefault(Pid id) const override;
71  Sid getPropertyStyle(Pid) const override;
72  virtual QString accessibleInfo() const override;
73  };
74 
75 
76 } // namespace Ms
77 #endif
virtual void write(XmlWriter &xml) const override
Definition: tempotext.cpp:58
Definition: durationtype.h:28
Pid
Definition: property.h:62
Definition: xml.h:67
bool setProperty(Pid propertyId, const QVariant &) override
Definition: tempotext.cpp:356
one measure in a system
Definition: measure.h:65
void undoSetFollowText(bool v)
Definition: tempotext.cpp:331
Tempo marker which determines the midi tempo.
Definition: tempotext.h:29
void setTempo(qreal v)
Definition: tempotext.cpp:309
bool isRelative()
Definition: tempotext.h:54
void undoSetTempo(qreal v)
Definition: tempotext.cpp:322
QVariant getProperty(Pid propertyId) const override
Definition: tempotext.cpp:340
Sid getPropertyStyle(Pid) const override
Definition: tempotext.cpp:481
Element * parent() const
Definition: element.h:192
virtual void layout()
Definition: tempotext.cpp:399
QVariant propertyDefault(Pid id) const override
Definition: tempotext.cpp:380
Definition: score.h:391
PropertyFlags
Definition: property.h:54
void updateRelative()
Definition: tempotext.cpp:203
virtual void endEdit(EditData &) override
Definition: tempotext.cpp:214
bool followText() const
Definition: tempotext.h:57
qreal tempo() const
Definition: tempotext.h:51
void updateScore()
Definition: tempotext.cpp:191
qreal _relative
Definition: tempotext.h:32
virtual TempoText * clone() const override
Definition: tempotext.h:42
Definition: textbase.h:217
Definition: segment.h:50
bool _isRelative
Definition: tempotext.h:33
TempoText(Score *)
Definition: tempotext.cpp:44
Definition: aeolus.cpp:26
Sid
Definition: style.h:33
Definition: xml.h:218
virtual void read(XmlReader &) override
Definition: tempotext.cpp:72
static int findTempoDuration(const QString &s, int &len, TDuration &dur)
Definition: tempotext.cpp:132
virtual Pid propertyId(const QStringRef &xmlName) const override
Definition: textbase.cpp:1808
virtual ElementType type() const override
Definition: tempotext.h:43
Definition: element.h:111
void setRelative(qreal v)
Definition: tempotext.h:55
static QString duration2tempoTextString(const TDuration dur)
Definition: tempotext.cpp:175
virtual void undoChangeProperty(Pid id, const QVariant &, PropertyFlags ps) override
Definition: tempotext.cpp:237
virtual QString accessibleInfo() const override
Definition: tempotext.cpp:448
ElementType
Definition: types.h:34
Segment * segment() const
Definition: tempotext.h:48
static QString duration2userName(const TDuration t)
Definition: tempotext.cpp:425
void setFollowText(bool v)
Definition: tempotext.h:58
Measure * measure() const
Definition: tempotext.h:49
void updateTempo()
Definition: tempotext.cpp:256
bool _followText
Definition: tempotext.h:31
qreal _tempo
Definition: tempotext.h:30