MuseScore/libmscore/trill.h

131 lines
4.6 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 __TRILL_H__
#define __TRILL_H__
#include "line.h"
2013-05-13 18:49:17 +02:00
class QPainter;
namespace Ms {
2012-05-26 14:26:10 +02:00
class Trill;
class Accidental;
//---------------------------------------------------------
2012-07-25 11:49:34 +02:00
// @@ TrillSegment
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class TrillSegment : public LineSegment {
Q_OBJECT
2016-01-04 14:48:58 +01:00
std::vector<SymId> _symbols;
2013-11-19 16:06:08 +01:00
void symbolLine(SymId start, SymId fill);
void symbolLine(SymId start, SymId fill, SymId end);
2012-05-26 14:26:10 +02:00
protected:
public:
2016-09-04 16:17:33 +02:00
TrillSegment(Score* s) : LineSegment(s) {}
Trill* trill() const { return (Trill*)spanner(); }
virtual Element::Type type() const override { return Element::Type::TRILL_SEGMENT; }
2013-08-30 16:03:46 +02:00
virtual TrillSegment* clone() const override { return new TrillSegment(*this); }
virtual void draw(QPainter*) const override;
2014-08-13 21:01:21 +02:00
virtual bool acceptDrop(const DropData&) const override;
2013-08-30 16:03:46 +02:00
virtual Element* drop(const DropData&) override;
virtual void layout() override;
virtual QVariant getProperty(P_ID propertyId) const override;
virtual bool setProperty(P_ID propertyId, const QVariant&) override;
virtual QVariant propertyDefault(P_ID) const override;
virtual void add(Element*) override;
virtual void remove(Element*) override;
2013-09-02 12:29:25 +02:00
virtual void scanElements(void* data, void (*func)(void*, Element*), bool all) override;
2013-11-19 16:06:08 +01:00
2016-01-04 14:48:58 +01:00
std::vector<SymId> symbols() const { return _symbols; }
void setSymbols(const std::vector<SymId>& s) { _symbols = s; }
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
2012-07-25 11:49:34 +02:00
// @@ Trill
// @P trillType enum (Trill.DOWNPRALL_LINE, .PRALLPRALL_LINE, .PURE_LINE, .TRILL_LINE, .UPPRALL_LINE)
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class Trill : public SLine {
Q_OBJECT
2014-06-25 14:07:43 +02:00
Q_ENUMS(Type)
2012-09-17 18:09:30 +02:00
public:
2014-06-25 14:07:43 +02:00
enum class Type : char {
2015-07-12 10:10:36 +02:00
TRILL_LINE, UPPRALL_LINE, DOWNPRALL_LINE, PRALLPRALL_LINE
2012-09-17 18:09:30 +02:00
};
private:
2014-06-25 14:07:43 +02:00
Q_PROPERTY(Ms::Trill::Type trillType READ trillType WRITE undoSetTrillType)
Type _trillType;
2013-08-30 16:03:46 +02:00
Accidental* _accidental;
MScore::OrnamentStyle _ornamentStyle; // for use in ornaments such as trill
bool _playArticulation;
2012-05-26 14:26:10 +02:00
public:
Trill(Score* s);
2013-08-30 16:03:46 +02:00
virtual ~Trill();
virtual Trill* clone() const override { return new Trill(*this); }
virtual Element::Type type() const override { return Element::Type::TRILL; }
2012-05-26 14:26:10 +02:00
2013-08-30 16:03:46 +02:00
virtual void layout() override;
virtual LineSegment* createLineSegment() override;
virtual void add(Element*) override;
virtual void remove(Element*) override;
virtual void write(Xml&) const override;
virtual void read(XmlReader&) override;
2012-05-26 14:26:10 +02:00
void setTrillType(const QString& s);
2014-06-25 14:07:43 +02:00
void undoSetTrillType(Type val);
void setTrillType(Type tt) { _trillType = tt; }
Type trillType() const { return _trillType; }
void setOrnamentStyle(MScore::OrnamentStyle val) { _ornamentStyle = val;}
MScore::OrnamentStyle ornamentStyle() const { return _ornamentStyle;}
void setPlayArticulation(bool val) { _playArticulation = val;}
bool playArticulation() const { return _playArticulation; }
QString trillTypeName() const;
2016-02-04 17:06:32 +01:00
QString trillTypeUserName() const;
2013-08-30 16:03:46 +02:00
Accidental* accidental() const { return _accidental; }
void setAccidental(Accidental* a) { _accidental = a; }
2012-05-26 14:26:10 +02:00
Segment* segment() const { return (Segment*)parent(); }
2013-08-30 16:03:46 +02:00
virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true) override;
2012-09-17 18:09:30 +02:00
2013-08-30 16:03:46 +02:00
virtual QVariant getProperty(P_ID propertyId) const override;
virtual bool setProperty(P_ID propertyId, const QVariant&) override;
virtual QVariant propertyDefault(P_ID) const override;
virtual void setYoff(qreal) override;
2016-02-04 17:06:32 +01:00
virtual QString accessibleInfo() const override;
};
struct TrillTableItem {
Trill::Type type;
const char* name;
QString userName;
2012-05-26 14:26:10 +02:00
};
extern const TrillTableItem trillTable[];
extern int trillTableSize();
2013-05-13 18:49:17 +02:00
} // namespace Ms
2014-06-25 14:07:43 +02:00
Q_DECLARE_METATYPE(Ms::Trill::Type);
2013-05-13 18:49:17 +02:00
2012-05-26 14:26:10 +02:00
#endif