Skip to content

Commit

Permalink
Percussion panel - add useNotationPreview to notation configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mathesoncalum committed Feb 28, 2025
1 parent 15806e6 commit 420c20c
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 16 deletions.
4 changes: 4 additions & 0 deletions src/notation/inotationconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ class INotationConfiguration : MODULE_EXPORT_INTERFACE
virtual void setUseNewPercussionPanel(bool use) = 0;
virtual muse::async::Notification useNewPercussionPanelChanged() const = 0;

virtual bool percussionPanelUseNotationPreview() const = 0;
virtual void setPercussionPanelUseNotationPreview(bool use) = 0;
virtual muse::async::Notification percussionPanelUseNotationPreviewChanged() const = 0;

virtual PercussionPanelAutoShowMode percussionPanelAutoShowMode() const = 0;
virtual void setPercussionPanelAutoShowMode(PercussionPanelAutoShowMode autoShowMode) = 0;
virtual muse::async::Notification percussionPanelAutoShowModeChanged() const = 0;
Expand Down
21 changes: 21 additions & 0 deletions src/notation/internal/notationconfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ static const Settings::Key NEED_TO_SHOW_ADD_GUITAR_BEND_ERROR_MESSAGE_KEY(module
static const Settings::Key PIANO_KEYBOARD_NUMBER_OF_KEYS(module_name, "pianoKeyboard/numberOfKeys");

static const Settings::Key USE_NEW_PERCUSSION_PANEL_KEY(module_name, "ui/useNewPercussionPanel");
static const Settings::Key PERCUSSION_PANEL_USE_NOTATION_PREVIEW_KEY(module_name, "ui/percussionPanelUseNotationPreview");
static const Settings::Key PERCUSSION_PANEL_AUTO_SHOW_MODE_KEY(module_name, "ui/percussionPanelAutoShowMode");
static const Settings::Key AUTO_CLOSE_PERCUSSION_PANEL_KEY(module_name, "ui/autoClosePercussionPanel");
static const Settings::Key SHOW_PERCUSSION_PANEL_SWAP_DIALOG(module_name, "ui/showPercussionPanelPadSwapDialog");
Expand Down Expand Up @@ -326,6 +327,11 @@ void NotationConfiguration::init()
m_useNewPercussionPanelChanged.notify();
});

settings()->setDefaultValue(PERCUSSION_PANEL_USE_NOTATION_PREVIEW_KEY, Val(false));
settings()->valueChanged(PERCUSSION_PANEL_USE_NOTATION_PREVIEW_KEY).onReceive(this, [this](const Val&) {
m_percussionPanelUseNotationPreviewChanged.notify();
});

settings()->setDefaultValue(PERCUSSION_PANEL_AUTO_SHOW_MODE_KEY, Val(PercussionPanelAutoShowMode::UNPITCHED_STAFF));
settings()->valueChanged(PERCUSSION_PANEL_AUTO_SHOW_MODE_KEY).onReceive(this, [this](const Val&) {
m_percussionPanelAutoShowModeChanged.notify();
Expand Down Expand Up @@ -1152,6 +1158,21 @@ Notification NotationConfiguration::useNewPercussionPanelChanged() const
return m_useNewPercussionPanelChanged;
}

bool NotationConfiguration::percussionPanelUseNotationPreview() const
{
return settings()->value(PERCUSSION_PANEL_USE_NOTATION_PREVIEW_KEY).toBool();
}

void NotationConfiguration::setPercussionPanelUseNotationPreview(bool use)
{
settings()->setSharedValue(PERCUSSION_PANEL_USE_NOTATION_PREVIEW_KEY, Val(use));
}

Notification NotationConfiguration::percussionPanelUseNotationPreviewChanged() const
{
return m_percussionPanelUseNotationPreviewChanged;
}

PercussionPanelAutoShowMode NotationConfiguration::percussionPanelAutoShowMode() const
{
return settings()->value(PERCUSSION_PANEL_AUTO_SHOW_MODE_KEY).toEnum<PercussionPanelAutoShowMode>();
Expand Down
5 changes: 5 additions & 0 deletions src/notation/internal/notationconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ class NotationConfiguration : public INotationConfiguration, public muse::async:
void setUseNewPercussionPanel(bool use) override;
muse::async::Notification useNewPercussionPanelChanged() const override;

bool percussionPanelUseNotationPreview() const override;
void setPercussionPanelUseNotationPreview(bool use) override;
muse::async::Notification percussionPanelUseNotationPreviewChanged() const override;

PercussionPanelAutoShowMode percussionPanelAutoShowMode() const override;
void setPercussionPanelAutoShowMode(PercussionPanelAutoShowMode percussionPanelAutoShowMode) override;
muse::async::Notification percussionPanelAutoShowModeChanged() const override;
Expand Down Expand Up @@ -299,6 +303,7 @@ class NotationConfiguration : public INotationConfiguration, public muse::async:
muse::ValCh<bool> m_midiInputUseWrittenPitch;
muse::async::Channel<QColor> m_anchorColorChanged;
muse::async::Notification m_useNewPercussionPanelChanged;
muse::async::Notification m_percussionPanelUseNotationPreviewChanged;
muse::async::Notification m_percussionPanelAutoShowModeChanged;
muse::async::Notification m_autoClosePercussionPanelChanged;
muse::async::Notification m_showPercussionPanelPadSwapDialogChanged;
Expand Down
4 changes: 4 additions & 0 deletions src/notation/tests/mocks/notationconfigurationmock.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ class NotationConfigurationMock : public INotationConfiguration
MOCK_METHOD(void, setUseNewPercussionPanel, (bool), (override));
MOCK_METHOD(muse::async::Notification, useNewPercussionPanelChanged, (), (const, override));

MOCK_METHOD(bool, percussionPanelUseNotationPreview, (), (const, override));
MOCK_METHOD(void, setPercussionPanelUseNotationPreview, (bool), (override));
MOCK_METHOD(muse::async::Notification, percussionPanelUseNotationPreviewChanged, (), (const, override));

MOCK_METHOD(PercussionPanelAutoShowMode, percussionPanelAutoShowMode, (), (const, override));
MOCK_METHOD(void, setPercussionPanelAutoShowMode, (PercussionPanelAutoShowMode), (override));
MOCK_METHOD(muse::async::Notification, percussionPanelAutoShowModeChanged, (), (const, override));
Expand Down
33 changes: 18 additions & 15 deletions src/notation/view/percussionpanel/percussionpanelmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,15 @@ void PercussionPanelModel::setCurrentPanelMode(const PanelMode::Mode& panelMode)

bool PercussionPanelModel::useNotationPreview() const
{
return m_useNotationPreview;
return configuration()->percussionPanelUseNotationPreview();
}

void PercussionPanelModel::setUseNotationPreview(bool useNotationPreview)
{
if (m_useNotationPreview == useNotationPreview) {
if (configuration()->percussionPanelUseNotationPreview() == useNotationPreview) {
return;
}

m_useNotationPreview = useNotationPreview;
emit useNotationPreviewChanged(m_useNotationPreview);
configuration()->setPercussionPanelUseNotationPreview(useNotationPreview);
}

PercussionPanelPadListModel* PercussionPanelModel::padListModel() const
Expand Down Expand Up @@ -144,10 +142,10 @@ QList<QVariantMap> PercussionPanelModel::layoutMenuItems() const

QList<QVariantMap> menuItems = {
{ { "id", PAD_NAMES_CODE }, { "title", muse::qtrc("notation/percussion", "Pad names") },
{ "checkable", true }, { "checked", !m_useNotationPreview }, { "enabled", true } },
{ "checkable", true }, { "checked", !useNotationPreview() }, { "enabled", true } },

{ { "id", NOTATION_PREVIEW_CODE }, { "title", muse::qtrc("notation/percussion", "Notation preview") },
{ "checkable", true }, { "checked", m_useNotationPreview }, { "enabled", true } },
{ "checkable", true }, { "checked", useNotationPreview() }, { "enabled", true } },

{ }, // separator

Expand Down Expand Up @@ -301,16 +299,21 @@ void PercussionPanelModel::setUpConnections()
}
});

