From 9132db0f0859c22f45ab19455d2ae8ff74c14753 Mon Sep 17 00:00:00 2001 From: Robert Patterson Date: Tue, 17 Sep 2024 11:55:28 -0500 Subject: [PATCH 01/14] Changes to revive and complete PR #22991. --- src/engraving/dom/edit.cpp | 3 +- src/engraving/dom/score.h | 5 ++ src/notation/inotationconfiguration.h | 3 + .../internal/notationconfiguration.cpp | 17 ++++++ src/notation/internal/notationconfiguration.h | 4 ++ .../tests/mocks/notationconfigurationmock.h | 3 + .../pianokeyboard/pianokeyboardcontroller.cpp | 9 ++- .../pianokeyboard/pianokeyboardcontroller.h | 3 + .../pianokeyboardpanelcontextmenumodel.cpp | 58 ++++++++++++++++++- .../pianokeyboardpanelcontextmenumodel.h | 4 ++ .../notation/notationconfigurationstub.cpp | 10 ++++ .../notation/notationconfigurationstub.h | 3 + 12 files changed, 118 insertions(+), 4 deletions(-) diff --git a/src/engraving/dom/edit.cpp b/src/engraving/dom/edit.cpp index b7f47d0ec06e0..380f5a9e0c53b 100644 --- a/src/engraving/dom/edit.cpp +++ b/src/engraving/dom/edit.cpp @@ -24,6 +24,7 @@ #include #include "infrastructure/messagebox.h" +#include "notation/internal/notationconfiguration.h" #include "accidental.h" #include "articulation.h" @@ -1587,7 +1588,7 @@ NoteVal Score::noteVal(int pitch) const // if transposing, interpret MIDI pitch as representing desired written pitch // set pitch based on corresponding sounding pitch - if (!style().styleB(Sid::concertPitch)) { + if (!style().styleB(Sid::concertPitch) && notationConfiguration()->pianoKeyboardUseNotatedPitch().val) { nval.pitch += st->part()->instrument(inputState().tick())->transpose().chromatic; } // let addPitch calculate tpc values from pitch diff --git a/src/engraving/dom/score.h b/src/engraving/dom/score.h index 97861bba43a75..3f1fe2e012b43 100644 --- a/src/engraving/dom/score.h +++ b/src/engraving/dom/score.h @@ -90,6 +90,10 @@ namespace mu::engraving::compat { class WriteScoreHook; } +namespace mu::notation { +class INotationConfiguration; +} + namespace mu::engraving { class Articulation; class Audio; @@ -273,6 +277,7 @@ class Score : public EngravingObject, public muse::Injectable muse::Inject engravingFonts = { this }; muse::Inject application = { this }; muse::Inject elementsProvider = { this }; + muse::Inject notationConfiguration = { this }; // internal muse::Inject renderer = { this }; diff --git a/src/notation/inotationconfiguration.h b/src/notation/inotationconfiguration.h index ed4b51d9a2fa8..4ce05ee8748dc 100644 --- a/src/notation/inotationconfiguration.h +++ b/src/notation/inotationconfiguration.h @@ -193,6 +193,9 @@ class INotationConfiguration : MODULE_EXPORT_INTERFACE virtual muse::ValCh pianoKeyboardNumberOfKeys() const = 0; virtual void setPianoKeyboardNumberOfKeys(int number) = 0; + virtual muse::ValCh pianoKeyboardUseNotatedPitch() const = 0; + virtual void setPianoKeyboardUseNotatedPitch(bool useNotatedPitch) = 0; + // TODO: Delete when the new percussion panel is finished virtual bool useNewPercussionPanel() const = 0; virtual void setUseNewPercussionPanel(bool use) = 0; diff --git a/src/notation/internal/notationconfiguration.cpp b/src/notation/internal/notationconfiguration.cpp index 80331f0cbfab6..fe1dae7914a9a 100644 --- a/src/notation/internal/notationconfiguration.cpp +++ b/src/notation/internal/notationconfiguration.cpp @@ -89,6 +89,7 @@ static const Settings::Key NEED_TO_SHOW_ADD_FIGURED_BASS_ERROR_MESSAGE_KEY(modul static const Settings::Key NEED_TO_SHOW_ADD_GUITAR_BEND_ERROR_MESSAGE_KEY(module_name, "ui/dialogs/needToShowAddGuitarBendErrorMessage"); static const Settings::Key PIANO_KEYBOARD_NUMBER_OF_KEYS(module_name, "pianoKeyboard/numberOfKeys"); +static const Settings::Key PIANO_KEYBOARD_PITCH_STATE(module_name, "pianoKeyboard/useNotatedPitch"); static const Settings::Key USE_NEW_PERCUSSION_PANEL_KEY(module_name, "ui/useNewPercussionPanel"); static const Settings::Key AUTO_SHOW_PERCUSSION_PANEL_KEY(module_name, "ui/autoShowPercussionPanel"); @@ -220,6 +221,12 @@ void NotationConfiguration::init() m_pianoKeyboardNumberOfKeys.set(val.toInt()); }); + settings()->setDefaultValue(PIANO_KEYBOARD_PITCH_STATE, Val(true)); + m_pianoKeyboardUseNotatedPitch.val = settings()->value(PIANO_KEYBOARD_PITCH_STATE).toBool(); + settings()->valueChanged(PIANO_KEYBOARD_PITCH_STATE).onReceive(this, [this](const Val& val) { + m_pianoKeyboardUseNotatedPitch.set(val.toBool()); + }); + settings()->setDefaultValue(USE_NEW_PERCUSSION_PANEL_KEY, Val(false)); settings()->setDefaultValue(AUTO_SHOW_PERCUSSION_PANEL_KEY, Val(true)); @@ -919,6 +926,16 @@ void NotationConfiguration::setPianoKeyboardNumberOfKeys(int number) settings()->setSharedValue(PIANO_KEYBOARD_NUMBER_OF_KEYS, Val(number)); } +ValCh NotationConfiguration::pianoKeyboardUseNotatedPitch() const +{ + return m_pianoKeyboardUseNotatedPitch; +} + +void NotationConfiguration::setPianoKeyboardUseNotatedPitch(bool useNotatedPitch) +{ + settings()->setSharedValue(PIANO_KEYBOARD_PITCH_STATE, Val(useNotatedPitch)); +} + muse::io::path_t NotationConfiguration::firstScoreOrderListPath() const { return settings()->value(FIRST_SCORE_ORDER_LIST_KEY).toString(); diff --git a/src/notation/internal/notationconfiguration.h b/src/notation/internal/notationconfiguration.h index 78e929d23a389..78a998ae2d089 100644 --- a/src/notation/internal/notationconfiguration.h +++ b/src/notation/internal/notationconfiguration.h @@ -198,6 +198,9 @@ class NotationConfiguration : public INotationConfiguration, public muse::async: muse::ValCh pianoKeyboardNumberOfKeys() const override; void setPianoKeyboardNumberOfKeys(int number) override; + muse::ValCh pianoKeyboardUseNotatedPitch() const override; + void setPianoKeyboardUseNotatedPitch(bool useNotatedPitch) override; + bool useNewPercussionPanel() const override; void setUseNewPercussionPanel(bool use) override; @@ -231,6 +234,7 @@ class NotationConfiguration : public INotationConfiguration, public muse::async: muse::async::Notification m_isPlayRepeatsChanged; muse::async::Notification m_isPlayChordSymbolsChanged; muse::ValCh m_pianoKeyboardNumberOfKeys; + muse::ValCh m_pianoKeyboardUseNotatedPitch; muse::async::Channel m_anchorColorChanged; int m_styleDialogLastPageIndex = 0; diff --git a/src/notation/tests/mocks/notationconfigurationmock.h b/src/notation/tests/mocks/notationconfigurationmock.h index ce45c0fff2fdc..b0bf76334c631 100644 --- a/src/notation/tests/mocks/notationconfigurationmock.h +++ b/src/notation/tests/mocks/notationconfigurationmock.h @@ -183,6 +183,9 @@ class NotationConfigurationMock : public INotationConfiguration MOCK_METHOD(muse::ValCh, pianoKeyboardNumberOfKeys, (), (const, override)); MOCK_METHOD(void, setPianoKeyboardNumberOfKeys, (int), (override)); + MOCK_METHOD(muse::ValCh, pianoKeyboardUseNotatedPitch, (), (const, override)); + MOCK_METHOD(void, setPianoKeyboardUseNotatedPitch, (bool), (override)); + MOCK_METHOD(bool, useNewPercussionPanel, (), (const, override)); MOCK_METHOD(void, setUseNewPercussionPanel, (bool), (override)); diff --git a/src/notation/view/pianokeyboard/pianokeyboardcontroller.cpp b/src/notation/view/pianokeyboard/pianokeyboardcontroller.cpp index 66c8901d75508..124f6a57e342b 100644 --- a/src/notation/view/pianokeyboard/pianokeyboardcontroller.cpp +++ b/src/notation/view/pianokeyboard/pianokeyboardcontroller.cpp @@ -133,9 +133,9 @@ void PianoKeyboardController::updateNotesKeys(const std::vector& re }; for (const mu::engraving::Note* note : receivedNotes) { - newKeys.insert(static_cast(note->epitch())); + newKeys.insert(static_cast(useNotatedPitch() ? note->epitch() : note->ppitch())); for (const mu::engraving::Note* otherNote : note->chord()->notes()) { - newOtherNotesInChord.insert(static_cast(otherNote->epitch())); + newOtherNotesInChord.insert(static_cast(useNotatedPitch() ? otherNote->epitch() : otherNote->ppitch())); } } } @@ -175,3 +175,8 @@ INotationPtr PianoKeyboardController::currentNotation() const { return context()->currentNotation(); } + +bool PianoKeyboardController::useNotatedPitch() const +{ + return configuration()->pianoKeyboardUseNotatedPitch().val; +} diff --git a/src/notation/view/pianokeyboard/pianokeyboardcontroller.h b/src/notation/view/pianokeyboard/pianokeyboardcontroller.h index 140ead36b72b2..0170c5ac630fc 100644 --- a/src/notation/view/pianokeyboard/pianokeyboardcontroller.h +++ b/src/notation/view/pianokeyboard/pianokeyboardcontroller.h @@ -32,6 +32,7 @@ namespace mu::notation { class PianoKeyboardController : public muse::Injectable, public muse::async::Asyncable { + muse::Inject configuration = { this }; muse::Inject context = { this }; public: @@ -45,6 +46,8 @@ class PianoKeyboardController : public muse::Injectable, public muse::async::Asy bool isFromMidi() const; + bool useNotatedPitch() const; + private: INotationPtr currentNotation() const; diff --git a/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.cpp b/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.cpp index 4bb49b241ae35..ae19e847accae 100644 --- a/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.cpp +++ b/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.cpp @@ -35,6 +35,7 @@ using namespace muse::uicomponents; static const ActionCode SET_KEY_WIDTH_SCALING_CODE("piano-keyboard-set-key-width-scaling"); static const ActionCode SET_NUMBER_OF_KEYS_CODE("piano-keyboard-set-number-of-keys"); +static const ActionCode SET_NOTATED_PITCH_CODE("piano-keyboard-toggle-notated-pitch"); PianoKeyboardPanelContextMenuModel::PianoKeyboardPanelContextMenuModel(QObject* parent) : AbstractMenuModel(parent) @@ -44,7 +45,8 @@ PianoKeyboardPanelContextMenuModel::PianoKeyboardPanelContextMenuModel(QObject* void PianoKeyboardPanelContextMenuModel::load() { MenuItemList items { - makeViewMenu() + makeViewMenu(), + makePitchMenu(), }; setItems(items); @@ -71,6 +73,35 @@ int PianoKeyboardPanelContextMenuModel::numberOfKeys() const return configuration()->pianoKeyboardNumberOfKeys().val; } +MenuItem* PianoKeyboardPanelContextMenuModel::makePitchMenu() +{ + MenuItemList items; + + std::vector > possibleNotationStates { + { muse::TranslatableString("notation", "Use notated pitch"), true }, + { muse::TranslatableString("notation", "Use playback pitch"), false }, + }; + + for (auto [title, notationState] : possibleNotationStates) { + items << makeToggleNotatedPitchItem(title, notationState); + } + + configuration()->pianoKeyboardUseNotatedPitch().ch.onReceive(this, [this](bool) { + emit pianoKeyboardUseNotatedPitchChanged(); + }); + + dispatcher()->reg(this, SET_NOTATED_PITCH_CODE, [this](const ActionData& args) { + IF_ASSERT_FAILED(args.count() > 0) { + return; + } + + configuration()->setPianoKeyboardUseNotatedPitch(args.arg(0)); + emit pianoKeyboardUseNotatedPitchChanged(); + }); + + return makeMenu(muse::TranslatableString("notation", "Pitch mode for transposing instruments"), items); +} + MenuItem* PianoKeyboardPanelContextMenuModel::makeViewMenu() { MenuItemList items; @@ -167,6 +198,31 @@ MenuItem* PianoKeyboardPanelContextMenuModel::makeNumberOfKeysItem(const muse::T return item; } +MenuItem* PianoKeyboardPanelContextMenuModel::makeToggleNotatedPitchItem(const muse::TranslatableString& title, bool isNotatedPitch) +{ + UiAction action; + action.title = title; + action.code = SET_NOTATED_PITCH_CODE; + action.checkable = Checkable::Yes; + + MenuItem* item = new MenuItem(action, this); + item->setId(QString::fromStdString(SET_NOTATED_PITCH_CODE) + (isNotatedPitch ? "-notated" : "-playback")); + + ValCh currentState = configuration()->pianoKeyboardUseNotatedPitch(); + + bool checked = !(isNotatedPitch ^ currentState.val); + item->setState(UiActionState::make_enabled(checked)); + + currentState.ch.onReceive(item, [item, isNotatedPitch](bool s) { + bool checked = !(isNotatedPitch ^ s); + item->setState(UiActionState::make_enabled(checked)); + }); + + item->setArgs(ActionData::make_arg1(isNotatedPitch)); + + return item; +} + void PianoKeyboardPanelContextMenuModel::updateKeyWidthScalingItems() { qreal roundedCurrentScaling = NORMAL_KEY_WIDTH_SCALING; diff --git a/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.h b/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.h index a2fbb28537703..3ef6838fc37f9 100644 --- a/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.h +++ b/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.h @@ -58,13 +58,17 @@ class PianoKeyboardPanelContextMenuModel : public muse::uicomponents::AbstractMe void keyWidthScalingChanged(); void setKeyWidthScalingRequested(qreal scaling); void numberOfKeysChanged(); + void pianoKeyboardUseNotatedPitchChanged(); private: muse::uicomponents::MenuItem* makeViewMenu(); + muse::uicomponents::MenuItem* makePitchMenu(); muse::uicomponents::MenuItem* makeKeyWidthScalingItem(const muse::TranslatableString& title, qreal scaling); muse::uicomponents::MenuItem* makeNumberOfKeysItem(const muse::TranslatableString& title, int numberOfKeys); + muse::uicomponents::MenuItem* makeToggleNotatedPitchItem(const muse::TranslatableString& title, bool isNotatedPitch); + void updateKeyWidthScalingItems(); muse::uicomponents::MenuItemList m_keyWidthScalingItems; diff --git a/src/stubs/notation/notationconfigurationstub.cpp b/src/stubs/notation/notationconfigurationstub.cpp index 1327ddb1b579a..66d6a51c71053 100644 --- a/src/stubs/notation/notationconfigurationstub.cpp +++ b/src/stubs/notation/notationconfigurationstub.cpp @@ -465,6 +465,16 @@ void NotationConfigurationStub::setPianoKeyboardNumberOfKeys(int) { } +ValCh NotationConfigurationStub::pianoKeyboardUseNotatedPitch() const +{ + static ValCh vch; + return vch; +} + +void NotationConfigurationStub::setPianoKeyboardUseNotatedPitch(bool) +{ +} + bool NotationConfigurationStub::useNewPercussionPanel() const { return false diff --git a/src/stubs/notation/notationconfigurationstub.h b/src/stubs/notation/notationconfigurationstub.h index 6b1b8e811d2c5..c368d74a489a1 100644 --- a/src/stubs/notation/notationconfigurationstub.h +++ b/src/stubs/notation/notationconfigurationstub.h @@ -171,6 +171,9 @@ class NotationConfigurationStub : public INotationConfiguration ValCh pianoKeyboardNumberOfKeys() const override; void setPianoKeyboardNumberOfKeys(int number) override; + ValCh pianoKeyboardUseNotatedPitch() const override; + void setPianoKeyboardUseNotatedPitch(bool value) override; + bool useNewPercussionPanel() const override; void setUseNewPercussionPanel(bool use) override; From d5ca74ad8f2577230c463435a65c741481724e38 Mon Sep 17 00:00:00 2001 From: Robert Patterson Date: Tue, 17 Sep 2024 18:11:06 -0500 Subject: [PATCH 02/14] no message --- src/engraving/dom/edit.cpp | 10 +++++----- src/engraving/dom/score.h | 9 ++------- src/notation/internal/notationmidiinput.cpp | 4 ++-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/engraving/dom/edit.cpp b/src/engraving/dom/edit.cpp index 380f5a9e0c53b..43e7c75069dab 100644 --- a/src/engraving/dom/edit.cpp +++ b/src/engraving/dom/edit.cpp @@ -1563,7 +1563,7 @@ void Score::cmdRemoveTimeSig(TimeSig* ts) Note* Score::addTiedMidiPitch(int pitch, bool addFlag, Chord* prevChord) { - Note* n = addMidiPitch(pitch, addFlag); + Note* n = addMidiPitch(pitch, addFlag, true); if (prevChord) { Note* nn = prevChord->findNote(n->pitch()); if (nn) { @@ -1581,14 +1581,14 @@ Note* Score::addTiedMidiPitch(int pitch, bool addFlag, Chord* prevChord) return n; } -NoteVal Score::noteVal(int pitch) const +NoteVal Score::noteVal(int pitch, bool allowTransposition) const { NoteVal nval(pitch); Staff* st = staff(inputState().track() / VOICES); // if transposing, interpret MIDI pitch as representing desired written pitch // set pitch based on corresponding sounding pitch - if (!style().styleB(Sid::concertPitch) && notationConfiguration()->pianoKeyboardUseNotatedPitch().val) { + if (!style().styleB(Sid::concertPitch) && allowTransposition) { nval.pitch += st->part()->instrument(inputState().tick())->transpose().chromatic; } // let addPitch calculate tpc values from pitch @@ -1602,9 +1602,9 @@ NoteVal Score::noteVal(int pitch) const // addMidiPitch //--------------------------------------------------------- -Note* Score::addMidiPitch(int pitch, bool addFlag) +Note* Score::addMidiPitch(int pitch, bool addFlag, bool allowTransposition) { - NoteVal nval = noteVal(pitch); + NoteVal nval = noteVal(pitch, allowTransposition); return addPitch(nval, addFlag); } diff --git a/src/engraving/dom/score.h b/src/engraving/dom/score.h index 3f1fe2e012b43..502334c3166ee 100644 --- a/src/engraving/dom/score.h +++ b/src/engraving/dom/score.h @@ -90,10 +90,6 @@ namespace mu::engraving::compat { class WriteScoreHook; } -namespace mu::notation { -class INotationConfiguration; -} - namespace mu::engraving { class Articulation; class Audio; @@ -277,7 +273,6 @@ class Score : public EngravingObject, public muse::Injectable muse::Inject engravingFonts = { this }; muse::Inject application = { this }; muse::Inject elementsProvider = { this }; - muse::Inject notationConfiguration = { this }; // internal muse::Inject renderer = { this }; @@ -503,8 +498,8 @@ class Score : public EngravingObject, public muse::Injectable Note* addPitch(NoteVal&, bool addFlag, InputState* externalInputState = nullptr); Note* addTiedMidiPitch(int pitch, bool addFlag, Chord* prevChord); - NoteVal noteVal(int pitch) const; - Note* addMidiPitch(int pitch, bool addFlag); + NoteVal noteVal(int pitch, bool allowTransposition) const; + Note* addMidiPitch(int pitch, bool addFlag, bool allowTransposition); Note* addNote(Chord*, const NoteVal& noteVal, bool forceAccidental = false, const std::set& articulationIds = {}, InputState* externalInputState = nullptr); Note* addNoteToTiedChord(Chord*, const NoteVal& noteVal, bool forceAccidental = false, const std::set& articulationIds = {}); diff --git a/src/notation/internal/notationmidiinput.cpp b/src/notation/internal/notationmidiinput.cpp index 7c8701a995377..4d42b46f41330 100644 --- a/src/notation/internal/notationmidiinput.cpp +++ b/src/notation/internal/notationmidiinput.cpp @@ -212,7 +212,7 @@ Note* NotationMidiInput::addNoteToScore(const muse::midi::Event& e) } } - mu::engraving::Note* note = sc->addMidiPitch(inputEv.pitch, inputEv.chord); + mu::engraving::Note* note = sc->addMidiPitch(inputEv.pitch, inputEv.chord, configuration()->pianoKeyboardUseNotatedPitch().val); sc->activeMidiPitches().push_back(inputEv); @@ -250,7 +250,7 @@ Note* NotationMidiInput::makeNote(const muse::midi::Event& e) note->setParent(chord); note->setStaffIdx(engraving::track2staff(inputState.cr()->track())); - engraving::NoteVal nval = score->noteVal(e.note()); + engraving::NoteVal nval = score->noteVal(e.note(), configuration()->pianoKeyboardUseNotatedPitch().val); note->setNval(nval); return note; From 9711ea2495fd2e949afe4fc578ec6e54ecba64dd Mon Sep 17 00:00:00 2001 From: Robert Patterson Date: Tue, 17 Sep 2024 18:54:51 -0500 Subject: [PATCH 03/14] changes for all midi inputs --- src/engraving/dom/cmd.cpp | 4 ++-- src/engraving/dom/edit.cpp | 4 ++-- src/engraving/dom/score.h | 4 ++-- src/notation/internal/notationmidiinput.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/engraving/dom/cmd.cpp b/src/engraving/dom/cmd.cpp index 0af025c6d9fdd..bcac54f2e12d6 100644 --- a/src/engraving/dom/cmd.cpp +++ b/src/engraving/dom/cmd.cpp @@ -3384,7 +3384,7 @@ void Score::cmdMoveLyrics(Lyrics* lyrics, DirectionV dir) // realtimeAdvance //--------------------------------------------------------- -void Score::realtimeAdvance() +void Score::realtimeAdvance(bool allowTransposition) { InputState& is = inputState(); if (!is.noteEntryMode()) { @@ -3410,7 +3410,7 @@ void Score::realtimeAdvance() Chord* prevChord = prevCR->isChord() ? toChord(prevCR) : 0; bool partOfChord = false; for (const MidiInputEvent& ev : midiPitches) { - addTiedMidiPitch(ev.pitch, partOfChord, prevChord); + addTiedMidiPitch(ev.pitch, partOfChord, prevChord, allowTransposition); partOfChord = true; } } diff --git a/src/engraving/dom/edit.cpp b/src/engraving/dom/edit.cpp index 43e7c75069dab..2eb28169280c0 100644 --- a/src/engraving/dom/edit.cpp +++ b/src/engraving/dom/edit.cpp @@ -1561,9 +1561,9 @@ void Score::cmdRemoveTimeSig(TimeSig* ts) // addTiedMidiPitch //--------------------------------------------------------- -Note* Score::addTiedMidiPitch(int pitch, bool addFlag, Chord* prevChord) +Note* Score::addTiedMidiPitch(int pitch, bool addFlag, Chord* prevChord, bool allowTransposition) { - Note* n = addMidiPitch(pitch, addFlag, true); + Note* n = addMidiPitch(pitch, addFlag, allowTransposition); if (prevChord) { Note* nn = prevChord->findNote(n->pitch()); if (nn) { diff --git a/src/engraving/dom/score.h b/src/engraving/dom/score.h index 502334c3166ee..6074a20b94a24 100644 --- a/src/engraving/dom/score.h +++ b/src/engraving/dom/score.h @@ -382,7 +382,7 @@ class Score : public EngravingObject, public muse::Injectable void cmdMoveRest(Rest*, DirectionV); void cmdMoveLyrics(Lyrics*, DirectionV); - void realtimeAdvance(); + void realtimeAdvance(bool allowTransposition); void addRemoveBreaks(int interval, bool lock); @@ -497,7 +497,7 @@ class Score : public EngravingObject, public muse::Injectable bool containsElement(const EngravingItem*) const; Note* addPitch(NoteVal&, bool addFlag, InputState* externalInputState = nullptr); - Note* addTiedMidiPitch(int pitch, bool addFlag, Chord* prevChord); + Note* addTiedMidiPitch(int pitch, bool addFlag, Chord* prevChord, bool allowTransposition); NoteVal noteVal(int pitch, bool allowTransposition) const; Note* addMidiPitch(int pitch, bool addFlag, bool allowTransposition); Note* addNote(Chord*, const NoteVal& noteVal, bool forceAccidental = false, const std::set& articulationIds = {}, diff --git a/src/notation/internal/notationmidiinput.cpp b/src/notation/internal/notationmidiinput.cpp index 4d42b46f41330..5e23097ff6559 100644 --- a/src/notation/internal/notationmidiinput.cpp +++ b/src/notation/internal/notationmidiinput.cpp @@ -306,7 +306,7 @@ void NotationMidiInput::doRealtimeAdvance() QTimer::singleShot(100, Qt::PreciseTimer, [this]() { m_undoStack->prepareChanges(); - m_getScore->score()->realtimeAdvance(); + m_getScore->score()->realtimeAdvance(configuration()->pianoKeyboardUseNotatedPitch().val); m_undoStack->commitChanges(); }); From fc698e7346ae4893951b51b321c8697b155e4dc3 Mon Sep 17 00:00:00 2001 From: Robert Patterson Date: Tue, 17 Sep 2024 14:25:03 -0500 Subject: [PATCH 04/14] Move property getter and setter for pianoKeyboardUseNotatedPitch to IEngravingConfiguration to make it accessible in Score class. --- src/engraving/iengravingconfiguration.h | 4 ++++ .../internal/engravingconfiguration.cpp | 19 +++++++++++++++++++ .../internal/engravingconfiguration.h | 4 ++++ .../tests/mocks/engravingconfigurationmock.h | 3 +++ src/notation/inotationconfiguration.h | 3 --- .../internal/notationconfiguration.cpp | 17 ----------------- src/notation/internal/notationconfiguration.h | 4 ---- .../tests/mocks/notationconfigurationmock.h | 3 --- .../pianokeyboard/pianokeyboardcontroller.h | 2 +- .../pianokeyboardpanelcontextmenumodel.cpp | 6 +++--- .../pianokeyboardpanelcontextmenumodel.h | 1 + 11 files changed, 35 insertions(+), 31 deletions(-) diff --git a/src/engraving/iengravingconfiguration.h b/src/engraving/iengravingconfiguration.h index 986673444ba72..f29a2bc0e6352 100644 --- a/src/engraving/iengravingconfiguration.h +++ b/src/engraving/iengravingconfiguration.h @@ -28,6 +28,7 @@ #include "async/channel.h" #include "async/notification.h" #include "engraving/types/types.h" +#include "framework/global/types/retval.h" namespace muse::draw { class Color; @@ -116,6 +117,9 @@ class IEngravingConfiguration : MODULE_EXPORT_INTERFACE virtual bool isAccessibleEnabled() const = 0; + virtual muse::ValCh pianoKeyboardUseNotatedPitch() const = 0; + virtual void setPianoKeyboardUseNotatedPitch(bool useNotatedPitch) = 0; + /// these configurations will be removed after solving https://github.com/musescore/MuseScore/issues/14294 virtual bool guitarProImportExperimental() const = 0; virtual bool useStretchedBends() const = 0; diff --git a/src/engraving/internal/engravingconfiguration.cpp b/src/engraving/internal/engravingconfiguration.cpp index 608518e737672..3a46c02ca8b51 100644 --- a/src/engraving/internal/engravingconfiguration.cpp +++ b/src/engraving/internal/engravingconfiguration.cpp @@ -51,6 +51,8 @@ static const Settings::Key UNLINKED_COLOR("engraving", "engraving/colors/unlinke static const Settings::Key DYNAMICS_APPLY_TO_ALL_VOICES("engraving", "score/dynamicsApplyToAllVoices"); +static const Settings::Key PIANO_KEYBOARD_PITCH_STATE("engraving", "pianoKeyboard/useNotatedPitch"); + struct VoiceColor { Settings::Key key; Color color; @@ -105,6 +107,12 @@ void EngravingConfiguration::init() settings()->setDefaultValue(DYNAMICS_APPLY_TO_ALL_VOICES, Val(true)); + settings()->setDefaultValue(PIANO_KEYBOARD_PITCH_STATE, Val(true)); + m_pianoKeyboardUseNotatedPitch.val = settings()->value(PIANO_KEYBOARD_PITCH_STATE).toBool(); + settings()->valueChanged(PIANO_KEYBOARD_PITCH_STATE).onReceive(this, [this](const Val& val) { + m_pianoKeyboardUseNotatedPitch.set(val.toBool()); + }); + settings()->setDefaultValue(FORMATTING_COLOR, Val(Color("#A0A0A4").toQColor())); settings()->setDescription(FORMATTING_COLOR, muse::trc("engraving", "Formatting color")); settings()->setCanBeManuallyEdited(FORMATTING_COLOR, true); @@ -304,6 +312,17 @@ void EngravingConfiguration::setDynamicsApplyToAllVoices(bool v) settings()->setSharedValue(DYNAMICS_APPLY_TO_ALL_VOICES, Val(v)); } +muse::ValCh EngravingConfiguration::pianoKeyboardUseNotatedPitch() const +{ + return m_pianoKeyboardUseNotatedPitch; +} + +void EngravingConfiguration::setPianoKeyboardUseNotatedPitch(bool useNotatedPitch) +{ + settings()->setSharedValue(PIANO_KEYBOARD_PITCH_STATE, Val(useNotatedPitch)); +} + + muse::async::Notification EngravingConfiguration::scoreInversionChanged() const { return m_scoreInversionChanged; diff --git a/src/engraving/internal/engravingconfiguration.h b/src/engraving/internal/engravingconfiguration.h index 81b862a872ffc..24db39fbd663c 100644 --- a/src/engraving/internal/engravingconfiguration.h +++ b/src/engraving/internal/engravingconfiguration.h @@ -99,6 +99,9 @@ class EngravingConfiguration : public IEngravingConfiguration, public muse::Inje bool isAccessibleEnabled() const override; + muse::ValCh pianoKeyboardUseNotatedPitch() const override; + void setPianoKeyboardUseNotatedPitch(bool useNotatedPitch) override; + bool guitarProImportExperimental() const override; bool useStretchedBends() const override; bool shouldAddParenthesisOnStandardStaff() const override; @@ -119,6 +122,7 @@ class EngravingConfiguration : public IEngravingConfiguration, public muse::Inje muse::ValNt m_debuggingOptions; bool m_multiVoice = false; + muse::ValCh m_pianoKeyboardUseNotatedPitch; }; } diff --git a/src/engraving/tests/mocks/engravingconfigurationmock.h b/src/engraving/tests/mocks/engravingconfigurationmock.h index 6cb76baad624e..1c2e1c6f008cb 100644 --- a/src/engraving/tests/mocks/engravingconfigurationmock.h +++ b/src/engraving/tests/mocks/engravingconfigurationmock.h @@ -64,6 +64,9 @@ class EngravingConfigurationMock : public IEngravingConfiguration MOCK_METHOD(bool, dynamicsApplyToAllVoices, (), (const, override)); MOCK_METHOD(void, setDynamicsApplyToAllVoices, (bool), (override)); + MOCK_METHOD(muse::ValCh, pianoKeyboardUseNotatedPitch, (), (const, override)); + MOCK_METHOD(void, setPianoKeyboardUseNotatedPitch, (bool), (override)); + MOCK_METHOD(bool, scoreInversionEnabled, (), (const, override)); MOCK_METHOD(void, setScoreInversionEnabled, (bool), (override)); MOCK_METHOD(muse::async::Notification, scoreInversionChanged, (), (const, override)); diff --git a/src/notation/inotationconfiguration.h b/src/notation/inotationconfiguration.h index 4ce05ee8748dc..ed4b51d9a2fa8 100644 --- a/src/notation/inotationconfiguration.h +++ b/src/notation/inotationconfiguration.h @@ -193,9 +193,6 @@ class INotationConfiguration : MODULE_EXPORT_INTERFACE virtual muse::ValCh pianoKeyboardNumberOfKeys() const = 0; virtual void setPianoKeyboardNumberOfKeys(int number) = 0; - virtual muse::ValCh pianoKeyboardUseNotatedPitch() const = 0; - virtual void setPianoKeyboardUseNotatedPitch(bool useNotatedPitch) = 0; - // TODO: Delete when the new percussion panel is finished virtual bool useNewPercussionPanel() const = 0; virtual void setUseNewPercussionPanel(bool use) = 0; diff --git a/src/notation/internal/notationconfiguration.cpp b/src/notation/internal/notationconfiguration.cpp index fe1dae7914a9a..80331f0cbfab6 100644 --- a/src/notation/internal/notationconfiguration.cpp +++ b/src/notation/internal/notationconfiguration.cpp @@ -89,7 +89,6 @@ static const Settings::Key NEED_TO_SHOW_ADD_FIGURED_BASS_ERROR_MESSAGE_KEY(modul static const Settings::Key NEED_TO_SHOW_ADD_GUITAR_BEND_ERROR_MESSAGE_KEY(module_name, "ui/dialogs/needToShowAddGuitarBendErrorMessage"); static const Settings::Key PIANO_KEYBOARD_NUMBER_OF_KEYS(module_name, "pianoKeyboard/numberOfKeys"); -static const Settings::Key PIANO_KEYBOARD_PITCH_STATE(module_name, "pianoKeyboard/useNotatedPitch"); static const Settings::Key USE_NEW_PERCUSSION_PANEL_KEY(module_name, "ui/useNewPercussionPanel"); static const Settings::Key AUTO_SHOW_PERCUSSION_PANEL_KEY(module_name, "ui/autoShowPercussionPanel"); @@ -221,12 +220,6 @@ void NotationConfiguration::init() m_pianoKeyboardNumberOfKeys.set(val.toInt()); }); - settings()->setDefaultValue(PIANO_KEYBOARD_PITCH_STATE, Val(true)); - m_pianoKeyboardUseNotatedPitch.val = settings()->value(PIANO_KEYBOARD_PITCH_STATE).toBool(); - settings()->valueChanged(PIANO_KEYBOARD_PITCH_STATE).onReceive(this, [this](const Val& val) { - m_pianoKeyboardUseNotatedPitch.set(val.toBool()); - }); - settings()->setDefaultValue(USE_NEW_PERCUSSION_PANEL_KEY, Val(false)); settings()->setDefaultValue(AUTO_SHOW_PERCUSSION_PANEL_KEY, Val(true)); @@ -926,16 +919,6 @@ void NotationConfiguration::setPianoKeyboardNumberOfKeys(int number) settings()->setSharedValue(PIANO_KEYBOARD_NUMBER_OF_KEYS, Val(number)); } -ValCh NotationConfiguration::pianoKeyboardUseNotatedPitch() const -{ - return m_pianoKeyboardUseNotatedPitch; -} - -void NotationConfiguration::setPianoKeyboardUseNotatedPitch(bool useNotatedPitch) -{ - settings()->setSharedValue(PIANO_KEYBOARD_PITCH_STATE, Val(useNotatedPitch)); -} - muse::io::path_t NotationConfiguration::firstScoreOrderListPath() const { return settings()->value(FIRST_SCORE_ORDER_LIST_KEY).toString(); diff --git a/src/notation/internal/notationconfiguration.h b/src/notation/internal/notationconfiguration.h index 78a998ae2d089..78e929d23a389 100644 --- a/src/notation/internal/notationconfiguration.h +++ b/src/notation/internal/notationconfiguration.h @@ -198,9 +198,6 @@ class NotationConfiguration : public INotationConfiguration, public muse::async: muse::ValCh pianoKeyboardNumberOfKeys() const override; void setPianoKeyboardNumberOfKeys(int number) override; - muse::ValCh pianoKeyboardUseNotatedPitch() const override; - void setPianoKeyboardUseNotatedPitch(bool useNotatedPitch) override; - bool useNewPercussionPanel() const override; void setUseNewPercussionPanel(bool use) override; @@ -234,7 +231,6 @@ class NotationConfiguration : public INotationConfiguration, public muse::async: muse::async::Notification m_isPlayRepeatsChanged; muse::async::Notification m_isPlayChordSymbolsChanged; muse::ValCh m_pianoKeyboardNumberOfKeys; - muse::ValCh m_pianoKeyboardUseNotatedPitch; muse::async::Channel m_anchorColorChanged; int m_styleDialogLastPageIndex = 0; diff --git a/src/notation/tests/mocks/notationconfigurationmock.h b/src/notation/tests/mocks/notationconfigurationmock.h index b0bf76334c631..ce45c0fff2fdc 100644 --- a/src/notation/tests/mocks/notationconfigurationmock.h +++ b/src/notation/tests/mocks/notationconfigurationmock.h @@ -183,9 +183,6 @@ class NotationConfigurationMock : public INotationConfiguration MOCK_METHOD(muse::ValCh, pianoKeyboardNumberOfKeys, (), (const, override)); MOCK_METHOD(void, setPianoKeyboardNumberOfKeys, (int), (override)); - MOCK_METHOD(muse::ValCh, pianoKeyboardUseNotatedPitch, (), (const, override)); - MOCK_METHOD(void, setPianoKeyboardUseNotatedPitch, (bool), (override)); - MOCK_METHOD(bool, useNewPercussionPanel, (), (const, override)); MOCK_METHOD(void, setUseNewPercussionPanel, (bool), (override)); diff --git a/src/notation/view/pianokeyboard/pianokeyboardcontroller.h b/src/notation/view/pianokeyboard/pianokeyboardcontroller.h index 0170c5ac630fc..468c557eb47ae 100644 --- a/src/notation/view/pianokeyboard/pianokeyboardcontroller.h +++ b/src/notation/view/pianokeyboard/pianokeyboardcontroller.h @@ -32,7 +32,7 @@ namespace mu::notation { class PianoKeyboardController : public muse::Injectable, public muse::async::Asyncable { - muse::Inject configuration = { this }; + muse::Inject configuration = { this }; muse::Inject context = { this }; public: diff --git a/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.cpp b/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.cpp index ae19e847accae..b35eea6232b45 100644 --- a/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.cpp +++ b/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.cpp @@ -86,7 +86,7 @@ MenuItem* PianoKeyboardPanelContextMenuModel::makePitchMenu() items << makeToggleNotatedPitchItem(title, notationState); } - configuration()->pianoKeyboardUseNotatedPitch().ch.onReceive(this, [this](bool) { + engravingConfiguration()->pianoKeyboardUseNotatedPitch().ch.onReceive(this, [this](bool) { emit pianoKeyboardUseNotatedPitchChanged(); }); @@ -95,7 +95,7 @@ MenuItem* PianoKeyboardPanelContextMenuModel::makePitchMenu() return; } - configuration()->setPianoKeyboardUseNotatedPitch(args.arg(0)); + engravingConfiguration()->setPianoKeyboardUseNotatedPitch(args.arg(0)); emit pianoKeyboardUseNotatedPitchChanged(); }); @@ -208,7 +208,7 @@ MenuItem* PianoKeyboardPanelContextMenuModel::makeToggleNotatedPitchItem(const m MenuItem* item = new MenuItem(action, this); item->setId(QString::fromStdString(SET_NOTATED_PITCH_CODE) + (isNotatedPitch ? "-notated" : "-playback")); - ValCh currentState = configuration()->pianoKeyboardUseNotatedPitch(); + ValCh currentState = engravingConfiguration()->pianoKeyboardUseNotatedPitch(); bool checked = !(isNotatedPitch ^ currentState.val); item->setState(UiActionState::make_enabled(checked)); diff --git a/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.h b/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.h index 3ef6838fc37f9..7641286529d82 100644 --- a/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.h +++ b/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.h @@ -42,6 +42,7 @@ class PianoKeyboardPanelContextMenuModel : public muse::uicomponents::AbstractMe Q_PROPERTY(qreal keyWidthScaling READ keyWidthScaling WRITE setKeyWidthScaling NOTIFY keyWidthScalingChanged) muse::Inject configuration = { this }; + muse::Inject engravingConfiguration = { this }; muse::Inject dispatcher = { this }; public: From c244f271e20baf9deeafbaef7f7d13c89807f8ca Mon Sep 17 00:00:00 2001 From: Robert Patterson Date: Tue, 17 Sep 2024 14:56:36 -0500 Subject: [PATCH 05/14] uncrustification --- src/engraving/internal/engravingconfiguration.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/engraving/internal/engravingconfiguration.cpp b/src/engraving/internal/engravingconfiguration.cpp index 3a46c02ca8b51..09ec40aa70790 100644 --- a/src/engraving/internal/engravingconfiguration.cpp +++ b/src/engraving/internal/engravingconfiguration.cpp @@ -322,7 +322,6 @@ void EngravingConfiguration::setPianoKeyboardUseNotatedPitch(bool useNotatedPitc settings()->setSharedValue(PIANO_KEYBOARD_PITCH_STATE, Val(useNotatedPitch)); } - muse::async::Notification EngravingConfiguration::scoreInversionChanged() const { return m_scoreInversionChanged; From 867ca44acc1afabcc934d88342993a60ac8d3c5e Mon Sep 17 00:00:00 2001 From: Robert Patterson Date: Tue, 17 Sep 2024 16:10:44 -0500 Subject: [PATCH 06/14] remove unneeded stub functions --- src/stubs/notation/notationconfigurationstub.cpp | 10 ---------- src/stubs/notation/notationconfigurationstub.h | 3 --- 2 files changed, 13 deletions(-) diff --git a/src/stubs/notation/notationconfigurationstub.cpp b/src/stubs/notation/notationconfigurationstub.cpp index 66d6a51c71053..1327ddb1b579a 100644 --- a/src/stubs/notation/notationconfigurationstub.cpp +++ b/src/stubs/notation/notationconfigurationstub.cpp @@ -465,16 +465,6 @@ void NotationConfigurationStub::setPianoKeyboardNumberOfKeys(int) { } -ValCh NotationConfigurationStub::pianoKeyboardUseNotatedPitch() const -{ - static ValCh vch; - return vch; -} - -void NotationConfigurationStub::setPianoKeyboardUseNotatedPitch(bool) -{ -} - bool NotationConfigurationStub::useNewPercussionPanel() const { return false diff --git a/src/stubs/notation/notationconfigurationstub.h b/src/stubs/notation/notationconfigurationstub.h index c368d74a489a1..6b1b8e811d2c5 100644 --- a/src/stubs/notation/notationconfigurationstub.h +++ b/src/stubs/notation/notationconfigurationstub.h @@ -171,9 +171,6 @@ class NotationConfigurationStub : public INotationConfiguration ValCh pianoKeyboardNumberOfKeys() const override; void setPianoKeyboardNumberOfKeys(int number) override; - ValCh pianoKeyboardUseNotatedPitch() const override; - void setPianoKeyboardUseNotatedPitch(bool value) override; - bool useNewPercussionPanel() const override; void setUseNewPercussionPanel(bool use) override; From 03e217a2ea774604edf24d328829e7bc140a5fe0 Mon Sep 17 00:00:00 2001 From: Robert Patterson Date: Tue, 17 Sep 2024 19:12:21 -0500 Subject: [PATCH 07/14] reverted to using INotationConfiguration with a boolean passed into Score, plus other codereview fixes. --- src/engraving/iengravingconfiguration.h | 4 ---- .../internal/engravingconfiguration.cpp | 18 ------------------ .../internal/engravingconfiguration.h | 4 ---- .../tests/mocks/engravingconfigurationmock.h | 3 --- src/notation/inotationconfiguration.h | 3 +++ .../internal/notationconfiguration.cpp | 17 +++++++++++++++++ src/notation/internal/notationconfiguration.h | 4 ++++ .../tests/mocks/notationconfigurationmock.h | 3 +++ .../pianokeyboard/pianokeyboardcontroller.cpp | 2 +- .../pianokeyboard/pianokeyboardcontroller.h | 3 ++- .../pianokeyboardpanelcontextmenumodel.cpp | 6 +++--- .../pianokeyboardpanelcontextmenumodel.h | 1 - .../notation/notationconfigurationstub.cpp | 10 ++++++++++ src/stubs/notation/notationconfigurationstub.h | 3 +++ 14 files changed, 46 insertions(+), 35 deletions(-) diff --git a/src/engraving/iengravingconfiguration.h b/src/engraving/iengravingconfiguration.h index f29a2bc0e6352..986673444ba72 100644 --- a/src/engraving/iengravingconfiguration.h +++ b/src/engraving/iengravingconfiguration.h @@ -28,7 +28,6 @@ #include "async/channel.h" #include "async/notification.h" #include "engraving/types/types.h" -#include "framework/global/types/retval.h" namespace muse::draw { class Color; @@ -117,9 +116,6 @@ class IEngravingConfiguration : MODULE_EXPORT_INTERFACE virtual bool isAccessibleEnabled() const = 0; - virtual muse::ValCh pianoKeyboardUseNotatedPitch() const = 0; - virtual void setPianoKeyboardUseNotatedPitch(bool useNotatedPitch) = 0; - /// these configurations will be removed after solving https://github.com/musescore/MuseScore/issues/14294 virtual bool guitarProImportExperimental() const = 0; virtual bool useStretchedBends() const = 0; diff --git a/src/engraving/internal/engravingconfiguration.cpp b/src/engraving/internal/engravingconfiguration.cpp index 09ec40aa70790..608518e737672 100644 --- a/src/engraving/internal/engravingconfiguration.cpp +++ b/src/engraving/internal/engravingconfiguration.cpp @@ -51,8 +51,6 @@ static const Settings::Key UNLINKED_COLOR("engraving", "engraving/colors/unlinke static const Settings::Key DYNAMICS_APPLY_TO_ALL_VOICES("engraving", "score/dynamicsApplyToAllVoices"); -static const Settings::Key PIANO_KEYBOARD_PITCH_STATE("engraving", "pianoKeyboard/useNotatedPitch"); - struct VoiceColor { Settings::Key key; Color color; @@ -107,12 +105,6 @@ void EngravingConfiguration::init() settings()->setDefaultValue(DYNAMICS_APPLY_TO_ALL_VOICES, Val(true)); - settings()->setDefaultValue(PIANO_KEYBOARD_PITCH_STATE, Val(true)); - m_pianoKeyboardUseNotatedPitch.val = settings()->value(PIANO_KEYBOARD_PITCH_STATE).toBool(); - settings()->valueChanged(PIANO_KEYBOARD_PITCH_STATE).onReceive(this, [this](const Val& val) { - m_pianoKeyboardUseNotatedPitch.set(val.toBool()); - }); - settings()->setDefaultValue(FORMATTING_COLOR, Val(Color("#A0A0A4").toQColor())); settings()->setDescription(FORMATTING_COLOR, muse::trc("engraving", "Formatting color")); settings()->setCanBeManuallyEdited(FORMATTING_COLOR, true); @@ -312,16 +304,6 @@ void EngravingConfiguration::setDynamicsApplyToAllVoices(bool v) settings()->setSharedValue(DYNAMICS_APPLY_TO_ALL_VOICES, Val(v)); } -muse::ValCh EngravingConfiguration::pianoKeyboardUseNotatedPitch() const -{ - return m_pianoKeyboardUseNotatedPitch; -} - -void EngravingConfiguration::setPianoKeyboardUseNotatedPitch(bool useNotatedPitch) -{ - settings()->setSharedValue(PIANO_KEYBOARD_PITCH_STATE, Val(useNotatedPitch)); -} - muse::async::Notification EngravingConfiguration::scoreInversionChanged() const { return m_scoreInversionChanged; diff --git a/src/engraving/internal/engravingconfiguration.h b/src/engraving/internal/engravingconfiguration.h index 24db39fbd663c..81b862a872ffc 100644 --- a/src/engraving/internal/engravingconfiguration.h +++ b/src/engraving/internal/engravingconfiguration.h @@ -99,9 +99,6 @@ class EngravingConfiguration : public IEngravingConfiguration, public muse::Inje bool isAccessibleEnabled() const override; - muse::ValCh pianoKeyboardUseNotatedPitch() const override; - void setPianoKeyboardUseNotatedPitch(bool useNotatedPitch) override; - bool guitarProImportExperimental() const override; bool useStretchedBends() const override; bool shouldAddParenthesisOnStandardStaff() const override; @@ -122,7 +119,6 @@ class EngravingConfiguration : public IEngravingConfiguration, public muse::Inje muse::ValNt m_debuggingOptions; bool m_multiVoice = false; - muse::ValCh m_pianoKeyboardUseNotatedPitch; }; } diff --git a/src/engraving/tests/mocks/engravingconfigurationmock.h b/src/engraving/tests/mocks/engravingconfigurationmock.h index 1c2e1c6f008cb..6cb76baad624e 100644 --- a/src/engraving/tests/mocks/engravingconfigurationmock.h +++ b/src/engraving/tests/mocks/engravingconfigurationmock.h @@ -64,9 +64,6 @@ class EngravingConfigurationMock : public IEngravingConfiguration MOCK_METHOD(bool, dynamicsApplyToAllVoices, (), (const, override)); MOCK_METHOD(void, setDynamicsApplyToAllVoices, (bool), (override)); - MOCK_METHOD(muse::ValCh, pianoKeyboardUseNotatedPitch, (), (const, override)); - MOCK_METHOD(void, setPianoKeyboardUseNotatedPitch, (bool), (override)); - MOCK_METHOD(bool, scoreInversionEnabled, (), (const, override)); MOCK_METHOD(void, setScoreInversionEnabled, (bool), (override)); MOCK_METHOD(muse::async::Notification, scoreInversionChanged, (), (const, override)); diff --git a/src/notation/inotationconfiguration.h b/src/notation/inotationconfiguration.h index ed4b51d9a2fa8..4ce05ee8748dc 100644 --- a/src/notation/inotationconfiguration.h +++ b/src/notation/inotationconfiguration.h @@ -193,6 +193,9 @@ class INotationConfiguration : MODULE_EXPORT_INTERFACE virtual muse::ValCh pianoKeyboardNumberOfKeys() const = 0; virtual void setPianoKeyboardNumberOfKeys(int number) = 0; + virtual muse::ValCh pianoKeyboardUseNotatedPitch() const = 0; + virtual void setPianoKeyboardUseNotatedPitch(bool useNotatedPitch) = 0; + // TODO: Delete when the new percussion panel is finished virtual bool useNewPercussionPanel() const = 0; virtual void setUseNewPercussionPanel(bool use) = 0; diff --git a/src/notation/internal/notationconfiguration.cpp b/src/notation/internal/notationconfiguration.cpp index 80331f0cbfab6..fe1dae7914a9a 100644 --- a/src/notation/internal/notationconfiguration.cpp +++ b/src/notation/internal/notationconfiguration.cpp @@ -89,6 +89,7 @@ static const Settings::Key NEED_TO_SHOW_ADD_FIGURED_BASS_ERROR_MESSAGE_KEY(modul static const Settings::Key NEED_TO_SHOW_ADD_GUITAR_BEND_ERROR_MESSAGE_KEY(module_name, "ui/dialogs/needToShowAddGuitarBendErrorMessage"); static const Settings::Key PIANO_KEYBOARD_NUMBER_OF_KEYS(module_name, "pianoKeyboard/numberOfKeys"); +static const Settings::Key PIANO_KEYBOARD_PITCH_STATE(module_name, "pianoKeyboard/useNotatedPitch"); static const Settings::Key USE_NEW_PERCUSSION_PANEL_KEY(module_name, "ui/useNewPercussionPanel"); static const Settings::Key AUTO_SHOW_PERCUSSION_PANEL_KEY(module_name, "ui/autoShowPercussionPanel"); @@ -220,6 +221,12 @@ void NotationConfiguration::init() m_pianoKeyboardNumberOfKeys.set(val.toInt()); }); + settings()->setDefaultValue(PIANO_KEYBOARD_PITCH_STATE, Val(true)); + m_pianoKeyboardUseNotatedPitch.val = settings()->value(PIANO_KEYBOARD_PITCH_STATE).toBool(); + settings()->valueChanged(PIANO_KEYBOARD_PITCH_STATE).onReceive(this, [this](const Val& val) { + m_pianoKeyboardUseNotatedPitch.set(val.toBool()); + }); + settings()->setDefaultValue(USE_NEW_PERCUSSION_PANEL_KEY, Val(false)); settings()->setDefaultValue(AUTO_SHOW_PERCUSSION_PANEL_KEY, Val(true)); @@ -919,6 +926,16 @@ void NotationConfiguration::setPianoKeyboardNumberOfKeys(int number) settings()->setSharedValue(PIANO_KEYBOARD_NUMBER_OF_KEYS, Val(number)); } +ValCh NotationConfiguration::pianoKeyboardUseNotatedPitch() const +{ + return m_pianoKeyboardUseNotatedPitch; +} + +void NotationConfiguration::setPianoKeyboardUseNotatedPitch(bool useNotatedPitch) +{ + settings()->setSharedValue(PIANO_KEYBOARD_PITCH_STATE, Val(useNotatedPitch)); +} + muse::io::path_t NotationConfiguration::firstScoreOrderListPath() const { return settings()->value(FIRST_SCORE_ORDER_LIST_KEY).toString(); diff --git a/src/notation/internal/notationconfiguration.h b/src/notation/internal/notationconfiguration.h index 78e929d23a389..78a998ae2d089 100644 --- a/src/notation/internal/notationconfiguration.h +++ b/src/notation/internal/notationconfiguration.h @@ -198,6 +198,9 @@ class NotationConfiguration : public INotationConfiguration, public muse::async: muse::ValCh pianoKeyboardNumberOfKeys() const override; void setPianoKeyboardNumberOfKeys(int number) override; + muse::ValCh pianoKeyboardUseNotatedPitch() const override; + void setPianoKeyboardUseNotatedPitch(bool useNotatedPitch) override; + bool useNewPercussionPanel() const override; void setUseNewPercussionPanel(bool use) override; @@ -231,6 +234,7 @@ class NotationConfiguration : public INotationConfiguration, public muse::async: muse::async::Notification m_isPlayRepeatsChanged; muse::async::Notification m_isPlayChordSymbolsChanged; muse::ValCh m_pianoKeyboardNumberOfKeys; + muse::ValCh m_pianoKeyboardUseNotatedPitch; muse::async::Channel m_anchorColorChanged; int m_styleDialogLastPageIndex = 0; diff --git a/src/notation/tests/mocks/notationconfigurationmock.h b/src/notation/tests/mocks/notationconfigurationmock.h index ce45c0fff2fdc..b0bf76334c631 100644 --- a/src/notation/tests/mocks/notationconfigurationmock.h +++ b/src/notation/tests/mocks/notationconfigurationmock.h @@ -183,6 +183,9 @@ class NotationConfigurationMock : public INotationConfiguration MOCK_METHOD(muse::ValCh, pianoKeyboardNumberOfKeys, (), (const, override)); MOCK_METHOD(void, setPianoKeyboardNumberOfKeys, (int), (override)); + MOCK_METHOD(muse::ValCh, pianoKeyboardUseNotatedPitch, (), (const, override)); + MOCK_METHOD(void, setPianoKeyboardUseNotatedPitch, (bool), (override)); + MOCK_METHOD(bool, useNewPercussionPanel, (), (const, override)); MOCK_METHOD(void, setUseNewPercussionPanel, (bool), (override)); diff --git a/src/notation/view/pianokeyboard/pianokeyboardcontroller.cpp b/src/notation/view/pianokeyboard/pianokeyboardcontroller.cpp index 124f6a57e342b..82fe3bfc5662f 100644 --- a/src/notation/view/pianokeyboard/pianokeyboardcontroller.cpp +++ b/src/notation/view/pianokeyboard/pianokeyboardcontroller.cpp @@ -178,5 +178,5 @@ INotationPtr PianoKeyboardController::currentNotation() const bool PianoKeyboardController::useNotatedPitch() const { - return configuration()->pianoKeyboardUseNotatedPitch().val; + return notationConfiguration()->pianoKeyboardUseNotatedPitch().val; } diff --git a/src/notation/view/pianokeyboard/pianokeyboardcontroller.h b/src/notation/view/pianokeyboard/pianokeyboardcontroller.h index 468c557eb47ae..907ee6bd67c23 100644 --- a/src/notation/view/pianokeyboard/pianokeyboardcontroller.h +++ b/src/notation/view/pianokeyboard/pianokeyboardcontroller.h @@ -26,13 +26,14 @@ #include "modularity/ioc.h" #include "context/iglobalcontext.h" +#include "inotationconfiguration.h" #include "pianokeyboardtypes.h" namespace mu::notation { class PianoKeyboardController : public muse::Injectable, public muse::async::Asyncable { - muse::Inject configuration = { this }; + muse::Inject notationConfiguration = { this }; muse::Inject context = { this }; public: diff --git a/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.cpp b/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.cpp index b35eea6232b45..ae19e847accae 100644 --- a/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.cpp +++ b/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.cpp @@ -86,7 +86,7 @@ MenuItem* PianoKeyboardPanelContextMenuModel::makePitchMenu() items << makeToggleNotatedPitchItem(title, notationState); } - engravingConfiguration()->pianoKeyboardUseNotatedPitch().ch.onReceive(this, [this](bool) { + configuration()->pianoKeyboardUseNotatedPitch().ch.onReceive(this, [this](bool) { emit pianoKeyboardUseNotatedPitchChanged(); }); @@ -95,7 +95,7 @@ MenuItem* PianoKeyboardPanelContextMenuModel::makePitchMenu() return; } - engravingConfiguration()->setPianoKeyboardUseNotatedPitch(args.arg(0)); + configuration()->setPianoKeyboardUseNotatedPitch(args.arg(0)); emit pianoKeyboardUseNotatedPitchChanged(); }); @@ -208,7 +208,7 @@ MenuItem* PianoKeyboardPanelContextMenuModel::makeToggleNotatedPitchItem(const m MenuItem* item = new MenuItem(action, this); item->setId(QString::fromStdString(SET_NOTATED_PITCH_CODE) + (isNotatedPitch ? "-notated" : "-playback")); - ValCh currentState = engravingConfiguration()->pianoKeyboardUseNotatedPitch(); + ValCh currentState = configuration()->pianoKeyboardUseNotatedPitch(); bool checked = !(isNotatedPitch ^ currentState.val); item->setState(UiActionState::make_enabled(checked)); diff --git a/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.h b/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.h index 7641286529d82..3ef6838fc37f9 100644 --- a/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.h +++ b/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.h @@ -42,7 +42,6 @@ class PianoKeyboardPanelContextMenuModel : public muse::uicomponents::AbstractMe Q_PROPERTY(qreal keyWidthScaling READ keyWidthScaling WRITE setKeyWidthScaling NOTIFY keyWidthScalingChanged) muse::Inject configuration = { this }; - muse::Inject engravingConfiguration = { this }; muse::Inject dispatcher = { this }; public: diff --git a/src/stubs/notation/notationconfigurationstub.cpp b/src/stubs/notation/notationconfigurationstub.cpp index 1327ddb1b579a..66d6a51c71053 100644 --- a/src/stubs/notation/notationconfigurationstub.cpp +++ b/src/stubs/notation/notationconfigurationstub.cpp @@ -465,6 +465,16 @@ void NotationConfigurationStub::setPianoKeyboardNumberOfKeys(int) { } +ValCh NotationConfigurationStub::pianoKeyboardUseNotatedPitch() const +{ + static ValCh vch; + return vch; +} + +void NotationConfigurationStub::setPianoKeyboardUseNotatedPitch(bool) +{ +} + bool NotationConfigurationStub::useNewPercussionPanel() const { return false diff --git a/src/stubs/notation/notationconfigurationstub.h b/src/stubs/notation/notationconfigurationstub.h index 6b1b8e811d2c5..c368d74a489a1 100644 --- a/src/stubs/notation/notationconfigurationstub.h +++ b/src/stubs/notation/notationconfigurationstub.h @@ -171,6 +171,9 @@ class NotationConfigurationStub : public INotationConfiguration ValCh pianoKeyboardNumberOfKeys() const override; void setPianoKeyboardNumberOfKeys(int number) override; + ValCh pianoKeyboardUseNotatedPitch() const override; + void setPianoKeyboardUseNotatedPitch(bool value) override; + bool useNewPercussionPanel() const override; void setUseNewPercussionPanel(bool use) override; From 47d2f727338042ec569ba0132eef17949ddc4b8f Mon Sep 17 00:00:00 2001 From: Robert Patterson Date: Wed, 18 Sep 2024 18:46:02 -0500 Subject: [PATCH 08/14] move menu to playback bar and use terse menu text --- src/notation/inotationconfiguration.h | 4 +- .../internal/notationconfiguration.cpp | 14 ++--- src/notation/internal/notationconfiguration.h | 6 +- src/notation/internal/notationmidiinput.cpp | 6 +- .../tests/mocks/notationconfigurationmock.h | 4 +- .../pianokeyboard/pianokeyboardcontroller.cpp | 8 +-- .../pianokeyboard/pianokeyboardcontroller.h | 2 +- .../pianokeyboardpanelcontextmenumodel.cpp | 58 +------------------ .../pianokeyboardpanelcontextmenumodel.h | 4 -- src/playback/internal/playbackcontroller.cpp | 14 +++++ src/playback/internal/playbackcontroller.h | 1 + src/playback/internal/playbackuiactions.cpp | 36 +++++++++++- src/playback/internal/playbackuiactions.h | 4 ++ src/playback/view/playbacktoolbarmodel.cpp | 24 ++++++++ src/playback/view/playbacktoolbarmodel.h | 3 + 15 files changed, 104 insertions(+), 84 deletions(-) diff --git a/src/notation/inotationconfiguration.h b/src/notation/inotationconfiguration.h index 4ce05ee8748dc..9a65b6a90575f 100644 --- a/src/notation/inotationconfiguration.h +++ b/src/notation/inotationconfiguration.h @@ -193,8 +193,8 @@ class INotationConfiguration : MODULE_EXPORT_INTERFACE virtual muse::ValCh pianoKeyboardNumberOfKeys() const = 0; virtual void setPianoKeyboardNumberOfKeys(int number) = 0; - virtual muse::ValCh pianoKeyboardUseNotatedPitch() const = 0; - virtual void setPianoKeyboardUseNotatedPitch(bool useNotatedPitch) = 0; + virtual muse::ValCh midiUseWrittenPitch() const = 0; + virtual void setMidiUseWrittenPitch(bool useWrittenPitch) = 0; // TODO: Delete when the new percussion panel is finished virtual bool useNewPercussionPanel() const = 0; diff --git a/src/notation/internal/notationconfiguration.cpp b/src/notation/internal/notationconfiguration.cpp index fe1dae7914a9a..cf49ab1526607 100644 --- a/src/notation/internal/notationconfiguration.cpp +++ b/src/notation/internal/notationconfiguration.cpp @@ -89,7 +89,7 @@ static const Settings::Key NEED_TO_SHOW_ADD_FIGURED_BASS_ERROR_MESSAGE_KEY(modul static const Settings::Key NEED_TO_SHOW_ADD_GUITAR_BEND_ERROR_MESSAGE_KEY(module_name, "ui/dialogs/needToShowAddGuitarBendErrorMessage"); static const Settings::Key PIANO_KEYBOARD_NUMBER_OF_KEYS(module_name, "pianoKeyboard/numberOfKeys"); -static const Settings::Key PIANO_KEYBOARD_PITCH_STATE(module_name, "pianoKeyboard/useNotatedPitch"); +static const Settings::Key PIANO_KEYBOARD_PITCH_STATE(module_name, "pianoKeyboard/useWrittenPitch"); static const Settings::Key USE_NEW_PERCUSSION_PANEL_KEY(module_name, "ui/useNewPercussionPanel"); static const Settings::Key AUTO_SHOW_PERCUSSION_PANEL_KEY(module_name, "ui/autoShowPercussionPanel"); @@ -222,9 +222,9 @@ void NotationConfiguration::init() }); settings()->setDefaultValue(PIANO_KEYBOARD_PITCH_STATE, Val(true)); - m_pianoKeyboardUseNotatedPitch.val = settings()->value(PIANO_KEYBOARD_PITCH_STATE).toBool(); + m_midiInputUseWrittenPitch.val = settings()->value(PIANO_KEYBOARD_PITCH_STATE).toBool(); settings()->valueChanged(PIANO_KEYBOARD_PITCH_STATE).onReceive(this, [this](const Val& val) { - m_pianoKeyboardUseNotatedPitch.set(val.toBool()); + m_midiInputUseWrittenPitch.set(val.toBool()); }); settings()->setDefaultValue(USE_NEW_PERCUSSION_PANEL_KEY, Val(false)); @@ -926,14 +926,14 @@ void NotationConfiguration::setPianoKeyboardNumberOfKeys(int number) settings()->setSharedValue(PIANO_KEYBOARD_NUMBER_OF_KEYS, Val(number)); } -ValCh NotationConfiguration::pianoKeyboardUseNotatedPitch() const +ValCh NotationConfiguration::midiUseWrittenPitch() const { - return m_pianoKeyboardUseNotatedPitch; + return m_midiInputUseWrittenPitch; } -void NotationConfiguration::setPianoKeyboardUseNotatedPitch(bool useNotatedPitch) +void NotationConfiguration::setMidiUseWrittenPitch(bool useWrittenPitch) { - settings()->setSharedValue(PIANO_KEYBOARD_PITCH_STATE, Val(useNotatedPitch)); + settings()->setSharedValue(PIANO_KEYBOARD_PITCH_STATE, Val(useWrittenPitch)); } muse::io::path_t NotationConfiguration::firstScoreOrderListPath() const diff --git a/src/notation/internal/notationconfiguration.h b/src/notation/internal/notationconfiguration.h index 78a998ae2d089..134b9682330f3 100644 --- a/src/notation/internal/notationconfiguration.h +++ b/src/notation/internal/notationconfiguration.h @@ -198,8 +198,8 @@ class NotationConfiguration : public INotationConfiguration, public muse::async: muse::ValCh pianoKeyboardNumberOfKeys() const override; void setPianoKeyboardNumberOfKeys(int number) override; - muse::ValCh pianoKeyboardUseNotatedPitch() const override; - void setPianoKeyboardUseNotatedPitch(bool useNotatedPitch) override; + muse::ValCh midiUseWrittenPitch() const override; + void setMidiUseWrittenPitch(bool useWrittenPitch) override; bool useNewPercussionPanel() const override; void setUseNewPercussionPanel(bool use) override; @@ -234,7 +234,7 @@ class NotationConfiguration : public INotationConfiguration, public muse::async: muse::async::Notification m_isPlayRepeatsChanged; muse::async::Notification m_isPlayChordSymbolsChanged; muse::ValCh m_pianoKeyboardNumberOfKeys; - muse::ValCh m_pianoKeyboardUseNotatedPitch; + muse::ValCh m_midiInputUseWrittenPitch; muse::async::Channel m_anchorColorChanged; int m_styleDialogLastPageIndex = 0; diff --git a/src/notation/internal/notationmidiinput.cpp b/src/notation/internal/notationmidiinput.cpp index 5e23097ff6559..107ba615b6e91 100644 --- a/src/notation/internal/notationmidiinput.cpp +++ b/src/notation/internal/notationmidiinput.cpp @@ -212,7 +212,7 @@ Note* NotationMidiInput::addNoteToScore(const muse::midi::Event& e) } } - mu::engraving::Note* note = sc->addMidiPitch(inputEv.pitch, inputEv.chord, configuration()->pianoKeyboardUseNotatedPitch().val); + mu::engraving::Note* note = sc->addMidiPitch(inputEv.pitch, inputEv.chord, configuration()->midiUseWrittenPitch().val); sc->activeMidiPitches().push_back(inputEv); @@ -250,7 +250,7 @@ Note* NotationMidiInput::makeNote(const muse::midi::Event& e) note->setParent(chord); note->setStaffIdx(engraving::track2staff(inputState.cr()->track())); - engraving::NoteVal nval = score->noteVal(e.note(), configuration()->pianoKeyboardUseNotatedPitch().val); + engraving::NoteVal nval = score->noteVal(e.note(), configuration()->midiUseWrittenPitch().val); note->setNval(nval); return note; @@ -306,7 +306,7 @@ void NotationMidiInput::doRealtimeAdvance() QTimer::singleShot(100, Qt::PreciseTimer, [this]() { m_undoStack->prepareChanges(); - m_getScore->score()->realtimeAdvance(configuration()->pianoKeyboardUseNotatedPitch().val); + m_getScore->score()->realtimeAdvance(configuration()->midiUseWrittenPitch().val); m_undoStack->commitChanges(); }); diff --git a/src/notation/tests/mocks/notationconfigurationmock.h b/src/notation/tests/mocks/notationconfigurationmock.h index b0bf76334c631..0fd1e9ce850df 100644 --- a/src/notation/tests/mocks/notationconfigurationmock.h +++ b/src/notation/tests/mocks/notationconfigurationmock.h @@ -183,8 +183,8 @@ class NotationConfigurationMock : public INotationConfiguration MOCK_METHOD(muse::ValCh, pianoKeyboardNumberOfKeys, (), (const, override)); MOCK_METHOD(void, setPianoKeyboardNumberOfKeys, (int), (override)); - MOCK_METHOD(muse::ValCh, pianoKeyboardUseNotatedPitch, (), (const, override)); - MOCK_METHOD(void, setPianoKeyboardUseNotatedPitch, (bool), (override)); + MOCK_METHOD(muse::ValCh, midiUseWrittenPitch, (), (const, override)); + MOCK_METHOD(void, setMidiUseWrittenPitch, (bool), (override)); MOCK_METHOD(bool, useNewPercussionPanel, (), (const, override)); MOCK_METHOD(void, setUseNewPercussionPanel, (bool), (override)); diff --git a/src/notation/view/pianokeyboard/pianokeyboardcontroller.cpp b/src/notation/view/pianokeyboard/pianokeyboardcontroller.cpp index 82fe3bfc5662f..5b751d0afc486 100644 --- a/src/notation/view/pianokeyboard/pianokeyboardcontroller.cpp +++ b/src/notation/view/pianokeyboard/pianokeyboardcontroller.cpp @@ -133,9 +133,9 @@ void PianoKeyboardController::updateNotesKeys(const std::vector& re }; for (const mu::engraving::Note* note : receivedNotes) { - newKeys.insert(static_cast(useNotatedPitch() ? note->epitch() : note->ppitch())); + newKeys.insert(static_cast(useWrittenPitch() ? note->epitch() : note->ppitch())); for (const mu::engraving::Note* otherNote : note->chord()->notes()) { - newOtherNotesInChord.insert(static_cast(useNotatedPitch() ? otherNote->epitch() : otherNote->ppitch())); + newOtherNotesInChord.insert(static_cast(useWrittenPitch() ? otherNote->epitch() : otherNote->ppitch())); } } } @@ -176,7 +176,7 @@ INotationPtr PianoKeyboardController::currentNotation() const return context()->currentNotation(); } -bool PianoKeyboardController::useNotatedPitch() const +bool PianoKeyboardController::useWrittenPitch() const { - return notationConfiguration()->pianoKeyboardUseNotatedPitch().val; + return notationConfiguration()->midiUseWrittenPitch().val; } diff --git a/src/notation/view/pianokeyboard/pianokeyboardcontroller.h b/src/notation/view/pianokeyboard/pianokeyboardcontroller.h index 907ee6bd67c23..99475df750218 100644 --- a/src/notation/view/pianokeyboard/pianokeyboardcontroller.h +++ b/src/notation/view/pianokeyboard/pianokeyboardcontroller.h @@ -47,7 +47,7 @@ class PianoKeyboardController : public muse::Injectable, public muse::async::Asy bool isFromMidi() const; - bool useNotatedPitch() const; + bool useWrittenPitch() const; private: INotationPtr currentNotation() const; diff --git a/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.cpp b/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.cpp index ae19e847accae..4bb49b241ae35 100644 --- a/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.cpp +++ b/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.cpp @@ -35,7 +35,6 @@ using namespace muse::uicomponents; static const ActionCode SET_KEY_WIDTH_SCALING_CODE("piano-keyboard-set-key-width-scaling"); static const ActionCode SET_NUMBER_OF_KEYS_CODE("piano-keyboard-set-number-of-keys"); -static const ActionCode SET_NOTATED_PITCH_CODE("piano-keyboard-toggle-notated-pitch"); PianoKeyboardPanelContextMenuModel::PianoKeyboardPanelContextMenuModel(QObject* parent) : AbstractMenuModel(parent) @@ -45,8 +44,7 @@ PianoKeyboardPanelContextMenuModel::PianoKeyboardPanelContextMenuModel(QObject* void PianoKeyboardPanelContextMenuModel::load() { MenuItemList items { - makeViewMenu(), - makePitchMenu(), + makeViewMenu() }; setItems(items); @@ -73,35 +71,6 @@ int PianoKeyboardPanelContextMenuModel::numberOfKeys() const return configuration()->pianoKeyboardNumberOfKeys().val; } -MenuItem* PianoKeyboardPanelContextMenuModel::makePitchMenu() -{ - MenuItemList items; - - std::vector > possibleNotationStates { - { muse::TranslatableString("notation", "Use notated pitch"), true }, - { muse::TranslatableString("notation", "Use playback pitch"), false }, - }; - - for (auto [title, notationState] : possibleNotationStates) { - items << makeToggleNotatedPitchItem(title, notationState); - } - - configuration()->pianoKeyboardUseNotatedPitch().ch.onReceive(this, [this](bool) { - emit pianoKeyboardUseNotatedPitchChanged(); - }); - - dispatcher()->reg(this, SET_NOTATED_PITCH_CODE, [this](const ActionData& args) { - IF_ASSERT_FAILED(args.count() > 0) { - return; - } - - configuration()->setPianoKeyboardUseNotatedPitch(args.arg(0)); - emit pianoKeyboardUseNotatedPitchChanged(); - }); - - return makeMenu(muse::TranslatableString("notation", "Pitch mode for transposing instruments"), items); -} - MenuItem* PianoKeyboardPanelContextMenuModel::makeViewMenu() { MenuItemList items; @@ -198,31 +167,6 @@ MenuItem* PianoKeyboardPanelContextMenuModel::makeNumberOfKeysItem(const muse::T return item; } -MenuItem* PianoKeyboardPanelContextMenuModel::makeToggleNotatedPitchItem(const muse::TranslatableString& title, bool isNotatedPitch) -{ - UiAction action; - action.title = title; - action.code = SET_NOTATED_PITCH_CODE; - action.checkable = Checkable::Yes; - - MenuItem* item = new MenuItem(action, this); - item->setId(QString::fromStdString(SET_NOTATED_PITCH_CODE) + (isNotatedPitch ? "-notated" : "-playback")); - - ValCh currentState = configuration()->pianoKeyboardUseNotatedPitch(); - - bool checked = !(isNotatedPitch ^ currentState.val); - item->setState(UiActionState::make_enabled(checked)); - - currentState.ch.onReceive(item, [item, isNotatedPitch](bool s) { - bool checked = !(isNotatedPitch ^ s); - item->setState(UiActionState::make_enabled(checked)); - }); - - item->setArgs(ActionData::make_arg1(isNotatedPitch)); - - return item; -} - void PianoKeyboardPanelContextMenuModel::updateKeyWidthScalingItems() { qreal roundedCurrentScaling = NORMAL_KEY_WIDTH_SCALING; diff --git a/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.h b/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.h index 3ef6838fc37f9..a2fbb28537703 100644 --- a/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.h +++ b/src/notation/view/pianokeyboard/pianokeyboardpanelcontextmenumodel.h @@ -58,17 +58,13 @@ class PianoKeyboardPanelContextMenuModel : public muse::uicomponents::AbstractMe void keyWidthScalingChanged(); void setKeyWidthScalingRequested(qreal scaling); void numberOfKeysChanged(); - void pianoKeyboardUseNotatedPitchChanged(); private: muse::uicomponents::MenuItem* makeViewMenu(); - muse::uicomponents::MenuItem* makePitchMenu(); muse::uicomponents::MenuItem* makeKeyWidthScalingItem(const muse::TranslatableString& title, qreal scaling); muse::uicomponents::MenuItem* makeNumberOfKeysItem(const muse::TranslatableString& title, int numberOfKeys); - muse::uicomponents::MenuItem* makeToggleNotatedPitchItem(const muse::TranslatableString& title, bool isNotatedPitch); - void updateKeyWidthScalingItems(); muse::uicomponents::MenuItemList m_keyWidthScalingItems; diff --git a/src/playback/internal/playbackcontroller.cpp b/src/playback/internal/playbackcontroller.cpp index fabb26749e5b4..072a2c834eecd 100644 --- a/src/playback/internal/playbackcontroller.cpp +++ b/src/playback/internal/playbackcontroller.cpp @@ -52,6 +52,8 @@ static const ActionCode LOOP_IN_CODE("loop-in"); static const ActionCode LOOP_OUT_CODE("loop-out"); static const ActionCode METRONOME_CODE("metronome"); static const ActionCode MIDI_ON_CODE("midi-on"); +static const ActionCode INPUT_WRITTEN_PITCH("midi-input-written-pitch"); +static const ActionCode INPUT_SOUNDING_PITCH("midi-input-sounding-pitch"); static const ActionCode COUNT_IN_CODE("countin"); static const ActionCode PAN_CODE("pan"); static const ActionCode REPEAT_CODE("repeat"); @@ -107,6 +109,8 @@ void PlaybackController::init() dispatcher()->reg(this, PAN_CODE, this, &PlaybackController::toggleAutomaticallyPan); dispatcher()->reg(this, METRONOME_CODE, this, &PlaybackController::toggleMetronome); dispatcher()->reg(this, MIDI_ON_CODE, this, &PlaybackController::toggleMidiInput); + dispatcher()->reg(this, INPUT_WRITTEN_PITCH, this, &PlaybackController::toggleMidiInputPitch); + dispatcher()->reg(this, INPUT_SOUNDING_PITCH, this, &PlaybackController::toggleMidiInputPitch); dispatcher()->reg(this, COUNT_IN_CODE, this, &PlaybackController::toggleCountIn); dispatcher()->reg(this, PLAYBACK_SETUP, this, &PlaybackController::openPlaybackSetupDialog); @@ -728,6 +732,14 @@ void PlaybackController::toggleMidiInput() notifyActionCheckedChanged(MIDI_ON_CODE); } +void PlaybackController::toggleMidiInputPitch() +{ + bool useWrittenPitch = notationConfiguration()->midiUseWrittenPitch().val; + notationConfiguration()->setMidiUseWrittenPitch(!useWrittenPitch); + notifyActionCheckedChanged(INPUT_WRITTEN_PITCH); + notifyActionCheckedChanged(INPUT_SOUNDING_PITCH); +} + void PlaybackController::toggleCountIn() { bool countInEnabled = notationConfiguration()->isCountInEnabled(); @@ -1401,6 +1413,8 @@ bool PlaybackController::actionChecked(const ActionCode& actionCode) const QMap isChecked { { LOOP_CODE, isLoopEnabled() }, { MIDI_ON_CODE, notationConfiguration()->isMidiInputEnabled() }, + { INPUT_WRITTEN_PITCH, notationConfiguration()->midiUseWrittenPitch().val }, + { INPUT_SOUNDING_PITCH, !notationConfiguration()->midiUseWrittenPitch().val }, { REPEAT_CODE, notationConfiguration()->isPlayRepeatsEnabled() }, { PLAY_CHORD_SYMBOLS_CODE, notationConfiguration()->isPlayChordSymbolsEnabled() }, { PAN_CODE, notationConfiguration()->isAutomaticallyPanEnabled() }, diff --git a/src/playback/internal/playbackcontroller.h b/src/playback/internal/playbackcontroller.h index 664d4c7dd0740..c0e5abeaa362b 100644 --- a/src/playback/internal/playbackcontroller.h +++ b/src/playback/internal/playbackcontroller.h @@ -163,6 +163,7 @@ class PlaybackController : public IPlaybackController, public muse::actions::Act void toggleAutomaticallyPan(); void toggleMetronome(); void toggleMidiInput(); + void toggleMidiInputPitch(); void toggleCountIn(); void toggleLoopPlayback(); diff --git a/src/playback/internal/playbackuiactions.cpp b/src/playback/internal/playbackuiactions.cpp index fbdc6ba26b688..050f01372ecfc 100644 --- a/src/playback/internal/playbackuiactions.cpp +++ b/src/playback/internal/playbackuiactions.cpp @@ -78,7 +78,7 @@ const UiActionList PlaybackUiActions::m_mainActions = { ) }; -const UiActionList PlaybackUiActions::m_settingsActions = { +const UiActionList PlaybackUiActions::m_midiInputActions = { UiAction("midi-on", mu::context::UiCtxAny, mu::context::CTX_ANY, @@ -87,6 +87,28 @@ const UiActionList PlaybackUiActions::m_settingsActions = { IconCode::Code::MIDI_INPUT, Checkable::Yes ), +}; + +const UiActionList PlaybackUiActions::m_midiInputPitchActions = { + UiAction("midi-input-written-pitch", + mu::context::UiCtxAny, + mu::context::CTX_ANY, + TranslatableString("action", "Written pitch"), + TranslatableString("action", "Input written pitch"), + IconCode::Code::NONE, + Checkable::Yes + ), + UiAction("midi-input-sounding-pitch", + mu::context::UiCtxAny, + mu::context::CTX_ANY, + TranslatableString("action", "Sounding pitch"), + TranslatableString("action", "Input sounding pitch"), + IconCode::Code::NONE, + Checkable::Yes + ), +}; + +const UiActionList PlaybackUiActions::m_settingsActions = { UiAction("repeat", mu::context::UiCtxAny, mu::context::CTX_NOTATION_FOCUSED, @@ -165,6 +187,8 @@ const UiActionList& PlaybackUiActions::actionsList() const static UiActionList alist; if (alist.empty()) { alist.insert(alist.end(), m_mainActions.cbegin(), m_mainActions.cend()); + alist.insert(alist.end(), m_midiInputActions.cbegin(), m_midiInputActions.cend()); + alist.insert(alist.end(), m_midiInputPitchActions.cbegin(), m_midiInputPitchActions.cend()); alist.insert(alist.end(), m_settingsActions.cbegin(), m_settingsActions.cend()); alist.insert(alist.end(), m_loopBoundaryActions.cbegin(), m_loopBoundaryActions.cend()); } @@ -199,6 +223,16 @@ muse::async::Channel PlaybackUiActions::actionCheckedChanged() c return m_actionCheckedChanged; } +const UiActionList& PlaybackUiActions::midiInputActions() +{ + return m_midiInputActions; +} + +const UiActionList& PlaybackUiActions::midiInputPitchActions() +{ + return m_midiInputPitchActions; +} + const UiActionList& PlaybackUiActions::settingsActions() { return m_settingsActions; diff --git a/src/playback/internal/playbackuiactions.h b/src/playback/internal/playbackuiactions.h index 8c096f1493d7e..f3ab0f98b63cb 100644 --- a/src/playback/internal/playbackuiactions.h +++ b/src/playback/internal/playbackuiactions.h @@ -47,6 +47,8 @@ class PlaybackUiActions : public muse::ui::IUiActionsModule, public muse::async: bool actionChecked(const muse::ui::UiAction& act) const override; muse::async::Channel actionCheckedChanged() const override; + static const muse::ui::UiActionList& midiInputActions(); + static const muse::ui::UiActionList& midiInputPitchActions(); static const muse::ui::UiActionList& settingsActions(); static const muse::ui::UiActionList& loopBoundaryActions(); @@ -54,6 +56,8 @@ class PlaybackUiActions : public muse::ui::IUiActionsModule, public muse::async: private: static const muse::ui::UiActionList m_mainActions; + static const muse::ui::UiActionList m_midiInputActions; + static const muse::ui::UiActionList m_midiInputPitchActions; static const muse::ui::UiActionList m_settingsActions; static const muse::ui::UiActionList m_loopBoundaryActions; diff --git a/src/playback/view/playbacktoolbarmodel.cpp b/src/playback/view/playbacktoolbarmodel.cpp index 43c82fcd6aedf..a810b3facea60 100644 --- a/src/playback/view/playbacktoolbarmodel.cpp +++ b/src/playback/view/playbacktoolbarmodel.cpp @@ -36,6 +36,7 @@ using namespace muse::uicomponents; using namespace muse::audio; static const ActionCode PLAY_ACTION_CODE("play"); +static const ActionCode TOGGLE_INPUT_PITCH_CODE("toggle-written-sounding-pitch"); static MusicalSymbolCodes::Code tempoDurationToNoteIcon(DurationType durationType) { @@ -95,6 +96,13 @@ void PlaybackToolBarModel::updateActions() MenuItemList result; MenuItemList settingsItems; + for (const UiAction& action : PlaybackUiActions::midiInputActions()) { + settingsItems << makeMenuItem(action.code); + } + + settingsItems << makePitchMenu(); + settingsItems << makeSeparator(); + for (const UiAction& action : PlaybackUiActions::settingsActions()) { settingsItems << makeMenuItem(action.code); } @@ -131,6 +139,22 @@ void PlaybackToolBarModel::updateActions() setItems(result); } +MenuItem* PlaybackToolBarModel::makePitchMenu() +{ + MenuItemList items; + + for (const UiAction& action : PlaybackUiActions::midiInputPitchActions()) { + items << makeMenuItem(action.code); + } + + MenuItem* menu = makeMenu(muse::TranslatableString("notation", "Input pitch"), items); + UiAction action = menu->action(); + action.iconCode = IconCode::Code::MUSIC_NOTES; + menu->setAction(action); + + return menu; +} + void PlaybackToolBarModel::onActionsStateChanges(const ActionCodeList& codes) { AbstractMenuModel::onActionsStateChanges(codes); diff --git a/src/playback/view/playbacktoolbarmodel.h b/src/playback/view/playbacktoolbarmodel.h index 4ceaa8a02905f..79317b6df9841 100644 --- a/src/playback/view/playbacktoolbarmodel.h +++ b/src/playback/view/playbacktoolbarmodel.h @@ -26,6 +26,7 @@ #include "modularity/ioc.h" #include "iplaybackcontroller.h" +#include "notation/inotationconfiguration.h" #include "context/iglobalcontext.h" namespace mu::playback { @@ -50,6 +51,7 @@ class PlaybackToolBarModel : public muse::uicomponents::AbstractMenuModel muse::Inject playbackController; muse::Inject globalContext; + muse::Inject notationConfiguration = { this }; public: explicit PlaybackToolBarModel(QObject* parent = nullptr); @@ -88,6 +90,7 @@ public slots: private: void setupConnections(); + muse::uicomponents::MenuItem* makePitchMenu(); void updateActions(); void onActionsStateChanges(const muse::actions::ActionCodeList& codes) override; From 8c8c62e55ede83e021c67d50b3613ef206b8181b Mon Sep 17 00:00:00 2001 From: Robert Patterson Date: Wed, 18 Sep 2024 19:03:23 -0500 Subject: [PATCH 09/14] make function name consistent with UI --- src/playback/view/playbacktoolbarmodel.cpp | 4 ++-- src/playback/view/playbacktoolbarmodel.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/playback/view/playbacktoolbarmodel.cpp b/src/playback/view/playbacktoolbarmodel.cpp index a810b3facea60..d39c2b1a0923a 100644 --- a/src/playback/view/playbacktoolbarmodel.cpp +++ b/src/playback/view/playbacktoolbarmodel.cpp @@ -100,7 +100,7 @@ void PlaybackToolBarModel::updateActions() settingsItems << makeMenuItem(action.code); } - settingsItems << makePitchMenu(); + settingsItems << makeInputPitchMenu(); settingsItems << makeSeparator(); for (const UiAction& action : PlaybackUiActions::settingsActions()) { @@ -139,7 +139,7 @@ void PlaybackToolBarModel::updateActions() setItems(result); } -MenuItem* PlaybackToolBarModel::makePitchMenu() +MenuItem* PlaybackToolBarModel::makeInputPitchMenu() { MenuItemList items; diff --git a/src/playback/view/playbacktoolbarmodel.h b/src/playback/view/playbacktoolbarmodel.h index 79317b6df9841..52d87eb9c983a 100644 --- a/src/playback/view/playbacktoolbarmodel.h +++ b/src/playback/view/playbacktoolbarmodel.h @@ -90,7 +90,7 @@ public slots: private: void setupConnections(); - muse::uicomponents::MenuItem* makePitchMenu(); + muse::uicomponents::MenuItem* makeInputPitchMenu(); void updateActions(); void onActionsStateChanges(const muse::actions::ActionCodeList& codes) override; From 144de39abd456bee374be8a82a253692bf48e1c3 Mon Sep 17 00:00:00 2001 From: Robert Patterson Date: Wed, 18 Sep 2024 19:16:47 -0500 Subject: [PATCH 10/14] clean up cruft --- src/engraving/dom/edit.cpp | 1 - src/playback/view/playbacktoolbarmodel.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/src/engraving/dom/edit.cpp b/src/engraving/dom/edit.cpp index 2eb28169280c0..9e6cb6e280304 100644 --- a/src/engraving/dom/edit.cpp +++ b/src/engraving/dom/edit.cpp @@ -24,7 +24,6 @@ #include #include "infrastructure/messagebox.h" -#include "notation/internal/notationconfiguration.h" #include "accidental.h" #include "articulation.h" diff --git a/src/playback/view/playbacktoolbarmodel.cpp b/src/playback/view/playbacktoolbarmodel.cpp index d39c2b1a0923a..f23477da80018 100644 --- a/src/playback/view/playbacktoolbarmodel.cpp +++ b/src/playback/view/playbacktoolbarmodel.cpp @@ -36,7 +36,6 @@ using namespace muse::uicomponents; using namespace muse::audio; static const ActionCode PLAY_ACTION_CODE("play"); -static const ActionCode TOGGLE_INPUT_PITCH_CODE("toggle-written-sounding-pitch"); static MusicalSymbolCodes::Code tempoDurationToNoteIcon(DurationType durationType) { From ab64440aebff80044c273b3699b442aca196c71c Mon Sep 17 00:00:00 2001 From: Robert Patterson Date: Wed, 18 Sep 2024 19:25:17 -0500 Subject: [PATCH 11/14] one more name change (they say naming is the hardest thing in programming) --- src/notation/internal/notationconfiguration.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/notation/internal/notationconfiguration.cpp b/src/notation/internal/notationconfiguration.cpp index cf49ab1526607..ce7a59827f425 100644 --- a/src/notation/internal/notationconfiguration.cpp +++ b/src/notation/internal/notationconfiguration.cpp @@ -59,6 +59,7 @@ static const Settings::Key MOUSE_ZOOM_PRECISION(module_name, "ui/canvas/zoomPrec static const Settings::Key USER_STYLES_PATH(module_name, "application/paths/myStyles"); static const Settings::Key IS_MIDI_INPUT_ENABLED(module_name, "io/midi/enableInput"); +static const Settings::Key USE_MIDI_INPUT_WRITTEN_PITCH(module_name, "io/midi/useWrittenPitch"); static const Settings::Key IS_AUTOMATICALLY_PAN_ENABLED(module_name, "application/playback/panPlayback"); static const Settings::Key PLAYBACK_SMOOTH_PANNING(module_name, "application/playback/smoothPan"); static const Settings::Key IS_PLAY_REPEATS_ENABLED(module_name, "application/playback/playRepeats"); @@ -89,7 +90,6 @@ static const Settings::Key NEED_TO_SHOW_ADD_FIGURED_BASS_ERROR_MESSAGE_KEY(modul static const Settings::Key NEED_TO_SHOW_ADD_GUITAR_BEND_ERROR_MESSAGE_KEY(module_name, "ui/dialogs/needToShowAddGuitarBendErrorMessage"); static const Settings::Key PIANO_KEYBOARD_NUMBER_OF_KEYS(module_name, "pianoKeyboard/numberOfKeys"); -static const Settings::Key PIANO_KEYBOARD_PITCH_STATE(module_name, "pianoKeyboard/useWrittenPitch"); static const Settings::Key USE_NEW_PERCUSSION_PANEL_KEY(module_name, "ui/useNewPercussionPanel"); static const Settings::Key AUTO_SHOW_PERCUSSION_PANEL_KEY(module_name, "ui/autoShowPercussionPanel"); @@ -221,9 +221,9 @@ void NotationConfiguration::init() m_pianoKeyboardNumberOfKeys.set(val.toInt()); }); - settings()->setDefaultValue(PIANO_KEYBOARD_PITCH_STATE, Val(true)); - m_midiInputUseWrittenPitch.val = settings()->value(PIANO_KEYBOARD_PITCH_STATE).toBool(); - settings()->valueChanged(PIANO_KEYBOARD_PITCH_STATE).onReceive(this, [this](const Val& val) { + settings()->setDefaultValue(USE_MIDI_INPUT_WRITTEN_PITCH, Val(true)); + m_midiInputUseWrittenPitch.val = settings()->value(USE_MIDI_INPUT_WRITTEN_PITCH).toBool(); + settings()->valueChanged(USE_MIDI_INPUT_WRITTEN_PITCH).onReceive(this, [this](const Val& val) { m_midiInputUseWrittenPitch.set(val.toBool()); }); @@ -933,7 +933,7 @@ ValCh NotationConfiguration::midiUseWrittenPitch() const void NotationConfiguration::setMidiUseWrittenPitch(bool useWrittenPitch) { - settings()->setSharedValue(PIANO_KEYBOARD_PITCH_STATE, Val(useWrittenPitch)); + settings()->setSharedValue(USE_MIDI_INPUT_WRITTEN_PITCH, Val(useWrittenPitch)); } muse::io::path_t NotationConfiguration::firstScoreOrderListPath() const From d44b99ed9fd9db040ae527e0ad20db8e52569010 Mon Sep 17 00:00:00 2001 From: Robert Patterson Date: Wed, 18 Sep 2024 19:43:13 -0500 Subject: [PATCH 12/14] stub module did not get name changes (because it's not in any project, arghh) --- src/stubs/notation/notationconfigurationstub.cpp | 4 ++-- src/stubs/notation/notationconfigurationstub.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/stubs/notation/notationconfigurationstub.cpp b/src/stubs/notation/notationconfigurationstub.cpp index 66d6a51c71053..e4a4c28b8319b 100644 --- a/src/stubs/notation/notationconfigurationstub.cpp +++ b/src/stubs/notation/notationconfigurationstub.cpp @@ -465,13 +465,13 @@ void NotationConfigurationStub::setPianoKeyboardNumberOfKeys(int) { } -ValCh NotationConfigurationStub::pianoKeyboardUseNotatedPitch() const +ValCh NotationConfigurationStub::midiUseWrittenPitch() const { static ValCh vch; return vch; } -void NotationConfigurationStub::setPianoKeyboardUseNotatedPitch(bool) +void NotationConfigurationStub::setMidiUseWrittenPitch(bool) { } diff --git a/src/stubs/notation/notationconfigurationstub.h b/src/stubs/notation/notationconfigurationstub.h index c368d74a489a1..0ebedae9e6572 100644 --- a/src/stubs/notation/notationconfigurationstub.h +++ b/src/stubs/notation/notationconfigurationstub.h @@ -171,8 +171,8 @@ class NotationConfigurationStub : public INotationConfiguration ValCh pianoKeyboardNumberOfKeys() const override; void setPianoKeyboardNumberOfKeys(int number) override; - ValCh pianoKeyboardUseNotatedPitch() const override; - void setPianoKeyboardUseNotatedPitch(bool value) override; + ValCh midiUseWrittenPitch() const override; + void setMidiUseWrittenPitch(bool value) override; bool useNewPercussionPanel() const override; void setUseNewPercussionPanel(bool use) override; From 1dc1d35ce090a272053ca61d05ae54a5a7a48bf3 Mon Sep 17 00:00:00 2001 From: Robert Patterson Date: Wed, 2 Oct 2024 13:05:18 -0500 Subject: [PATCH 13/14] code review items --- .../view/pianokeyboard/pianokeyboardcontroller.cpp | 11 ++++------- .../view/pianokeyboard/pianokeyboardcontroller.h | 2 -- src/playback/internal/playbackcontroller.cpp | 9 ++++----- src/playback/internal/playbackcontroller.h | 2 +- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/notation/view/pianokeyboard/pianokeyboardcontroller.cpp b/src/notation/view/pianokeyboard/pianokeyboardcontroller.cpp index 5b751d0afc486..040966c7465f5 100644 --- a/src/notation/view/pianokeyboard/pianokeyboardcontroller.cpp +++ b/src/notation/view/pianokeyboard/pianokeyboardcontroller.cpp @@ -132,10 +132,12 @@ void PianoKeyboardController::updateNotesKeys(const std::vector& re m_keyStatesChanged.notify(); }; + const bool useWrittenPitch = notationConfiguration()->midiUseWrittenPitch().val; + for (const mu::engraving::Note* note : receivedNotes) { - newKeys.insert(static_cast(useWrittenPitch() ? note->epitch() : note->ppitch())); + newKeys.insert(static_cast(useWrittenPitch ? note->epitch() : note->ppitch())); for (const mu::engraving::Note* otherNote : note->chord()->notes()) { - newOtherNotesInChord.insert(static_cast(useWrittenPitch() ? otherNote->epitch() : otherNote->ppitch())); + newOtherNotesInChord.insert(static_cast(useWrittenPitch ? otherNote->epitch() : otherNote->ppitch())); } } } @@ -175,8 +177,3 @@ INotationPtr PianoKeyboardController::currentNotation() const { return context()->currentNotation(); } - -bool PianoKeyboardController::useWrittenPitch() const -{ - return notationConfiguration()->midiUseWrittenPitch().val; -} diff --git a/src/notation/view/pianokeyboard/pianokeyboardcontroller.h b/src/notation/view/pianokeyboard/pianokeyboardcontroller.h index 99475df750218..a10db82af20f7 100644 --- a/src/notation/view/pianokeyboard/pianokeyboardcontroller.h +++ b/src/notation/view/pianokeyboard/pianokeyboardcontroller.h @@ -47,8 +47,6 @@ class PianoKeyboardController : public muse::Injectable, public muse::async::Asy bool isFromMidi() const; - bool useWrittenPitch() const; - private: INotationPtr currentNotation() const; diff --git a/src/playback/internal/playbackcontroller.cpp b/src/playback/internal/playbackcontroller.cpp index 072a2c834eecd..f38e9f29e3c0c 100644 --- a/src/playback/internal/playbackcontroller.cpp +++ b/src/playback/internal/playbackcontroller.cpp @@ -109,8 +109,8 @@ void PlaybackController::init() dispatcher()->reg(this, PAN_CODE, this, &PlaybackController::toggleAutomaticallyPan); dispatcher()->reg(this, METRONOME_CODE, this, &PlaybackController::toggleMetronome); dispatcher()->reg(this, MIDI_ON_CODE, this, &PlaybackController::toggleMidiInput); - dispatcher()->reg(this, INPUT_WRITTEN_PITCH, this, &PlaybackController::toggleMidiInputPitch); - dispatcher()->reg(this, INPUT_SOUNDING_PITCH, this, &PlaybackController::toggleMidiInputPitch); + dispatcher()->reg(this, INPUT_WRITTEN_PITCH, [this]() { PlaybackController::setMidiInputPitch(true); }); + dispatcher()->reg(this, INPUT_SOUNDING_PITCH, [this]() { PlaybackController::setMidiInputPitch(false); }); dispatcher()->reg(this, COUNT_IN_CODE, this, &PlaybackController::toggleCountIn); dispatcher()->reg(this, PLAYBACK_SETUP, this, &PlaybackController::openPlaybackSetupDialog); @@ -732,10 +732,9 @@ void PlaybackController::toggleMidiInput() notifyActionCheckedChanged(MIDI_ON_CODE); } -void PlaybackController::toggleMidiInputPitch() +void PlaybackController::setMidiInputPitch(bool useWrittenPitch) { - bool useWrittenPitch = notationConfiguration()->midiUseWrittenPitch().val; - notationConfiguration()->setMidiUseWrittenPitch(!useWrittenPitch); + notationConfiguration()->setMidiUseWrittenPitch(useWrittenPitch); notifyActionCheckedChanged(INPUT_WRITTEN_PITCH); notifyActionCheckedChanged(INPUT_SOUNDING_PITCH); } diff --git a/src/playback/internal/playbackcontroller.h b/src/playback/internal/playbackcontroller.h index c0e5abeaa362b..730517dd5fae3 100644 --- a/src/playback/internal/playbackcontroller.h +++ b/src/playback/internal/playbackcontroller.h @@ -163,7 +163,7 @@ class PlaybackController : public IPlaybackController, public muse::actions::Act void toggleAutomaticallyPan(); void toggleMetronome(); void toggleMidiInput(); - void toggleMidiInputPitch(); + void setMidiInputPitch(bool useWrittenPitch); void toggleCountIn(); void toggleLoopPlayback(); From 6a0159d719a35e01ff333ee0752bd064405b18cb Mon Sep 17 00:00:00 2001 From: Robert Patterson Date: Wed, 2 Oct 2024 13:43:20 -0500 Subject: [PATCH 14/14] naming is the hardest thing --- src/playback/internal/playbackcontroller.cpp | 6 +++--- src/playback/internal/playbackcontroller.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/playback/internal/playbackcontroller.cpp b/src/playback/internal/playbackcontroller.cpp index f38e9f29e3c0c..be710f01711e1 100644 --- a/src/playback/internal/playbackcontroller.cpp +++ b/src/playback/internal/playbackcontroller.cpp @@ -109,8 +109,8 @@ void PlaybackController::init() dispatcher()->reg(this, PAN_CODE, this, &PlaybackController::toggleAutomaticallyPan); dispatcher()->reg(this, METRONOME_CODE, this, &PlaybackController::toggleMetronome); dispatcher()->reg(this, MIDI_ON_CODE, this, &PlaybackController::toggleMidiInput); - dispatcher()->reg(this, INPUT_WRITTEN_PITCH, [this]() { PlaybackController::setMidiInputPitch(true); }); - dispatcher()->reg(this, INPUT_SOUNDING_PITCH, [this]() { PlaybackController::setMidiInputPitch(false); }); + dispatcher()->reg(this, INPUT_WRITTEN_PITCH, [this]() { PlaybackController::setMidiUseWrittenPitch(true); }); + dispatcher()->reg(this, INPUT_SOUNDING_PITCH, [this]() { PlaybackController::setMidiUseWrittenPitch(false); }); dispatcher()->reg(this, COUNT_IN_CODE, this, &PlaybackController::toggleCountIn); dispatcher()->reg(this, PLAYBACK_SETUP, this, &PlaybackController::openPlaybackSetupDialog); @@ -732,7 +732,7 @@ void PlaybackController::toggleMidiInput() notifyActionCheckedChanged(MIDI_ON_CODE); } -void PlaybackController::setMidiInputPitch(bool useWrittenPitch) +void PlaybackController::setMidiUseWrittenPitch(bool useWrittenPitch) { notationConfiguration()->setMidiUseWrittenPitch(useWrittenPitch); notifyActionCheckedChanged(INPUT_WRITTEN_PITCH); diff --git a/src/playback/internal/playbackcontroller.h b/src/playback/internal/playbackcontroller.h index 730517dd5fae3..84640c5ebe310 100644 --- a/src/playback/internal/playbackcontroller.h +++ b/src/playback/internal/playbackcontroller.h @@ -163,7 +163,7 @@ class PlaybackController : public IPlaybackController, public muse::actions::Act void toggleAutomaticallyPan(); void toggleMetronome(); void toggleMidiInput(); - void setMidiInputPitch(bool useWrittenPitch); + void setMidiUseWrittenPitch(bool useWrittenPitch); void toggleCountIn(); void toggleLoopPlayback();