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 authored and shoogle committed Jan 11, 2025
1 parent ed9f1f2 commit 4d5ea05
Show file tree
Hide file tree
Showing 20 changed files with 477 additions and 8 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)
2 changes: 1 addition & 1 deletion share/styles/MSN/16mm_MSN.mss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="4.40">
<Style>
<Style preset="16mm MSN" edited="false">
<pageWidth>8.27</pageWidth>
<pageHeight>11.69</pageHeight>
<pagePrintableWidth>7.8763</pagePrintableWidth>
Expand Down
2 changes: 1 addition & 1 deletion share/styles/MSN/18mm_MSN.mss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="4.40">
<Style>
<Style preset="18mm MSN" edited="false">
<pageWidth>8.27</pageWidth>
<pageHeight>11.69</pageHeight>
<pagePrintableWidth>7.8763</pagePrintableWidth>
Expand Down
2 changes: 1 addition & 1 deletion share/styles/MSN/20mm_MSN.mss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="4.40">
<Style>
<Style preset="20mm MSN" edited="false">
<pageWidth>16.54</pageWidth>
<pageHeight>11.69</pageHeight>
<pagePrintableWidth>15.7526</pagePrintableWidth>
Expand Down
2 changes: 1 addition & 1 deletion share/styles/MSN/22mm_MSN.mss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="4.40">
<Style>
<Style preset="22mm MSN" edited="false">
<pageWidth>16.54</pageWidth>
<pageHeight>11.69</pageHeight>
<pagePrintableWidth>15.7526</pagePrintableWidth>
Expand Down
2 changes: 1 addition & 1 deletion share/styles/MSN/25mm_MSN.mss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="4.40">
<Style>
<Style preset="25mm MSN" edited="false">
<pageWidth>16.54</pageWidth>
<pageHeight>11.69</pageHeight>
<pagePrintableWidth>15.7526</pagePrintableWidth>
Expand Down
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
)
14 changes: 13 additions & 1 deletion src/engraving/style/style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,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 @@ -555,7 +557,17 @@ bool MStyle::write(IODevice* device)

void MStyle::save(XmlWriter& xml, bool optimize)
{
xml.startElement("Style");
muse::XmlStreamWriter::Attributes attributes;

if (preset() != ScoreStylePreset::DEFAULT) {
attributes.push_back({ "preset", TConv::toXml(preset()) });
}

if (presetEdited()) {
attributes.push_back({ "edited", String(u"true") });
}

xml.startElement("Style", attributes);

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) { m_preset = preset; }
bool presetEdited() const { return m_presetEdited; }
void setPresetEdited(bool isEdited) { m_presetEdited = 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 @@ -1185,6 +1185,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 @@ -2789,3 +2789,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 @@ -246,5 +246,11 @@ class TConv

static AsciiStringView toXml(PartialSpannerDirection v);
static PartialSpannerDirection fromXml(const AsciiStringView& str, PartialSpannerDirection 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);
};
}
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 @@ -67,6 +67,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 4d5ea05

Please sign in to comment.