From be5fcecfd61c3d0469867f800211f23cb4ac1c39 Mon Sep 17 00:00:00 2001 From: CMakeScore <185574671+CMakeScore@users.noreply.github.com> Date: Fri, 1 Nov 2024 22:28:09 +0900 Subject: [PATCH 1/2] Fix #19121: Added a shortcut to add dynamics text --- src/app/configs/data/shortcuts.xml | 4 ++++ src/app/configs/data/shortcuts_azerty.xml | 4 ++++ src/app/configs/data/shortcuts_mac.xml | 4 ++++ src/appshell/view/appmenumodel.cpp | 1 + src/engraving/dom/edit.cpp | 9 +++++++++ src/notation/internal/notationactioncontroller.cpp | 1 + src/notation/internal/notationinteraction.cpp | 1 + src/notation/internal/notationuiactions.cpp | 8 +++++++- src/notation/view/noteinputbarmodel.cpp | 1 + 9 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/app/configs/data/shortcuts.xml b/src/app/configs/data/shortcuts.xml index 7aff6538cc952..0ebb60c0c4d76 100644 --- a/src/app/configs/data/shortcuts.xml +++ b/src/app/configs/data/shortcuts.xml @@ -738,6 +738,10 @@ staff-text Ctrl+T + + dynamics + Ctrl+D + expression-text Ctrl+E diff --git a/src/app/configs/data/shortcuts_azerty.xml b/src/app/configs/data/shortcuts_azerty.xml index d841a82891c63..5c9b1bcd7366f 100644 --- a/src/app/configs/data/shortcuts_azerty.xml +++ b/src/app/configs/data/shortcuts_azerty.xml @@ -764,6 +764,10 @@ staff-text Ctrl+T + + dynamics + Ctrl+D + expression-text Ctrl+E diff --git a/src/app/configs/data/shortcuts_mac.xml b/src/app/configs/data/shortcuts_mac.xml index b9df7baef3024..8186e3135d07e 100644 --- a/src/app/configs/data/shortcuts_mac.xml +++ b/src/app/configs/data/shortcuts_mac.xml @@ -738,6 +738,10 @@ staff-text Ctrl+T + + dynamics + Ctrl+D + expression-text Ctrl+E diff --git a/src/appshell/view/appmenumodel.cpp b/src/appshell/view/appmenumodel.cpp index 3b8c5c6640c35..d9020c97519c6 100644 --- a/src/appshell/view/appmenumodel.cpp +++ b/src/appshell/view/appmenumodel.cpp @@ -609,6 +609,7 @@ MenuItemList AppMenuModel::makeTextItems() makeSeparator(), makeMenuItem("system-text"), makeMenuItem("staff-text"), + makeMenuItem("dynamics"), makeMenuItem("expression-text"), makeMenuItem("rehearsalmark-text"), makeMenuItem("instrument-change-text"), diff --git a/src/engraving/dom/edit.cpp b/src/engraving/dom/edit.cpp index 7e8c2fa400b74..74847c84139aa 100644 --- a/src/engraving/dom/edit.cpp +++ b/src/engraving/dom/edit.cpp @@ -943,6 +943,15 @@ TextBase* Score::addText(TextStyleType type, EngravingItem* destinationElement) undoAddElement(textBox); break; } + case TextStyleType::DYNAMICS: { + ChordRest* chordRest = chordOrRest(destinationElement); + if (!chordRest) { + break; + } + textBox = Factory::createDynamic(dummy()->segment()); + chordRest->undoAddAnnotation(textBox); + break; + } case TextStyleType::HARP_PEDAL_DIAGRAM: case TextStyleType::HARP_PEDAL_TEXT_DIAGRAM: { ChordRest* chordRest = getSelectedChordRest(); diff --git a/src/notation/internal/notationactioncontroller.cpp b/src/notation/internal/notationactioncontroller.cpp index e57ae581fc626..e265d3993ed42 100644 --- a/src/notation/internal/notationactioncontroller.cpp +++ b/src/notation/internal/notationactioncontroller.cpp @@ -327,6 +327,7 @@ void NotationActionController::init() registerAction("system-text", [this]() { addText(TextStyleType::SYSTEM); }); registerAction("staff-text", [this]() { addText(TextStyleType::STAFF); }); + registerAction("dynamics", [this]() { addText(TextStyleType::DYNAMICS); }); registerAction("expression-text", [this]() { addText(TextStyleType::EXPRESSION); }); registerAction("rehearsalmark-text", [this]() { addText(TextStyleType::REHEARSAL_MARK); }); registerAction("instrument-change-text", [this]() { addText(TextStyleType::INSTRUMENT_CHANGE); }); diff --git a/src/notation/internal/notationinteraction.cpp b/src/notation/internal/notationinteraction.cpp index 07f9df815bc6c..7437b5da0efea 100644 --- a/src/notation/internal/notationinteraction.cpp +++ b/src/notation/internal/notationinteraction.cpp @@ -4613,6 +4613,7 @@ Ret NotationInteraction::canAddTextToItem(TextStyleType type, const EngravingIte static const std::set needSelectNoteOrRestTypes { TextStyleType::SYSTEM, TextStyleType::STAFF, + TextStyleType::DYNAMICS, TextStyleType::EXPRESSION, TextStyleType::REHEARSAL_MARK, TextStyleType::INSTRUMENT_CHANGE, diff --git a/src/notation/internal/notationuiactions.cpp b/src/notation/internal/notationuiactions.cpp index 335b0a5afce2d..4d2233d2f1dfb 100644 --- a/src/notation/internal/notationuiactions.cpp +++ b/src/notation/internal/notationuiactions.cpp @@ -1276,6 +1276,12 @@ const UiActionList NotationUiActions::m_actions = { TranslatableString("action", "St&aff text"), TranslatableString("action", "Add text: staff text") ), + UiAction("dynamics", + mu::context::UiCtxProjectOpened, + mu::context::CTX_ANY, + TranslatableString("action", "&Dynamic"), + TranslatableString("action", "Add text: dynamic") + ), UiAction("expression-text", mu::context::UiCtxProjectOpened, mu::context::CTX_ANY, @@ -1309,7 +1315,7 @@ const UiActionList NotationUiActions::m_actions = { UiAction("chord-text", mu::context::UiCtxProjectOpened, mu::context::CTX_ANY, - TranslatableString("action", "Chor&d symbol"), + TranslatableString("action", "C&hord symbol"), TranslatableString("action", "Add text: chord symbol") ), UiAction("roman-numeral-text", diff --git a/src/notation/view/noteinputbarmodel.cpp b/src/notation/view/noteinputbarmodel.cpp index ae383b567436f..da031e47a5065 100644 --- a/src/notation/view/noteinputbarmodel.cpp +++ b/src/notation/view/noteinputbarmodel.cpp @@ -740,6 +740,7 @@ MenuItemList NoteInputBarModel::makeTextItems() makeMenuItem("system-text"), makeMenuItem("staff-text"), makeMenuItem("expression-text"), + makeMenuItem("dynamics"), makeMenuItem("rehearsalmark-text"), makeMenuItem("instrument-change-text"), makeMenuItem("fingering-text"), From 83f4b53c44f2358a67c59bcaacc25425449e0a25 Mon Sep 17 00:00:00 2001 From: CMakeScore <185574671+CMakeScore@users.noreply.github.com> Date: Tue, 5 Nov 2024 23:43:53 +0900 Subject: [PATCH 2/2] Assign to voice according to preferences --- src/notation/internal/notationinteraction.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/notation/internal/notationinteraction.cpp b/src/notation/internal/notationinteraction.cpp index 7437b5da0efea..c49bc3a0a61cc 100644 --- a/src/notation/internal/notationinteraction.cpp +++ b/src/notation/internal/notationinteraction.cpp @@ -4676,6 +4676,10 @@ void NotationInteraction::addText(TextStyleType type, EngravingItem* item) } } + if (text->hasVoiceAssignmentProperties()) { + text->setInitialTrackAndVoiceAssignment(item->track(), false); + } + apply(); showItem(text);