MuseScore  3.4
Music composition and notation
Public Types | Public Member Functions | Properties | Private Member Functions | Private Attributes | List of all members
Ms::PluginAPI::Cursor Class Reference

Cursor can be used by plugins to manipulate the score. More...

#include <cursor.h>

Inheritance diagram for Ms::PluginAPI::Cursor:
Inheritance graph
[legend]
Collaboration diagram for Ms::PluginAPI::Cursor:
Collaboration graph
[legend]

Public Types

enum  RewindMode { SCORE_START = 0, SELECTION_START = 1, SELECTION_END = 2 }
 

Public Member Functions

 Cursor (Ms::Score *s=nullptr)
 
Scorescore () const
 
void setScore (Score *s)
 
int track () const
 
void setTrack (int v)
 
int staffIdx () const
 
void setStaffIdx (int v)
 
int voice () const
 
void setVoice (int v)
 
int filter () const
 
void setFilter (int f)
 
Elementelement () const
 
Segmentsegment () const
 
Measuremeasure () const
 
int tick ()
 
double time ()
 
qreal tempo ()
 
int qmlKeySignature ()
 
Q_INVOKABLE void rewind (RewindMode mode)
 Rewind cursor to a certain position. More...
 
Q_INVOKABLE bool next ()
 Move the cursor to the next segment. More...
 
Q_INVOKABLE bool nextMeasure ()
 Move the cursor to the first segment of the next measure. More...
 
Q_INVOKABLE bool prev ()
 Move the cursor to the previous segment. More...
 
Q_INVOKABLE void add (Ms::PluginAPI::Element *)
 Adds the given element to a score at this cursor's position. More...
 
Q_INVOKABLE void addNote (int pitch, bool addToChord=false)
 Adds a note to the current cursor position. More...
 
Q_INVOKABLE void setDuration (int z, int n)
 Set duration of the notes added by the cursor. More...
 

Properties

int track
 Current track. More...
 
int staffIdx
 Current staff (track / 4) More...
 
int voice
 Current voice (track % 4) More...
 
int filter
 Segment type filter, a bitmask from PluginAPI::PluginAPI::Segment values. More...
 
int tick
 MIDI tick position, read only. More...
 
double time
 Time at tick position, read only. More...
 
qreal tempo
 Tempo at current tick, read only. More...
 
int keySignature
 Key signature of current staff at tick pos. More...
 
Ms::PluginAPI::Score score
 Associated score. More...
 
Ms::PluginAPI::Element element
 Current element at track, read only. More...
 
Ms::PluginAPI::Segment segment
 Current segment, read only. More...
 
Ms::PluginAPI::Measure measure
 Current measure, read only. More...
 

Private Member Functions

void prevInTrack ()
 
void nextInTrack ()
 
void setScore (Ms::Score *s)
 
Ms::ElementcurrentElement () const
 

Private Attributes

Ms::Score_score = nullptr
 
int _track = 0
 
Ms::Segment_segment = nullptr
 
SegmentType _filter
 

Detailed Description

Cursor can be used by plugins to manipulate the score.

Member Enumeration Documentation

◆ RewindMode

Enumerator
SCORE_START 

Rewind to the start of a score.

SELECTION_START 

Rewind to the start of a selection.

SELECTION_END 

Rewind to the end of a selection.

Constructor & Destructor Documentation

◆ Cursor()

Ms::PluginAPI::Cursor::Cursor ( Ms::Score s = nullptr)

Member Function Documentation

◆ add()

void Ms::PluginAPI::Cursor::add ( Ms::PluginAPI::Element wrapped)

Adds the given element to a score at this cursor's position.

◆ addNote()

void Ms::PluginAPI::Cursor::addNote ( int  pitch,
bool  addToChord = false 
)

Adds a note to the current cursor position.

The duration of the added note equals to what has been set by the previous setDuration() call.

Parameters
pitchMIDI pitch of the added note.
addToChordadd note to the current chord instead of replacing it. This parameter is available since MuseScore 3.3.4.

◆ currentElement()

Ms::Element * Ms::PluginAPI::Cursor::currentElement ( ) const
private

◆ element()

Element* Ms::PluginAPI::Cursor::element ( ) const

◆ filter()

int Ms::PluginAPI::Cursor::filter ( ) const
inline

◆ measure()

Measure* Ms::PluginAPI::Cursor::measure ( ) const

◆ next()

bool Ms::PluginAPI::Cursor::next ( )

Move the cursor to the next segment.

Returns
false if the end of the score is reached, true otherwise.

◆ nextInTrack()

