MuseScore/libmscore/lyrics.h

157 lines
6.1 KiB
C
Raw Normal View History

2012-05-26 14:26:10 +02:00
//=============================================================================
// 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"
2012-05-26 14:26:10 +02:00
#include "text.h"
namespace Ms {
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// Lyrics
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class LyricsLine;
2017-12-27 11:51:00 +01:00
class Lyrics final : public TextBase {
Q_GADGET
2012-05-26 14:26:10 +02:00
public:
2019-03-21 17:37:06 +01:00
enum class Syllabic : char {
///.\{
SINGLE, BEGIN, END, MIDDLE
///\}
};
Q_ENUM(Syllabic)
2018-08-02 13:27:08 +02:00
// 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;
2015-01-23 23:50:49 +01:00
// 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.
2018-08-02 13:27:08 +02:00
static constexpr int TEMP_MELISMA_TICKS = 1;
2012-05-26 14:26:10 +02:00
2018-08-02 13:27:08 +02:00
// WORD_MIN_DISTANCE has never been implemented
// static constexpr qreal LYRICS_WORD_MIN_DISTANCE = 0.33; // min. distance between lyrics from different words
2012-05-26 14:26:10 +02:00
private:
Fraction _ticks; ///< if > 0 then draw an underline to tick() + _ticks
2012-05-26 14:26:10 +02:00
///< (melisma)
Syllabic _syllabic;
LyricsLine* _separator;
2018-06-29 13:33:47 +02:00
bool isMelisma() const;
2018-07-19 13:03:25 +02:00
virtual void undoChangeProperty(Pid id, const QVariant&, PropertyFlags ps) override;
2012-05-26 14:26:10 +02:00
protected:
int _no; ///< row index
2018-07-02 10:24:58 +02:00
bool _even;
2012-05-26 14:26:10 +02:00
public:
2012-11-26 15:54:08 +01:00
Lyrics(Score* = 0);
2012-05-26 14:26:10 +02:00
Lyrics(const Lyrics&);
~Lyrics();
virtual Lyrics* clone() const override { return new Lyrics(*this); }
virtual ElementType type() const override { return ElementType::LYRICS; }
2014-02-19 12:18:44 +01:00
virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true) override;
2017-03-31 13:03:15 +02:00
virtual bool acceptDrop(EditData&) const override;
virtual Element* drop(EditData&) override;
2014-02-19 12:18:44 +01:00
Segment* segment() const { return toSegment(parent()->parent()); }
Measure* measure() const { return toMeasure(parent()->parent()->parent()); }
ChordRest* chordRest() const { return toChordRest(parent()); }
2012-05-26 14:26:10 +02:00
2014-02-19 12:18:44 +01:00
virtual void layout() override;
2018-07-19 13:03:25 +02:00
void layout2(int);
2012-05-26 14:26:10 +02:00
2016-11-19 11:51:21 +01:00
virtual void write(XmlWriter& xml) const override;
2014-02-19 12:18:44 +01:00
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); }
2018-06-29 13:33:47 +02:00
void setNo(int n) { _no = n; }
int no() const { return _no; }
2017-07-10 11:45:50 +02:00
bool isEven() const { return _no % 1; }
void setSyllabic(Syllabic s) { _syllabic = s; }
Syllabic syllabic() const { return _syllabic; }
2014-02-19 12:18:44 +01:00
virtual void add(Element*) override;
virtual void remove(Element*) override;
2017-03-31 13:03:15 +02:00
virtual void endEdit(EditData&) override;
2012-05-26 14:26:10 +02:00
Fraction ticks() const { return _ticks; }
void setTicks(const Fraction& tick) { _ticks = tick; }
Fraction endTick() const;
void removeFromScore();
2018-07-19 13:03:25 +02:00
using ScoreElement::undoChangeProperty;
2017-12-27 11:51:00 +01:00
using TextBase::paste;
virtual void paste(EditData&) override;
2014-08-13 21:01:21 +02:00
2018-03-27 15:36:00 +02:00
virtual QVariant getProperty(Pid propertyId) const override;
virtual bool setProperty(Pid propertyId, const QVariant&) override;
virtual QVariant propertyDefault(Pid id) const override;
2019-05-15 06:21:57 +02:00
virtual Sid getPropertyStyle(Pid) const override;
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// LyricsLine
2019-03-21 17:37:06 +01:00
/// \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); }
2017-06-02 10:27:32 +02:00
virtual ElementType type() const override { return ElementType::LYRICSLINE; }
virtual void layout() override;
virtual LineSegment* createLineSegment() override;
virtual void removeUnmanaged() override;
2018-08-02 13:27:08 +02:00
virtual void styleChanged() override;
Lyrics* lyrics() const { return toLyrics(parent()); }
Lyrics* nextLyrics() const { return _nextLyrics; }
2018-03-27 15:36:00 +02:00
virtual bool setProperty(Pid propertyId, const QVariant& v) override;
2018-09-25 10:36:01 +02:00
virtual SpannerSegment* layoutSystem(System*) override;
};
//---------------------------------------------------------
// LyricsLineSegment
2019-03-21 17:37:06 +01:00
/// \cond PLUGIN_API \private \endcond
//---------------------------------------------------------
class LyricsLineSegment final : public LineSegment {
protected:
int _numOfDashes;
qreal _dashLength;
2017-11-27 16:55:52 +01:00
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(); }
};
2013-05-13 18:49:17 +02:00
} // namespace Ms
2012-05-26 14:26:10 +02:00
#endif