MuseScore Plugins 3.3
Plugins API for MuseScore
Loading...
Searching...
No Matches
selection.h
1//=============================================================================
2// MuseScore
3// Music Composition & Notation
4//
5// Copyright (C) 2019 Werner Schweer and others
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 __PLUGIN_API_SELECTION_H__
14#define __PLUGIN_API_SELECTION_H__
15
16#include "elements.h"
17#include "score.h"
18
19namespace Ms {
20namespace PluginAPI {
21
22//---------------------------------------------------------
23// Selection
24// Wrapper class for internal Ms::Selection
26//---------------------------------------------------------
27
28class Selection : public QObject {
29 Q_OBJECT
32 Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Element> elements READ elements)
33
34
39 Q_PROPERTY(bool isRange READ isRange)
60 Q_PROPERTY(int startStaff READ startStaff)
67 Q_PROPERTY(int endStaff READ endStaff)
68
69 protected:
71 Ms::Selection* _select;
72
73 bool checkSelectionIsNotLocked() const;
75
76 public:
78 Selection(Ms::Selection* select) : QObject(), _select(select) {}
79 virtual ~Selection() { }
80
81 QQmlListProperty<Element> elements()
82 { return wrapContainerProperty<Element>(this, _select->elements()); }
83
84 bool isRange() const { return _select->isRange(); }
85
86 Segment* startSegment() const { return wrap<Segment>(_select->startSegment()); }
87 Segment* endSegment() const { return wrap<Segment>(_select->endSegment()); }
88 int startStaff() const { return _select->staffStart(); }
89 int endStaff() const { return _select->staffEnd(); }
91
92 Q_INVOKABLE bool select(Ms::PluginAPI::Element* e, bool add = false);
93 Q_INVOKABLE bool selectRange(int startTick, int endTick, int startStaff, int endStaff);
94 Q_INVOKABLE bool deselect(Ms::PluginAPI::Element* e);
95 Q_INVOKABLE bool clear();
96};
97
98extern Selection* selectionWrap(Ms::Selection* select);
99
100} // namespace PluginAPI
101} // namespace Ms
102#endif
Definition elements.h:85
Main class of the plugins framework. Named as MuseScore in QML.
Definition qmlpluginapi.h:62
Definition elements.h:715
Definition selection.h:28
bool isRange
Whether this selection covers a range of a score, as opposed to a list of distinct elements.
Definition selection.h:39
Ms::PluginAPI::Segment * startSegment
Start segment of selection, included.
Definition selection.h:46
Ms::PluginAPI::Segment * endSegment
End segment of selection, excluded.
Definition selection.h:53
QQmlListProperty< Ms::PluginAPI::Element > elements
Current GUI selections for the score.
Definition selection.h:32
Q_INVOKABLE bool select(Ms::PluginAPI::Element *e, bool add=false)
Selects the given element.
Definition selection.cpp:62
Q_INVOKABLE bool clear()
Clears the selection.
Definition selection.cpp:161
Q_INVOKABLE bool selectRange(int startTick, int endTick, int startStaff, int endStaff)
Selects a range in a score.
Definition selection.cpp:104
Q_INVOKABLE bool deselect(Ms::PluginAPI::Element *e)
Deselects the given element.
Definition selection.cpp:140
int endStaff
End staff of selection, included.
Definition selection.h:67
int startStaff
First staff of selection, included.
Definition selection.h:60
Definition cursor.cpp:30