Skip to content

Commit

Permalink
fix #306551: expose SymId enumeration to plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrio95 authored and igorkorsukov committed Dec 15, 2020
1 parent 71d8c8b commit 852309b
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 15 deletions.
1 change: 1 addition & 0 deletions Doxyfile.plugins
Expand Up @@ -799,6 +799,7 @@ INPUT = doc/plugins.md \
mscore/plugin/api \
libmscore/types.h \
libmscore/style.h \
libmscore/sym.h \
libmscore/note.h \
libmscore/mscore.h \
libmscore/lyrics.h \
Expand Down
2 changes: 1 addition & 1 deletion src/libmscore/accidental.h
Expand Up @@ -24,10 +24,10 @@

#include "config.h"
#include "element.h"
#include "sym.h"

namespace Ms {
class Note;
enum class SymId;
enum class AccidentalVal : signed char;

//---------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions src/libmscore/articulation.h
Expand Up @@ -17,6 +17,7 @@

#include "element.h"
#include "mscore.h"
#include "sym.h"

namespace Ms {
class ChordRest;
Expand All @@ -25,8 +26,6 @@ class Measure;
class System;
class Page;

enum class SymId;

//---------------------------------------------------------
// ArticulationInfo
// gives infos about note attributes
Expand Down
3 changes: 1 addition & 2 deletions src/libmscore/breath.h
Expand Up @@ -14,10 +14,9 @@
#define __BREATH_H__

#include "element.h"
#include "sym.h"

namespace Ms {
enum class SymId;

//---------------------------------------------------------
// BreathType
//---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/libmscore/element.h
Expand Up @@ -18,6 +18,7 @@
#include "fraction.h"
#include "scoreElement.h"
#include "shape.h"
#include "sym.h"

namespace Ms {
#ifdef Q_OS_MAC
Expand All @@ -32,7 +33,6 @@ namespace Ms {

class XmlReader;
class XmlWriter;
enum class SymId;
enum class Pid;
class StaffType;

Expand Down
3 changes: 1 addition & 2 deletions src/libmscore/fermata.h
Expand Up @@ -15,6 +15,7 @@

#include "element.h"
#include "mscore.h"
#include "sym.h"

namespace Ms {
class ChordRest;
Expand All @@ -23,8 +24,6 @@ class Measure;
class System;
class Page;

enum class SymId;

//---------------------------------------------------------
// Fermata
//---------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/libmscore/key.h
Expand Up @@ -16,6 +16,8 @@
#include <QPointF>
#include <QList>

#include "sym.h"

namespace Ms {
class XmlWriter;
class Score;
Expand Down Expand Up @@ -77,8 +79,6 @@ static inline bool operator!=(const Key a, const Key b) { return static_cast<int
static inline Key operator+=(Key& a, const Key& b) { return a = Key(static_cast<int>(a) + static_cast<int>(b)); }
static inline Key operator-=(Key& a, const Key& b) { return a = Key(static_cast<int>(a) - static_cast<int>(b)); }

enum class SymId;

//---------------------------------------------------------
// KeySym
// position of one symbol in KeySig
Expand Down
2 changes: 1 addition & 1 deletion src/libmscore/note.h
Expand Up @@ -26,6 +26,7 @@
#include "pitchspelling.h"
#include "shape.h"
#include "key.h"
#include "sym.h"

namespace Ms {
class Tie;
Expand All @@ -42,7 +43,6 @@ class NoteDot;
class Spanner;
class StaffType;
class NoteEditData;
enum class SymId;
enum class AccidentalType : unsigned char;

static const int MAX_DOTS = 4;
Expand Down
2 changes: 1 addition & 1 deletion src/libmscore/rest.h
Expand Up @@ -15,10 +15,10 @@

#include "chordrest.h"
#include "notedot.h"
#include "sym.h"

namespace Ms {
class TDuration;
enum class SymId;

//---------------------------------------------------------
// @@ Rest
Expand Down
2 changes: 1 addition & 1 deletion src/libmscore/score.h
Expand Up @@ -32,6 +32,7 @@
#include "spannermap.h"
#include "layoutbreak.h"
#include "property.h"
#include "sym.h"

namespace mu {
namespace notation {
Expand Down Expand Up @@ -105,7 +106,6 @@ struct LayoutContext;
enum class Tid;
enum class ClefType : signed char;
enum class BeatType : char;
enum class SymId;
enum class Key;
enum class HairpinType : signed char;
enum class SegmentType;
Expand Down
1 change: 1 addition & 0 deletions src/libmscore/style.h
Expand Up @@ -26,6 +26,7 @@ struct ChordDescription;
class Element;
class Score;

// Needs to be duplicated here and in sym.h since moc doesn't handle macros from #include'd files
#ifdef SCRIPT_INTERFACE
#define BEGIN_QT_REGISTERED_ENUM(Name) \
class MSQE_##Name { \
Expand Down
27 changes: 27 additions & 0 deletions src/libmscore/sym.h
Expand Up @@ -21,13 +21,30 @@
#include "ft2build.h"
#include FT_FREETYPE_H

// Needs to be duplicated here and in style.h since moc doesn't handle macros from #include'd files
#ifdef SCRIPT_INTERFACE
#define BEGIN_QT_REGISTERED_ENUM(Name) \
class MSQE_##Name { \
Q_GADGET \
public:
#define END_QT_REGISTERED_ENUM(Name) \
Q_ENUM(Name); \
}; \
using Name = MSQE_##Name::Name;
#else
#define BEGIN_QT_REGISTERED_ENUM(Name)
#define END_QT_REGISTERED_ENUM(Name)
#endif

namespace Ms {
//---------------------------------------------------------
// SymId
// must be in sync with symNames
//---------------------------------------------------------

BEGIN_QT_REGISTERED_ENUM(SymId)
enum class SymId {
///.\{
noSym,

// DO NOT edit the SMuFL standard symbol IDs (see below) manually!
Expand Down Expand Up @@ -2864,10 +2881,13 @@ enum class SymId {
// END OF TABLE

lastSym
///\}
};
END_QT_REGISTERED_ENUM(SymId)

//---------------------------------------------------------
// Sym
/// \cond PLUGIN_API \private \endcond
//---------------------------------------------------------

class Sym
Expand Down Expand Up @@ -2937,6 +2957,7 @@ class Sym

//---------------------------------------------------------
// GlyphKey
/// \cond PLUGIN_API \private \endcond
//---------------------------------------------------------

struct GlyphKey {
Expand All @@ -2953,6 +2974,11 @@ struct GlyphKey {
bool operator==(const GlyphKey&) const;
};

//---------------------------------------------------------
// GlyphPixmap
/// \cond PLUGIN_API \private \endcond
//---------------------------------------------------------

struct GlyphPixmap {
QPixmap pm;
QPointF offset;
Expand All @@ -2965,6 +2991,7 @@ inline uint qHash(const GlyphKey& k)

//---------------------------------------------------------
// ScoreFont
/// \cond PLUGIN_API \private \endcond
//---------------------------------------------------------

class ScoreFont
Expand Down
2 changes: 1 addition & 1 deletion src/libmscore/symbol.h
Expand Up @@ -14,11 +14,11 @@
#define __SYMBOL_H__

#include "bsymbol.h"
#include "sym.h"

namespace Ms {
class Segment;
class ScoreFont;
enum class SymId;

//---------------------------------------------------------
// @@ Symbol
Expand Down
2 changes: 1 addition & 1 deletion src/libmscore/utils.h
Expand Up @@ -15,10 +15,10 @@

#include "mscore.h"
#include "interval.h"
#include "sym.h"

namespace Ms {
enum class Key;
enum class SymId;

//---------------------------------------------------------
// cycles
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/api/elements.h
Expand Up @@ -313,6 +313,10 @@ class Element : public Ms::PluginAPI::ScoreElement
API_PROPERTY(dashLineLen, DASH_LINE_LEN)
API_PROPERTY(dashGapLen, DASH_GAP_LEN)
// API_PROPERTY_READ_ONLY( tick, TICK ) // wasn't available in 2.X, disabled due to fractions transition
/**
* Symbol ID of this element (if approproate),
* one of PluginAPI::PluginAPI::SymId values.
*/
API_PROPERTY(symbol, SYMBOL)
API_PROPERTY(playRepeats, PLAY_REPEATS)
API_PROPERTY(createSystemHeader, CREATE_SYSTEM_HEADER)
Expand Down Expand Up @@ -416,8 +420,10 @@ class Note : public Element
Q_OBJECT
Q_PROPERTY(Ms::PluginAPI::Element* accidental READ accidental)
Q_PROPERTY(Ms::AccidentalType accidentalType READ accidentalType WRITE setAccidentalType)
/** List of dots attached to this note */
Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Element> dots READ dots)
// Q_PROPERTY(int dotsCount READ qmlDotsCount)
/** List of other elements attached to this note: fingerings, symbols, bends etc. */
Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Element> elements READ elements)
/// List of PlayEvents associated with this note.
/// Important: You must call Score.createPlayEvents()
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/api/qmlpluginapi.cpp
Expand Up @@ -49,6 +49,7 @@ Enum* PluginAPI::noteHeadGroupEnum;
Enum* PluginAPI::noteValueTypeEnum;
Enum* PluginAPI::segmentTypeEnum;
Enum* PluginAPI::spannerAnchorEnum;
Enum* PluginAPI::symIdEnum;

//---------------------------------------------------------
// PluginAPI::initEnums
Expand Down Expand Up @@ -82,6 +83,7 @@ void PluginAPI::initEnums()
PluginAPI::noteValueTypeEnum = wrapEnum<Ms::Note::ValueType>();
PluginAPI::segmentTypeEnum = wrapEnum<Ms::SegmentType>();
PluginAPI::spannerAnchorEnum = wrapEnum<Ms::Spanner::Anchor>();
PluginAPI::symIdEnum = wrapEnum<Ms::SymId>();

initialized = true;
}
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/api/qmlpluginapi.h
Expand Up @@ -157,6 +157,9 @@ class PluginAPI : public Ms::QmlPlugin
/// Contains Ms::SegmentType enumeration values
DECLARE_API_ENUM(Segment, segmentTypeEnum)
DECLARE_API_ENUM(Spanner, spannerAnchorEnum) // probably unavailable in 2.X
/// Contains Ms::SymId enumeration values
/// \since MuseScore 3.5
DECLARE_API_ENUM(SymId, symIdEnum)

QFile logFile;

Expand Down

0 comments on commit 852309b

Please sign in to comment.