MuseScore/libmscore/chordrest.h

166 lines
6.3 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 __CHORDREST_H__
#define __CHORDREST_H__
#include "symbol.h"
#include "duration.h"
2013-05-13 18:49:17 +02:00
namespace Ms {
enum class CrossMeasure : signed char {
UNKNOWN = -1,
NONE = 0,
FIRST,
SECOND
2013-05-16 10:36:56 +02:00
};
2013-05-12 12:51:42 +02:00
2012-05-26 14:26:10 +02:00
class Score;
class Measure;
class Beam;
class Tuplet;
class Segment;
class Slur;
class Articulation;
class Lyrics;
class TabDurationSymbol;
class Spanner;
2012-07-25 11:49:34 +02:00
//-------------------------------------------------------------------
2012-07-11 21:29:42 +02:00
// @@ ChordRest
2012-07-25 11:49:34 +02:00
/// Virtual base class. Chords and rests can be part of a beam
//
// @P durationType int
// @P beamMode Ms::BeamMode (AUTO, BEGIN, MID, END, NONE, BEGIN32, BEGIN64, INVALID)
// @P small bool small chord/rest
2012-07-25 11:49:34 +02:00
//-------------------------------------------------------------------
2012-05-26 14:26:10 +02:00
class ChordRest : public DurationElement {
Q_OBJECT
Q_PROPERTY(int durationType READ durationTypeTicks WRITE setDurationType)
Q_PROPERTY(BeamMode beamMode READ beamMode WRITE undoSetBeamMode)
Q_PROPERTY(bool small READ small WRITE undoSetSmall)
2012-05-26 14:26:10 +02:00
TDuration _durationType;
int _staffMove; // -1, 0, +1, used for crossbeaming
protected:
2012-11-20 20:51:18 +01:00
QList<Articulation*> _articulations;
2012-05-26 14:26:10 +02:00
Beam* _beam;
2013-05-29 10:31:26 +02:00
QList<Lyrics*> _lyricsList;
TabDurationSymbol* _tabDur; // stores a duration symbol in tablature staves
2012-05-26 14:26:10 +02:00
BeamMode _beamMode;
bool _up; // actual stem direction
bool _small;
2013-05-12 12:51:42 +02:00
// CrossMeasure: combine 2 tied notes if across a bar line and can be combined in a single duration
CrossMeasure _crossMeasure; ///< 0: no cross-measure modification; 1: 1st note of a mod.; -1: 2nd note
2013-05-12 12:51:42 +02:00
TDuration _crossMeasureTDur; ///< the total Duration type of the combined notes
2013-07-11 14:44:35 +02:00
Space _space; // cached value from layout
2012-05-26 14:26:10 +02:00
public:
ChordRest(Score*);
ChordRest(const ChordRest&);
ChordRest &operator=(const ChordRest&);
~ChordRest();
virtual ElementType type() const = 0;
virtual Element* drop(const DropData&);
2013-06-10 21:13:04 +02:00
virtual Segment* segment() const { return (Segment*)parent(); }
2013-06-16 23:33:37 +02:00
virtual Measure* measure() const = 0;
2012-05-26 14:26:10 +02:00
2013-07-31 11:05:48 +02:00
virtual void writeProperties(Xml& xml) const;
virtual bool readProperties(XmlReader&);
2012-05-26 14:26:10 +02:00
virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true);
void setBeamMode(BeamMode m) { _beamMode = m; }
2013-03-01 10:07:27 +01:00
void undoSetBeamMode(BeamMode m);
2012-05-26 14:26:10 +02:00
BeamMode beamMode() const { return _beamMode; }
void setBeam(Beam* b);
virtual Beam* beam() const { return _beam; }
int beams() const { return _durationType.hooks(); }
virtual qreal upPos() const = 0;
virtual qreal downPos() const = 0;
virtual qreal centerX() const = 0;
2014-05-17 15:48:18 +02:00
int line(bool up) const { return up ? upLine() : downLine(); }
int line() const { return _up ? upLine() : downLine(); }
2014-05-16 13:52:22 +02:00
virtual int upLine() const = 0;
virtual int downLine() const = 0;
virtual QPointF stemPos() const = 0;
virtual qreal stemPosX() const = 0;
2014-05-17 15:48:18 +02:00
virtual QPointF stemPosBeam() const = 0;
2014-05-16 13:52:22 +02:00
2012-05-26 14:26:10 +02:00
bool up() const { return _up; }
void setUp(bool val) { _up = val; }
2012-11-20 20:51:18 +01:00
QList<Articulation*>& articulations() { return _articulations; }
const QList<Articulation*>& articulations() const { return _articulations; }
2012-05-26 14:26:10 +02:00
Articulation* hasArticulation(const Articulation*);
2012-11-20 20:51:18 +01:00
2012-05-26 14:26:10 +02:00
bool small() const { return _small; }
void setSmall(bool val);
void undoSetSmall(bool val);
2012-05-26 14:26:10 +02:00
int staffMove() const { return _staffMove; }
void setStaffMove(int val) { _staffMove = val; }
void layoutArticulations();
const TDuration& durationType() const { return _crossMeasure == CrossMeasure::FIRST ?
2013-05-12 12:51:42 +02:00
_crossMeasureTDur : _durationType; }
const TDuration& actualDurationType() const { return _durationType; }
2012-05-26 14:26:10 +02:00
void setDurationType(TDuration::DurationType t);
void setDurationType(const QString& s);
void setDurationType(int ticks);
void setDurationType(const TDuration& v);
void setDots(int n) { _durationType.setDots(n); }
int dots() const { return _crossMeasure == CrossMeasure::FIRST ? _crossMeasureTDur.dots()
: (_crossMeasure == CrossMeasure::SECOND ? 0 : _durationType.dots()); }
2013-05-12 12:51:42 +02:00
int actualDots() const { return _durationType.dots(); }
int durationTypeTicks() { return _crossMeasure == CrossMeasure::FIRST ? _crossMeasureTDur.ticks()
2013-05-12 12:51:42 +02:00
: _durationType.ticks(); }
2012-05-26 14:26:10 +02:00
virtual void setTrack(int val);
virtual int tick() const;
virtual int rtick() const;
2012-05-26 14:26:10 +02:00
virtual Space space() const { return _space; }
const QList<Lyrics*>& lyricsList() const { return _lyricsList; }
QList<Lyrics*>& lyricsList() { return _lyricsList; }
Lyrics* lyrics(int no) { return _lyricsList.value(no); }
virtual void add(Element*);
virtual void remove(Element*);
2013-07-11 12:25:25 +02:00
void removeDeleteBeam(bool beamed = false);
2012-08-12 11:44:36 +02:00
CrossMeasure crossMeasure() const { return _crossMeasure; }
void setCrossMeasure(CrossMeasure val) { _crossMeasure = val; }
2013-05-12 12:51:42 +02:00
virtual void crossMeasureSetup(bool /*on*/) { }
2012-05-26 14:26:10 +02:00
virtual QVariant getProperty(P_ID propertyId) const;
virtual bool setProperty(P_ID propertyId, const QVariant&);
2012-08-12 11:44:36 +02:00
virtual QVariant propertyDefault(P_ID) const;
2013-06-16 23:33:37 +02:00
bool isGrace() const;
2014-04-23 18:07:38 +02:00
bool isGraceBefore() const;
bool isGraceAfter() const;
2013-06-19 16:25:29 +02:00
void writeBeam(Xml& xml);
2012-05-26 14:26:10 +02:00
};
2013-05-13 18:49:17 +02:00
} // namespace Ms
2012-05-26 14:26:10 +02:00
#endif