Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/engraving/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ else()
internal/engravingfontsprovider.h
internal/engravingfont.cpp
internal/engravingfont.h
internal/palettescoreprovider.cpp
internal/palettescoreprovider.h
${API_V1_SRC}
)
endif()
Expand Down
2 changes: 0 additions & 2 deletions src/engraving/dom/masterscore.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ class MasterScore : public Score

bool m_saved = false;
};

extern MasterScore* gpaletteScore;
}

#endif // MU_ENGRAVING_MASTERSCORE_H
7 changes: 3 additions & 4 deletions src/engraving/dom/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ using namespace muse;
using namespace mu::engraving;

namespace mu::engraving {
MasterScore* gpaletteScore; ///< system score, used for palettes etc.
std::set<Score*> Score::validScores;

bool noSeq = false;
Expand Down Expand Up @@ -338,14 +337,14 @@ Score* Score::clone()
return excerpt->excerptScore();
}

Score* Score::paletteScore()
Score* Score::paletteScore() const
{
return gpaletteScore;
return paletteScoreProvider() ? paletteScoreProvider()->paletteScore() : nullptr;
}

bool Score::isPaletteScore() const
{
return this == gpaletteScore;
return this == paletteScore();
}

static void onBracketItemDestruction(const Score* score, const BracketItem* item)
Expand Down
5 changes: 3 additions & 2 deletions src/engraving/dom/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "draw/iimageprovider.h"
#include "global/iapplication.h"
#include "../iengravingfontsprovider.h"
#include "../ipalettescoreprovider.h"

#include "../types/constants.h"

Expand Down Expand Up @@ -333,7 +334,7 @@ class Score : public EngravingObject, public muse::Contextable
muse::GlobalInject<IEngravingFontsProvider> engravingFonts;
muse::GlobalInject<muse::IApplication> application;
muse::ContextInject<IEngravingElementsProvider> elementsProvider = { this };

muse::ContextInject<IPaletteScoreProvider> paletteScoreProvider = { this };
// internal
muse::GlobalInject<rendering::IScoreRenderer> renderer;

Expand All @@ -343,7 +344,7 @@ class Score : public EngravingObject, public muse::Contextable
virtual ~Score();
Score* clone();

static Score* paletteScore();
Score* paletteScore() const;
bool isPaletteScore() const;

virtual bool isMaster() const { return false; }
Expand Down
59 changes: 18 additions & 41 deletions src/engraving/engravingmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,11 @@
#include "draw/internal/ifontsdatabase.h"

#include "infrastructure/smufl.h"
#include "infrastructure/localfileinfoprovider.h"

#ifndef ENGRAVING_NO_INTERNAL
#include "internal/engravingconfiguration.h"
#include "internal/engravingfontsprovider.h"
#endif

#ifndef ENGRAVING_NO_ACCESSIBILITY
#include "engraving/accessibility/accessibleitem.h"
#include "internal/palettescoreprovider.h"
#endif

#include "engraving/style/defaultstyle.h"
Expand All @@ -46,14 +42,11 @@
#include "engraving/dom/masterscore.h"
#include "engraving/dom/drumset.h"
#include "engraving/dom/figuredbass.h"
#include "engraving/dom/fret.h"

#include "rendering/score/scorerenderer.h"
#include "rendering/single/singlerenderer.h"
#include "rendering/editmode/editmoderenderer.h"

#include "compat/scoreaccess.h"

#ifndef ENGRAVING_NO_API
#include "global/api/iapiregister.h"
#include "api/v1/qmlpluginapi.h"
Expand Down Expand Up @@ -267,32 +260,6 @@ void EngravingModule::onInit(const IApplication::RunMode&)
MScore::setNudgeStep10(1.0); // Ctrl + cursor key (default 1.0)
MScore::setNudgeStep50(0.01); // Alt + cursor key (default 0.01)

// Palette
{
#ifndef ENGRAVING_NO_ACCESSIBILITY
AccessibleItem::enabled = false;
#endif
gpaletteScore = compat::ScoreAccess::createMasterScore(globalCtx());
gpaletteScore->setFileInfoProvider(std::make_shared<LocalFileInfoProvider>(""));

#ifndef ENGRAVING_NO_ACCESSIBILITY
AccessibleItem::enabled = true;
#endif

if (gpaletteScore->elementsProvider()) {
gpaletteScore->elementsProvider()->unreg(gpaletteScore);
}

#ifndef ENGRAVING_NO_INTERNAL
gpaletteScore->setStyle(DefaultStyle::baseStyle());
gpaletteScore->style().set(Sid::musicalTextFont, String(u"Leland Text"));
IEngravingFontPtr scoreFont = m_engravingfonts->fontByName("Leland");
gpaletteScore->setEngravingFont(scoreFont);
gpaletteScore->setNoteHeadWidth(scoreFont->width(SymId::noteheadBlack,
gpaletteScore->style().spatium()) / gpaletteScore->style().defaultSpatium());
#endif
}

//! NOTE And some initialization in the `Notation::init()`
}

Expand All @@ -303,20 +270,30 @@ void EngravingModule::onDeinit()
#endif
}

void EngravingModule::onDestroy()
{
delete gpaletteScore;
gpaletteScore = nullptr;
}

IContextSetup* EngravingModule::newContext(const muse::modularity::ContextPtr& ctx) const
{
return new EngravingContext(ctx);
}

void EngravingContext::registerExports()
{
#ifdef MUE_BUILD_ENGRAVING_DEVTOOLS
#ifndef ENGRAVING_NO_INTERNAL
m_paletteScoreProvider = std::make_shared<PaletteScoreProvider>(iocContext());
ioc()->registerExport<IPaletteScoreProvider>(mname, m_paletteScoreProvider);
ioc()->registerExport<IEngravingElementsProvider>(mname, new EngravingElementsProvider());
#endif
}

void EngravingContext::onInit(const muse::IApplication::RunMode&)
{
#ifndef ENGRAVING_NO_INTERNAL
m_paletteScoreProvider->init();
#endif
}

void EngravingContext::onDeinit()
{
#ifndef ENGRAVING_NO_INTERNAL
m_paletteScoreProvider->deinit();
#endif
}
8 changes: 7 additions & 1 deletion src/engraving/engravingmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
namespace mu::engraving {
class EngravingConfiguration;
class EngravingFontsProvider;
class PaletteScoreProvider;
class EngravingModule : public muse::modularity::IModuleSetup
{
public:
Expand All @@ -41,7 +42,6 @@ class EngravingModule : public muse::modularity::IModuleSetup
void registerUiTypes() override;
void onInit(const muse::IApplication::RunMode& mode) override;
void onDeinit() override;
void onDestroy() override;

muse::modularity::IContextSetup* newContext(const muse::modularity::ContextPtr& ctx) const override;

Expand All @@ -59,6 +59,12 @@ class EngravingContext : public muse::modularity::IContextSetup
: muse::modularity::IContextSetup(ctx) {}

void registerExports() override;
void onInit(const muse::IApplication::RunMode& mode) override;
void onDeinit() override;

private:

std::shared_ptr<PaletteScoreProvider> m_paletteScoreProvider;
};
}

Expand Down
77 changes: 77 additions & 0 deletions src/engraving/internal/palettescoreprovider.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-Studio-CLA-applies
*
* MuseScore Studio
* Music Composition & Notation
*
* Copyright (C) 2026 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 "palettescoreprovider.h"

#ifndef ENGRAVING_NO_ACCESSIBILITY
#include "../accessibility/accessibleitem.h"
#endif

#include "../compat/scoreaccess.h"
#include "../infrastructure/localfileinfoprovider.h"
#include "../style/defaultstyle.h"

using namespace muse;
using namespace mu::engraving;

PaletteScoreProvider::PaletteScoreProvider(const modularity::ContextPtr& iocCtx)
: muse::Contextable(iocCtx)
{
}

PaletteScoreProvider::~PaletteScoreProvider()
{
}

void PaletteScoreProvider::init()
{
#ifndef ENGRAVING_NO_ACCESSIBILITY
AccessibleItem::enabled = false;
#endif
m_paletteScore = compat::ScoreAccess::createMasterScore(iocContext());
m_paletteScore->setFileInfoProvider(std::make_shared<LocalFileInfoProvider>(""));

#ifndef ENGRAVING_NO_ACCESSIBILITY
AccessibleItem::enabled = true;
#endif

if (m_paletteScore->elementsProvider()) {
m_paletteScore->elementsProvider()->unreg(m_paletteScore);
}

m_paletteScore->setStyle(DefaultStyle::baseStyle());
m_paletteScore->style().set(Sid::musicalTextFont, String(u"Leland Text"));
IEngravingFontPtr scoreFont = engravingfonts()->fontByName("Leland");
m_paletteScore->setEngravingFont(scoreFont);
m_paletteScore->setNoteHeadWidth(scoreFont->width(SymId::noteheadBlack,
m_paletteScore->style().spatium()) / m_paletteScore->style().defaultSpatium());
}

void PaletteScoreProvider::deinit()
{
delete m_paletteScore;
m_paletteScore = nullptr;
}

MasterScore* PaletteScoreProvider::paletteScore() const
{
return m_paletteScore;
}
45 changes: 45 additions & 0 deletions src/engraving/internal/palettescoreprovider.h
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) 2026 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/>.
*/

#pragma once

#include "modularity/ioc.h"
#include "../ipalettescoreprovider.h"
#include "../iengravingfontsprovider.h"

namespace mu::engraving {
class PaletteScoreProvider : public IPaletteScoreProvider, public muse::Contextable
{
muse::GlobalInject<IEngravingFontsProvider> engravingfonts;
public:
PaletteScoreProvider(const muse::modularity::ContextPtr& iocCtx);
~PaletteScoreProvider() override;

void init();
void deinit();

MasterScore* paletteScore() const override;

private:
MasterScore* m_paletteScore = nullptr;
};
}
37 changes: 37 additions & 0 deletions src/engraving/ipalettescoreprovider.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-Studio-CLA-applies
*
* MuseScore Studio
* Music Composition & Notation
*
* Copyright (C) 2026 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/>.
*/
#pragma once

#include "modularity/imoduleinterface.h"

namespace mu::engraving {
class MasterScore;
class IPaletteScoreProvider : MODULE_CONTEXT_INTERFACE
{
INTERFACE_ID(IPaletteScoreProvider)

public:
virtual ~IPaletteScoreProvider() = default;

virtual MasterScore* paletteScore() const = 0;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void EngravingElementsModel::reload()
EngravingObjectSet notpalettes;

for (const mu::engraving::EngravingObject* el : elements) {
if (el == mu::engraving::gpaletteScore || el->score() == mu::engraving::gpaletteScore) {
if (el->score()->isPaletteScore()) {
continue;
}

Expand Down Expand Up @@ -252,7 +252,7 @@ void EngravingElementsModel::load(const EngravingObjectSet& elements, Item* root
{
TRACEFUNC;
for (const mu::engraving::EngravingObject* el : elements) {
if (el == mu::engraving::gpaletteScore) {
if (el->score()->isPaletteScore()) {
continue;
}

Expand Down
Loading
Loading