Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start note input when pressing A-G keys #26554

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading