Skip to content

Commit

Permalink
added the ability to override the note input preview color
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanPudashkin committed Jan 22, 2025
1 parent 28e9841 commit 1187454
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/engraving/rendering/score/tdraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2515,7 +2515,7 @@ void TDraw::draw(const ShadowNote* item, Painter* painter)
PointF ap(item->pagePos());
painter->translate(ap);
double lw = item->style().styleMM(Sid::stemWidth) * item->mag();
Pen pen(item->configuration()->highlightSelectionColor(item->voice()), lw, PenStyle::SolidLine, PenCapStyle::FlatCap);
Pen pen(item->color(), lw, PenStyle::SolidLine, PenCapStyle::FlatCap);
painter->setPen(pen);

bool up = item->computeUp();
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/rendering/single/singledraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2056,7 +2056,7 @@ void SingleDraw::draw(const ShadowNote* item, Painter* painter)
PointF ap(item->pagePos());
painter->translate(ap);
double lw = item->style().styleMM(Sid::stemWidth) * item->mag();
Pen pen(item->configuration()->highlightSelectionColor(item->voice()), lw, PenStyle::SolidLine, PenCapStyle::FlatCap);
Pen pen(item->color(), lw, PenStyle::SolidLine, PenCapStyle::FlatCap);
painter->setPen(pen);

bool up = item->computeUp();
Expand Down
2 changes: 2 additions & 0 deletions src/notation/inotationconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class INotationConfiguration : MODULE_EXPORT_INTERFACE

virtual QColor dropRectColor() const = 0;

virtual muse::draw::Color noteInputPreviewColor() const = 0;

virtual int selectionProximity() const = 0;
virtual void setSelectionProximity(int proximity) = 0;
virtual muse::async::Channel<int> selectionProximityChanged() const = 0;
Expand Down
11 changes: 11 additions & 0 deletions src/notation/internal/notationconfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ static const Settings::Key FOREGROUND_COLOR(module_name, "ui/canvas/foreground/c
static const Settings::Key FOREGROUND_WALLPAPER_PATH(module_name, "ui/canvas/foreground/wallpaper");
static const Settings::Key FOREGROUND_USE_COLOR(module_name, "ui/canvas/foreground/useColor");

static const Settings::Key NOTE_INPUT_PREVIEW_COLOR(module_name, "ui/canvas/noteInputPreviewColor");

static const Settings::Key SELECTION_PROXIMITY(module_name, "ui/canvas/misc/selectionProximity");

static const Settings::Key DEFAULT_ZOOM_TYPE(module_name, "ui/canvas/zoomDefaultType");
Expand Down Expand Up @@ -162,6 +164,10 @@ void NotationConfiguration::init()
m_foregroundChanged.notify();
});

settings()->setDefaultValue(NOTE_INPUT_PREVIEW_COLOR, Val(selectionColor()));
settings()->setCanBeManuallyEdited(NOTE_INPUT_PREVIEW_COLOR, true);
settings()->setDescription(NOTE_INPUT_PREVIEW_COLOR, muse::trc("notation", "Note input preview note color"));

settings()->setDefaultValue(FOREGROUND_WALLPAPER_PATH, Val());
settings()->valueChanged(FOREGROUND_WALLPAPER_PATH).onReceive(nullptr, [this](const Val&) {
m_foregroundChanged.notify();
Expand Down Expand Up @@ -533,6 +539,11 @@ QColor NotationConfiguration::dropRectColor() const
return color;
}

muse::draw::Color NotationConfiguration::noteInputPreviewColor() const
{
return settings()->value(NOTE_INPUT_PREVIEW_COLOR).toQColor();
}

int NotationConfiguration::selectionProximity() const
{
return settings()->value(SELECTION_PROXIMITY).toInt();
Expand Down
2 changes: 2 additions & 0 deletions src/notation/internal/notationconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class NotationConfiguration : public INotationConfiguration, public muse::async:

QColor dropRectColor() const override;

muse::draw::Color noteInputPreviewColor() const override;

int selectionProximity() const override;
void setSelectionProximity(int proximity) override;
muse::async::Channel<int> selectionProximityChanged() const override;
Expand Down
8 changes: 8 additions & 0 deletions src/notation/internal/notationinteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,14 @@ void NotationInteraction::showShadowNoteAtPosition(ShadowNote& shadowNote, const
shadowNote.setVoice(voice);
shadowNote.setLineIndex(line);

Color color = configuration()->noteInputPreviewColor();

if (color.isValid() && color != configuration()->selectionColor()) {
shadowNote.setColor(color);
} else {
shadowNote.setColor(configuration()->selectionColor(voice));
}

mu::engraving::SymId symNotehead;

if (inputState.rest()) {
Expand Down
2 changes: 2 additions & 0 deletions src/notation/tests/mocks/notationconfigurationmock.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class NotationConfigurationMock : public INotationConfiguration

MOCK_METHOD(QColor, dropRectColor, (), (const, override));

MOCK_METHOD(muse::draw::Color, noteInputPreviewColor, (), (const, override));

MOCK_METHOD(int, selectionProximity, (), (const, override));
MOCK_METHOD(void, setSelectionProximity, (int), (override));
MOCK_METHOD(muse::async::Channel<int>, selectionProximityChanged, (), (const, override));
Expand Down
5 changes: 5 additions & 0 deletions src/stubs/notation/notationconfigurationstub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ QColor NotationConfigurationStub::dropRectColor() const
return QColor();
}

muse::draw::Color NotationConfigurationStub::noteInputPreviewColor() const
{
return muse::draw::Color();
}

int NotationConfigurationStub::selectionProximity() const
{
return 1;
Expand Down
2 changes: 2 additions & 0 deletions src/stubs/notation/notationconfigurationstub.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class NotationConfigurationStub : public INotationConfiguration

QColor dropRectColor() const override;

muse::draw::Color noteInputPreviewColor() const override;

int selectionProximity() const override;
void setSelectionProximity(int proximity) override;
muse::async::Channel<int> selectionProximityChanged() const override;
Expand Down

0 comments on commit 1187454

Please sign in to comment.