MuseScore  3.4
Music composition and notation
elements.h
Go to the documentation of this file.
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/lyrics.h"
20 #include "libmscore/measure.h"
21 #include "libmscore/note.h"
22 #include "libmscore/notedot.h"
23 #include "libmscore/segment.h"
24 #include "libmscore/accidental.h"
26 #include "libmscore/score.h"
27 #include "libmscore/undo.h"
28 #include "playevent.h"
29 #include "libmscore/types.h"
30 
31 namespace Ms {
32 namespace PluginAPI {
33 
34 class Element;
35 class Tie;
36 extern Tie* tieWrap(Ms::Tie* tie);
37 
38 //---------------------------------------------------------
39 // wrap
40 //---------------------------------------------------------
41 
42 extern Element* wrap(Ms::Element* se, Ownership own = Ownership::SCORE);
43 
44 // TODO: add RESET functions
45 #define API_PROPERTY(name, pid) \
46  Q_PROPERTY(QVariant name READ get_##name WRITE set_##name) \
47  QVariant get_##name() const { return get(Ms::Pid::pid); } \
48  void set_##name(QVariant val) { set(Ms::Pid::pid, val); }
49 
56 #define API_PROPERTY_T(type, name, pid) \
57  Q_PROPERTY(type name READ get_##name WRITE set_##name) \
58  type get_##name() const { return get(Ms::Pid::pid).value<type>(); } \
59  void set_##name(type val) { set(Ms::Pid::pid, QVariant::fromValue(val)); }
60 
61 #define API_PROPERTY_READ_ONLY(name, pid) \
62  Q_PROPERTY(QVariant name READ get_##name) \
63  QVariant get_##name() const { return get(Ms::Pid::pid); }
64 
65 
66 #define API_PROPERTY_READ_ONLY_T(type, name, pid) \
67  Q_PROPERTY(type name READ get_##name) \
68  type get_##name() const { return get(Ms::Pid::pid).value<type>(); } \
69 
70 //---------------------------------------------------------
71 // Element
72 // Element wrapper
73 //---------------------------------------------------------
74 
76  Q_OBJECT
77 
87  Q_PROPERTY(qreal offsetX READ offsetX WRITE setOffsetX)
92  Q_PROPERTY(qreal offsetY READ offsetY WRITE setOffsetY)
104  Q_PROPERTY(qreal posX READ posX)
116  Q_PROPERTY(qreal posY READ posY)
117 
124  Q_PROPERTY(QRectF bbox READ bbox)
125 
126  API_PROPERTY( subtype, SUBTYPE )
136  API_PROPERTY_T( int, z, Z )
137  API_PROPERTY( small, SMALL )
138  API_PROPERTY( showCourtesy, SHOW_COURTESY )
139  API_PROPERTY( lineType, LINE_TYPE )
141  API_PROPERTY( fixed, FIXED )
142  API_PROPERTY( fixedLine, FIXED_LINE )
144  API_PROPERTY( headType, HEAD_TYPE )
146  API_PROPERTY( headGroup, HEAD_GROUP )
147  API_PROPERTY( articulationAnchor, ARTICULATION_ANCHOR )
149  API_PROPERTY( stemDirection, STEM_DIRECTION )
150  API_PROPERTY( noStem, NO_STEM )
151  API_PROPERTY( slurDirection, SLUR_DIRECTION )
152  API_PROPERTY( leadingSpace, LEADING_SPACE )
153  API_PROPERTY( distribute, DISTRIBUTE )
154  API_PROPERTY( mirrorHead, MIRROR_HEAD )
155  API_PROPERTY( dotPosition, DOT_POSITION )
156  API_PROPERTY( tuning, TUNING )
157  API_PROPERTY( pause, PAUSE )
158  API_PROPERTY( barlineType, BARLINE_TYPE )
159  API_PROPERTY( barlineSpan, BARLINE_SPAN )
160  API_PROPERTY( barlineSpanFrom, BARLINE_SPAN_FROM )
161  API_PROPERTY( barlineSpanTo, BARLINE_SPAN_TO )
169  API_PROPERTY_T( QPointF, offset, OFFSET )
171  API_PROPERTY( string, STRING )
172  API_PROPERTY( ghost, GHOST )
174  API_PROPERTY( timesigNominal, TIMESIG_NOMINAL )
175  API_PROPERTY( timesigActual, TIMESIG_ACTUAL )
176  API_PROPERTY( numberType, NUMBER_TYPE )
177  API_PROPERTY( bracketType, BRACKET_TYPE )
178  API_PROPERTY( normalNotes, NORMAL_NOTES )
179  API_PROPERTY( actualNotes, ACTUAL_NOTES )
182  API_PROPERTY( growLeft, GROW_LEFT )
183  API_PROPERTY( growRight, GROW_RIGHT )
184  API_PROPERTY( boxHeight, BOX_HEIGHT )
185  API_PROPERTY( boxWidth, BOX_WIDTH )
186  API_PROPERTY( topGap, TOP_GAP )
187  API_PROPERTY( bottomGap, BOTTOM_GAP )
188  API_PROPERTY( leftMargin, LEFT_MARGIN )
189  API_PROPERTY( rightMargin, RIGHT_MARGIN )
190  API_PROPERTY( topMargin, TOP_MARGIN )
191  API_PROPERTY( bottomMargin, BOTTOM_MARGIN )
192  API_PROPERTY( layoutBreakType, LAYOUT_BREAK )
193  API_PROPERTY( autoscale, AUTOSCALE )
195  API_PROPERTY( scale, SCALE )
196  API_PROPERTY( lockAspectRatio, LOCK_ASPECT_RATIO )
197  API_PROPERTY( sizeIsSpatium, SIZE_IS_SPATIUM )
199  API_PROPERTY( beamPos, BEAM_POS )
200  API_PROPERTY( beamMode, BEAM_MODE )
201  API_PROPERTY( beamNoSlope, BEAM_NO_SLOPE )
202  API_PROPERTY( userLen, USER_LEN )
203  API_PROPERTY( space, SPACE )
204  API_PROPERTY( tempo, TEMPO )
205  API_PROPERTY( tempoFollowText, TEMPO_FOLLOW_TEXT )
206  API_PROPERTY( accidentalBracket, ACCIDENTAL_BRACKET )
207  API_PROPERTY( numeratorString, NUMERATOR_STRING )
208  API_PROPERTY( denominatorString, DENOMINATOR_STRING )
209  API_PROPERTY( fbprefix, FBPREFIX )
210  API_PROPERTY( fbdigit, FBDIGIT )
211  API_PROPERTY( fbsuffix, FBSUFFIX )
212  API_PROPERTY( fbcontinuationline, FBCONTINUATIONLINE )
213  API_PROPERTY( ottavaType, OTTAVA_TYPE )
214  API_PROPERTY( numbersOnly, NUMBERS_ONLY )
215  API_PROPERTY( trillType, TRILL_TYPE )
216  API_PROPERTY( vibratoType, VIBRATO_TYPE )
217  API_PROPERTY( hairpinCircledTip, HAIRPIN_CIRCLEDTIP )
218  API_PROPERTY( hairpinType, HAIRPIN_TYPE )
219  API_PROPERTY( hairpinHeight, HAIRPIN_HEIGHT )
220  API_PROPERTY( hairpinContHeight, HAIRPIN_CONT_HEIGHT )
221  API_PROPERTY( veloChange, VELO_CHANGE )
222  API_PROPERTY( singleNoteDynamics, SINGLE_NOTE_DYNAMICS )
223  API_PROPERTY( veloChangeMethod, VELO_CHANGE_METHOD )
224  API_PROPERTY( veloChangeSpeed, VELO_CHANGE_SPEED )
225  API_PROPERTY( dynamicRange, DYNAMIC_RANGE )
226  API_PROPERTY( placement, PLACEMENT )
227  API_PROPERTY( velocity, VELOCITY )
228  API_PROPERTY( jumpTo, JUMP_TO )
229  API_PROPERTY( playUntil, PLAY_UNTIL )
230  API_PROPERTY( continueAt, CONTINUE_AT )
231  API_PROPERTY( label, LABEL )
232  API_PROPERTY( markerType, MARKER_TYPE )
233  API_PROPERTY( arpUserLen1, ARP_USER_LEN1 )
234  API_PROPERTY( arpUserLen2, ARP_USER_LEN2 )
235  API_PROPERTY( measureNumberMode, MEASURE_NUMBER_MODE )
236  API_PROPERTY( glissType, GLISS_TYPE )
237  API_PROPERTY( glissText, GLISS_TEXT )
238  API_PROPERTY( glissShowText, GLISS_SHOW_TEXT )
239  API_PROPERTY( diagonal, DIAGONAL )
240  API_PROPERTY( groups, GROUPS )
241  API_PROPERTY( lineStyle, LINE_STYLE )
243  API_PROPERTY( lineWidth, LINE_WIDTH )
244  API_PROPERTY( lassoPos, LASSO_POS )
245  API_PROPERTY( lassoSize, LASSO_SIZE )
246  API_PROPERTY( timeStretch, TIME_STRETCH )
247  API_PROPERTY( ornamentStyle, ORNAMENT_STYLE )
248  API_PROPERTY( timesig, TIMESIG )
249  API_PROPERTY( timesigGlobal, TIMESIG_GLOBAL )
250  API_PROPERTY( timesigStretch, TIMESIG_STRETCH )
251  API_PROPERTY( timesigType, TIMESIG_TYPE )
252  API_PROPERTY( spannerTick, SPANNER_TICK )
253  API_PROPERTY( spannerTicks, SPANNER_TICKS )
254  API_PROPERTY( spannerTrack2, SPANNER_TRACK2 )
255  API_PROPERTY( userOff2, OFFSET2 )
256  API_PROPERTY( breakMmr, BREAK_MMR )
257  API_PROPERTY( repeatCount, REPEAT_COUNT )
258  API_PROPERTY( userStretch, USER_STRETCH )
259  API_PROPERTY( noOffset, NO_OFFSET )
260  API_PROPERTY( irregular, IRREGULAR )
261  API_PROPERTY( anchor, ANCHOR )
262  API_PROPERTY( slurUoff1, SLUR_UOFF1 )
263  API_PROPERTY( slurUoff2, SLUR_UOFF2 )
264  API_PROPERTY( slurUoff3, SLUR_UOFF3 )
265  API_PROPERTY( slurUoff4, SLUR_UOFF4 )
266  API_PROPERTY( staffMove, STAFF_MOVE )
267  API_PROPERTY( verse, VERSE )
268  API_PROPERTY( syllabic, SYLLABIC )
269  API_PROPERTY( lyricTicks, LYRIC_TICKS )
270  API_PROPERTY( volta_ending, VOLTA_ENDING )
271  API_PROPERTY( lineVisible, LINE_VISIBLE )
273  API_PROPERTY( useDrumset, USE_DRUMSET )
274  API_PROPERTY( duration, DURATION )
275  API_PROPERTY( durationType, DURATION_TYPE )
277  API_PROPERTY_T( int, track, TRACK )
278  API_PROPERTY( glissandoStyle, GLISSANDO_STYLE )
279  API_PROPERTY( fretStrings, FRET_STRINGS )
280  API_PROPERTY( fretFrets, FRET_FRETS )
281  /*API_PROPERTY( fretBarre, FRET_BARRE )*/
282  API_PROPERTY( fretOffset, FRET_OFFSET )
283  API_PROPERTY( fretNumPos, FRET_NUM_POS )
284  API_PROPERTY( systemBracket, SYSTEM_BRACKET )
287  API_PROPERTY_T( bool, autoplace, AUTOPLACE )
288  API_PROPERTY( dashLineLen, DASH_LINE_LEN )
289  API_PROPERTY( dashGapLen, DASH_GAP_LEN )
290 // API_PROPERTY_READ_ONLY( tick, TICK ) // wasn't available in 2.X, disabled due to fractions transition
291  API_PROPERTY( playbackVoice1, PLAYBACK_VOICE1 )
292  API_PROPERTY( playbackVoice2, PLAYBACK_VOICE2 )
293  API_PROPERTY( playbackVoice3, PLAYBACK_VOICE3 )
294  API_PROPERTY( playbackVoice4, PLAYBACK_VOICE4 )
295  API_PROPERTY( symbol, SYMBOL )
296  API_PROPERTY( playRepeats, PLAY_REPEATS )
297  API_PROPERTY( createSystemHeader, CREATE_SYSTEM_HEADER )
298  API_PROPERTY( staffLines, STAFF_LINES )
299  API_PROPERTY( lineDistance, LINE_DISTANCE )
300  API_PROPERTY( stepOffset, STEP_OFFSET )
301  API_PROPERTY( staffShowBarlines, STAFF_SHOW_BARLINES )
302  API_PROPERTY( staffShowLedgerlines, STAFF_SHOW_LEDGERLINES )
303  API_PROPERTY( staffStemless, STAFF_STEMLESS )
304  API_PROPERTY( staffNoteheadScheme, STAFF_NOTEHEAD_SCHEME )
305  API_PROPERTY( staffGenClef, STAFF_GEN_CLEF )
306  API_PROPERTY( staffGenTimesig, STAFF_GEN_TIMESIG )
307  API_PROPERTY( staffGenKeysig, STAFF_GEN_KEYSIG )
308  API_PROPERTY( staffYoffset, STAFF_YOFFSET )
309  API_PROPERTY( staffUserdist, STAFF_USERDIST )
310  API_PROPERTY( staffBarlineSpan, STAFF_BARLINE_SPAN )
311  API_PROPERTY( staffBarlineSpanFrom, STAFF_BARLINE_SPAN_FROM )
312  API_PROPERTY( staffBarlineSpanTo, STAFF_BARLINE_SPAN_TO )
313  API_PROPERTY( bracketSpan, BRACKET_SPAN )
314  API_PROPERTY( bracketColumn, BRACKET_COLUMN )
315  API_PROPERTY( inameLayoutPosition, INAME_LAYOUT_POSITION )
316  API_PROPERTY( subStyle, SUB_STYLE )
317  API_PROPERTY( fontFace, FONT_FACE )
318  API_PROPERTY( fontSize, FONT_SIZE )
319  API_PROPERTY( fontStyle, FONT_STYLE )
320  API_PROPERTY( frameType, FRAME_TYPE )
321  API_PROPERTY( frameWidth, FRAME_WIDTH )
322  API_PROPERTY( framePadding, FRAME_PADDING )
323  API_PROPERTY( frameRound, FRAME_ROUND )
324  API_PROPERTY( frameFgColor, FRAME_FG_COLOR )
325  API_PROPERTY( frameBgColor, FRAME_BG_COLOR )
326  API_PROPERTY( sizeSpatiumDependent, SIZE_SPATIUM_DEPENDENT )
327  API_PROPERTY( align, ALIGN )
328  API_PROPERTY( systemFlag, SYSTEM_FLAG )
329  API_PROPERTY( beginText, BEGIN_TEXT )
330  API_PROPERTY( beginTextAlign, BEGIN_TEXT_ALIGN )
331  API_PROPERTY( beginTextPlace, BEGIN_TEXT_PLACE )
332  API_PROPERTY( beginHookType, BEGIN_HOOK_TYPE )
333  API_PROPERTY( beginHookHeight, BEGIN_HOOK_HEIGHT )
334  API_PROPERTY( beginFontFace, BEGIN_FONT_FACE )
335  API_PROPERTY( beginFontSize, BEGIN_FONT_SIZE )
336  API_PROPERTY( beginFontStyle, BEGIN_FONT_STYLE )
337  API_PROPERTY( beginTextOffset, BEGIN_TEXT_OFFSET )
338  API_PROPERTY( continueText, CONTINUE_TEXT )
339  API_PROPERTY( continueTextAlign, CONTINUE_TEXT_ALIGN )
340  API_PROPERTY( continueTextPlace, CONTINUE_TEXT_PLACE )
341  API_PROPERTY( continueFontFace, CONTINUE_FONT_FACE )
342  API_PROPERTY( continueFontSize, CONTINUE_FONT_SIZE )
343  API_PROPERTY( continueFontStyle, CONTINUE_FONT_STYLE )
344  API_PROPERTY( continueTextOffset, CONTINUE_TEXT_OFFSET )
345  API_PROPERTY( endText, END_TEXT )
346  API_PROPERTY( endTextAlign, END_TEXT_ALIGN )
347  API_PROPERTY( endTextPlace, END_TEXT_PLACE )
348  API_PROPERTY( endHookType, END_HOOK_TYPE )
349  API_PROPERTY( endHookHeight, END_HOOK_HEIGHT )
350  API_PROPERTY( endFontFace, END_FONT_FACE )
351  API_PROPERTY( endFontSize, END_FONT_SIZE )
352  API_PROPERTY( endFontStyle, END_FONT_STYLE )
353  API_PROPERTY( endTextOffset, END_TEXT_OFFSET )
354  API_PROPERTY( posAbove, POS_ABOVE )
355  API_PROPERTY_T( int, voice, VOICE )
356  API_PROPERTY_READ_ONLY( position, POSITION ) // TODO: needed?
357 
358  qreal offsetX() const { return element()->offset().x() / element()->spatium(); }
359  qreal offsetY() const { return element()->offset().y() / element()->spatium(); }
360  void setOffsetX(qreal offX);
361  void setOffsetY(qreal offY);
362 
363  qreal posX() const { return element()->pos().x() / element()->spatium(); }
364  qreal posY() const { return element()->pos().y() / element()->spatium(); }
365 
366  Ms::PluginAPI::Element* parent() const { return wrap(element()->parent()); }
367 
368  QRectF bbox() const;
369 
370  public:
373  : Ms::PluginAPI::ScoreElement(e, own) {}
374 
377  Ms::Element* element() { return toElement(e); }
378  const Ms::Element* element() const { return toElement(e); }
381 
383  Q_INVOKABLE Ms::PluginAPI::Element* clone() const { return wrap(element()->clone(), Ownership::PLUGIN); }
384 
385  Q_INVOKABLE QString subtypeName() const { return element()->subtypeName(); }
387  Q_INVOKABLE QString _name() const { return name(); }
388  };
389 
390 //---------------------------------------------------------
391 // Note
392 // Note wrapper
393 //---------------------------------------------------------
394 
395 class Note : public Element {
396  Q_OBJECT
397  Q_PROPERTY(Ms::PluginAPI::Element* accidental READ accidental)
398  Q_PROPERTY(Ms::AccidentalType accidentalType READ accidentalType WRITE setAccidentalType)
399  Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Element> dots READ dots)
400 // Q_PROPERTY(int dotsCount READ qmlDotsCount)
401  Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Element> elements READ elements)
406  Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::PlayEvent> playEvents READ playEvents)
407 // Q_PROPERTY(int fret READ fret WRITE undoSetFret)
408 // Q_PROPERTY(bool ghost READ ghost WRITE undoSetGhost)
409 // Q_PROPERTY(Ms::NoteHead::Group headGroup READ headGroup WRITE undoSetHeadGroup)
410 // Q_PROPERTY(Ms::NoteHead::Type headType READ headType WRITE undoSetHeadType)
411 // Q_PROPERTY(bool hidden READ hidden)
412 // Q_PROPERTY(int line READ line)
413 // Q_PROPERTY(bool mirror READ mirror)
414 // Q_PROPERTY(int pitch READ pitch WRITE undoSetPitch)
415 // Q_PROPERTY(bool play READ play WRITE undoSetPlay)
416 // Q_PROPERTY(int ppitch READ ppitch)
417 // Q_PROPERTY(bool small READ small WRITE undoSetSmall)
418 // Q_PROPERTY(int string READ string WRITE undoSetString)
419 // Q_PROPERTY(int subchannel READ subchannel)
422  Q_PROPERTY(Ms::PluginAPI::Tie* tieBack READ tieBack)
425  Q_PROPERTY(Ms::PluginAPI::Tie* tieForward READ tieForward)
429  Q_PROPERTY(Ms::PluginAPI::Note* firstTiedNote READ firstTiedNote)
433  Q_PROPERTY(Ms::PluginAPI::Note* lastTiedNote READ lastTiedNote)
436  Q_PROPERTY(Ms::NoteType noteType READ noteType)
437 
442  API_PROPERTY_T( int, pitch, PITCH )
447  API_PROPERTY_T( int, tpc1, TPC1 )
452  API_PROPERTY_T( int, tpc2, TPC2 )
458  Q_PROPERTY(int tpc READ tpc WRITE setTpc)
459 // Q_PROPERTY(qreal tuning READ tuning WRITE undoSetTuning)
460 // Q_PROPERTY(Ms::MScore::Direction userDotPosition READ userDotPosition WRITE undoSetUserDotPosition)
461 // Q_PROPERTY(Ms::MScore::DirectionH userMirror READ userMirror WRITE undoSetUserMirror)
463  API_PROPERTY( veloType, VELO_TYPE )
464  API_PROPERTY_T( int, veloOffset, VELO_OFFSET )
465 
466  public:
468  Note(Ms::Note* c = nullptr, Ownership own = Ownership::PLUGIN)
469  : Element(c, own) {}
470 
471  Ms::Note* note() { return toNote(e); }
472  const Ms::Note* note() const { return toNote(e); }
473 
474  int tpc() const { return note()->tpc(); }
475  void setTpc(int val);
476 
477  Ms::PluginAPI::Tie* tieBack() const { return note()->tieBack() != nullptr ? tieWrap(note()->tieBack()) : nullptr; }
478  Ms::PluginAPI::Tie* tieForward() const { return note()->tieFor() != nullptr ? tieWrap(note()->tieFor()) : nullptr; }
479 
480  Ms::PluginAPI::Note* firstTiedNote() { return wrap<Note>(note()->firstTiedNote()); }
481  Ms::PluginAPI::Note* lastTiedNote() { return wrap<Note>(note()->lastTiedNote()); }
482 
483  QQmlListProperty<Element> dots() { return wrapContainerProperty<Element>(this, note()->dots()); }
484  QQmlListProperty<Element> elements() { return wrapContainerProperty<Element>(this, note()->el()); }
485  QQmlListProperty<PlayEvent> playEvents() { return wrapPlayEventsContainerProperty(this, note()->playEvents()); }
486 
487  Element* accidental() { return wrap<Element>(note()->accidental()); }
488 
489  Ms::AccidentalType accidentalType() { return note()->accidentalType(); }
490  void setAccidentalType(Ms::AccidentalType t) { note()->setAccidentalType(t); }
491  Ms::NoteType noteType() { return note()->noteType(); }
492 
493  static void addInternal(Ms::Note* note, Ms::Element* el);
494  static bool isChildAllowed(Ms::ElementType elementType);
496 
499  Q_INVOKABLE Ms::PluginAPI::PlayEvent* createPlayEvent() { return playEventWrap(new NoteEvent(), nullptr); }
500 
503  Q_INVOKABLE void add(Ms::PluginAPI::Element* wrapped);
506  Q_INVOKABLE void remove(Ms::PluginAPI::Element* wrapped);
507  };
508 
509 //---------------------------------------------------------
510 // Chord
511 // Chord wrapper
512 //---------------------------------------------------------
513 
514 class Chord : public Element {
515  Q_OBJECT
516  Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Chord> graceNotes READ graceNotes)
517  Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Note> notes READ notes )
518  Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Element> lyrics READ lyrics ) // TODO: move to ChordRest
519  //Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Element> stem READ stem )
520  //Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Element> stemSlash READ stemSlash )
521  //Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Element> beam READ beam )
522  //Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Element> hook READ hook )
525  Q_PROPERTY(Ms::NoteType noteType READ noteType)
528  Q_PROPERTY(Ms::PlayEventType playEventType READ playEventType WRITE setPlayEventType)
529 
530  public:
532  Chord(Ms::Chord* c = nullptr, Ownership own = Ownership::PLUGIN)
533  : Element(c, own) {}
534 
535  Ms::Chord* chord() { return toChord(e); }
536  const Ms::Chord* chord() const { return toChord(e); }
537 
538  QQmlListProperty<Chord> graceNotes() { return wrapContainerProperty<Chord>(this, chord()->graceNotes()); }
539  QQmlListProperty<Note> notes() { return wrapContainerProperty<Note>(this, chord()->notes()); }
540  QQmlListProperty<Element> lyrics() { return wrapContainerProperty<Element>(this, chord()->lyrics()); } // TODO: move to ChordRest // TODO: special type for Lyrics?
541  //QQmlListProperty<Element> stem() { return wrapContainerProperty<Element>(this, chord()->stem()); }
542  //QQmlListProperty<Element> stemSlash() { return wrapContainerProperty<Element>(this, chord()->stemSlash()); }
543  //QQmlListProperty<Element> beam() { return wrapContainerProperty<Element>(this, chord()->beam()); }
544  //QQmlListProperty<Element> hook() { return wrapContainerProperty<Element>(this, chord()->hook()); }
545  Ms::NoteType noteType() { return chord()->noteType(); }
546  Ms::PlayEventType playEventType() { return chord()->playEventType(); }
547  void setPlayEventType(Ms::PlayEventType v);
548 
549  static void addInternal(Ms::Chord* chord, Ms::Element* el);
551 
554  Q_INVOKABLE void add(Ms::PluginAPI::Element* wrapped);
557  Q_INVOKABLE void remove(Ms::PluginAPI::Element* wrapped);
558  };
559 
560 //---------------------------------------------------------
561 // Segment
562 // Segment
563 //---------------------------------------------------------
564 
565 class Segment : public Element {
566  Q_OBJECT
571  Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Element> annotations READ annotations)
575  Q_PROPERTY(Ms::PluginAPI::Segment* nextInMeasure READ nextInMeasure)
579  Q_PROPERTY(Ms::PluginAPI::Segment* next READ nextInScore)
583  Q_PROPERTY(Ms::PluginAPI::Segment* prevInMeasure READ prevInMeasure)
587  Q_PROPERTY(Ms::PluginAPI::Segment* prev READ prevInScore)
588  // segmentType was read&write in MuseScore 2.X plugin API.
589  // Allowing plugins to change random segments types doesn't seem to be a
590  // good idea though.
592  Q_PROPERTY(Ms::SegmentType segmentType READ segmentType)
599  Q_PROPERTY(int tick READ tick) // TODO: revise libmscore (or this API):
600  // Pid::TICK is relative or absolute in different contexts
601 
602  public:
604  Segment(Ms::Segment* s = nullptr, Ownership own = Ownership::SCORE)
605  : Element(s, own) {}
606 
607  Ms::Segment* segment() { return toSegment(e); }
608  const Ms::Segment* segment() const { return toSegment(e); }
609 
610  int tick() const { return segment()->tick().ticks(); }
611 
612  Ms::SegmentType segmentType() const { return segment()->segmentType(); }
613 
614  Segment* nextInScore() { return wrap<Segment>(segment()->next1()); }
615  Segment* nextInMeasure() { return wrap<Segment>(segment()->next()); }
616  Segment* prevInScore() { return wrap<Segment>(segment()->prev1()); }
617  Segment* prevInMeasure() { return wrap<Segment>(segment()->prev()); }
618  QQmlListProperty<Element> annotations() { return wrapContainerProperty<Element>(this, segment()->annotations()); }
620 
623  Q_INVOKABLE Ms::PluginAPI::Element* elementAt(int track);
624  };
625 
626 //---------------------------------------------------------
627 // Measure
628 // Measure wrapper
629 //---------------------------------------------------------
630 
631 class Measure : public Element {
632  Q_OBJECT
634  Q_PROPERTY(Ms::PluginAPI::Segment* firstSegment READ firstSegment)
636  Q_PROPERTY(Ms::PluginAPI::Segment* lastSegment READ lastSegment)
637 
638  // TODO: to MeasureBase?
639 // Q_PROPERTY(bool lineBreak READ lineBreak WRITE undoSetLineBreak)
640  Q_PROPERTY(Ms::PluginAPI::Measure* nextMeasure READ nextMeasure)
641 // Q_PROPERTY(Ms::Measure* nextMeasureMM READ nextMeasureMM)
642 // Q_PROPERTY(bool pageBreak READ pageBreak WRITE undoSetPageBreak)
643  Q_PROPERTY(Ms::PluginAPI::Measure* prevMeasure READ prevMeasure)
644 // Q_PROPERTY(Ms::Measure* prevMeasureMM READ prevMeasureMM)
645 
648  Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Element> elements READ elements)
649 
650  public:
652  Measure(Ms::Measure* m = nullptr, Ownership own = Ownership::SCORE)
653  : Element(m, own) {}
654 
655  Ms::Measure* measure() { return toMeasure(e); }
656  const Ms::Measure* measure() const { return toMeasure(e); }
657 
658  Segment* firstSegment() { return wrap<Segment>(measure()->firstEnabled(), Ownership::SCORE); }
659  Segment* lastSegment() { return wrap<Segment>(measure()->last(), Ownership::SCORE); }
660 
661  Measure* prevMeasure() { return wrap<Measure>(measure()->prevMeasure(), Ownership::SCORE); }
662  Measure* nextMeasure() { return wrap<Measure>(measure()->nextMeasure(), Ownership::SCORE); }
663 
664  QQmlListProperty<Element> elements() { return wrapContainerProperty<Element>(this, measure()->el()); }
666  };
667 
668 #undef API_PROPERTY
669 #undef API_PROPERTY_T
670 #undef API_PROPERTY_READ_ONLY
671 #undef API_PROPERTY_READ_ONLY_T
672 
673 } // namespace PluginAPI
674 } // namespace Ms
675 #endif
Wrapper * wrap(T *t, Ownership own=Ownership::SCORE)
Definition: scoreelement.h:97
QVariant noStem
Definition: elements.h:150
QVariant role
Definition: elements.h:276
QVariant boxHeight
Definition: elements.h:184
Measure * prevMeasure()
Definition: elements.h:661
Definition: elements.h:631
Definition of class Accidental.
QVariant dashGapLen
Definition: elements.h:289
const Ms::Measure * measure() const
Definition: elements.h:656
QVariant singleNoteDynamics
Definition: elements.h:222
QVariant playbackVoice3
Definition: elements.h:293
const Ms::Segment * segment() const
Definition: elements.h:608
QVariant systemFlag
Definition: elements.h:328
Segment * prevInMeasure()
Definition: elements.h:617
QVariant distribute
Definition: elements.h:153
QVariant bracketType
Definition: elements.h:177
QVariant frameBgColor
Definition: elements.h:325
QVariant volta_ending
Definition: elements.h:270
QVariant barlineSpanTo
Definition: elements.h:161
Ms::NoteType noteType()
Definition: elements.h:545
QVariant staffLines
Definition: elements.h:298
QVariant glissType
Definition: elements.h:236
QVariant mag
Definition: elements.h:272
QVariant headGroup
Notehead group, one of PluginAPI::PluginAPI::NoteHeadGroup values.
Definition: elements.h:146
QVariant numberType
Definition: elements.h:176
QVariant fbprefix
Definition: elements.h:209
QVariant showCourtesy
Definition: elements.h:138
QVariant timesigStretch
Definition: elements.h:250
QVariant fretFrets
Definition: elements.h:280
Base class for most of object wrappers exposed to QML.
Definition: scoreelement.h:42
QVariant fretOffset
Definition: elements.h:282
QVariant hairpinType
Definition: elements.h:218
QVariant staffNoteheadScheme
Definition: elements.h:304
QVariant vibratoType
Definition: elements.h:216
QVariant fbdigit
Definition: elements.h:210
QVariant space
Definition: elements.h:203
Definition: noteevent.h:25
QVariant play
Definition: elements.h:173
QVariant text
Definition: elements.h:198
QVariant lineWidth
Definition: elements.h:243
QVariant rightMargin
Definition: elements.h:189
QVariant measureNumberMode
Definition: elements.h:235
QVariant fbcontinuationline
Definition: elements.h:212
Definition of undo-releated classes and structs.
QVariant staffGenKeysig
Definition: elements.h:307
QVariant line
Definition: elements.h:140
QVariant frameType
Definition: elements.h:320
QColor color
Element color.
Definition: elements.h:133
Ms::NoteType noteType()
Definition: elements.h:491
QVariant userLen
Definition: elements.h:202
QVariant hairpinHeight
Definition: elements.h:219
QVariant beamNoSlope
Definition: elements.h:201
Ms::SegmentType segmentType() const
Definition: elements.h:612
QVariant endHookHeight
Definition: elements.h:349
QVariant staffGenClef
Definition: elements.h:305
QVariant staffMove
Definition: elements.h:266
Definition: elements.h:565
QVariant bottomGap
Definition: elements.h:187
QVariant playbackVoice2
Definition: elements.h:292
QVariant align
Definition: elements.h:327
QVariant tempoFollowText
Definition: elements.h:205
QVariant staffGenTimesig
Definition: elements.h:306
QVariant repeatCount
Definition: elements.h:257
Ms::PluginAPI::Note * lastTiedNote()
Definition: elements.h:481
QVariant slurUoff3
Definition: elements.h:264
Definition of Score class.
QVariant continueFontStyle
Definition: elements.h:343
QVariant timesigActual
Definition: elements.h:175
one measure in a system
Definition: measure.h:65
QVariant topMargin
Definition: elements.h:190
QVariant veloChange
Definition: elements.h:221
QVariant gap
Definition: elements.h:285
Measure * nextMeasure()
Definition: elements.h:662
QVariant staffShowBarlines
Definition: elements.h:301
Segment * prevInScore()
Definition: elements.h:616
bool selected
Definition: elements.h:127
qreal offsetY() const
Definition: elements.h:359
QVariant normalNotes
Definition: elements.h:178
QVariant endFontFace
Definition: elements.h:350
AccidentalType
Definition: types.h:152
QVariant staffBarlineSpan
Definition: elements.h:310
QVariant lineType
Definition: elements.h:139
QVariant lineVisible
Definition: elements.h:271
QVariant small
Definition: elements.h:137
QVariant beginFontFace
Definition: elements.h:334
QVariant beginTextPlace
Definition: elements.h:331
QVariant fixedLine
Definition: elements.h:142
Base class of score layout elements.
Definition: element.h:158
QVariant createSystemHeader
Definition: elements.h:297
QVariant subStyle
Definition: elements.h:316
QVariant noOffset
Definition: elements.h:259
Definition: elements.h:75
QQmlListProperty< Element > annotations()
Definition: elements.h:618
Ms::PluginAPI::Tie * tieForward() const
Definition: elements.h:478
QVariant lineStyle
Definition: elements.h:241
Ms::ScoreElement *const e
Definition: scoreelement.h:60
QVariant sizeSpatiumDependent
Definition: elements.h:326
QVariant label
Definition: elements.h:231
#define API_PROPERTY_READ_ONLY(name, pid)
Definition: elements.h:61
QVariant staffStemless
Definition: elements.h:303
QVariant barlineSpanFrom
Definition: elements.h:160
QVariant articulationAnchor
Definition: elements.h:147
QVariant boxWidth
Definition: elements.h:185
QVariant staffYoffset
Definition: elements.h:308
QVariant continueTextOffset
Definition: elements.h:344
virtual const QPointF pos() const
Definition: element.h:230
QVariant trillType
Definition: elements.h:215
QVariant beginFontSize
Definition: elements.h:335
QVariant fret
Definition: elements.h:170
QVariant hairpinCircledTip
Definition: elements.h:217
QVariant endText
Definition: elements.h:345
QVariant staffBarlineSpanFrom
Definition: elements.h:311
QVariant dotPosition
Definition: elements.h:155
Element(Ms::Element *e=nullptr, Ownership own=Ownership::PLUGIN)
Definition: elements.h:372
QVariant playbackVoice1
Definition: elements.h:291
QVariant irregular
Definition: elements.h:260
QVariant frameWidth
Definition: elements.h:321
QVariant beamMode
Definition: elements.h:200
QVariant slurDirection
Definition: elements.h:151
QVariant numeratorString
Definition: elements.h:207
QVariant spannerTrack2
Definition: elements.h:254
QVariant jumpTo
Definition: elements.h:228
QVariant fixed
Definition: elements.h:141
PlayEventType
Determines whether oranaments are automatically generated when playing a score and whether the PlayEv...
Definition: types.h:489
Definition: inspectorAmbitus.cpp:21
QVariant tempo
Definition: elements.h:204
QVariant lassoPos
Definition: elements.h:244
Ms::Chord * chord()
Definition: elements.h:535
Segment * lastSegment()
Definition: elements.h:659
Ms::PluginAPI::Tie * tieBack() const
Definition: elements.h:477
void setOffsetY(qreal offY)
Definition: elements.cpp:34
QVariant fbsuffix
Definition: elements.h:211
Tie * tieWrap(Ms::Tie *tie)
Definition: tie.cpp:34
QVariant lyricTicks
Definition: elements.h:269
#define API_PROPERTY_T(type, name, pid)
API_PROPERTY flavor which allows to define the property type.
Definition: elements.h:56
QVariant staffUserdist
Definition: elements.h:309
QVariant breakMmr
Definition: elements.h:256
QVariant fontStyle
Definition: elements.h:319
QVariant sizeIsSpatium
Definition: elements.h:197
QVariant duration
Definition: elements.h:274
Ms::Measure * measure()
Definition: elements.h:655
QVariant slurUoff1
Definition: elements.h:262
int z
Stacking order of this element.
Definition: elements.h:136
QVariant beginFontStyle
Definition: elements.h:336
QVariant glissText
Definition: elements.h:237
Ms::PlayEventType playEventType()
Definition: elements.h:546
Definition: playevent.h:32
virtual Q_INVOKABLE QString subtypeName() const
Definition: element.cpp:154
QVariant headType
Notehead type, one of PluginAPI::PluginAPI::NoteHeadType values.
Definition: elements.h:144
Ms::PluginAPI::Element * parent() const
Definition: elements.h:366
QVariant posAbove
Definition: elements.h:354
QVariant frameRound
Definition: elements.h:323
Provides access to internal Ms::Tie objects.
Definition: tie.h:28
QVariant inameLayoutPosition
Definition: elements.h:315
QVariant markerType
Definition: elements.h:232
QVariant subtype
Definition: elements.h:126
QVariant mirrorHead
Definition: elements.h:154
QVariant leftMargin
Definition: elements.h:188
QVariant hairpinContHeight
Definition: elements.h:220
QVariant beginTextAlign
Definition: elements.h:330
Ownership
Definition: scoreelement.h:32
QVariant frameFgColor
Definition: elements.h:324
qreal posY() const
Definition: elements.h:364
QVariant stepOffset
Definition: elements.h:300
QVariant spannerTicks
Definition: elements.h:253
QVariant arpUserLen1
Definition: elements.h:233
QVariant direction
Definition: elements.h:148
QVariant ornamentStyle
Definition: elements.h:247
int tpc() const
Definition: elements.h:474
QVariant playUntil
Definition: elements.h:229
QVariant staffShowLedgerlines
Definition: elements.h:302
QVariant veloChangeMethod
Definition: elements.h:223
QVariant verse
Definition: elements.h:267
QVariant groups
Definition: elements.h:240
QVariant timesig
Definition: elements.h:248
const Ms::Element * element() const
Returns the underlying Ms::Element.
Definition: elements.h:378
Q_INVOKABLE Ms::PluginAPI::Element * clone() const
Definition: elements.h:383
QVariant symbol
Definition: elements.h:295
QVariant continueTextPlace
Definition: elements.h:340
SegmentType
Definition: types.h:333
const Ms::Chord * chord() const
Definition: elements.h:536
QVariant veloChangeSpeed
Definition: elements.h:224
QVariant p2
Definition: elements.h:181
QVariant beginHookHeight
Definition: elements.h:333
QQmlListProperty< PlayEvent > playEvents()
Definition: elements.h:485
QVariant beginTextOffset
Definition: elements.h:337
const Ms::Note * note() const
Definition: elements.h:472
QVariant placement
Definition: elements.h:226
Element * accidental()
Definition: elements.h:487
QVariant tuning
Definition: elements.h:156
QVariant size
Definition: elements.h:194
QVariant scale
Definition: elements.h:195
QVariant layoutBreakType
Definition: elements.h:192
int tick() const
Definition: elements.h:610
QVariant beginHookType
Definition: elements.h:332
bool autoplace
Whether this element participates in autoplacement.
Definition: elements.h:287
Definition of class Measure.
QVariant endFontStyle
Definition: elements.h:352
qreal posX() const
Definition: elements.h:363
Definition: segment.h:50
QVariant lineDistance
Definition: elements.h:299
QVariant stemDirection
Definition: elements.h:149
Q_INVOKABLE QString subtypeName() const
Definition: elements.h:385
void setAccidentalType(Ms::AccidentalType t)
Definition: elements.h:490
Segment * firstSegment()
Definition: elements.h:658
QVariant actualNotes
Definition: elements.h:179
QVariant fretNumPos
Definition: elements.h:283
Definition: aeolus.cpp:26
QVariant growLeft
Definition: elements.h:182
QQmlListProperty< Element > elements()
Definition: elements.h:664
QVariant timesigGlobal
Definition: elements.h:249
QVariant bottomMargin
Definition: elements.h:191
QVariant continueFontSize
Definition: elements.h:342
#define API_PROPERTY(name, pid)
Definition: elements.h:45
QVariant fontFace
Definition: elements.h:317
QQmlListProperty< Element > elements()
Definition: elements.h:484
Q_INVOKABLE Ms::PluginAPI::PlayEvent * createPlayEvent()
Creates a PlayEvent object for use in Javascript.
Definition: elements.h:499
QVariant bracketSpan
Definition: elements.h:313
QVariant userOff2
Definition: elements.h:255
NoteType
Definition: types.h:255
QVariant lassoSize
Definition: elements.h:245
QVariant bracketColumn
Definition: elements.h:314
qreal offsetX() const
Definition: elements.h:358
QVariant endHookType
Definition: elements.h:348
QVariant diagonal
Definition: elements.h:239
QVariant lockAspectRatio
Definition: elements.h:196
QVariant beamPos
Definition: elements.h:199
Definition: inspectorAmbitus.cpp:21
QPointF offset
Offset from a reference position in spatium units.
Definition: elements.h:169
QVariant anchor
Definition: elements.h:261
QVariant barlineSpan
Definition: elements.h:159
a Tie has a Note as startElement/endElement
Definition: tie.h:60
QVariant staffBarlineSpanTo
Definition: elements.h:312
#define API_PROPERTY_READ_ONLY_T(type, name, pid)
Definition: elements.h:66
QVariant framePadding
Definition: elements.h:322
QVariant useDrumset
Definition: elements.h:273
Graphic representation of a chord.
Definition: chord.h:55
QVariant continueTextAlign
Definition: elements.h:339
QVariant systemBracket
Definition: elements.h:284
QVariant continueText
Definition: elements.h:338
Main class of the plugins framework. Named as MuseScore in QML.
Definition: qmlpluginapi.h:54
const QPointF & offset() const
Definition: element.h:245
QVariant topGap
Definition: elements.h:186
Definition of classes Note and NoteHead.
Definition of classes Chord, HelpLine and NoteList.
QRectF bbox() const
QVariant pause
Definition: elements.h:157
Element * wrap(Ms::Element *e, Ownership own)
Wraps Ms::Element choosing the correct wrapper type at runtime based on the actual element type...
Definition: elements.cpp:247
QVariant p1
Definition: elements.h:180
QVariant velocity
Definition: elements.h:227
QVariant endTextPlace
Definition: elements.h:347
QVariant syllabic
Definition: elements.h:268
QVariant playRepeats
Definition: elements.h:296
QVariant timesigType
Definition: elements.h:251
QVariant continueAt
Definition: elements.h:230
QVariant lineColor
Definition: elements.h:242
QVariant barlineType
Definition: elements.h:158
Q_INVOKABLE QString _name() const
Deprecated: same as ScoreElement::name. Left for compatibility purposes.
Definition: elements.h:387
QVariant autoscale
Definition: elements.h:193
int tpc(int idx, int pitch, int opt)
Definition: pitchspelling.cpp:539
int track
Definition: elements.h:277
QVariant fretStrings
Definition: elements.h:279
Segment * nextInScore()
Definition: elements.h:614
QVariant dynamicRange
Definition: elements.h:225
QmlPlayEventsListAccess wrapPlayEventsContainerProperty(QObject *obj, NoteEventList &c)
Definition: playevent.h:115
QVariant slurUoff4
Definition: elements.h:265
QQmlListProperty< Element > dots()
Definition: elements.h:483
Definition: editdrumset.cpp:32
Graphic representation of a note.
Definition: note.h:212
Ms::AccidentalType accidentalType()
Definition: elements.h:489
Ms::Note * note()
Definition: elements.h:471
QVariant denominatorString
Definition: elements.h:208
Ms::PluginAPI::Note * firstTiedNote()
Definition: elements.h:480
ElementType
Definition: types.h:34
QVariant glissandoStyle
Definition: elements.h:278
QVariant beginText
Definition: elements.h:329
QVariant ghost
Definition: elements.h:172
QVariant growRight
Definition: elements.h:183
Definition: elements.h:514
qreal spatium() const
Definition: element.cpp:130
QVariant timesigNominal
Definition: elements.h:174
Segment * nextInMeasure()
Definition: elements.h:615
Ms::Segment * segment()
Definition: elements.h:607
QVariant durationType
Definition: elements.h:275
QQmlListProperty< Note > notes()
Definition: elements.h:539
QVariant timeStretch
Definition: elements.h:246
Ms::Element * element()
Returns the underlying Ms::Element.
Definition: elements.h:377
QVariant numbersOnly
Definition: elements.h:214
QQmlListProperty< Element > lyrics()
Definition: elements.h:540
QVariant ottavaType
Definition: elements.h:213
bool generated
Definition: elements.h:128
QVariant playbackVoice4
Definition: elements.h:294
QVariant continueFontFace
Definition: elements.h:341
int voice
Definition: elements.h:355
QVariant accidentalBracket
Definition: elements.h:206
Definition: inspectorAmbitus.cpp:22
void setOffsetX(qreal offX)
Definition: elements.cpp:24
QVariant userStretch
Definition: elements.h:258
QQmlListProperty< Chord > graceNotes()
Definition: elements.h:538
QVariant fontSize
Definition: elements.h:318
QVariant slurUoff2
Definition: elements.h:263
bool visible
Definition: elements.h:134
QVariant leadingSpace
Definition: elements.h:152
QVariant dashLineLen
Definition: elements.h:288
QVariant endTextOffset
Definition: elements.h:353
QVariant glissShowText
Definition: elements.h:238
QVariant arpUserLen2
Definition: elements.h:234
Definition: elements.h:395
QVariant spannerTick
Definition: elements.h:252
QVariant endFontSize
Definition: elements.h:351
QVariant position
Definition: elements.h:356
QVariant endTextAlign
Definition: elements.h:346