MuseScore/libmscore/chordrest.h

154 lines
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 __CHORDREST_H__
#define __CHORDREST_H__
#include "symbol.h"
#include "duration.h"
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
//
2012-07-12 11:36:01 +02:00
// @P durationType int
2013-03-01 10:07:27 +01:00
// @P beamMode BeamMode
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);
2012-05-26 14:26:10 +02:00
TDuration _durationType;
int _staffMove; // -1, 0, +1, used for crossbeaming
Spanner* _spannerFor;
Spanner* _spannerBack;
2012-05-26 14:26:10 +02:00
QList<Element*> _annotations;
protected:
2012-11-20 20:51:18 +01:00
QList<Articulation*> _articulations;
2012-05-26 14:26:10 +02:00
Beam* _beam;
BeamMode _beamMode;
bool _up; // actual stem direction
bool _small;
Space _space; // cached value from layout
QList<Lyrics*> _lyricsList;
TabDurationSymbol* _tabDur; // stores a duration symbol in tablature staves
public:
ChordRest(Score*);
ChordRest(const ChordRest&);
ChordRest &operator=(const ChordRest&);
~ChordRest();
virtual ElementType type() const = 0;
virtual Element* drop(const DropData&);
Segment* segment() const { return (Segment*)parent(); }
2013-02-25 11:17:08 +01:00
virtual Measure* measure() const { return parent() ? (Measure*)(parent()->parent()) : 0; }
2012-05-26 14:26:10 +02:00
2013-01-11 18:10:18 +01:00
virtual void read(XmlReader&) = 0;
2012-05-26 14:26:10 +02:00
void writeProperties(Xml& xml) const;
2013-01-11 18:10:18 +01:00
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;
virtual int upLine() const { return 0;}
virtual int downLine() const { return 8;}
int line(bool up) const { return up ? upLine() : downLine(); }
int line() const { return _up ? upLine() : downLine(); }
2013-01-02 14:33:23 +01:00
virtual QPointF stemPos() const { return canvasPos(); } // point to connect stem
virtual qreal stemPosX() const { return canvasPos().x(); }
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);
virtual void setMag(qreal val);
2012-05-26 14:26:10 +02:00
int staffMove() const { return _staffMove; }
void setStaffMove(int val) { _staffMove = val; }
Spanner* spannerFor() const { return _spannerFor; }
Spanner* spannerBack() const { return _spannerBack; }
2012-05-26 14:26:10 +02:00
void addSlurFor(Slur* s) { addSpannerFor((Spanner*)s); }
void addSlurBack(Slur* s) { addSpannerBack((Spanner*)s); }
bool removeSlurFor(Slur* s) { return removeSpannerFor((Spanner*)s); }
bool removeSlurBack(Slur* s) { return removeSpannerBack((Spanner*)s); }
void addSpannerFor(Spanner*);
void addSpannerBack(Spanner*);
bool removeSpannerFor(Spanner*);
bool removeSpannerBack(Spanner*);
const QList<Element*>& annotations() const { return _annotations; }
QList<Element*>& annotations() { return _annotations; }
void removeAnnotation(Element* e) { _annotations.removeOne(e); }
void layoutArticulations();
const TDuration& durationType() const { return _durationType; }
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 _durationType.dots(); }
2012-06-07 09:24:05 +02:00
int durationTypeTicks() { return _durationType.ticks(); }
2012-05-26 14:26:10 +02:00
virtual void setTrack(int val);
virtual int tick() const;
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*);
void removeDeleteBeam();
2012-08-12 11:44:36 +02:00
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;
2012-05-26 14:26:10 +02:00
};
#endif