MuseScore Plugins 3.2.3
Plugins API for MuseScore
Loading...
Searching...
No Matches
lyrics.h
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 __LYRICS_H__
14#define __LYRICS_H__
15
16#include "line.h"
17#include "text.h"
18
19namespace Ms {
20
21//---------------------------------------------------------
22// Lyrics
23//---------------------------------------------------------
24
25class LyricsLine;
26
27class Lyrics final : public TextBase {
28 Q_GADGET
29 public:
30 enum class Syllabic : char {
34 };
35 Q_ENUM(Syllabic)
36
37 // MELISMA FIRST UNDERSCORE:
38 // used as_ticks value to mark a melisma for which only the first chord has been spanned so far
39 // and to give the user a visible feedback that the undercore has been actually entered;
40 // it should be cleared to 0 at some point, so that it will not be carried over
41 // if the melisma is not extended beyond a single chord, but no suitable place to do this
42 // has been identified yet.
43 static constexpr int TEMP_MELISMA_TICKS = 1;
44
45 // WORD_MIN_DISTANCE has never been implemented
46 // static constexpr qreal LYRICS_WORD_MIN_DISTANCE = 0.33; // min. distance between lyrics from different words
47
48 private:
49 Fraction _ticks;
51 Syllabic _syllabic;
52 LyricsLine* _separator;
53
54 bool isMelisma() const;
55 virtual void undoChangeProperty(Pid id, const QVariant&, PropertyFlags ps) override;
56
57 protected:
58 int _no;
59 bool _even;
60
61 public:
62 Lyrics(Score* = 0);
63 Lyrics(const Lyrics&);
64 ~Lyrics();
65 virtual Lyrics* clone() const override { return new Lyrics(*this); }
66 virtual ElementType type() const override { return ElementType::LYRICS; }
67 virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true) override;
68 virtual bool acceptDrop(EditData&) const override;
69 virtual Element* drop(EditData&) override;
70
71 Segment* segment() const { return toSegment(parent()->parent()); }
72 Measure* measure() const { return toMeasure(parent()->parent()->parent()); }
73 ChordRest* chordRest() const { return toChordRest(parent()); }
74
75 virtual void layout() override;
76 void layout2(int);
77
78 virtual void write(XmlWriter& xml) const override;
79 virtual void read(XmlReader&) override;
80 virtual bool readProperties(XmlReader&);
81 virtual int subtype() const override { return _no; }
82 virtual QString subtypeName() const override { return QObject::tr("Verse %1").arg(_no + 1); }
83 void setNo(int n) { _no = n; }
84 int no() const { return _no; }
85 bool isEven() const { return _no % 1; }
86 void setSyllabic(Syllabic s) { _syllabic = s; }
87 Syllabic syllabic() const { return _syllabic; }
88 virtual void add(Element*) override;
89 virtual void remove(Element*) override;
90 virtual void endEdit(EditData&) override;
91
92 Fraction ticks() const { return _ticks; }
93 void setTicks(const Fraction& tick) { _ticks = tick; }
94 Fraction endTick() const;
95 void removeFromScore();
96
97 using ScoreElement::undoChangeProperty;
98 using TextBase::paste;
99 virtual void paste(EditData&) override;
100
101 virtual QVariant getProperty(Pid propertyId) const override;
102 virtual bool setProperty(Pid propertyId, const QVariant&) override;
103 virtual QVariant propertyDefault(Pid id) const override;
104 virtual Sid getPropertyStyle(Pid) const override;
105 };
106
107//---------------------------------------------------------
108// LyricsLine
110//---------------------------------------------------------
111
112class LyricsLine final : public SLine {
113 protected:
114 Lyrics* _nextLyrics;
115
116 public:
117 LyricsLine(Score*);
118 LyricsLine(const LyricsLine&);
119
120 virtual LyricsLine* clone() const override { return new LyricsLine(*this); }
121 virtual ElementType type() const override { return ElementType::LYRICSLINE; }
122 virtual void layout() override;
123 virtual LineSegment* createLineSegment() override;
124 virtual void removeUnmanaged() override;
125 virtual void styleChanged() override;
126
127 Lyrics* lyrics() const { return toLyrics(parent()); }
128 Lyrics* nextLyrics() const { return _nextLyrics; }
129 bool isEndMelisma() const { return lyrics()->ticks().isNotZero(); }
130 bool isDash() const { return !isEndMelisma(); }
131 virtual bool setProperty(Pid propertyId, const QVariant& v) override;
132 virtual SpannerSegment* layoutSystem(System*) override;
133 };
134
135//---------------------------------------------------------
136// LyricsLineSegment
138//---------------------------------------------------------
139
140class LyricsLineSegment final : public LineSegment {
141 protected:
142 int _numOfDashes = 0;
143 qreal _dashLength = 0;
144
145 public:
146 LyricsLineSegment(Spanner*, Score*);
147
148 virtual LyricsLineSegment* clone() const override { return new LyricsLineSegment(*this); }
149 virtual ElementType type() const override { return ElementType::LYRICSLINE_SEGMENT; }
150 virtual void draw(QPainter*) const override;
151 virtual void layout() override;
152 // helper functions
153 LyricsLine* lyricsLine() const { return toLyricsLine(spanner()); }
154 Lyrics* lyrics() const { return lyricsLine()->lyrics(); }
155 };
156
157} // namespace Ms
158#endif
Definition lyrics.h:27
int _no
row index
Definition lyrics.h:58
Syllabic
Definition lyrics.h:30
Definition cursor.cpp:29
ElementType
Definition types.h:34