if (!audioSettings()) {
return;
if (audioSettings()) {
audioSettings()->trackInputParamsChanged().onReceive(this, [this](InstrumentTrackId trackId) {
if (trackId != currentTrackId()) {
return;
}
updateSoundTitle(trackId);
});
}

audioSettings()->trackInputParamsChanged().onReceive(this, [this](InstrumentTrackId trackId) {
if (trackId != currentTrackId()) {
return;
}
updateSoundTitle(trackId);
});
if (configuration()) {
configuration()->percussionPanelUseNotationPreviewChanged().onNotify(this, [this]() {
const bool useNotationPreview = configuration()->percussionPanelUseNotationPreview();
emit useNotationPreviewChanged(useNotationPreview);
});
}
}

void PercussionPanelModel::setDrumset(engraving::Drumset* drumset)
Expand Down
1 change: 0 additions & 1 deletion src/notation/view/percussionpanel/percussionpanelmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ class PercussionPanelModel : public QObject, public muse::Injectable, public mus

PanelMode::Mode m_currentPanelMode = PanelMode::Mode::WRITE;
PanelMode::Mode m_panelModeToRestore = PanelMode::Mode::WRITE;
bool m_useNotationPreview = false;

PercussionPanelPadListModel* m_padListModel = nullptr;
};
Expand Down
15 changes: 15 additions & 0 deletions src/stubs/notation/notationconfigurationstub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,21 @@ muse::async::Notification NotationConfigurationStub::useNewPercussionPanelChange
return n;
}

bool NotationConfigurationStub::percussionPanelUseNotationPreview() const
{
return false;
}

void NotationConfigurationStub::setPercussionPanelUseNotationPreview(bool)
{
}

muse::async::Notification NotationConfigurationStub::percussionPanelUseNotationPreviewChanged() const
{
static muse::async::Notification n;
return n;
}

bool NotationConfigurationStub::autoShowPercussionPanel() const
{
return true;
Expand Down
4 changes: 4 additions & 0 deletions src/stubs/notation/notationconfigurationstub.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ class NotationConfigurationStub : public INotationConfiguration
void setUseNewPercussionPanel(bool use) override;
muse::async::Notification useNewPercussionPanelChanged() const override;

bool percussionPanelUseNotationPreview() const override;
void setPercussionPanelUseNotationPreview(bool use);
muse::async::Notification percussionPanelUseNotationPreviewChanged() const override;

PercussionPanelAutoShowMode percussionPanelAutoShowMode() const override;
void setPercussionPanelAutoShowMode(PercussionPanelAutoShowMode autoShowMode) override;
muse::async::Notification percussionPanelAutoShowModeChanged() const override;
Expand Down

0 comments on commit 420c20c

Please sign in to comment.