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 __CHORD_H__
|
|
|
|
#define __CHORD_H__
|
|
|
|
|
|
|
|
/**
|
|
|
|
\file
|
|
|
|
Definition of classes Chord, HelpLine and NoteList.
|
|
|
|
*/
|
|
|
|
|
2014-07-15 18:05:24 +02:00
|
|
|
#include <functional>
|
2012-05-26 14:26:10 +02:00
|
|
|
#include "chordrest.h"
|
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
class QPainter;
|
|
|
|
|
|
|
|
namespace Ms {
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
class Note;
|
|
|
|
class Hook;
|
|
|
|
class Arpeggio;
|
|
|
|
class Tremolo;
|
|
|
|
class Chord;
|
|
|
|
class Glissando;
|
|
|
|
class Stem;
|
|
|
|
class Chord;
|
2013-03-25 13:15:50 +01:00
|
|
|
class StemSlash;
|
|
|
|
class LedgerLine;
|
2013-06-10 21:13:04 +02:00
|
|
|
class AccidentalState;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2014-03-28 16:29:55 +01:00
|
|
|
enum class TremoloChordType : char { TremoloSingle, TremoloFirstNote, TremoloSecondNote };
|
|
|
|
enum class PlayEventType : char {
|
|
|
|
Auto, // Play events for all notes are calculated by MuseScore.
|
|
|
|
User, // Some play events are modified by user. The events must be written into the mscx file.
|
|
|
|
InvalidUser // The user modified play events must be replaced by MuseScore generated ones on
|
|
|
|
// next recalculation. The actual play events must be saved on the undo stack.
|
|
|
|
};
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2012-07-11 21:29:42 +02:00
|
|
|
// @@ Chord
|
2014-05-16 13:44:32 +02:00
|
|
|
/// Graphic representation of a chord.
|
|
|
|
/// Single notes are handled as degenerated chords.
|
2012-07-25 11:49:34 +02:00
|
|
|
//
|
2014-05-16 13:44:32 +02:00
|
|
|
// @P notes array[Ms::Note] the list of notes (read only)
|
|
|
|
// @P lyrics array[Ms::Lyrics] the list of lyrics (read only)
|
|
|
|
// @P graceNotes array[Ms::Chord] the list of grace note chords (read only)
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
class Chord : public ChordRest {
|
2012-05-28 11:29:21 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2013-08-15 01:25:08 +02:00
|
|
|
struct LedgerLineData {
|
|
|
|
int line;
|
|
|
|
qreal minX, maxX;
|
|
|
|
bool visible;
|
|
|
|
bool accidental;
|
|
|
|
};
|
|
|
|
|
2013-05-16 17:06:31 +02:00
|
|
|
Q_PROPERTY(QQmlListProperty<Ms::Note> notes READ qmlNotes)
|
|
|
|
Q_PROPERTY(QQmlListProperty<Ms::Lyrics> lyrics READ qmlLyrics)
|
2013-09-23 12:40:23 +02:00
|
|
|
Q_PROPERTY(QQmlListProperty<Ms::Chord> graceNotes READ qmlGraceNotes)
|
2012-05-30 17:12:30 +02:00
|
|
|
|
2014-06-26 10:53:57 +02:00
|
|
|
QList<Note*> _notes; // sorted to decreasing line step
|
|
|
|
LedgerLine* _ledgerLines; // single linked list
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2014-06-26 10:53:57 +02:00
|
|
|
Stem* _stem;
|
|
|
|
Hook* _hook;
|
|
|
|
StemSlash* _stemSlash; // for acciacatura
|
2013-03-25 16:27:20 +01:00
|
|
|
|
2014-06-26 10:53:57 +02:00
|
|
|
Arpeggio* _arpeggio;
|
|
|
|
Tremolo* _tremolo;
|
|
|
|
Glissando* _glissando;
|
|
|
|
ElementList _el; ///< chordline, slur
|
|
|
|
QList<Chord*> _graceNotes;
|
|
|
|
int _graceIndex; ///< if this is a grace note, index in parent list
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2014-06-26 10:53:57 +02:00
|
|
|
MScore::Direction _stemDirection;
|
|
|
|
NoteType _noteType; ///< mark grace notes: acciaccatura and appoggiatura
|
|
|
|
bool _noStem;
|
|
|
|
PlayEventType _playEventType; ///< 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;
|
2013-08-15 01:25:08 +02:00
|
|
|
void createLedgerLines(int track, std::vector<LedgerLineData> &vecLines, bool visible);
|
2013-08-03 01:45:46 +02:00
|
|
|
void addLedgerLines(int move);
|
2013-03-25 16:27:20 +01:00
|
|
|
void processSiblings(std::function<void(Element*)> func);
|
2013-06-16 23:33:37 +02:00
|
|
|
void layoutPitched();
|
2013-05-23 15:39:14 +02:00
|
|
|
void layoutTablature();
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
Chord(Score* s = 0);
|
2014-06-27 13:41:49 +02:00
|
|
|
Chord(const Chord&, bool link = false);
|
2012-05-26 14:26:10 +02:00
|
|
|
~Chord();
|
2014-06-27 13:41:49 +02:00
|
|
|
Chord &operator=(const Chord&) = delete;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2014-06-27 13:41:49 +02:00
|
|
|
virtual Chord* clone() const { return new Chord(*this, false); }
|
|
|
|
virtual Chord* linkedClone() { return new Chord(*this, true); }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
virtual void setScore(Score* s);
|
2014-06-26 10:53:57 +02:00
|
|
|
virtual Element::Type type() const { return Element::Type::CHORD; }
|
2013-05-28 15:42:02 +02:00
|
|
|
virtual qreal mag() const;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
virtual void write(Xml& xml) const;
|
2013-01-11 18:10:18 +01:00
|
|
|
virtual void read(XmlReader&);
|
2012-05-26 14:26:10 +02:00
|
|
|
virtual void setSelected(bool f);
|
|
|
|
virtual Element* drop(const DropData&);
|
|
|
|
|
2014-06-26 10:53:57 +02:00
|
|
|
void setStemDirection(MScore::Direction d) { _stemDirection = d; }
|
|
|
|
MScore::Direction stemDirection() const { return _stemDirection; }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2014-06-26 10:53:57 +02:00
|
|
|
LedgerLine* ledgerLines() { return _ledgerLines; }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-01-02 14:33:23 +01:00
|
|
|
void layoutStem1();
|
2013-07-11 12:25:25 +02:00
|
|
|
void layoutHook1(); // create hook if required
|
2013-01-02 14:33:23 +01:00
|
|
|
void layoutStem();
|
2012-05-26 14:26:10 +02:00
|
|
|
void layoutArpeggio2();
|
|
|
|
|
2014-03-28 16:29:55 +01:00
|
|
|
QQmlListProperty<Ms::Note> qmlNotes() { return QQmlListProperty<Ms::Note>(this, _notes); }
|
|
|
|
QQmlListProperty<Ms::Lyrics> qmlLyrics() { return QQmlListProperty<Ms::Lyrics>(this, _lyricsList); }
|
|
|
|
QQmlListProperty<Ms::Chord> qmlGraceNotes() { return QQmlListProperty<Ms::Chord>(this, _graceNotes); }
|
|
|
|
QList<Note*>& notes() { return _notes; }
|
|
|
|
const QList<Note*>& notes() const { return _notes; }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-01-02 20:13:58 +01:00
|
|
|
// Chord has at least one Note
|
2013-03-22 15:26:55 +01:00
|
|
|
Note* upNote() const;
|
|
|
|
Note* downNote() const;
|
2012-09-06 14:00:14 +02:00
|
|
|
virtual int upString() const;
|
|
|
|
virtual int downString() const;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-09-02 19:07:39 +02:00
|
|
|
qreal maxHeadWidth() const;
|
2013-05-14 01:43:08 +02:00
|
|
|
|
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; }
|
2013-01-02 09:29:17 +01:00
|
|
|
void setStemSlash(StemSlash* s);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-09-23 12:40:23 +02:00
|
|
|
const QList<Chord*>& graceNotes() const { return _graceNotes; }
|
|
|
|
QList<Chord*>& graceNotes() { return _graceNotes; }
|
2014-04-23 18:07:38 +02:00
|
|
|
int getGraceNotesBefore(QList<Chord*>*);
|
|
|
|
int getGraceNotesAfter(QList<Chord*>*);
|
2013-06-16 23:33:37 +02:00
|
|
|
int graceIndex() const { return _graceIndex; }
|
|
|
|
void setGraceIndex(int val) { _graceIndex = val; }
|
2013-06-10 21:13:04 +02:00
|
|
|
|
2014-05-17 15:48:18 +02:00
|
|
|
virtual int upLine() const;
|
|
|
|
virtual int downLine() const;
|
|
|
|
virtual QPointF stemPos() const; ///< page coordinates
|
|
|
|
virtual QPointF stemPosBeam() const; ///< page coordinates
|
2013-07-29 11:12:32 +02:00
|
|
|
virtual qreal stemPosX() const;
|
2014-04-23 18:07:38 +02:00
|
|
|
bool underBeam() const;
|
2012-05-26 14:26:10 +02:00
|
|
|
Hook* hook() const { return _hook; }
|
|
|
|
|
2013-07-13 18:53:50 +02:00
|
|
|
Q_INVOKABLE virtual void add(Ms::Element*);
|
|
|
|
Q_INVOKABLE virtual void remove(Ms::Element*);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
Note* selectedNote() const;
|
|
|
|
virtual void layout();
|
|
|
|
void layout2();
|
2014-04-22 17:02:03 +02:00
|
|
|
void updateNotes(AccidentalState*);
|
|
|
|
void cmdUpdateNotes(AccidentalState*);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2012-11-19 09:29:46 +01:00
|
|
|
NoteType noteType() const { return _noteType; }
|
|
|
|
void setNoteType(NoteType t) { _noteType = t; }
|
2014-05-27 10:35:28 +02:00
|
|
|
bool isGrace() const { return _noteType != NoteType::NORMAL; }
|
2014-04-23 18:07:38 +02:00
|
|
|
void toGraceAfter();
|
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;
|
2012-11-19 09:29:46 +01:00
|
|
|
|
2014-03-28 16:29:55 +01:00
|
|
|
bool noStem() const { return _noStem; }
|
|
|
|
void setNoStem(bool val) { _noStem = val; }
|
2012-11-19 09:29:46 +01:00
|
|
|
|
2014-03-28 16:29:55 +01:00
|
|
|
PlayEventType playEventType() const { return _playEventType; }
|
|
|
|
void setPlayEventType(PlayEventType v) { _playEventType = v; }
|
2012-11-19 09:29:46 +01:00
|
|
|
|
2014-05-15 13:42:03 +02:00
|
|
|
TremoloChordType tremoloChordType() const;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
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*);
|
|
|
|
|
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&);
|
2013-03-14 13:30:25 +01:00
|
|
|
virtual QVariant propertyDefault(P_ID) const;
|
|
|
|
|
2012-11-19 10:08:15 +01:00
|
|
|
virtual void reset();
|
2013-06-10 21:13:04 +02:00
|
|
|
|
|
|
|
virtual Segment* segment() const;
|
|
|
|
virtual Measure* measure() const;
|
2014-04-09 09:40:25 +02:00
|
|
|
|
|
|
|
void sortNotes();
|
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
|
|
|
|
|