MuseScore Plugins  3.5
Plugins API for MuseScore
part.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_PART_H__
14 #define __PLUGIN_API_PART_H__
15 
16 #include "scoreelement.h"
17 #include "libmscore/part.h"
18 
19 namespace Ms {
20 namespace PluginAPI {
21 
22 class Instrument;
23 class Part;
24 
25 //---------------------------------------------------------
26 // InstrumentListProperty
28 //---------------------------------------------------------
29 
30 class InstrumentListProperty : public QQmlListProperty<Instrument> {
31 public:
32  InstrumentListProperty(Part* p);
33 
34  static int count(QQmlListProperty<Instrument>* l);
35  static Instrument* at(QQmlListProperty<Instrument>* l, int i);
36  };
37 
38 //---------------------------------------------------------
39 // Part
40 //---------------------------------------------------------
41 
43  Q_OBJECT
44  Q_PROPERTY(int startTrack READ startTrack)
45  Q_PROPERTY(int endTrack READ endTrack)
53  Q_PROPERTY(QString instrumentId READ instrumentId)
55  Q_PROPERTY(int harmonyCount READ harmonyCount)
57  Q_PROPERTY(bool hasDrumStaff READ hasDrumStaff)
59  Q_PROPERTY(bool hasPitchedStaff READ hasPitchedStaff)
61  Q_PROPERTY(bool hasTabStaff READ hasTabStaff)
63  Q_PROPERTY(int lyricCount READ lyricCount)
65  Q_PROPERTY(int midiChannel READ midiChannel)
67  Q_PROPERTY(int midiProgram READ midiProgram)
71  Q_PROPERTY(QString longName READ longName)
75  Q_PROPERTY(QString shortName READ shortName)
81  Q_PROPERTY(QString partName READ partName)
85  Q_PROPERTY(bool show READ show WRITE setShow)
86 
91  Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Instrument> instruments READ instruments);
92 
93  public:
95  Part(Ms::Part* p = nullptr, Ownership o = Ownership::SCORE)
96  : ScoreElement(p, o) {}
97 
98  Ms::Part* part() { return toPart(e); }
99  const Ms::Part* part() const { return toPart(e); }
100 
101  int startTrack() const { return part()->startTrack(); }
102  int endTrack() const { return part()->endTrack(); }
103  QString instrumentId() const { return part()->instrument()->instrumentId(); }
104  int harmonyCount() const { return part()->harmonyCount(); }
105  bool hasPitchedStaff() const { return part()->hasPitchedStaff(); }
106  bool hasTabStaff() const { return part()->hasTabStaff(); }
107  bool hasDrumStaff() const { return part()->hasDrumStaff(); }
108  int lyricCount() const { return part()->lyricCount(); }
109  int midiChannel() const { return part()->midiChannel(); }
110  int midiProgram() const { return part()->midiProgram(); }
111  QString longName() const { return part()->longName(); }
112  QString shortName() const { return part()->shortName(); }
113  QString partName() const { return part()->partName(); }
114  bool show() const { return part()->show(); }
115  void setShow(bool val) { set(Pid::VISIBLE, val); }
116 
117  InstrumentListProperty instruments();
119 
124  Q_INVOKABLE Ms::PluginAPI::Instrument* instrumentAtTick(int tick);
125  };
126 } // namespace PluginAPI
127 } // namespace Ms
128 #endif
Base class for most of object wrappers exposed to QML.
Definition: scoreelement.h:42
Definition: part.h:42
Definition: cursor.cpp:30
Main class of the plugins framework. Named as MuseScore in QML.
Definition: qmlpluginapi.h:62
Definition: instrument.h:207