MuseScore/libmscore/chord.h

220 lines
7.1 KiB
C
Raw Normal View History

2012-05-26 14:26:10 +02:00
//=============================================================================
// MuseScore
// Music Composition & Notation
// $Id: chord.h 5563 2012-04-20 13:30:27Z wschweer $
//
// 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 __CHORD_H__
#define __CHORD_H__
/**
\file
Definition of classes Chord, HelpLine and NoteList.
*/
#include "chordrest.h"
2012-11-20 20:51:18 +01:00
#include "noteevent.h"
2012-05-26 14:26:10 +02:00
class Note;
class Hook;
class Arpeggio;
class Tremolo;
class Chord;
class Glissando;
class Stem;
class QPainter;
class Chord;
enum TremoloChordType { TremoloSingle, TremoloFirstNote, TremoloSecondNote };
//---------------------------------------------------------
2012-07-25 11:49:34 +02:00
// @@ StemSlash
/// used for grace notes of type acciaccatura
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class StemSlash : public Element {
Q_OBJECT
2012-05-26 14:26:10 +02:00
QLineF line;
public:
StemSlash(Score*);
StemSlash &operator=(const Stem&);
void setLine(const QLineF& l);
virtual StemSlash* clone() const { return new StemSlash(*this); }
virtual ElementType type() const { return STEM_SLASH; }
virtual void draw(QPainter*) const;
virtual void layout();
Chord* chord() const { return (Chord*)parent(); }
};
//---------------------------------------------------------
2012-07-25 11:49:34 +02:00
// @@ LedgerLine
2012-05-26 14:26:10 +02:00
/// Graphic representation of a ledger line.
///
/// parent: Chord
/// x-origin: Chord
/// y-origin: SStaff
//---------------------------------------------------------
class LedgerLine : public Line {
Q_OBJECT
2012-05-26 14:26:10 +02:00
public:
LedgerLine(Score*);
LedgerLine &operator=(const LedgerLine&);
virtual LedgerLine* clone() const { return new LedgerLine(*this); }
virtual ElementType type() const { return LEDGER_LINE; }
virtual QPointF pagePos() const; ///< position in page coordinates
Chord* chord() const { return (Chord*)parent(); }
virtual void layout();
qreal measureXPos() const;
};
//---------------------------------------------------------
2012-07-11 21:29:42 +02:00
// @@ Chord
2012-07-25 11:49:34 +02:00
/// Graphic representation of a chord.
/// Single notes are handled as degenerated chords.
//
// @P notes array[Note] the list of notes (read only)
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class Chord : public ChordRest {
Q_OBJECT
Q_PROPERTY(QDeclarativeListProperty<Note> notes READ qmlNotes);
2012-05-26 14:26:10 +02:00
QList<Note*> _notes; // sorted to increasing pitch
QList<LedgerLine*> _ledgerLines;
Stem* _stem;
Hook* _hook;
StemSlash* _stemSlash;
2012-08-04 15:46:43 +02:00
MScore::Direction _stemDirection;
2012-05-26 14:26:10 +02:00
Arpeggio* _arpeggio;
Tremolo* _tremolo;
TremoloChordType _tremoloChordType;
Glissando* _glissando;
ElementList _el; ///< chordline
NoteType _noteType; ///< mark grace notes: acciaccatura and appoggiatura
bool _noStem;
2012-11-19 09:29:46 +01:00
bool _userPlayEvents; ///< play events were modified by user
2012-05-26 14:26:10 +02:00
virtual qreal upPos() const;
virtual qreal downPos() const;
virtual qreal centerX() const;
void addLedgerLine(qreal x, int staffIdx, int line, int extend, bool visible);
void addLedgerLines(qreal x, int move);
public:
Chord(Score* s = 0);
Chord(const Chord&);
~Chord();
Chord &operator=(const Chord&);
virtual Chord* clone() const { return new Chord(*this); }
virtual Chord* linkedClone();
virtual void setScore(Score* s);
virtual ElementType type() const { return CHORD; }
2012-07-24 14:20:43 +02:00
virtual const QRectF& bbox() const;
2012-05-26 14:26:10 +02:00
virtual void write(Xml& xml) const;
void read(const QDomElement&, QList<Tuplet*>*, QList<Spanner*>*);
virtual void read(const QDomElement&);
virtual void setSelected(bool f);
virtual Element* drop(const DropData&);
2012-08-04 15:46:43 +02:00
void setStemDirection(MScore::Direction d) { _stemDirection = d; }
MScore::Direction stemDirection() const { return _stemDirection; }
2012-05-26 14:26:10 +02:00
QList<LedgerLine*>* ledgerLines() { return &_ledgerLines; }
virtual void layoutStem1();
virtual void layoutStem();
void layoutArpeggio2();
QDeclarativeListProperty<Note> qmlNotes() { return QDeclarativeListProperty<Note>(this, _notes); }
2012-05-26 14:26:10 +02:00
QList<Note*>& notes() { return _notes; }
const QList<Note*>& notes() const { return _notes; }
Note* upNote() const { return _notes.size() ? _notes.back() : 0; }
Note* downNote() const { return _notes.size() ? _notes.front(): 0; }
2012-05-26 14:26:10 +02:00
virtual int upLine() const;
virtual int downLine() const;
virtual int upString() const;
virtual int downString() const;
2012-05-26 14:26:10 +02:00
Note* findNote(int pitch) const;
Stem* stem() const { return _stem; }
void setStem(Stem* s);
Arpeggio* arpeggio() const { return _arpeggio; }
Tremolo* tremolo() const { return _tremolo; }
void setTremolo(Tremolo* t) { _tremolo = t; }
Glissando* glissando() const { return _glissando; }
StemSlash* stemSlash() const { return _stemSlash; }
void setStemSlash(StemSlash* s) { delete _stemSlash; _stemSlash = s; }
virtual QPointF stemPos() const; ///< page coordinates
QPointF stemPosBeam() const; ///< page coordinates
2012-05-26 14:26:10 +02:00
Hook* hook() const { return _hook; }
2012-06-07 09:24:05 +02:00
Q_INVOKABLE virtual void add(Element*);
Q_INVOKABLE virtual void remove(Element*);
2012-05-26 14:26:10 +02:00
Note* selectedNote() const;
virtual void layout();
void layout2();
void readNote(const QDomElement& node, QList<Tuplet*>*, QList<Spanner*>*);
2012-11-19 09:29:46 +01:00
NoteType noteType() const { return _noteType; }
void setNoteType(NoteType t) { _noteType = t; }
bool isGrace() const { return _noteType != NOTE_NORMAL; }
2012-05-26 14:26:10 +02:00
virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true);
virtual void setTrack(int val);
void computeUp();
2012-11-19 09:29:46 +01:00
2012-05-26 14:26:10 +02:00
qreal dotPosX() const;
void setDotPosX(qreal val);
2012-11-19 09:29:46 +01:00
bool noStem() const { return _noStem; }
void setNoStem(bool val) { _noStem = val; }
bool userPlayEvents() const { return _userPlayEvents; }
void setUserPlayEvents(bool v) { _userPlayEvents = v; }
2012-05-26 14:26:10 +02:00
virtual void setMag(qreal val);
void pitchChanged();
TremoloChordType tremoloChordType() const { return _tremoloChordType; }
void setTremoloChordType(TremoloChordType t) { _tremoloChordType = t; }
2012-11-19 09:29:46 +01:00
ElementList& el() { return _el; }
const ElementList& el() const { return _el; }
2012-05-26 14:26:10 +02:00
QPointF layoutArticulation(Articulation*);
virtual QVariant getProperty(P_ID propertyId) const;
virtual bool setProperty(P_ID propertyId, const QVariant&);
2012-11-19 10:08:15 +01:00
virtual void reset();
2012-05-26 14:26:10 +02:00
};
#endif