Skip to content

Commit

Permalink
Add: Accessibility Panel - Score Style Preset option
Browse files Browse the repository at this point in the history
  • Loading branch information
nasehim7 committed Aug 23, 2024
1 parent a4d34f0 commit 71e5201
Show file tree
Hide file tree
Showing 15 changed files with 475 additions and 3 deletions.
2 changes: 1 addition & 1 deletion share/styles/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ install(FILES
cchords_sym.xml
DESTINATION ${Mscore_SHARE_NAME}${Mscore_INSTALL_NAME}styles
)

add_subdirectory(MSN)
8 changes: 8 additions & 0 deletions share/styles/MSN/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
install(FILES
16mm_MSN.mss
18mm_MSN.mss
20mm_MSN.mss
22mm_MSN.mss
25mm_MSN.mss
DESTINATION ${Mscore_SHARE_NAME}${Mscore_INSTALL_NAME}styles/MSN
)
31 changes: 30 additions & 1 deletion src/engraving/style/style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ int MStyle::defaultStyleVersion() const
return styleI(Sid::defaultsVersion);
}

void MStyle::setPreset(ScoreStylePreset preset)
{
m_preset = preset;
}

void MStyle::setPresetEdited(bool isEdited)
{
m_presetedited = isEdited;
}

bool MStyle::readProperties(XmlReader& e)
{
const AsciiStringView tag(e.name());
Expand Down Expand Up @@ -293,6 +303,8 @@ bool MStyle::read(IODevice* device, bool ign)
readVersion(e.attribute("version"));
while (e.readNextStartElement()) {
if (e.name() == "Style") {
m_preset = TConv::fromXml(e.asciiAttribute("preset", "Default"), ScoreStylePreset::DEFAULT);
m_presetedited = e.attribute("edited", String(u"false")) == "true";
read(e, nullptr);
} else {
e.unknown();
Expand Down Expand Up @@ -542,7 +554,24 @@ bool MStyle::write(IODevice* device)

void MStyle::save(XmlWriter& xml, bool optimize)
{
xml.startElement("Style");
if (presetEdited()) {
if (preset() != ScoreStylePreset::DEFAULT) {
xml.startElement("Style", {
{ "preset", TConv::toXml(preset()) },
{ "edited", String(u"true") }
});
} else {
xml.startElement("Style", {
{ "edited", String(u"true") }
});
}
} else if (preset() != ScoreStylePreset::DEFAULT) {
xml.startElement("Style", {
{ "preset", TConv::toXml(preset()) }
});
} else {
xml.startElement("Style", {});
}

for (const StyleDef::StyleValue& st : StyleDef::styleValues) {
Sid idx = st.styleIdx();
Expand Down
7 changes: 7 additions & 0 deletions src/engraving/style/style.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ class MStyle
void setDefaultStyleVersion(const int defaultsVersion);
int defaultStyleVersion() const;

ScoreStylePreset preset() const { return m_preset; }
void setPreset(ScoreStylePreset preset);
bool presetEdited() const { return m_presetedited; }
void setPresetEdited(bool isEdited);

bool read(muse::io::IODevice* device, bool ign = false);
bool write(muse::io::IODevice* device);
void save(XmlWriter& xml, bool optimize);
Expand All @@ -100,6 +105,8 @@ class MStyle

void readVersion(String versionTag);
int m_version = 0;
ScoreStylePreset m_preset = ScoreStylePreset::DEFAULT;
bool m_presetedited = false;
};
} // namespace mu::engraving

Expand Down
10 changes: 10 additions & 0 deletions src/engraving/types/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,16 @@ struct std::hash<mu::engraving::InstrumentTrackId>
}
};

enum class ScoreStylePreset {
DEFAULT = 0,
MSN_16MM,
MSN_18MM,
MSN_20MM,
MSN_22MM,
MSN_25MM,
MAX_PRESET
};

#ifndef NO_QT_SUPPORT
Q_DECLARE_METATYPE(mu::engraving::BeamMode)
Q_DECLARE_METATYPE(mu::engraving::JumpType)
Expand Down
39 changes: 39 additions & 0 deletions src/engraving/types/typesconv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2746,3 +2746,42 @@ String TConv::translatedUserName(Key v, bool isAtonal, bool isCustom)
{
return userName(v, isAtonal, isCustom).translated();
}

const std::array<Item<ScoreStylePreset>, 6> SCORE_STYLE_PRESETS = { {
//: Score notation style: Default
{ ScoreStylePreset::DEFAULT, "Default", muse::TranslatableString("engraving/scorestylepreset", "Default") },
//: Score notation style: Modified Stave Notation (MSN) with 16mm staff size. Intended for visually-impaired musicians.
{ ScoreStylePreset::MSN_16MM, "16mm MSN", muse::TranslatableString("engraving/scorestylepreset", "16mm MSN") },
//: Score notation style: Modified Stave Notation (MSN) with 18mm staff size. Intended for visually-impaired musicians.
{ ScoreStylePreset::MSN_18MM, "18mm MSN", muse::TranslatableString("engraving/scorestylepreset", "18mm MSN") },
//: Score notation style: Modified Stave Notation (MSN) with 20mm staff size. Intended for visually-impaired musicians.
{ ScoreStylePreset::MSN_20MM, "20mm MSN", muse::TranslatableString("engraving/scorestylepreset", "20mm MSN") },
//: Score notation style: Modified Stave Notation (MSN) with 22mm staff size. Intended for visually-impaired musicians.
{ ScoreStylePreset::MSN_22MM, "22mm MSN", muse::TranslatableString("engraving/scorestylepreset", "22mm MSN") },
//: Score notation style: Modified Stave Notation (MSN) with 25mm staff size. Intended for visually-impaired musicians.
{ ScoreStylePreset::MSN_25MM, "25mm MSN", muse::TranslatableString("engraving/scorestylepreset", "25mm MSN") }
} };

AsciiStringView TConv::toXml(ScoreStylePreset preset)
{
return findXmlTagByType<ScoreStylePreset>(SCORE_STYLE_PRESETS, preset);
}

ScoreStylePreset TConv::fromXml(const AsciiStringView& tag, ScoreStylePreset def)
{
if (tag == "Default") {
return def;
}

return findTypeByXmlTag<ScoreStylePreset>(SCORE_STYLE_PRESETS, tag, def);
}

const muse::TranslatableString& TConv::userName(ScoreStylePreset v)
{
return findUserNameByType<ScoreStylePreset>(SCORE_STYLE_PRESETS, v);
}

String TConv::translatedUserName(ScoreStylePreset v)
{
return findUserNameByType<ScoreStylePreset>(SCORE_STYLE_PRESETS, v).translated();
}
6 changes: 6 additions & 0 deletions src/engraving/types/typesconv.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ class TConv

static AsciiStringView toXml(AutoOnOff autoOnOff);
static AutoOnOff fromXml(const AsciiStringView& str, AutoOnOff def);

static AsciiStringView toXml(ScoreStylePreset preset);
static ScoreStylePreset fromXml(const AsciiStringView& tag, ScoreStylePreset def);

static const TranslatableString& userName(ScoreStylePreset v);
static String translatedUserName(ScoreStylePreset v);
};
}

