MuseScore/libmscore/articulation.h

126 lines
3.8 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 __ARTICULATION_H__
#define __ARTICULATION_H__
2012-08-04 15:46:43 +02:00
#include "mscore.h"
2012-05-26 14:26:10 +02:00
#include "symbol.h"
#include "sym.h"
class QPainter;
2013-05-13 18:49:17 +02:00
namespace Ms {
2012-05-26 14:26:10 +02:00
class ChordRest;
//---------------------------------------------------------
// ArticulationInfo
// gives infos about note attributes
//---------------------------------------------------------
enum ArticulationAnchor {
A_TOP_STAFF,
A_BOTTOM_STAFF,
A_CHORD, // anchor depends on chord direction
A_TOP_CHORD, // attribute is alway placed at top of chord
A_BOTTOM_CHORD, // attribute is placed at bottom of chord
};
// flags:
enum { ARTICULATION_SHOW_IN_PITCHED_STAFF = 1, ARTICULATION_SHOW_IN_TABLATURE = 2 };
struct ArticulationInfo {
SymId upSym;
SymId downSym;
QString name;
QString description; // translated name
qreal timeStretch; // for fermata
int flags;
};
//---------------------------------------------------------
2012-07-25 11:49:34 +02:00
// @@ Articulation
/// articulation marks
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class Articulation : public Element {
Q_OBJECT
ArticulationType _articulationType;
2012-08-04 15:46:43 +02:00
MScore::Direction _direction;
2012-05-26 14:26:10 +02:00
QString _channelName;
ArticulationAnchor _anchor;
bool _up;
2013-06-03 14:39:59 +02:00
qreal _timeStretch; // for fermata
2012-05-26 14:26:10 +02:00
virtual void draw(QPainter*) const;
public:
Articulation(Score*);
Articulation &operator=(const Articulation&);
virtual Articulation* clone() const { return new Articulation(*this); }
virtual ElementType type() const { return ARTICULATION; }
2013-05-29 17:11:57 +02:00
virtual qreal mag() const { return parent() ? parent()->mag(): 1.0; }
2013-05-28 15:42:02 +02:00
void setArticulationType(ArticulationType);
ArticulationType articulationType() const { return _articulationType; }
2012-05-26 14:26:10 +02:00
void setSubtype(const QString& s);
QString subtypeName() const;
virtual void layout();
2013-01-11 18:10:18 +01:00
virtual void read(XmlReader&);
2012-05-26 14:26:10 +02:00
virtual void write(Xml& xml) const;
2012-11-19 10:08:15 +01:00
virtual void reset();
2012-05-26 14:26:10 +02:00
virtual QLineF dragAnchor() const;
virtual QVariant getProperty(P_ID propertyId) const;
virtual bool setProperty(P_ID propertyId, const QVariant&);
virtual QVariant propertyDefault(P_ID) const;
2012-05-26 14:26:10 +02:00
QString subtypeUserName() const;
virtual QPointF pagePos() const; ///< position in page coordinates
virtual QPointF canvasPos() const;
bool up() const { return _up; }
void setUp(bool val) { _up = val; }
2012-08-04 15:46:43 +02:00
void setDirection(MScore::Direction d);
MScore::Direction direction() const { return _direction; }
2012-05-26 14:26:10 +02:00
ChordRest* chordRest() const;
static ArticulationInfo articulationList[];
ArticulationAnchor anchor() const { return _anchor; }
void setAnchor(ArticulationAnchor v) { _anchor = v; }
2013-06-03 14:39:59 +02:00
qreal timeStretch() const { return _timeStretch; }
void setTimeStretch(qreal val) { _timeStretch = val; }
2012-05-26 14:26:10 +02:00
QString channelName() const { return _channelName; }
void setChannelName(const QString& s) { _channelName = s; }
const ArticulationInfo* articulationInfo() const { return &articulationList[articulationType()]; }
static QString idx2name(int idx);
};
2013-05-13 18:49:17 +02:00
} // namespace Ms
2012-05-26 14:26:10 +02:00
#endif