diff --git a/src/notation/internal/notationactioncontroller.cpp b/src/notation/internal/notationactioncontroller.cpp index db7a9a918ea75..7b5866b91027e 100644 --- a/src/notation/internal/notationactioncontroller.cpp +++ b/src/notation/internal/notationactioncontroller.cpp @@ -760,12 +760,16 @@ void NotationActionController::toggleNoteInputInsert() void NotationActionController::handleNoteAction(NoteName note, NoteAddingMode addingMode) { + startNoteInput(); + NoteInputParams params; const bool addFlag = addingMode == NoteAddingMode::CurrentChord; bool ok = currentNotationScore()->resolveNoteInputParams(static_cast(note), addFlag, params); if (!ok) { + LOGE() << "Could not resolve note input params, note: " << (int)note << ", addFlag: " << addFlag; return; } + handleNoteAction(ActionData::make_arg2(params, addingMode)); } @@ -773,22 +777,20 @@ void NotationActionController::handleNoteAction(const muse::actions::ActionData& { TRACEFUNC; - INotationNoteInputPtr noteInput = currentNotationNoteInput(); - if (!noteInput) { + IF_ASSERT_FAILED(args.count() > 1) { return; } - IF_ASSERT_FAILED(args.count() > 1) { + INotationNoteInputPtr noteInput = currentNotationNoteInput(); + if (!noteInput) { return; } + startNoteInput(); + const NoteInputParams params = args.arg(0); const NoteAddingMode addingMode = args.arg(1); - if (!noteInput->isNoteInputMode()) { - noteInput->startNoteInput(configuration()->defaultNoteInputMethod()); - } - if (addingMode == NoteAddingMode::NextChord) { if (noteInput->usingNoteInputMethod(NoteInputMethod::BY_DURATION)) { noteInput->setInputNote(params); @@ -820,7 +822,9 @@ void NotationActionController::padNote(const Pad& pad) return; } - startNoteInputIfNeed(); + if (interaction->selection()->isNone()) { + startNoteInput(); + } if (pad >= Pad::DOT && pad <= Pad::DOT4) { if (!noteInput->isNoteInputMode() || !configuration()->addAccidentalDotsArticulationsToNextNoteEntered()) { @@ -891,7 +895,9 @@ void NotationActionController::toggleAccidental(AccidentalType type) return; } - startNoteInputIfNeed(); + if (interaction->selection()->isNone()) { + startNoteInput(); + } if (noteInput->isNoteInputMode() && configuration()->addAccidentalDotsArticulationsToNextNoteEntered()) { noteInput->setAccidental(type); @@ -915,7 +921,9 @@ void NotationActionController::toggleArticulation(SymbolId articulationSymbolId) return; } - startNoteInputIfNeed(); + if (interaction->selection()->isNone()) { + startNoteInput(); + } if (noteInput->isNoteInputMode() && configuration()->addAccidentalDotsArticulationsToNextNoteEntered()) { noteInput->setArticulation(articulationSymbolId); @@ -1214,17 +1222,19 @@ void NotationActionController::changeVoice(voice_idx_t voiceIndex) { TRACEFUNC; - auto interaction = currentNotationInteraction(); + INotationInteractionPtr interaction = currentNotationInteraction(); if (!interaction) { return; } - auto noteInput = interaction->noteInput(); + INotationNoteInputPtr noteInput = interaction->noteInput(); if (!noteInput) { return; } - startNoteInputIfNeed(); + if (interaction->selection()->isNone()) { + startNoteInput(); + } noteInput->setCurrentVoice(voiceIndex); @@ -2156,21 +2166,10 @@ void NotationActionController::playSelectedElement(bool playChord) currentNotationScore()->setPlayNote(false); } -void NotationActionController::startNoteInputIfNeed() +void NotationActionController::startNoteInput() { - TRACEFUNC; - - INotationInteractionPtr interaction = currentNotationInteraction(); - if (!interaction) { - return; - } - - INotationNoteInputPtr noteInput = interaction->noteInput(); - if (!noteInput) { - return; - } - - if (interaction->selection()->isNone() && !noteInput->isNoteInputMode()) { + INotationNoteInputPtr noteInput = currentNotationNoteInput(); + if (noteInput && !noteInput->isNoteInputMode()) { noteInput->startNoteInput(configuration()->defaultNoteInputMethod()); } } diff --git a/src/notation/internal/notationactioncontroller.h b/src/notation/internal/notationactioncontroller.h index fde15b1f2efea..4fe14f7befb6f 100644 --- a/src/notation/internal/notationactioncontroller.h +++ b/src/notation/internal/notationactioncontroller.h @@ -206,7 +206,7 @@ class NotationActionController : public muse::actions::Actionable, public muse:: void navigateToTextElementByFraction(const Fraction& fraction); void navigateToTextElementInNearMeasure(MoveDirection direction); - void startNoteInputIfNeed(); + void startNoteInput(); bool hasSelection() const; mu::engraving::EngravingItem* selectedElement() const;