MuseScore Plugins 3.2.3
Plugins API for MuseScore
Loading...
Searching...
No Matches
cursor.h
1//=============================================================================
2// MuseScore
3// Music Composition & Notation
4//
5// Copyright (C) 2012 Werner Schweer
6//
7// This program is free software; you can redistribute it and/or modify
8// it under the terms of the GNU General Public License version 2
9// as published by the Free Software Foundation and appearing in
10// the file LICENCE.GPL
11//=============================================================================
12
13#ifndef __CURSOR_H__
14#define __CURSOR_H__
15
16namespace Ms {
17
18class Element;
19class Score;
20class Chord;
21class Rest;
22class Note;
23class Segment;
24class RepeatSegment;
25class ChordRest;
26class StaffText;
27class Measure;
28
29enum class SegmentType;
30
31namespace PluginAPI {
32
33class Element;
34class Measure;
35class Segment;
36class Score;
37
38//---------------------------------------------------------
39// @@ Cursor
41//---------------------------------------------------------
42
43class Cursor : public QObject {
44 Q_OBJECT
46 Q_PROPERTY(int track READ track WRITE setTrack)
48 Q_PROPERTY(int staffIdx READ staffIdx WRITE setStaffIdx)
50 Q_PROPERTY(int voice READ voice WRITE setVoice)
59 Q_PROPERTY(int filter READ filter WRITE setFilter)
60
62 Q_PROPERTY(int tick READ tick) // FIXME: fraction transition
64 Q_PROPERTY(double time READ time)
65
67 Q_PROPERTY(qreal tempo READ tempo)
68
70 Q_PROPERTY(int keySignature READ qmlKeySignature)
72 Q_PROPERTY(Ms::PluginAPI::Score* score READ score WRITE setScore)
73
75 Q_PROPERTY(Ms::PluginAPI::Element* element READ element)
77 Q_PROPERTY(Ms::PluginAPI::Segment* segment READ segment)
79 Q_PROPERTY(Ms::PluginAPI::Measure* measure READ measure)
80
81 public:
87 Q_ENUM(RewindMode);
88
89 private:
90 Ms::Score* _score = nullptr;
91 int _track = 0;
92// bool _expandRepeats; // used?
93
94 //state
95 Ms::Segment* _segment = nullptr;
96 SegmentType _filter;
97
98 // utility methods
99 void nextInTrack();
100 void setScore(Ms::Score* s);
101
102 public:
104 Cursor(Ms::Score* s = nullptr);
105// Cursor(Score*, bool); // not implemented? what is bool?
106
107 Score* score() const;
108 void setScore(Score* s);
109
110 int track() const { return _track; }
111 void setTrack(int v);
112
113 int staffIdx() const;
114 void setStaffIdx(int v);
115
116 int voice() const;
117 void setVoice(int v);
118
119 int filter() const { return int(_filter); }
120 void setFilter(int f) { _filter = SegmentType(f); }
121
122 Element* element() const;
123 Segment* segment() const;
124 Measure* measure() const;
125
126 int tick();
127 double time();
128 qreal tempo();
129
130 int qmlKeySignature();
132
133 Q_INVOKABLE void rewind(RewindMode mode);
134
135 Q_INVOKABLE bool next();
136 Q_INVOKABLE bool nextMeasure();
137 Q_INVOKABLE void add(Ms::PluginAPI::Element*);
138
139 Q_INVOKABLE void addNote(int pitch);
140
141 //@ set duration
142 //@ z: numerator
143 //@ n: denominator
144 //@ Quarter, if n == 0
145 Q_INVOKABLE void setDuration(int z, int n);
146 };
147
148} // namespace PluginAPI
149} // namespace Ms
150#endif
151
Cursor can be used by plugins to manipulate the score.
Definition cursor.h:43
qreal tempo
Tempo at current tick, read only.
Definition cursor.h:67
Ms::PluginAPI::Segment * segment
Current segment, read only.
Definition cursor.h:77
Q_INVOKABLE void addNote(int pitch)
Adds a note to the current cursor position.
Definition cursor.cpp:211
RewindMode
Definition cursor.h:82
@ SELECTION_START
Rewind to the start of a selection.
Definition cursor.h:84
@ SELECTION_END
Rewind to the end of a selection.
Definition cursor.h:85
@ SCORE_START
Rewind to the start of a score.
Definition cursor.h:83
Q_INVOKABLE bool next()
Move the cursor to the next segment.
Definition cursor.cpp:128
Q_INVOKABLE bool nextMeasure()
Move the cursor to the first segment of the next measure.
Definition cursor.cpp:147
Q_INVOKABLE void rewind(RewindMode mode)
Rewind cursor to a certain position.
Definition cursor.cpp:85
Ms::PluginAPI::Score * score
Associated score.
Definition cursor.h:72
double time
Time at tick position, read only.
Definition cursor.h:64
Ms::PluginAPI::Measure * measure
Current measure, read only.
Definition cursor.h:79
Ms::PluginAPI::Element * element
Current element at track, read only.
Definition cursor.h:75
int voice
Current voice (track % 4)
Definition cursor.h:50
int keySignature
Key signature of current staff at tick pos.
Definition cursor.h:70
Q_INVOKABLE void setDuration(int z, int n)
Set duration of the notes added by the cursor.
Definition cursor.cpp:233
int tick
MIDI tick position, read only.
Definition cursor.h:62
Q_INVOKABLE void add(Ms::PluginAPI::Element *)
Adds the given element to a score at this cursor's position.
Definition cursor.cpp:167
int track
Current track.
Definition cursor.h:46
int staffIdx
Current staff (track / 4)
Definition cursor.h:48
int filter
Segment type filter, a bitmask from PluginAPI::PluginAPI::Segment values.
Definition cursor.h:59
Definition elements.h:69
Definition elements.h:534
Main class of the plugins framework. Named as MuseScore in QML.
Definition qmlpluginapi.h:55
Definition score.h:36
Definition elements.h:474
Definition cursor.cpp:29
SegmentType
Definition types.h:332