Expand Down
2 changes: 2 additions & 0 deletions src/inspector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/models/measures/measuressettingsmodel.h
${CMAKE_CURRENT_LIST_DIR}/models/score/scoreappearancesettingsmodel.cpp
${CMAKE_CURRENT_LIST_DIR}/models/score/scoreappearancesettingsmodel.h
${CMAKE_CURRENT_LIST_DIR}/models/score/scoreaccessibilitysettingsmodel.cpp
${CMAKE_CURRENT_LIST_DIR}/models/score/scoreaccessibilitysettingsmodel.h
${CMAKE_CURRENT_LIST_DIR}/models/score/scoredisplaysettingsmodel.cpp
${CMAKE_CURRENT_LIST_DIR}/models/score/scoredisplaysettingsmodel.h
${CMAKE_CURRENT_LIST_DIR}/models/score/internal/pagetypelistmodel.cpp
Expand Down
1 change: 1 addition & 0 deletions src/inspector/models/abstractinspectormodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class AbstractInspectorModel : public QObject, public muse::async::Asyncable
SECTION_TEXT,
SECTION_SCORE_DISPLAY,
SECTION_SCORE_APPEARANCE,
SECTION_SCORE_ACCESSIBILITY,
SECTION_PARTS,
};
Q_ENUM(InspectorSectionType)
Expand Down
7 changes: 6 additions & 1 deletion src/inspector/models/inspectorlistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "text/textsettingsmodel.h"
#include "score/scoredisplaysettingsmodel.h"
#include "score/scoreappearancesettingsmodel.h"
#include "score/scoreaccessibilitysettingsmodel.h"
#include "notation/inotationinteraction.h"

#include "internal/services/elementrepositoryservice.h"
Expand Down Expand Up @@ -73,7 +74,8 @@ void InspectorListModel::buildModelsForEmptySelection()

static const InspectorSectionTypeSet persistentSections {
InspectorSectionType::SECTION_SCORE_DISPLAY,
InspectorSectionType::SECTION_SCORE_APPEARANCE
InspectorSectionType::SECTION_SCORE_APPEARANCE,
InspectorSectionType::SECTION_SCORE_ACCESSIBILITY
};

removeUnusedModels({}, false /*isRangeSelection*/, {}, persistentSections);
Expand Down Expand Up @@ -195,6 +197,9 @@ void InspectorListModel::createModelsBySectionType(const InspectorSectionTypeSet
case InspectorSectionType::SECTION_SCORE_APPEARANCE:
newModel = new ScoreAppearanceSettingsModel(this, m_repository);
break;
case InspectorSectionType::SECTION_SCORE_ACCESSIBILITY:
newModel = new ScoreAccessibilitySettingsModel(this, m_repository);
break;
case InspectorSectionType::SECTION_PARTS:
newModel = new PartsSettingsModel(this, m_repository);
break;
Expand Down
Loading

0 comments on commit 71e5201

Please sign in to comment.