|
27 | 27 |
|
28 | 28 | #include "engraving/dom/engravingitem.h" |
29 | 29 | #include "engraving/dom/arpeggio.h" |
| 30 | +#include "engraving/dom/fret.h" |
30 | 31 | #include "engraving/dom/barline.h" |
31 | 32 | #include "engraving/dom/beam.h" |
32 | 33 | #include "engraving/dom/bracketItem.h" |
@@ -2665,6 +2666,76 @@ class Lyrics : public EngravingItem |
2665 | 2666 | apiv1::EngravingItem* separator() const { return wrap(lyrics()->separator()); } |
2666 | 2667 | }; |
2667 | 2668 |
|
| 2669 | +//--------------------------------------------------------- |
| 2670 | +// FretDiagram |
| 2671 | +/// Exposes FretDiagram dot, marker, and barre manipulation |
| 2672 | +/// to the QML plugin API. |
| 2673 | +/// \since MuseScore 4.7 |
| 2674 | +//--------------------------------------------------------- |
| 2675 | + |
| 2676 | +class FretDiagram : public EngravingItem |
| 2677 | +{ |
| 2678 | + Q_OBJECT |
| 2679 | + |
| 2680 | + /// Number of strings in the diagram. |
| 2681 | + Q_PROPERTY(int strings READ strings WRITE setStrings) |
| 2682 | + /// Number of frets shown in the diagram. |
| 2683 | + Q_PROPERTY(int frets READ frets WRITE setFrets) |
| 2684 | + /// Fret offset (0-based: value N means the top of the diagram is at fret N+1). |
| 2685 | + Q_PROPERTY(int fretOffset READ fretOffset WRITE setFretOffset) |
| 2686 | + /// Whether to show the nut (thick line at top of diagram). |
| 2687 | + Q_PROPERTY(bool showNut READ showNut WRITE setShowNut) |
| 2688 | + |
| 2689 | +public: |
| 2690 | + /// \cond MS_INTERNAL |
| 2691 | + FretDiagram(mu::engraving::FretDiagram* fd = nullptr, Ownership own = Ownership::PLUGIN) |
| 2692 | + : EngravingItem(fd, own) {} |
| 2693 | + |
| 2694 | + mu::engraving::FretDiagram* fretDiagram() { return toFretDiagram(e); } |
| 2695 | + const mu::engraving::FretDiagram* fretDiagram() const { return toFretDiagram(e); } |
| 2696 | + /// \endcond |
| 2697 | + |
| 2698 | + int strings() const { return fretDiagram()->strings(); } |
| 2699 | + void setStrings(int n) { fretDiagram()->setStrings(n); } |
| 2700 | + int frets() const { return fretDiagram()->frets(); } |
| 2701 | + void setFrets(int n) { fretDiagram()->setFrets(n); } |
| 2702 | + int fretOffset() const { return fretDiagram()->fretOffset(); } |
| 2703 | + void setFretOffset(int val) { fretDiagram()->setFretOffset(val); } |
| 2704 | + bool showNut() const { return fretDiagram()->showNut(); } |
| 2705 | + void setShowNut(bool val) { fretDiagram()->setShowNut(val); } |
| 2706 | + |
| 2707 | + /// Set a dot on the specified string at the specified fret. |
| 2708 | + /// \param string 0-based string index (0 = highest pitched string) |
| 2709 | + /// \param fret fret number (1-based, 0 removes the dot) |
| 2710 | + /// \param add if true, add a second dot without removing existing ones |
| 2711 | + /// \param dotType dot type: 0=normal, 1=cross, 2=square, 3=triangle |
| 2712 | + Q_INVOKABLE void setDot(int string, int fret, bool add = false, int dotType = 0) { |
| 2713 | + fretDiagram()->setDot(string, fret, add, |
| 2714 | + static_cast<mu::engraving::FretDotType>(dotType)); |
| 2715 | + } |
| 2716 | + |
| 2717 | + /// Set a marker on the specified string. |
| 2718 | + /// \param string 0-based string index (0 = highest pitched string) |
| 2719 | + /// \param markerType marker type: 0=none, 1=circle (open), 2=cross (muted) |
| 2720 | + Q_INVOKABLE void setMarker(int string, int markerType) { |
| 2721 | + fretDiagram()->setMarker(string, |
| 2722 | + static_cast<mu::engraving::FretMarkerType>(markerType)); |
| 2723 | + } |
| 2724 | + |
| 2725 | + /// Set a barre across strings at the specified fret. |
| 2726 | + /// \param startString 0-based start string index |
| 2727 | + /// \param endString 0-based end string index |
| 2728 | + /// \param fret fret number (1-based) |
| 2729 | + Q_INVOKABLE void setBarre(int startString, int endString, int fret) { |
| 2730 | + fretDiagram()->setBarre(startString, endString, fret); |
| 2731 | + } |
| 2732 | + |
| 2733 | + /// Remove all dots, markers, and barres from the diagram. |
| 2734 | + Q_INVOKABLE void clear() { |
| 2735 | + fretDiagram()->clear(); |
| 2736 | + } |
| 2737 | +}; |
| 2738 | + |
2668 | 2739 | #undef API_PROPERTY |
2669 | 2740 | #undef API_PROPERTY_T |
2670 | 2741 | #undef API_PROPERTY_READ_ONLY |
|
0 commit comments