void Ms::PluginAPI::Cursor::nextInTrack ( )
private

◆ nextMeasure()

bool Ms::PluginAPI::Cursor::nextMeasure ( )

Move the cursor to the first segment of the next measure.

Returns
false if the end of the score is reached, true otherwise.

◆ prev()

bool Ms::PluginAPI::Cursor::prev ( )

Move the cursor to the previous segment.

Returns
false if the beginning of the score is reached, true otherwise.
Since
MuseScore 3.3.4

◆ prevInTrack()

void Ms::PluginAPI::Cursor::prevInTrack ( )
private

◆ qmlKeySignature()

int Ms::PluginAPI::Cursor::qmlKeySignature ( )

◆ rewind()

void Ms::PluginAPI::Cursor::rewind ( RewindMode  mode)

Rewind cursor to a certain position.

Parameters
modeDetermines the position where to move this cursor. See Cursor::RewindMode to see the list of available rewind modes.
Note
In MuseScore 2.X, this function took an integer value (0, 1 or 2) as its parameter. For compatibility reasons, the old values are still working, but it is recommended to use RewindMode enumerators instead.

◆ score()

Score* Ms::PluginAPI::Cursor::score ( ) const

◆ segment()

Segment* Ms::PluginAPI::Cursor::segment ( ) const

◆ setDuration()

void Ms::PluginAPI::Cursor::setDuration ( int  z,
int  n 
)

Set duration of the notes added by the cursor.

Parameters
znumerator
ndenominator. If n == 0, sets duration to a quarter.
See also
addNote()

◆ setFilter()

void Ms::PluginAPI::Cursor::setFilter ( int  f)
inline

◆ setScore() [1/2]

void Ms::PluginAPI::Cursor::setScore ( Ms::Score s)
private

◆ setScore() [2/2]

void Ms::PluginAPI::Cursor::setScore ( Score s)

◆ setStaffIdx()

void Ms::PluginAPI::Cursor::setStaffIdx ( int  v)

◆ setTrack()

void Ms::PluginAPI::Cursor::setTrack ( int  v)

◆ setVoice()

void Ms::PluginAPI::Cursor::setVoice ( int  v)

◆ staffIdx()

int Ms::PluginAPI::Cursor::staffIdx ( ) const

◆ tempo()

qreal Ms::PluginAPI::Cursor::tempo ( )

◆ tick()

int Ms::PluginAPI::Cursor::tick ( )

◆ time()

double Ms::PluginAPI::Cursor::time ( )

◆ track()

int Ms::PluginAPI::Cursor::track ( ) const
inline

◆ voice()

int Ms::PluginAPI::Cursor::voice ( ) const

Member Data Documentation

◆ _filter

SegmentType Ms::PluginAPI::Cursor::_filter
private

◆ _score

Ms::Score* Ms::PluginAPI::Cursor::_score = nullptr
private

◆ _segment

Ms::Segment* Ms::PluginAPI::Cursor::_segment = nullptr
private

◆ _track

int Ms::PluginAPI::Cursor::_track = 0
private

Property Documentation

◆ element

Element * Ms::PluginAPI::Cursor::element
read

Current element at track, read only.

◆ filter

int Ms::PluginAPI::Cursor::filter
readwrite

Segment type filter, a bitmask from PluginAPI::PluginAPI::Segment values.

Determines which segments this cursor will move to on next() and nextMeasure() operations. The default value is Ms::SegmentType::ChordRest so only segments containing chords and rests are handled by default.

◆ keySignature

int Ms::PluginAPI::Cursor::keySignature
read

Key signature of current staff at tick pos.

(read only)

◆ measure

Measure * Ms::PluginAPI::Cursor::measure
read

Current measure, read only.

◆ score

Score * Ms::PluginAPI::Cursor::score
readwrite

Associated score.

◆ segment

Segment * Ms::PluginAPI::Cursor::segment
read

Current segment, read only.

◆ staffIdx

int Ms::PluginAPI::Cursor::staffIdx
readwrite

Current staff (track / 4)

◆ tempo

qreal Ms::PluginAPI::Cursor::tempo
read

Tempo at current tick, read only.

◆ tick

int Ms::PluginAPI::Cursor::tick
read

MIDI tick position, read only.

◆ time

double Ms::PluginAPI::Cursor::time
read

Time at tick position, read only.

◆ track

int Ms::PluginAPI::Cursor::track
readwrite

Current track.

◆ voice

int Ms::PluginAPI::Cursor::voice
readwrite

Current voice (track % 4)


The documentation for this class was generated from the following files: