From fca602cb2e9180608010ac447d6e18e349fa43fd Mon Sep 17 00:00:00 2001 From: XiaoMigros Date: Wed, 28 Aug 2024 08:26:42 +0200 Subject: [PATCH] Allow for custom invisible color --- src/engraving/dom/soundflag.cpp | 2 +- src/engraving/iengravingconfiguration.h | 4 +++- .../internal/engravingconfiguration.cpp | 23 +++++++++++++++---- .../internal/engravingconfiguration.h | 5 +++- src/engraving/rendering/score/tdraw.cpp | 2 +- .../tests/mocks/engravingconfigurationmock.h | 10 ++++---- .../internal/notationconfiguration.cpp | 4 ++++ 7 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/engraving/dom/soundflag.cpp b/src/engraving/dom/soundflag.cpp index 989b593304ca3..dd9316b4b66ba 100644 --- a/src/engraving/dom/soundflag.cpp +++ b/src/engraving/dom/soundflag.cpp @@ -235,7 +235,7 @@ void SoundFlag::setIconFontSize(double size) Color SoundFlag::iconBackgroundColor() const { - Color color = curColor(); + Color color = curColor(true); if (!selected()) { color = Color("#CFD5DD"); color.setAlpha(128); diff --git a/src/engraving/iengravingconfiguration.h b/src/engraving/iengravingconfiguration.h index 8be5ecb666254..a2c84112f2174 100644 --- a/src/engraving/iengravingconfiguration.h +++ b/src/engraving/iengravingconfiguration.h @@ -54,7 +54,6 @@ class IEngravingConfiguration : MODULE_EXPORT_INTERFACE virtual Color defaultColor() const = 0; virtual Color scoreInversionColor() const = 0; - virtual Color invisibleColor() const = 0; virtual Color lassoColor() const = 0; virtual Color warningColor() const = 0; virtual Color warningSelectedColor() const = 0; @@ -81,6 +80,9 @@ class IEngravingConfiguration : MODULE_EXPORT_INTERFACE virtual Color formattingColor() const = 0; virtual muse::async::Channel formattingColorChanged() const = 0; + virtual Color invisibleColor() const = 0; + virtual muse::async::Channel invisibleColorChanged() const = 0; + virtual Color unlinkedColor() const = 0; virtual muse::async::Channel unlinkedColorChanged() const = 0; diff --git a/src/engraving/internal/engravingconfiguration.cpp b/src/engraving/internal/engravingconfiguration.cpp index c994579988616..93c6f87cdefdb 100644 --- a/src/engraving/internal/engravingconfiguration.cpp +++ b/src/engraving/internal/engravingconfiguration.cpp @@ -48,6 +48,7 @@ static const Settings::Key INVERT_SCORE_COLOR("engraving", "engraving/scoreColor static const Settings::Key ALL_VOICES_COLOR("engraving", "engraving/colors/allVoicesColor"); static const Settings::Key FORMATTING_COLOR("engraving", "engraving/colors/formattingColor"); static const Settings::Key FRAME_COLOR("engraving", "engraving/colors/frameColor"); +static const Settings::Key INVISIBLE_COLOR("engraving", "engraving/colors/invisibleColor"); static const Settings::Key UNLINKED_COLOR("engraving", "engraving/colors/unlinkedColor"); static const Settings::Key DYNAMICS_APPLY_TO_ALL_VOICES("engraving", "score/dynamicsApplyToAllVoices"); @@ -120,6 +121,13 @@ void EngravingConfiguration::init() m_formattingColorChanged.send(Color::fromQColor(val.toQColor())); }); + settings()->setDefaultValue(INVISIBLE_COLOR, Val(Color("#808080").toQColor())); + settings()->setDescription(INVISIBLE_COLOR, muse::trc("engraving", "Invisible color")); + settings()->setCanBeManuallyEdited(INVISIBLE_COLOR, true); + settings()->valueChanged(INVISIBLE_COLOR).onReceive(nullptr, [this](const Val& val) { + m_invisibleColorChanged.send(Color::fromQColor(val.toQColor())); + }); + settings()->setDefaultValue(UNLINKED_COLOR, Val(Color(UNLINKED_ITEM_COLOR).toQColor())); settings()->setDescription(UNLINKED_COLOR, muse::trc("engraving", "Desynchronized color")); settings()->setCanBeManuallyEdited(UNLINKED_COLOR, true); @@ -207,11 +215,6 @@ Color EngravingConfiguration::scoreInversionColor() const return Color(220, 220, 220); } -Color EngravingConfiguration::invisibleColor() const -{ - return "#808080"; -} - Color EngravingConfiguration::lassoColor() const { return "#00323200"; @@ -337,6 +340,16 @@ muse::async::Channel EngravingConfiguration::frameColorChanged() const return m_frameColorChanged; } +Color EngravingConfiguration::invisibleColor() const +{ + return Color::fromQColor(settings()->value(INVISIBLE_COLOR).toQColor()); +} + +muse::async::Channel EngravingConfiguration::invisibleColorChanged() const +{ + return m_invisibleColorChanged; +} + Color EngravingConfiguration::unlinkedColor() const { return Color::fromQColor(settings()->value(UNLINKED_COLOR).toQColor()); diff --git a/src/engraving/internal/engravingconfiguration.h b/src/engraving/internal/engravingconfiguration.h index 7fe3dbad8f957..fda05b22fe22c 100644 --- a/src/engraving/internal/engravingconfiguration.h +++ b/src/engraving/internal/engravingconfiguration.h @@ -60,7 +60,6 @@ class EngravingConfiguration : public IEngravingConfiguration, public muse::Inje Color defaultColor() const override; Color scoreInversionColor() const override; - Color invisibleColor() const override; Color lassoColor() const override; Color warningColor() const override; Color warningSelectedColor() const override; @@ -93,6 +92,9 @@ class EngravingConfiguration : public IEngravingConfiguration, public muse::Inje Color frameColor() const override; muse::async::Channel frameColorChanged() const override; + Color invisibleColor() const override; + muse::async::Channel invisibleColorChanged() const override; + Color unlinkedColor() const override; muse::async::Channel unlinkedColorChanged() const override; @@ -118,6 +120,7 @@ class EngravingConfiguration : public IEngravingConfiguration, public muse::Inje muse::async::Notification m_scoreInversionChanged; muse::async::Channel m_formattingColorChanged; muse::async::Channel m_frameColorChanged; + muse::async::Channel m_invisibleColorChanged; muse::async::Channel m_unlinkedColorChanged; muse::ValNt m_debuggingOptions; diff --git a/src/engraving/rendering/score/tdraw.cpp b/src/engraving/rendering/score/tdraw.cpp index 435510dcc067d..1567f07b7ca1e 100644 --- a/src/engraving/rendering/score/tdraw.cpp +++ b/src/engraving/rendering/score/tdraw.cpp @@ -2956,7 +2956,7 @@ void TDraw::draw(const SoundFlag* item, Painter* painter) f.setPointSizeF(item->spatium() * 2.0); painter->setFont(f); - painter->setPen(!item->selected() ? item->curColor() : Color::WHITE); + painter->setPen(!item->selected() ? item->curColor(true) : Color::WHITE); painter->drawText(item->ldata()->bbox(), muse::draw::AlignCenter, Char(item->iconCode())); } diff --git a/src/engraving/tests/mocks/engravingconfigurationmock.h b/src/engraving/tests/mocks/engravingconfigurationmock.h index 77a6a5ce395b7..69c427d887c3d 100644 --- a/src/engraving/tests/mocks/engravingconfigurationmock.h +++ b/src/engraving/tests/mocks/engravingconfigurationmock.h @@ -44,7 +44,6 @@ class EngravingConfigurationMock : public IEngravingConfiguration MOCK_METHOD(Color, defaultColor, (), (const, override)); MOCK_METHOD(Color, scoreInversionColor, (), (const, override)); - MOCK_METHOD(Color, invisibleColor, (), (const, override)); MOCK_METHOD(Color, lassoColor, (), (const, override)); MOCK_METHOD(Color, warningColor, (), (const, override)); MOCK_METHOD(Color, warningSelectedColor, (), (const, override)); @@ -68,15 +67,18 @@ class EngravingConfigurationMock : public IEngravingConfiguration MOCK_METHOD(void, setScoreInversionEnabled, (bool), (override)); MOCK_METHOD(muse::async::Notification, scoreInversionChanged, (), (const, override)); - MOCK_METHOD(Color, unlinkedColor, (), (const, override)); - MOCK_METHOD(muse::async::Channel, unlinkedColorChanged, (), (const, override)); - MOCK_METHOD(Color, formattingColor, (), (const, override)); MOCK_METHOD(muse::async::Channel, formattingColorChanged, (), (const, override)); MOCK_METHOD(Color, frameColor, (), (const, override)); MOCK_METHOD(muse::async::Channel, frameColorChanged, (), (const, override)); + MOCK_METHOD(Color, invisibleColor, (), (const, override)); + MOCK_METHOD(muse::async::Channel, invisibleColorChanged, (), (const, override)); + + MOCK_METHOD(Color, unlinkedColor, (), (const, override)); + MOCK_METHOD(muse::async::Channel, unlinkedColorChanged, (), (const, override)); + MOCK_METHOD(Color, highlightSelectionColor, (engraving::voice_idx_t), (const, override)); MOCK_METHOD(const DebuggingOptions&, debuggingOptions, (), (const, override)); diff --git a/src/notation/internal/notationconfiguration.cpp b/src/notation/internal/notationconfiguration.cpp index 20eec06261d09..a059bca8aebed 100644 --- a/src/notation/internal/notationconfiguration.cpp +++ b/src/notation/internal/notationconfiguration.cpp @@ -236,6 +236,10 @@ void NotationConfiguration::init() m_foregroundChanged.notify(); }); + engravingConfiguration()->invisibleColorChanged().onReceive(this, [this](const Color&) { + m_foregroundChanged.notify(); + }); + engravingConfiguration()->unlinkedColorChanged().onReceive(this, [this](const Color&) { m_foregroundChanged.notify(); });