MuseScore Plugins  3.5
Plugins API for MuseScore
elements.h
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2019 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 __PLUGIN_API_ELEMENTS_H__
14 #define __PLUGIN_API_ELEMENTS_H__
15 
16 #include "scoreelement.h"
17 #include "libmscore/element.h"
18 #include "libmscore/chord.h"
19 #include "libmscore/hook.h"
20 #include "libmscore/lyrics.h"
21 #include "libmscore/measure.h"
22 #include "libmscore/note.h"
23 #include "libmscore/notedot.h"
24 #include "libmscore/page.h"
25 #include "libmscore/segment.h"
26 #include "libmscore/staff.h"
27 #include "libmscore/stem.h"
28 #include "libmscore/stemslash.h"
29 #include "libmscore/tuplet.h"
30 #include "libmscore/accidental.h"
31 #include "libmscore/musescoreCore.h"
32 #include "libmscore/score.h"
33 #include "libmscore/undo.h"
34 #include "playevent.h"
35 #include "libmscore/types.h"
36 
37 namespace Ms {
38 namespace PluginAPI {
39 
40 class FractionWrapper;
41 class Element;
42 class Part;
43 class Staff;
44 class Tuplet;
45 class Tie;
46 extern Tie* tieWrap(Ms::Tie* tie);
47 
48 //---------------------------------------------------------
49 // wrap
50 //---------------------------------------------------------
51 
52 extern Element* wrap(Ms::Element* se, Ownership own = Ownership::SCORE);
53 
54 // TODO: add RESET functions
55 #define API_PROPERTY(name, pid) \
56  Q_PROPERTY(QVariant name READ get_##name WRITE set_##name) \
57  QVariant get_##name() const { return get(Ms::Pid::pid); } \
58  void set_##name(QVariant val) { set(Ms::Pid::pid, val); }
59 
66 #define API_PROPERTY_T(type, name, pid) \
67  Q_PROPERTY(type name READ get_##name WRITE set_##name) \
68  type get_##name() const { return get(Ms::Pid::pid).value<type>(); } \
69  void set_##name(type val) { set(Ms::Pid::pid, QVariant::fromValue(val)); }
70 
71 #define API_PROPERTY_READ_ONLY(name, pid) \
72  Q_PROPERTY(QVariant name READ get_##name) \
73  QVariant get_##name() const { return get(Ms::Pid::pid); }
74 
75 
76 #define API_PROPERTY_READ_ONLY_T(type, name, pid) \
77  Q_PROPERTY(type name READ get_##name) \
78  type get_##name() const { return get(Ms::Pid::pid).value<type>(); } \
79 
80 //---------------------------------------------------------
81 // Element
82 // Element wrapper
83 //---------------------------------------------------------
84 
86  Q_OBJECT
87 
92  Q_PROPERTY(Ms::PluginAPI::Element* parent READ parent)
97  Q_PROPERTY(Ms::PluginAPI::Staff* staff READ staff)
102  Q_PROPERTY(qreal offsetX READ offsetX WRITE setOffsetX)
107  Q_PROPERTY(qreal offsetY READ offsetY WRITE setOffsetY)
119  Q_PROPERTY(qreal posX READ posX)
131  Q_PROPERTY(qreal posY READ posY)
136  Q_PROPERTY(QPointF pagePos READ pagePos)
137 
144  Q_PROPERTY(QRectF bbox READ bbox)
145 
146  API_PROPERTY( subtype, SUBTYPE )
147  API_PROPERTY_READ_ONLY_T( bool, selected, SELECTED )
148  API_PROPERTY_READ_ONLY_T( bool, generated, GENERATED )
153  API_PROPERTY_T( QColor, color, COLOR )
154  API_PROPERTY_T( bool, visible, VISIBLE )
156  API_PROPERTY_T( int, z, Z )
157  API_PROPERTY( small, SMALL )
158  API_PROPERTY( showCourtesy, SHOW_COURTESY )
159  API_PROPERTY( lineType, LINE_TYPE )
160  API_PROPERTY( line, LINE )
161  API_PROPERTY( fixed, FIXED )
162  API_PROPERTY( fixedLine, FIXED_LINE )
164  API_PROPERTY( headType, HEAD_TYPE )
169  API_PROPERTY( headScheme, HEAD_SCHEME )
171  API_PROPERTY( headGroup, HEAD_GROUP )
172  API_PROPERTY( articulationAnchor, ARTICULATION_ANCHOR )
173  API_PROPERTY( direction, DIRECTION )
174  API_PROPERTY( stemDirection, STEM_DIRECTION )
175  API_PROPERTY( noStem, NO_STEM )
176  API_PROPERTY( slurDirection, SLUR_DIRECTION )
177  API_PROPERTY( leadingSpace, LEADING_SPACE )
178  API_PROPERTY( distribute, DISTRIBUTE )
179  API_PROPERTY( mirrorHead, MIRROR_HEAD )
180  API_PROPERTY( dotPosition, DOT_POSITION )
181  API_PROPERTY( tuning, TUNING )
182  API_PROPERTY( pause, PAUSE )
183  API_PROPERTY( barlineType, BARLINE_TYPE )
184  API_PROPERTY( barlineSpan, BARLINE_SPAN )
185  API_PROPERTY( barlineSpanFrom, BARLINE_SPAN_FROM )
186  API_PROPERTY( barlineSpanTo, BARLINE_SPAN_TO )
194  API_PROPERTY_T( QPointF, offset, OFFSET )
195  API_PROPERTY( fret, FRET )
196  API_PROPERTY( string, STRING )
197  API_PROPERTY( ghost, GHOST )
198  API_PROPERTY( play, PLAY )
199  API_PROPERTY( timesigNominal, TIMESIG_NOMINAL )
200  API_PROPERTY( timesigActual, TIMESIG_ACTUAL )
201  API_PROPERTY( growLeft, GROW_LEFT )
202  API_PROPERTY( growRight, GROW_RIGHT )
203  API_PROPERTY( boxHeight, BOX_HEIGHT )
204  API_PROPERTY( boxWidth, BOX_WIDTH )
205  API_PROPERTY( topGap, TOP_GAP )
206  API_PROPERTY( bottomGap, BOTTOM_GAP )
207  API_PROPERTY( leftMargin, LEFT_MARGIN )
208  API_PROPERTY( rightMargin, RIGHT_MARGIN )
209  API_PROPERTY( topMargin, TOP_MARGIN )
210  API_PROPERTY( bottomMargin, BOTTOM_MARGIN )
211  API_PROPERTY( layoutBreakType, LAYOUT_BREAK )
212  API_PROPERTY( autoscale, AUTOSCALE )
213  API_PROPERTY( size, SIZE )
214  API_PROPERTY( scale, SCALE )
215  API_PROPERTY( lockAspectRatio, LOCK_ASPECT_RATIO )
216  API_PROPERTY( sizeIsSpatium, SIZE_IS_SPATIUM )
217  API_PROPERTY( text, TEXT )
218  API_PROPERTY( beamPos, BEAM_POS )
219  API_PROPERTY( beamMode, BEAM_MODE )
220  API_PROPERTY( beamNoSlope, BEAM_NO_SLOPE )
221  API_PROPERTY( userLen, USER_LEN )
223  API_PROPERTY( space, SPACE )
224  API_PROPERTY( tempo, TEMPO )
225  API_PROPERTY( tempoFollowText, TEMPO_FOLLOW_TEXT )
226  API_PROPERTY( accidentalBracket, ACCIDENTAL_BRACKET )
227  API_PROPERTY( numeratorString, NUMERATOR_STRING )
228  API_PROPERTY( denominatorString, DENOMINATOR_STRING )
229  API_PROPERTY( fbprefix, FBPREFIX )
230  API_PROPERTY( fbdigit, FBDIGIT )
231  API_PROPERTY( fbsuffix, FBSUFFIX )
232  API_PROPERTY( fbcontinuationline, FBCONTINUATIONLINE )
233  API_PROPERTY( ottavaType, OTTAVA_TYPE )
234  API_PROPERTY( numbersOnly, NUMBERS_ONLY )
235  API_PROPERTY( trillType, TRILL_TYPE )
236  API_PROPERTY( vibratoType, VIBRATO_TYPE )
237  API_PROPERTY( hairpinCircledTip, HAIRPIN_CIRCLEDTIP )
238  API_PROPERTY( hairpinType, HAIRPIN_TYPE )
239  API_PROPERTY( hairpinHeight, HAIRPIN_HEIGHT )
240  API_PROPERTY( hairpinContHeight, HAIRPIN_CONT_HEIGHT )
241  API_PROPERTY( veloChange, VELO_CHANGE )
242  API_PROPERTY( singleNoteDynamics, SINGLE_NOTE_DYNAMICS )
243  API_PROPERTY( veloChangeMethod, VELO_CHANGE_METHOD )
244  API_PROPERTY( veloChangeSpeed, VELO_CHANGE_SPEED )
245  API_PROPERTY( dynamicRange, DYNAMIC_RANGE )
250  API_PROPERTY( changeMethod, CHANGE_METHOD )
251  API_PROPERTY( placement, PLACEMENT )
252  API_PROPERTY( velocity, VELOCITY )
253  API_PROPERTY( jumpTo, JUMP_TO )
254  API_PROPERTY( playUntil, PLAY_UNTIL )
255  API_PROPERTY( continueAt, CONTINUE_AT )
256  API_PROPERTY( label, LABEL )
257  API_PROPERTY( markerType, MARKER_TYPE )
258  API_PROPERTY( arpUserLen1, ARP_USER_LEN1 )
259  API_PROPERTY( arpUserLen2, ARP_USER_LEN2 )
260  API_PROPERTY( measureNumberMode, MEASURE_NUMBER_MODE )
261  API_PROPERTY( glissType, GLISS_TYPE )
262  API_PROPERTY( glissText, GLISS_TEXT )
263  API_PROPERTY( glissShowText, GLISS_SHOW_TEXT )
264  API_PROPERTY( diagonal, DIAGONAL )
265  API_PROPERTY( groups, GROUPS )
266  API_PROPERTY( lineStyle, LINE_STYLE )
267  API_PROPERTY( lineColor, COLOR )
268  API_PROPERTY( lineWidth, LINE_WIDTH )
269  API_PROPERTY( lassoPos, LASSO_POS )
270  API_PROPERTY( lassoSize, LASSO_SIZE )
271  API_PROPERTY( timeStretch, TIME_STRETCH )
272  API_PROPERTY( ornamentStyle, ORNAMENT_STYLE )
273  API_PROPERTY( timesig, TIMESIG )
274  API_PROPERTY( timesigGlobal, TIMESIG_GLOBAL )
275  API_PROPERTY( timesigStretch, TIMESIG_STRETCH )
276  API_PROPERTY( timesigType, TIMESIG_TYPE )
277  API_PROPERTY( spannerTick, SPANNER_TICK )
278  API_PROPERTY( spannerTicks, SPANNER_TICKS )
279  API_PROPERTY( spannerTrack2, SPANNER_TRACK2 )
280  API_PROPERTY( userOff2, OFFSET2 )
281  API_PROPERTY( breakMmr, BREAK_MMR )
282  API_PROPERTY( repeatCount, REPEAT_COUNT )
283  API_PROPERTY( userStretch, USER_STRETCH )
284  API_PROPERTY( noOffset, NO_OFFSET )
285  API_PROPERTY( irregular, IRREGULAR )
286  API_PROPERTY( anchor, ANCHOR )
287  API_PROPERTY( slurUoff1, SLUR_UOFF1 )
288  API_PROPERTY( slurUoff2, SLUR_UOFF2 )
289  API_PROPERTY( slurUoff3, SLUR_UOFF3 )
290  API_PROPERTY( slurUoff4, SLUR_UOFF4 )
291  API_PROPERTY( staffMove, STAFF_MOVE )
292  API_PROPERTY( verse, VERSE )
293  API_PROPERTY( syllabic, SYLLABIC )
294  API_PROPERTY( lyricTicks, LYRIC_TICKS )
295  API_PROPERTY( volta_ending, VOLTA_ENDING )
296  API_PROPERTY( lineVisible, LINE_VISIBLE )
297  API_PROPERTY( mag, MAG )
298  API_PROPERTY( useDrumset, USE_DRUMSET )
299  API_PROPERTY( durationType, DURATION_TYPE )
300  API_PROPERTY( role, ROLE )
301  API_PROPERTY_T( int, track, TRACK )
302  API_PROPERTY( glissandoStyle, GLISSANDO_STYLE )
303  API_PROPERTY( fretStrings, FRET_STRINGS )
304  API_PROPERTY( fretFrets, FRET_FRETS )
305  /*API_PROPERTY( fretBarre, FRET_BARRE )*/
306  API_PROPERTY( fretOffset, FRET_OFFSET )
307  API_PROPERTY( fretNumPos, FRET_NUM_POS )
308  API_PROPERTY( systemBracket, SYSTEM_BRACKET )
309  API_PROPERTY( gap, GAP )
311  API_PROPERTY_T( bool, autoplace, AUTOPLACE )
312  API_PROPERTY( dashLineLen, DASH_LINE_LEN )
313  API_PROPERTY( dashGapLen, DASH_GAP_LEN )
314 // API_PROPERTY_READ_ONLY( tick, TICK ) // wasn't available in 2.X, disabled due to fractions transition
319  API_PROPERTY( symbol, SYMBOL )
320  API_PROPERTY( playRepeats, PLAY_REPEATS )
321  API_PROPERTY( createSystemHeader, CREATE_SYSTEM_HEADER )
322  API_PROPERTY( staffLines, STAFF_LINES )
323  API_PROPERTY( lineDistance, LINE_DISTANCE )
324  API_PROPERTY( stepOffset, STEP_OFFSET )
325  API_PROPERTY( staffShowBarlines, STAFF_SHOW_BARLINES )
326  API_PROPERTY( staffShowLedgerlines, STAFF_SHOW_LEDGERLINES )
327  API_PROPERTY( staffStemless, STAFF_STEMLESS )
328  API_PROPERTY( staffGenClef, STAFF_GEN_CLEF )
329  API_PROPERTY( staffGenTimesig, STAFF_GEN_TIMESIG )
330  API_PROPERTY( staffGenKeysig, STAFF_GEN_KEYSIG )
331  API_PROPERTY( staffYoffset, STAFF_YOFFSET )
332  API_PROPERTY( bracketSpan, BRACKET_SPAN )
333  API_PROPERTY( bracketColumn, BRACKET_COLUMN )
334  API_PROPERTY( inameLayoutPosition, INAME_LAYOUT_POSITION )
335  API_PROPERTY( subStyle, SUB_STYLE )
336  API_PROPERTY( fontFace, FONT_FACE )
337  API_PROPERTY( fontSize, FONT_SIZE )
338  API_PROPERTY( fontStyle, FONT_STYLE )
339  API_PROPERTY( frameType, FRAME_TYPE )
340  API_PROPERTY( frameWidth, FRAME_WIDTH )
341  API_PROPERTY( framePadding, FRAME_PADDING )
342  API_PROPERTY( frameRound, FRAME_ROUND )
343  API_PROPERTY( frameFgColor, FRAME_FG_COLOR )
344  API_PROPERTY( frameBgColor, FRAME_BG_COLOR )
345  API_PROPERTY( sizeSpatiumDependent, SIZE_SPATIUM_DEPENDENT )
346  API_PROPERTY( align, ALIGN )
347  API_PROPERTY( systemFlag, SYSTEM_FLAG )
348  API_PROPERTY( beginText, BEGIN_TEXT )
349  API_PROPERTY( beginTextAlign, BEGIN_TEXT_ALIGN )
350  API_PROPERTY( beginTextPlace, BEGIN_TEXT_PLACE )
351  API_PROPERTY( beginHookType, BEGIN_HOOK_TYPE )
352  API_PROPERTY( beginHookHeight, BEGIN_HOOK_HEIGHT )
353  API_PROPERTY( beginFontFace, BEGIN_FONT_FACE )
354  API_PROPERTY( beginFontSize, BEGIN_FONT_SIZE )
355  API_PROPERTY( beginFontStyle, BEGIN_FONT_STYLE )
356  API_PROPERTY( beginTextOffset, BEGIN_TEXT_OFFSET )
357  API_PROPERTY( continueText, CONTINUE_TEXT )
358  API_PROPERTY( continueTextAlign, CONTINUE_TEXT_ALIGN )
359  API_PROPERTY( continueTextPlace, CONTINUE_TEXT_PLACE )
360  API_PROPERTY( continueFontFace, CONTINUE_FONT_FACE )
361  API_PROPERTY( continueFontSize, CONTINUE_FONT_SIZE )
362  API_PROPERTY( continueFontStyle, CONTINUE_FONT_STYLE )
363  API_PROPERTY( continueTextOffset, CONTINUE_TEXT_OFFSET )
364  API_PROPERTY( endText, END_TEXT )
365  API_PROPERTY( endTextAlign, END_TEXT_ALIGN )
366  API_PROPERTY( endTextPlace, END_TEXT_PLACE )
367  API_PROPERTY( endHookType, END_HOOK_TYPE )
368  API_PROPERTY( endHookHeight, END_HOOK_HEIGHT )
369  API_PROPERTY( endFontFace, END_FONT_FACE )
370  API_PROPERTY( endFontSize, END_FONT_SIZE )
371  API_PROPERTY( endFontStyle, END_FONT_STYLE )
372  API_PROPERTY( endTextOffset, END_TEXT_OFFSET )
373  API_PROPERTY( posAbove, POS_ABOVE )
374  API_PROPERTY_T( int, voice, VOICE )
375  API_PROPERTY_READ_ONLY( position, POSITION ) // TODO: needed?
381  API_PROPERTY( harmonyType, HARMONY_TYPE )
382 
383  qreal offsetX() const { return element()->offset().x() / element()->spatium(); }
384  qreal offsetY() const { return element()->offset().y() / element()->spatium(); }
385  void setOffsetX(qreal offX);
386  void setOffsetY(qreal offY);
387 
388  qreal posX() const { return element()->pos().x() / element()->spatium(); }
389  qreal posY() const { return element()->pos().y() / element()->spatium(); }
390 
391  QPointF pagePos() const { return element()->pagePos() / element()->spatium(); }
392 
393  Ms::PluginAPI::Element* parent() const { return wrap(element()->parent()); }
394  Staff* staff() { return wrap<Staff>(element()->staff()); }
395 
396  QRectF bbox() const;
397 
398  public:
400  Element(Ms::Element* e = nullptr, Ownership own = Ownership::PLUGIN)
401  : Ms::PluginAPI::ScoreElement(e, own) {}
402 
405  Ms::Element* element() { return toElement(e); }
406  const Ms::Element* element() const { return toElement(e); }
409 
411  Q_INVOKABLE Ms::PluginAPI::Element* clone() const { return wrap(element()->clone(), Ownership::PLUGIN); }
412 
413  Q_INVOKABLE QString subtypeName() const { return element()->subtypeName(); }
415  Q_INVOKABLE QString _name() const { return name(); }
416  };
417 
418 //---------------------------------------------------------
419 // Note
420 // Note wrapper
421 //---------------------------------------------------------
422 
423 class Note : public Element {
424  Q_OBJECT
425  Q_PROPERTY(Ms::PluginAPI::Element* accidental READ accidental)
426  Q_PROPERTY(Ms::AccidentalType accidentalType READ accidentalType WRITE setAccidentalType)
428  Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Element> dots READ dots)
429 // Q_PROPERTY(int dotsCount READ qmlDotsCount)
431  Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Element> elements READ elements)
436  Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::PlayEvent> playEvents READ playEvents)
437 // Q_PROPERTY(int fret READ fret WRITE undoSetFret)
438 // Q_PROPERTY(bool ghost READ ghost WRITE undoSetGhost)
439 // Q_PROPERTY(Ms::NoteHead::Group headGroup READ headGroup WRITE undoSetHeadGroup)
440 // Q_PROPERTY(Ms::NoteHead::Type headType READ headType WRITE undoSetHeadType)
441 // Q_PROPERTY(bool hidden READ hidden)
442 // Q_PROPERTY(int line READ line)
443 // Q_PROPERTY(bool mirror READ mirror)
444 // Q_PROPERTY(int pitch READ pitch WRITE undoSetPitch)
445 // Q_PROPERTY(bool play READ play WRITE undoSetPlay)
446 // Q_PROPERTY(int ppitch READ ppitch)
447 // Q_PROPERTY(bool small READ small WRITE undoSetSmall)
448 // Q_PROPERTY(int string READ string WRITE undoSetString)
449 // Q_PROPERTY(int subchannel READ subchannel)
452  Q_PROPERTY(Ms::PluginAPI::Tie* tieBack READ tieBack)
455  Q_PROPERTY(Ms::PluginAPI::Tie* tieForward READ tieForward)
459  Q_PROPERTY(Ms::PluginAPI::Note* firstTiedNote READ firstTiedNote)
463  Q_PROPERTY(Ms::PluginAPI::Note* lastTiedNote READ lastTiedNote)
466  Q_PROPERTY(Ms::NoteType noteType READ noteType)
467 
472  API_PROPERTY_T( int, pitch, PITCH )
477  API_PROPERTY_T( int, tpc1, TPC1 )
482  API_PROPERTY_T( int, tpc2, TPC2 )
488  Q_PROPERTY(int tpc READ tpc WRITE setTpc)
489 // Q_PROPERTY(qreal tuning READ tuning WRITE undoSetTuning)
490 // Q_PROPERTY(Ms::MScore::Direction userDotPosition READ userDotPosition WRITE undoSetUserDotPosition)
491 // Q_PROPERTY(Ms::MScore::DirectionH userMirror READ userMirror WRITE undoSetUserMirror)
493  API_PROPERTY( veloType, VELO_TYPE )
494  API_PROPERTY_T( int, veloOffset, VELO_OFFSET )
495 
496  public:
498  Note(Ms::Note* c = nullptr, Ownership own = Ownership::PLUGIN)
499  : Element(c, own) {}
500 
501  Ms::Note* note() { return toNote(e); }
502  const Ms::Note* note() const { return toNote(e); }
503 
504  int tpc() const { return note()->tpc(); }
505  void setTpc(int val);
506 
507  Ms::PluginAPI::Tie* tieBack() const { return note()->tieBack() != nullptr ? tieWrap(note()->tieBack()) : nullptr; }
508  Ms::PluginAPI::Tie* tieForward() const { return note()->tieFor() != nullptr ? tieWrap(note()->tieFor()) : nullptr; }
509 
510  Ms::PluginAPI::Note* firstTiedNote() { return wrap<Note>(note()->firstTiedNote()); }
511  Ms::PluginAPI::Note* lastTiedNote() { return wrap<Note>(note()->lastTiedNote()); }
512 
513  QQmlListProperty<Element> dots() { return wrapContainerProperty<Element>(this, note()->dots()); }
514  QQmlListProperty<Element> elements() { return wrapContainerProperty<Element>(this, note()->el()); }
515  QQmlListProperty<PlayEvent> playEvents() { return wrapPlayEventsContainerProperty(this, note()->playEvents()); }
516 
517  Element* accidental() { return wrap<Element>(note()->accidental()); }
518 
519  Ms::AccidentalType accidentalType() { return note()->accidentalType(); }
520  void setAccidentalType(Ms::AccidentalType t) { note()->setAccidentalType(t); }
521  Ms::NoteType noteType() { return note()->noteType(); }
522 
523  static void addInternal(Ms::Note* note, Ms::Element* el);
524  static bool isChildAllowed(Ms::ElementType elementType);
526 
529  Q_INVOKABLE Ms::PluginAPI::PlayEvent* createPlayEvent() { return playEventWrap(new NoteEvent(), nullptr); }
530 
533  Q_INVOKABLE void add(Ms::PluginAPI::Element* wrapped);
536  Q_INVOKABLE void remove(Ms::PluginAPI::Element* wrapped);
537  };
538 
539 //---------------------------------------------------------
540 // DurationElement
541 //---------------------------------------------------------
542 
543 class DurationElement : public Element {
544  Q_OBJECT
545 
550  API_PROPERTY_READ_ONLY( duration, DURATION )
556  Q_PROPERTY(Ms::PluginAPI::FractionWrapper* globalDuration READ globalDuration)
562  Q_PROPERTY(Ms::PluginAPI::FractionWrapper* actualDuration READ actualDuration)
567  Q_PROPERTY(Ms::PluginAPI::Tuplet* tuplet READ parentTuplet)
568 
569  public:
571  DurationElement(Ms::DurationElement* de = nullptr, Ownership own = Ownership::PLUGIN)
572  : Element(de, own) {}
573 
574  Ms::DurationElement* durationElement() { return toDurationElement(e); }
575  const Ms::DurationElement* durationElement() const { return toDurationElement(e); }
576 
577  FractionWrapper* globalDuration() const;
578  FractionWrapper* actualDuration() const;
579 
580  Tuplet* parentTuplet();
582  };
583 
584 //---------------------------------------------------------
585 // Tuplet
586 //---------------------------------------------------------
587 
588 class Tuplet : public DurationElement {
589  Q_OBJECT
590 
591  API_PROPERTY( numberType, NUMBER_TYPE )
592  API_PROPERTY( bracketType, BRACKET_TYPE )
594  API_PROPERTY_READ_ONLY_T( int, actualNotes, ACTUAL_NOTES )
599  API_PROPERTY_READ_ONLY_T( int, normalNotes, NORMAL_NOTES )
600  API_PROPERTY( p1, P1 )
601  API_PROPERTY( p2, P2 )
602 
607  Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Element> elements READ elements)
608 
609  public:
611  Tuplet(Ms::Tuplet* t = nullptr, Ownership own = Ownership::PLUGIN)
612  : DurationElement(t, own) {}
613 
614  Ms::Tuplet* tuplet() { return toTuplet(e); }
615  const Ms::Tuplet* tuplet() const { return toTuplet(e); }
616 
617  QQmlListProperty<Element> elements() { return wrapContainerProperty<Element>(this, tuplet()->elements()); }
619  };
620 
621 //---------------------------------------------------------
622 // ChordRest
623 // ChordRest wrapper
624 //---------------------------------------------------------
625 
626 class ChordRest : public DurationElement {
627  Q_OBJECT
632  Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Element> lyrics READ lyrics )
637  Q_PROPERTY(Ms::PluginAPI::Element* beam READ beam )
638 
639  public:
641  ChordRest(Ms::ChordRest* c = nullptr, Ownership own = Ownership::PLUGIN)
642  : DurationElement(c, own) {}
643 
644  Ms::ChordRest* chordRest() { return toChordRest(e); }
645 
646  QQmlListProperty<Element> lyrics() { return wrapContainerProperty<Element>(this, chordRest()->lyrics()); } // TODO: special type for Lyrics?
647  Element* beam() { return wrap(chordRest()->beam()); }
649  };
650 
651 //---------------------------------------------------------
652 // Chord
653 // Chord wrapper
654 //---------------------------------------------------------
655 
656 class Chord : public ChordRest {
657  Q_OBJECT
659  Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Chord> graceNotes READ graceNotes)
661  Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Note> notes READ notes )
663  Q_PROPERTY(Ms::PluginAPI::Element* stem READ stem )
666  Q_PROPERTY(Ms::PluginAPI::Element* stemSlash READ stemSlash )
668  Q_PROPERTY(Ms::PluginAPI::Element* hook READ hook )
671  Q_PROPERTY(Ms::NoteType noteType READ noteType)
674  Q_PROPERTY(Ms::PlayEventType playEventType READ playEventType WRITE setPlayEventType)
675 
676  public:
678  Chord(Ms::Chord* c = nullptr, Ownership own = Ownership::PLUGIN)
679  : ChordRest(c, own) {}
680 
681  Ms::Chord* chord() { return toChord(e); }
682  const Ms::Chord* chord() const { return toChord(e); }
683 
684  QQmlListProperty<Chord> graceNotes() { return wrapContainerProperty<Chord>(this, chord()->graceNotes()); }
685  QQmlListProperty<Note> notes() { return wrapContainerProperty<Note>(this, chord()->notes()); }
686  Element* stem() { return wrap(chord()->stem()); }
687  Element* stemSlash() { return wrap(chord()->stemSlash()); }
688  Element* hook() { return wrap(chord()->hook()); }
689  Ms::NoteType noteType() { return chord()->noteType(); }
690  Ms::PlayEventType playEventType() { return chord()->playEventType(); }
691  void setPlayEventType(Ms::PlayEventType v);
692 
693  static void addInternal(Ms::Chord* chord, Ms::Element* el);
695 
698  Q_INVOKABLE void add(Ms::PluginAPI::Element* wrapped);
701  Q_INVOKABLE void remove(Ms::PluginAPI::Element* wrapped);
702  };
703 
704 //---------------------------------------------------------
705 // Segment
706 // Segment
707 //---------------------------------------------------------
708 
709 class Segment : public Element {
710  Q_OBJECT
715  Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Element> annotations READ annotations)
719  Q_PROPERTY(Ms::PluginAPI::Segment* nextInMeasure READ nextInMeasure)
723  Q_PROPERTY(Ms::PluginAPI::Segment* next READ nextInScore)
727  Q_PROPERTY(Ms::PluginAPI::Segment* prevInMeasure READ prevInMeasure)
731  Q_PROPERTY(Ms::PluginAPI::Segment* prev READ prevInScore)
732  // segmentType was read&write in MuseScore 2.X plugin API.
733  // Allowing plugins to change random segments types doesn't seem to be a
734  // good idea though.
736  Q_PROPERTY(Ms::SegmentType segmentType READ segmentType)
743  Q_PROPERTY(int tick READ tick) // TODO: revise libmscore (or this API):
744  // Pid::TICK is relative or absolute in different contexts
745 
746  public:
748  Segment(Ms::Segment* s = nullptr, Ownership own = Ownership::SCORE)
749  : Element(s, own) {}
750 
751  Ms::Segment* segment() { return toSegment(e); }
752  const Ms::Segment* segment() const { return toSegment(e); }
753 
754  int tick() const { return segment()->tick().ticks(); }
755 
756  Ms::SegmentType segmentType() const { return segment()->segmentType(); }
757 
758  Segment* nextInScore() { return wrap<Segment>(segment()->next1()); }
759  Segment* nextInMeasure() { return wrap<Segment>(segment()->next()); }
760  Segment* prevInScore() { return wrap<Segment>(segment()->prev1()); }
761  Segment* prevInMeasure() { return wrap<Segment>(segment()->prev()); }
762  QQmlListProperty<Element> annotations() { return wrapContainerProperty<Element>(this, segment()->annotations()); }
764 
767  Q_INVOKABLE Ms::PluginAPI::Element* elementAt(int track);
768  };
769 
770 //---------------------------------------------------------
771 // Measure
772 // Measure wrapper
773 //---------------------------------------------------------
774 
775 class Measure : public Element {
776  Q_OBJECT
778  Q_PROPERTY(Ms::PluginAPI::Segment* firstSegment READ firstSegment)
780  Q_PROPERTY(Ms::PluginAPI::Segment* lastSegment READ lastSegment)
781 
782  // TODO: to MeasureBase?
783 // Q_PROPERTY(bool lineBreak READ lineBreak WRITE undoSetLineBreak)
785  Q_PROPERTY(Ms::PluginAPI::Measure* nextMeasure READ nextMeasure)
795  Q_PROPERTY(Ms::PluginAPI::Measure* nextMeasureMM READ nextMeasureMM)
796 // Q_PROPERTY(bool pageBreak READ pageBreak WRITE undoSetPageBreak)
798  Q_PROPERTY(Ms::PluginAPI::Measure* prevMeasure READ prevMeasure)
803  Q_PROPERTY(Ms::PluginAPI::Measure* prevMeasureMM READ prevMeasureMM)
804 
807  Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Element> elements READ elements)
808 
809  public:
811  Measure(Ms::Measure* m = nullptr, Ownership own = Ownership::SCORE)
812  : Element(m, own) {}
813 
814  Ms::Measure* measure() { return toMeasure(e); }
815  const Ms::Measure* measure() const { return toMeasure(e); }
816 
817  Segment* firstSegment() { return wrap<Segment>(measure()->firstEnabled(), Ownership::SCORE); }
818  Segment* lastSegment() { return wrap<Segment>(measure()->last(), Ownership::SCORE); }
819 
820  Measure* prevMeasure() { return wrap<Measure>(measure()->prevMeasure(), Ownership::SCORE); }
821  Measure* nextMeasure() { return wrap<Measure>(measure()->nextMeasure(), Ownership::SCORE); }
822 
823  Measure* prevMeasureMM() { return wrap<Measure>(measure()->prevMeasureMM(), Ownership::SCORE); }
824  Measure* nextMeasureMM() { return wrap<Measure>(measure()->nextMeasureMM(), Ownership::SCORE); }
825 
826  QQmlListProperty<Element> elements() { return wrapContainerProperty<Element>(this, measure()->el()); }
828  };
829 
830 //---------------------------------------------------------
831 // Page
832 //---------------------------------------------------------
833 
834 class Page : public Element {
835  Q_OBJECT
848  Q_PROPERTY(int pagenumber READ pagenumber)
849 
850  public:
852  Page(Ms::Page* p = nullptr, Ownership own = Ownership::SCORE)
853  : Element(p, own) {}
854 
855  Ms::Page* page() { return toPage(e); }
856  const Ms::Page* page() const { return toPage(e); }
857 
858  int pagenumber() const;
860  };
861 
862 //---------------------------------------------------------
863 // Staff
865 //---------------------------------------------------------
866 
867 class Staff : public ScoreElement {
868  Q_OBJECT
869 
870  API_PROPERTY_T( bool, small, SMALL )
871  API_PROPERTY_T( qreal, mag, MAG )
876  API_PROPERTY_T( QColor, color, COLOR )
877 
879  API_PROPERTY_T( bool, playbackVoice1, PLAYBACK_VOICE1 )
881  API_PROPERTY_T( bool, playbackVoice2, PLAYBACK_VOICE2 )
883  API_PROPERTY_T( bool, playbackVoice3, PLAYBACK_VOICE3 )
885  API_PROPERTY_T( bool, playbackVoice4, PLAYBACK_VOICE4 )
886 
887  API_PROPERTY_T( int, staffBarlineSpan, STAFF_BARLINE_SPAN )
888  API_PROPERTY_T( int, staffBarlineSpanFrom, STAFF_BARLINE_SPAN_FROM )
889  API_PROPERTY_T( int, staffBarlineSpanTo, STAFF_BARLINE_SPAN_TO )
890 
898  API_PROPERTY_T( qreal, staffUserdist, STAFF_USERDIST )
899 
901  Q_PROPERTY(Ms::PluginAPI::Part* part READ part);
902 
903  public:
905  Staff(Ms::Staff* staff, Ownership own = Ownership::PLUGIN)
906  : Ms::PluginAPI::ScoreElement(staff, own) {}
907 
908  Ms::Staff* staff() { return toStaff(e); }
909  const Ms::Staff* staff() const { return toStaff(e); }
910 
911  Part* part();
913  };
914 
915 #undef API_PROPERTY
916 #undef API_PROPERTY_T
917 #undef API_PROPERTY_READ_ONLY
918 #undef API_PROPERTY_READ_ONLY_T
919 
920 } // namespace PluginAPI
921 } // namespace Ms
922 #endif
Q_INVOKABLE QString _name() const
Deprecated: same as ScoreElement::name. Left for compatibility purposes.
Definition: elements.h:415
Definition: elements.h:775
Q_INVOKABLE Ms::PluginAPI::Element * clone() const
Create a copy of the element.
Definition: elements.h:411
Base class for most of object wrappers exposed to QML.
Definition: scoreelement.h:42
Ms::PluginAPI::Element parent
Parent element for this element.
Definition: elements.h:92
QColor color
Element color.
Definition: elements.h:153
Definition: elements.h:709
Q_INVOKABLE Ms::PluginAPI::PlayEvent * createPlayEvent()
Creates a PlayEvent object for use in Javascript.
Definition: elements.h:529
int z
Stacking order of this element.
Definition: elements.h:156
qreal offsetY
Y-axis offset from a reference position in spatium units.
Definition: elements.h:107
Definition: elements.h:588
Definition: part.h:42
QVariant headScheme
Notehead scheme, one of PluginAPI::PluginAPI::NoteHeadScheme values.
Definition: elements.h:169
ElementType
Definition: types.h:34
Definition: elements.h:85
PlayEventType
Determines whether oranaments are automatically generated when playing a score and whether the PlayEv...
Definition: types.h:587
NoteType
Definition: types.h:324
Definition: playevent.h:32
Provides access to internal Ms::Tie objects.
Definition: tie.h:28
QPointF offset
Offset from a reference position in spatium units.
Definition: elements.h:194
QPointF pagePos
Position of this element in page coordinates, in spatium units.
Definition: elements.h:136
QVariant space
For spacers: amount of space between staves.
Definition: elements.h:223
QVariant headGroup
Notehead group, one of PluginAPI::PluginAPI::NoteHeadGroup values.
Definition: elements.h:171
qreal posX
Reference position of this element relative to its parent element.
Definition: elements.h:119
AccidentalType
Definition: types.h:152
Definition: cursor.cpp:30
qreal posY
Reference position of this element relative to its parent element.
Definition: elements.h:131
Ms::PluginAPI::Staff staff
Staff which this element belongs to.
Definition: elements.h:97
QVariant headType
Notehead type, one of PluginAPI::PluginAPI::NoteHeadType values.
Definition: elements.h:164
Definition: elements.h:867
SegmentType
Definition: types.h:424
bool autoplace
Whether this element participates in autoplacement.
Definition: elements.h:311
Definition: elements.h:834
QVariant changeMethod
The way a ramp interpolates between values.
Definition: elements.h:250
QVariant harmonyType
For chord symbols, chord symbol type, one of PluginAPI::PluginAPI::HarmonyType values.
Definition: elements.h:381
QRectF bbox
Bounding box of this element.
Definition: elements.h:144
QVariant symbol
Symbol ID of this element (if approproate), one of PluginAPI::PluginAPI::SymId values.
Definition: elements.h:319
Main class of the plugins framework. Named as MuseScore in QML.
Definition: qmlpluginapi.h:62
Definition of classes Note and NoteHead.
Definition: elements.h:626
QString name
Name of this element&#39;s type, not localized.
Definition: scoreelement.h:54
Graphic representation of a note.
Definition: note.h:235
Definition: elements.h:656
Fraction object available to QML plugins.
Definition: fraction.h:32
Definition: elements.h:423
Definition: elements.h:543