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 4, 2024
1 parent f39da6c commit 58e5aad
Show file tree
Hide file tree
Showing 14 changed files with 481 additions and 4 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
)
1 change: 1 addition & 0 deletions src/engraving/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/types/groupnode.h
${CMAKE_CURRENT_LIST_DIR}/types/propertyvalue.cpp
${CMAKE_CURRENT_LIST_DIR}/types/propertyvalue.h
${CMAKE_CURRENT_LIST_DIR}/types/accessibilitystyle.h

${CMAKE_CURRENT_LIST_DIR}/style/styledef.cpp
${CMAKE_CURRENT_LIST_DIR}/style/styledef.h
Expand Down
61 changes: 59 additions & 2 deletions src/engraving/style/style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,34 @@ int MStyle::defaultStyleVersion() const
return styleI(Sid::defaultsVersion);
}

void MStyle::setStylePreset(AccessibilityStylePreset preset)
{
m_stylepreset = preset;
}

void MStyle::setStylePresetEdited(bool isEdited)
{
m_stylepresetedited = isEdited;
}

String MStyle::stylePreset2Name(AccessibilityStylePreset preset) const
{
switch (preset) {
case AccessibilityStylePreset::MSN_16MM:
return String(u"16mm MSN");
case AccessibilityStylePreset::MSN_18MM:
return String(u"18mm MSN");
case AccessibilityStylePreset::MSN_20MM:
return String(u"20mm MSN");
case AccessibilityStylePreset::MSN_22MM:
return String(u"22mm MSN");
case AccessibilityStylePreset::MSN_25MM:
return String(u"25mm MSN");
default:
return String(u"Default");
}
}

bool MStyle::readProperties(XmlReader& e)
{
const AsciiStringView tag(e.name());
Expand Down Expand Up @@ -279,6 +307,31 @@ void MStyle::readVersion(String versionTag)
m_version = versionTag.toInt();
}

void MStyle::readStylePreset(String presetTag)
{
String suffix = u" (edited)";
bool isEdited = presetTag.endsWith(suffix);
if (isEdited) {
setStylePresetEdited(true);
presetTag.chop(suffix.size());
} else {
setStylePresetEdited(false);
}
if (presetTag == "16mm MSN") {
m_stylepreset = AccessibilityStylePreset::MSN_16MM;
} else if (presetTag == "18mm MSN") {
m_stylepreset = AccessibilityStylePreset::MSN_18MM;
} else if (presetTag == "20mm MSN") {
m_stylepreset = AccessibilityStylePreset::MSN_20MM;
} else if (presetTag == "22mm MSN") {
m_stylepreset = AccessibilityStylePreset::MSN_22MM;
} else if (presetTag == "25mm MSN") {
m_stylepreset = AccessibilityStylePreset::MSN_25MM;
} else {
m_stylepreset = AccessibilityStylePreset::DEFAULT;
}
}

bool MStyle::read(IODevice* device, bool ign)
{
UNUSED(ign);
Expand All @@ -288,6 +341,7 @@ bool MStyle::read(IODevice* device, bool ign)
readVersion(e.attribute("version"));
while (e.readNextStartElement()) {
if (e.name() == "Style") {
readStylePreset(e.attribute("preset", String(u"Default")));
read(e, nullptr);
} else {
e.unknown();
Expand Down Expand Up @@ -535,8 +589,11 @@ bool MStyle::write(IODevice* device)

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

if (stylePresetEdited()) {
xml.startElement("Style", { { "preset", stylePreset2Name(stylePreset()) + String(u" (edited)") } });
} else {
xml.startElement("Style", { { "preset", stylePreset2Name(stylePreset()) } });
}
for (const StyleDef::StyleValue& st : StyleDef::styleValues) {
Sid idx = st.styleIdx();
if (idx == Sid::spatium) { // special handling for spatium
Expand Down
10 changes: 10 additions & 0 deletions src/engraving/style/style.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include "../types/dimension.h"
#include "../types/propertyvalue.h"
#include "../types/accessibilitystyle.h"

#include "styledef.h"

Expand Down Expand Up @@ -73,6 +74,12 @@ class MStyle
void setDefaultStyleVersion(const int defaultsVersion);
int defaultStyleVersion() const;

AccessibilityStylePreset stylePreset() const { return m_stylepreset; }
void setStylePreset(AccessibilityStylePreset preset);
bool stylePresetEdited() const { return m_stylepresetedited; }
void setStylePresetEdited(bool isEdited);
String stylePreset2Name(AccessibilityStylePreset preset) const;

bool read(muse::io::IODevice* device, bool ign = false);
bool write(muse::io::IODevice* device);
void save(XmlWriter& xml, bool optimize);
Expand All @@ -98,7 +105,10 @@ class MStyle
std::array<Millimetre, size_t(Sid::STYLES)> m_precomputedValues;

void readVersion(String versionTag);
void readStylePreset(String presetTag);
int m_version = 0;
AccessibilityStylePreset m_stylepreset = AccessibilityStylePreset::DEFAULT;
bool m_stylepresetedited = false;
};
} // namespace mu::engraving

Expand Down
36 changes: 36 additions & 0 deletions src/engraving/types/accessibilitystyle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-Studio-CLA-applies
*
* MuseScore Studio
* Music Composition & Notation
*
* Copyright (C) 2021 MuseScore Limited
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef MU_ENGRAVING_ACCESSIBILITYSTYLEPRESET_H
#define MU_ENGRAVING_ACCESSIBILITYSTYLEPRESET_H

namespace mu::engraving {
enum class AccessibilityStylePreset {
DEFAULT = 0,
MSN_16MM,
MSN_18MM,
MSN_20MM,
MSN_22MM,
MSN_25MM
};
}

#endif // MU_ENGRAVING_ACCESSIBILITYSTYLEPRESET_H
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 58e5aad

Please sign in to comment.