MuseScore Plugins 3.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
16#include "fraction.h"
17
18namespace Ms {
19
20class Element;
21class InputState;
22class Score;
23class Chord;
24class Rest;
25class Note;
26class Segment;
27class ChordRest;
28class StaffText;
29class Measure;
30
31enum class SegmentType;
32
33namespace PluginAPI {
34
35class Element;
36class Measure;
37class Segment;
38class Score;
39
40//---------------------------------------------------------
41// @@ Cursor
51//---------------------------------------------------------
52
53class Cursor : public QObject {
54 Q_OBJECT
56 Q_PROPERTY(int track READ track WRITE setTrack)
58 Q_PROPERTY(int staffIdx READ staffIdx WRITE setStaffIdx)
60 Q_PROPERTY(int voice READ voice WRITE setVoice)
69 Q_PROPERTY(int filter READ filter WRITE setFilter)
70
72 Q_PROPERTY(int tick READ tick) // FIXME: fraction transition
74 Q_PROPERTY(double time READ time)
75
77 Q_PROPERTY(qreal tempo READ tempo)
78
80 Q_PROPERTY(int keySignature READ qmlKeySignature)
82 Q_PROPERTY(Ms::PluginAPI::Score* score READ score WRITE setScore)
83
85 Q_PROPERTY(Ms::PluginAPI::Element* element READ element)
87 Q_PROPERTY(Ms::PluginAPI::Segment* segment READ qmlSegment)
89 Q_PROPERTY(Ms::PluginAPI::Measure* measure READ measure)
96 Q_PROPERTY(int stringNumber READ inputStateString WRITE setInputStateString)
97
98 public:
104 Q_ENUM(RewindMode);
105
111 Q_ENUM(InputStateMode);
112
113 private:
120 Q_PROPERTY(InputStateMode inputStateMode READ inputStateMode WRITE setInputStateMode)
121
122 Ms::Score* _score = nullptr;
123// bool _expandRepeats; // used?
124 SegmentType _filter;
125 std::unique_ptr<InputState> is;
126 InputStateMode _inputStateMode = INPUT_STATE_INDEPENDENT;
127
128 // utility methods
129 void prevInTrack();
130 void nextInTrack();
131 void setScore(Ms::Score* s);
132 Ms::Element* currentElement() const;
133
134 InputState& inputState();
135 const InputState& inputState() const { return const_cast<Cursor*>(this)->inputState(); }
136
137 Ms::Segment* segment() const;
138 void setSegment(Ms::Segment* seg);
139
140 int inputStateString() const;
141 void setInputStateString(int);
142
143 public:
145 Cursor(Ms::Score* s = nullptr);
146// Cursor(Score*, bool); // not implemented? what is bool?
147
148 Score* score() const;
149 void setScore(Score* s);
150
151 int track() const;
152 void setTrack(int v);
153
154 int staffIdx() const;
155 void setStaffIdx(int v);
156
157 int voice() const;
158 void setVoice(int v);
159
160 int filter() const { return int(_filter); }
161 void setFilter(int f) { _filter = SegmentType(f); }
162
163 InputStateMode inputStateMode() const { return _inputStateMode; }
164 void setInputStateMode(InputStateMode val);
165
166 Element* element() const;
167 Segment* qmlSegment() const;
168 Measure* measure() const;
169
170 int tick();
171 double time();
172 qreal tempo();
173
174 int qmlKeySignature();
176
177 Q_INVOKABLE void rewind(RewindMode mode);
178 Q_INVOKABLE void rewindToTick(int tick);
179
180 Q_INVOKABLE bool next();
181 Q_INVOKABLE bool nextMeasure();
182 Q_INVOKABLE bool prev();
183 Q_INVOKABLE void add(Ms::PluginAPI::Element*);
184
185 Q_INVOKABLE void addNote(int pitch, bool addToChord = false);
186 Q_INVOKABLE void addRest();
188
189 //@ set duration
190 //@ z: numerator
191 //@ n: denominator
192 //@ Quarter, if n == 0
193 Q_INVOKABLE void setDuration(int z, int n);
194 };
195
196} // namespace PluginAPI
197} // namespace Ms
198#endif
199
Cursor can be used by plugins to manipulate the score.
Definition cursor.h:53
qreal tempo
Tempo at current tick, read only.
Definition cursor.h:77
Q_INVOKABLE bool prev()
Move the cursor to the previous segment.
Definition cursor.cpp:184
Q_INVOKABLE void rewindToTick(int tick)
Rewind cursor to a position defined by tick.
Definition cursor.cpp:161
RewindMode
Definition cursor.h:99
@ SELECTION_START
Rewind to the start of a selection.
Definition cursor.h:101
@ SELECTION_END
Rewind to the end of a selection.
Definition cursor.h:102
@ SCORE_START
Rewind to the start of a score.
Definition cursor.h:100
Q_INVOKABLE void addNote(int pitch, bool addToChord=false)
Adds a note to the current cursor position.
Definition cursor.cpp:377
int stringNumber
A physical string number where this cursor currently at.
Definition cursor.h:96
Q_INVOKABLE bool next()
Move the cursor to the next segment.
Definition cursor.cpp:199
Q_INVOKABLE bool nextMeasure()
Move the cursor to the first segment of the next measure.
Definition cursor.cpp:216
Q_INVOKABLE void rewind(RewindMode mode)
Rewind cursor to a certain position.
Definition cursor.cpp:116
InputStateMode inputStateMode
Behavior of input state (position, notes duration etc.) of this cursor with respect to input state of...
Definition cursor.h:120
Q_INVOKABLE void addRest()
Adds a rest to the current cursor position.
Definition cursor.cpp:401
Ms::PluginAPI::Score * score
Associated score.
Definition cursor.h:82
Ms::PluginAPI::Segment * segment
Current segment, read only.
Definition cursor.h:87
double time
Time at tick position, read only.
Definition cursor.h:74
Ms::PluginAPI::Measure * measure
Current measure, read only.
Definition cursor.h:89
Ms::PluginAPI::Element * element
Current element at track, read only.
Definition cursor.h:85
int voice
Current voice (track % 4)
Definition cursor.h:60
int keySignature
Key signature of current staff at tick pos.
Definition cursor.h:80
InputStateMode
Definition cursor.h:107
@ INPUT_STATE_INDEPENDENT
Input state of cursor is independent of score input state (default)
Definition cursor.h:108
@ INPUT_STATE_SYNC_WITH_SCORE
Input state of cursor is synchronized with score input state.
Definition cursor.h:109
Q_INVOKABLE void setDuration(int z, int n)
Set duration of the notes added by the cursor.
Definition cursor.cpp:508
int tick
MIDI tick position, read only.
Definition cursor.h:72
Q_INVOKABLE void add(Ms::PluginAPI::Element *)
Adds the given element to a score at this cursor's position.
Definition cursor.cpp:236
int track
Current track.
Definition cursor.h:56
Q_INVOKABLE void addTuplet(Ms::PluginAPI::FractionWrapper *ratio, Ms::PluginAPI::FractionWrapper *duration)
Adds a tuplet to the current cursor position.
Definition cursor.cpp:446
int staffIdx
Current staff (track / 4)
Definition cursor.h:58
int filter
Segment type filter, a bitmask from PluginAPI::PluginAPI::Segment values.
Definition cursor.h:69
Definition elements.h:85
Fraction object available to QML plugins.
Definition fraction.h:32
Definition elements.h:781
Main class of the plugins framework. Named as MuseScore in QML.
Definition qmlpluginapi.h:62
Definition score.h:41
Definition elements.h:715
Definition cursor.cpp:30
SegmentType
Definition types.h:436