Skip to content

Commit

Permalink
Allow for custom invisible color
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoMigros committed Dec 2, 2024
1 parent e30f030 commit fca602c
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/engraving/dom/soundflag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/engraving/iengravingconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -81,6 +80,9 @@ class IEngravingConfiguration : MODULE_EXPORT_INTERFACE
virtual Color formattingColor() const = 0;
virtual muse::async::Channel<Color> formattingColorChanged() const = 0;

virtual Color invisibleColor() const = 0;
virtual muse::async::Channel<Color> invisibleColorChanged() const = 0;

virtual Color unlinkedColor() const = 0;
virtual muse::async::Channel<Color> unlinkedColorChanged() const = 0;

Expand Down
23 changes: 18 additions & 5 deletions src/engraving/internal/engravingconfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -337,6 +340,16 @@ muse::async::Channel<Color> EngravingConfiguration::frameColorChanged() const
return m_frameColorChanged;
}

Color EngravingConfiguration::invisibleColor() const
{
return Color::fromQColor(settings()->value(INVISIBLE_COLOR).toQColor());
}

muse::async::Channel<Color> EngravingConfiguration::invisibleColorChanged() const
{
return m_invisibleColorChanged;
}

Color EngravingConfiguration::unlinkedColor() const
{
return Color::fromQColor(settings()->value(UNLINKED_COLOR).toQColor());
Expand Down
5 changes: 4 additions & 1 deletion src/engraving/internal/engravingconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -93,6 +92,9 @@ class EngravingConfiguration : public IEngravingConfiguration, public muse::Inje
Color frameColor() const override;
muse::async::Channel<Color> frameColorChanged() const override;

Color invisibleColor() const override;
muse::async::Channel<Color> invisibleColorChanged() const override;

Color unlinkedColor() const override;
muse::async::Channel<Color> unlinkedColorChanged() const override;

Expand All @@ -118,6 +120,7 @@ class EngravingConfiguration : public IEngravingConfiguration, public muse::Inje
muse::async::Notification m_scoreInversionChanged;
muse::async::Channel<Color> m_formattingColorChanged;
muse::async::Channel<Color> m_frameColorChanged;
muse::async::Channel<Color> m_invisibleColorChanged;
muse::async::Channel<Color> m_unlinkedColorChanged;

muse::ValNt<DebuggingOptions> m_debuggingOptions;
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/rendering/score/tdraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}

Expand Down
10 changes: 6 additions & 4 deletions src/engraving/tests/mocks/engravingconfigurationmock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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<Color>, unlinkedColorChanged, (), (const, override));

MOCK_METHOD(Color, formattingColor, (), (const, override));
MOCK_METHOD(muse::async::Channel<Color>, formattingColorChanged, (), (const, override));

MOCK_METHOD(Color, frameColor, (), (const, override));
MOCK_METHOD(muse::async::Channel<Color>, frameColorChanged, (), (const, override));

MOCK_METHOD(Color, invisibleColor, (), (const, override));
MOCK_METHOD(muse::async::Channel<Color>, invisibleColorChanged, (), (const, override));

MOCK_METHOD(Color, unlinkedColor, (), (const, override));
MOCK_METHOD(muse::async::Channel<Color>, unlinkedColorChanged, (), (const, override));

MOCK_METHOD(Color, highlightSelectionColor, (engraving::voice_idx_t), (const, override));

MOCK_METHOD(const DebuggingOptions&, debuggingOptions, (), (const, override));
Expand Down
4 changes: 4 additions & 0 deletions src/notation/internal/notationconfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down

0 comments on commit fca602c

Please sign in to comment.