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 Jun 18, 2024
1 parent 81b8d04 commit 5848b4d
Show file tree
Hide file tree
Showing 20 changed files with 6,560 additions and 2 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)
1,420 changes: 1,420 additions & 0 deletions share/styles/MSN/16mm_MSN.mss

Large diffs are not rendered by default.

1,016 changes: 1,016 additions & 0 deletions share/styles/MSN/18mm_MSN.mss

Large diffs are not rendered by default.

1,350 changes: 1,350 additions & 0 deletions share/styles/MSN/20mm_MSN.mss

Large diffs are not rendered by default.

1,016 changes: 1,016 additions & 0 deletions share/styles/MSN/24mm_MSN.mss

Large diffs are not rendered by default.

1,350 changes: 1,350 additions & 0 deletions share/styles/MSN/25mm_MSN.mss

Large diffs are not rendered by default.

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
24mm_MSN.mss
25mm_MSN.mss
DESTINATION ${Mscore_SHARE_NAME}${Mscore_INSTALL_NAME}styles/MSN
)
2 changes: 2 additions & 0 deletions src/engraving/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/style/style.h
${CMAKE_CURRENT_LIST_DIR}/style/defaultstyle.cpp
${CMAKE_CURRENT_LIST_DIR}/style/defaultstyle.h
${CMAKE_CURRENT_LIST_DIR}/style/scorestylepreset.cpp
${CMAKE_CURRENT_LIST_DIR}/style/scorestylepreset.h

