Skip to content

Commit

Permalink
Merge pull request #26554 from RomanPudashkin/start_note_input_fix
Browse files Browse the repository at this point in the history
Start note input when pressing A-G keys
  • Loading branch information
RomanPudashkin authored Feb 17, 2025
2 parents 5ba97bc + e397ac3 commit 0584c02
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
53 changes: 26 additions & 27 deletions src/notation/internal/notationactioncontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,35 +760,37 @@ 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<int>(note), addFlag, params);
if (!ok) {
LOGE() << "Could not resolve note input params, note: " << (int)note << ", addFlag: " << addFlag;
return;
}

handleNoteAction(ActionData::make_arg2<NoteInputParams, NoteAddingMode>(params, addingMode));
}

void NotationActionController::handleNoteAction(const muse::actions::ActionData& args)
{
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<NoteInputParams>(0);
const NoteAddingMode addingMode = args.arg<NoteAddingMode>(1);

if (!noteInput->isNoteInputMode()) {
noteInput->startNoteInput(configuration()->defaultNoteInputMethod());
}

if (addingMode == NoteAddingMode::NextChord) {
if (noteInput->usingNoteInputMethod(NoteInputMethod::BY_DURATION)) {
noteInput->setInputNote(params);
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -891,7 +895,9 @@ void NotationActionController::toggleAccidental(AccidentalType type)
return;
}

startNoteInputIfNeed();
if (interaction->selection()->isNone()) {
startNoteInput();
}

if (noteInput->isNoteInputMode() && configuration()->addAccidentalDotsArticulationsToNextNoteEntered()) {
noteInput->setAccidental(type);
Expand All @@ -915,7 +921,9 @@ void NotationActionController::toggleArticulation(SymbolId articulationSymbolId)
return;
}

startNoteInputIfNeed();
if (interaction->selection()->isNone()) {
startNoteInput();
}

if (noteInput->isNoteInputMode() && configuration()->addAccidentalDotsArticulationsToNextNoteEntered()) {
noteInput->setArticulation(articulationSymbolId);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/notation/internal/notationactioncontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0584c02

Please sign in to comment.