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