${CMAKE_CURRENT_LIST_DIR}/rendering/README.h
${CMAKE_CURRENT_LIST_DIR}/rendering/iscorerenderer.h
Expand Down
1 change: 1 addition & 0 deletions src/engraving/dom/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ static constexpr PropertyMetaData propertyList[] = {
{ Pid::SCORE_FONT, true, "scoreFont", P_TYPE::STRING, PropertyGroup::APPEARANCE, DUMMY_QT_TR_NOOP("propertyName", "score font") },
{ Pid::SYMBOLS_SIZE, false, "symbolsSize", P_TYPE::REAL, PropertyGroup::APPEARANCE, DUMMY_QT_TR_NOOP("propertyName", "symbols size") },
{ Pid::SYMBOL_ANGLE, false, "symbolAngle", P_TYPE::REAL, PropertyGroup::APPEARANCE, DUMMY_QT_TR_NOOP("propertyName", "symbol angle") },
{ Pid::SCORE_STYLE_PRESET, false, "scoreStylePreset", P_TYPE::STRING, PropertyGroup::APPEARANCE, DUMMY_QT_TR_NOOP("propertyName", "score style preset") },

{ Pid::APPLY_TO_ALL_STAVES, false, "applyToAllStaves", P_TYPE::BOOL, PropertyGroup::NONE, DUMMY_QT_TR_NOOP("propertyName", "apply to all staves") },

Expand Down
1 change: 1 addition & 0 deletions src/engraving/dom/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ enum class Pid {
SCORE_FONT,
SYMBOLS_SIZE,
SYMBOL_ANGLE,
SCORE_STYLE_PRESET,

APPLY_TO_ALL_STAVES,

Expand Down
45 changes: 45 additions & 0 deletions src/engraving/style/scorestylepreset.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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/>.
*/
#include "scorestylepreset.h"

using namespace mu::engraving;

muse::io::path_t ScoreStylePresetHelper::getStyleFilePath(ScoreStylePreset preset) const
{
muse::io::path_t basePath = globalConfiguration()->appDataPath() + "styles/MSN/";
switch (preset) {
case ScoreStylePreset::DEFAULT:
return notationConfiguration()->defaultStyleFilePath();
case ScoreStylePreset::MSN_16MM:
return basePath + "16mm_MSN.mss";
case ScoreStylePreset::MSN_18MM:
return basePath + "18mm_MSN.mss";
case ScoreStylePreset::MSN_20MM:
return basePath + "20mm_MSN.mss";
case ScoreStylePreset::MSN_24MM:
return basePath + "24mm_MSN.mss";
case ScoreStylePreset::MSN_25MM:
return basePath + "25mm_MSN.mss";
default:
return muse::io::path_t();
}
}
49 changes: 49 additions & 0 deletions src/engraving/style/scorestylepreset.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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_SCORESTYLEPRESET_H
#define MU_ENGRAVING_SCORESTYLEPRESET_H

#include "global/iglobalconfiguration.h"
#include "notation/inotationconfiguration.h"
#include "modularity/ioc.h"

namespace mu::engraving {
enum class ScoreStylePreset {
CUSTOM,
DEFAULT,
MSN_16MM,
MSN_18MM,
MSN_20MM,
MSN_24MM,
MSN_25MM
};

class ScoreStylePresetHelper
{
INJECT(muse::IGlobalConfiguration, globalConfiguration);
INJECT(notation::INotationConfiguration, notationConfiguration)
public:
muse::io::path_t getStyleFilePath(ScoreStylePreset preset) const;
};
} // namespace mu::engraving

#endif // MU_ENGRAVING_SCORESTYLEPRESET_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
150 changes: 150 additions & 0 deletions src/inspector/models/score/scoreaccessibilitysettingsmodel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/*
* 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/>.
*/
#include "scoreaccessibilitysettingsmodel.h"

#include "translation.h"
#include "log.h"

using namespace mu::inspector;
using namespace mu::notation;

ScoreAccessibilitySettingsModel::ScoreAccessibilitySettingsModel(QObject* parent, IElementRepositoryService* repository)
: AbstractInspectorModel(parent, repository)
{
setSectionType(InspectorSectionType::SECTION_SCORE_ACCESSIBILITY);
setTitle(muse::qtrc("inspector", "Accessibility"));
createProperties();
connect(m_scoreStylePreset, &PropertyItem::valueChanged, this, [this]() {
if (!m_ignoreStyleChange) {
setScoreStylePreset(m_scoreStylePreset);
}
});

globalContext()->currentNotation()->style()->styleChanged().onNotify(this, [this]() {
if (!m_ignoreStyleChange && m_scoreStylePreset->value().toInt() != static_cast<int>(mu::engraving::ScoreStylePreset::CUSTOM)) {
m_scoreStylePreset->setValue(static_cast<int>(mu::engraving::ScoreStylePreset::CUSTOM));
emit scoreStylePresetChanged();
}
});
}

PropertyItem* ScoreAccessibilitySettingsModel::scoreStylePreset() const
{
return m_scoreStylePreset;
}

void ScoreAccessibilitySettingsModel::setScoreStylePreset(PropertyItem* preset)
{
m_ignoreStyleChange = true;
m_scoreStylePreset = preset;
loadStyle(preset);
emit scoreStylePresetChanged();
m_ignoreStyleChange = false;
}

void ScoreAccessibilitySettingsModel::createProperties()
{
m_scoreStylePreset = buildPropertyItem(mu::engraving::Pid::SCORE_STYLE_PRESET);
m_scoreStylePreset->setDefaultValue(static_cast<int>(mu::engraving::ScoreStylePreset::DEFAULT));
m_scoreStylePreset->setValue(static_cast<int>(mu::engraving::ScoreStylePreset::DEFAULT));
}

void ScoreAccessibilitySettingsModel::requestElements()
{
// Placeholder
}

void ScoreAccessibilitySettingsModel::loadProperties()
{
static PropertyIdSet propertyIdSet {
Pid::SCORE_STYLE_PRESET
};

loadProperties(propertyIdSet);
}

void ScoreAccessibilitySettingsModel::loadProperties(const mu::engraving::PropertyIdSet& propertyIdSet)
{
if (muse::contains(propertyIdSet, Pid::SCORE_STYLE_PRESET)) {
loadPropertyItem(m_scoreStylePreset);
}
}

void ScoreAccessibilitySettingsModel::resetProperties()
{
m_scoreStylePreset->resetToDefault();
emit scoreStylePresetChanged();
}

QVariantList ScoreAccessibilitySettingsModel::possibleScoreStylePreset() const
{
QMap<mu::engraving::ScoreStylePreset, QString> types {
{ mu::engraving::ScoreStylePreset::DEFAULT, muse::qtrc("inspector", "Default") },
{ mu::engraving::ScoreStylePreset::MSN_16MM, muse::qtrc("inspector", "16mm MSN") },
{ mu::engraving::ScoreStylePreset::MSN_18MM, muse::qtrc("inspector", "18mm MSN") },
{ mu::engraving::ScoreStylePreset::MSN_20MM, muse::qtrc("inspector", "20mm MSN") },
{ mu::engraving::ScoreStylePreset::MSN_24MM, muse::qtrc("inspector", "24mm MSN") },
{ mu::engraving::ScoreStylePreset::MSN_25MM, muse::qtrc("inspector", "25mm MSN") }
};

QVariantList result;

if (m_scoreStylePreset->value().toInt() == static_cast<int>(mu::engraving::ScoreStylePreset::CUSTOM)) {
QVariantMap customObj;
customObj["text"] = muse::qtrc("inspector", "Custom");
customObj["value"] = static_cast<int>(mu::engraving::ScoreStylePreset::CUSTOM);
result << customObj;
}

for (mu::engraving::ScoreStylePreset type : types.keys()) {
QVariantMap obj;
obj["text"] = types[type];
obj["value"] = static_cast<int>(type);
result << obj;
}

return result;
}

void ScoreAccessibilitySettingsModel::loadStyle(PropertyItem* preset)
{
int presetValue = preset->value().toInt();

mu::engraving::ScoreStylePreset stylePreset = static_cast<mu::engraving::ScoreStylePreset>(presetValue);

mu::engraving::ScoreStylePresetHelper scoreStylePresetHelper;
muse::io::path_t filePath = scoreStylePresetHelper.getStyleFilePath(stylePreset);

if (stylePreset == mu::engraving::ScoreStylePreset::DEFAULT) {
if (filePath.empty()) {
mu::engraving::StyleIdSet emptySet;
globalContext()->currentNotation()->style()->resetAllStyleValues(emptySet);
} else {
globalContext()->currentNotation()->style()->loadStyle(filePath, true);
}
} else if (!filePath.empty()) {
LOGI() << "Loading style from filePath:" << filePath;
globalContext()->currentNotation()->style()->loadStyle(filePath, true);
} else {
LOGI() << "filePath is empty";
}
}
61 changes: 61 additions & 0 deletions src/inspector/models/score/scoreaccessibilitysettingsmodel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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_INSPECTOR_SCOREACCESSIBILITYSETTINGSMODEL_H
#define MU_INSPECTOR_SCOREACCESSIBILITYSETTINGSMODEL_H

#include "models/abstractinspectormodel.h"
#include "models/propertyitem.h"
#include "async/asyncable.h"
#include "context/iglobalcontext.h"
#include "engraving/style/scorestylepreset.h"

namespace mu::inspector {
class ScoreAccessibilitySettingsModel : public AbstractInspectorModel
{
Q_OBJECT
INJECT(mu::context::IGlobalContext, globalContext)
Q_PROPERTY(PropertyItem * scoreStylePreset READ scoreStylePreset WRITE setScoreStylePreset NOTIFY scoreStylePresetChanged)

public:
explicit ScoreAccessibilitySettingsModel(QObject* parent, IElementRepositoryService* repository);

void createProperties() override;
void requestElements() override;
void loadProperties() override;
void resetProperties() override;

PropertyItem* scoreStylePreset() const;
void setScoreStylePreset(PropertyItem* preset);
Q_INVOKABLE QVariantList possibleScoreStylePreset() const;
void loadStyle(PropertyItem* preset);

void loadProperties(const mu::engraving::PropertyIdSet& propertyIdSet);

signals:
void scoreStylePresetChanged();
private:
PropertyItem* m_scoreStylePreset = nullptr;
bool m_ignoreStyleChange = false;
};
}

#endif // MU_INSPECTOR_SCOREACCESSIBILITYSETTINGSMODEL_H
Loading

0 comments on commit 5848b4d

Please sign in to comment.