Skip to content

Commit

Permalink
Merge pull request #25252 from CMakeScore/text-shortcuts-improvements
Browse files Browse the repository at this point in the history
Fix #19121: Create dynamics with shortcut or through "Add -> Text" menu
  • Loading branch information
mathesoncalum authored Nov 6, 2024
2 parents 3f9e519 + 83f4b53 commit 92c997f
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/app/configs/data/shortcuts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,10 @@
<key>staff-text</key>
<seq>Ctrl+T</seq>
</SC>
<SC>
<key>dynamics</key>
<seq>Ctrl+D</seq>
</SC>
<SC>
<key>expression-text</key>
<seq>Ctrl+E</seq>
Expand Down
4 changes: 4 additions & 0 deletions src/app/configs/data/shortcuts_azerty.xml
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,10 @@
<key>staff-text</key>
<seq>Ctrl+T</seq>
</SC>
<SC>
<key>dynamics</key>
<seq>Ctrl+D</seq>
</SC>
<SC>
<key>expression-text</key>
<seq>Ctrl+E</seq>
Expand Down
4 changes: 4 additions & 0 deletions src/app/configs/data/shortcuts_mac.xml
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,10 @@
<key>staff-text</key>
<seq>Ctrl+T</seq>
</SC>
<SC>
<key>dynamics</key>
<seq>Ctrl+D</seq>
</SC>
<SC>
<key>expression-text</key>
<seq>Ctrl+E</seq>
Expand Down
1 change: 1 addition & 0 deletions src/appshell/view/appmenumodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
9 changes: 9 additions & 0 deletions src/engraving/dom/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/notation/internal/notationactioncontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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); });
Expand Down
5 changes: 5 additions & 0 deletions src/notation/internal/notationinteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4609,6 +4609,7 @@ Ret NotationInteraction::canAddTextToItem(TextStyleType type, const EngravingIte
static const std::set<TextStyleType> needSelectNoteOrRestTypes {
TextStyleType::SYSTEM,
TextStyleType::STAFF,
TextStyleType::DYNAMICS,
TextStyleType::EXPRESSION,
TextStyleType::REHEARSAL_MARK,
TextStyleType::INSTRUMENT_CHANGE,
Expand Down Expand Up @@ -4671,6 +4672,10 @@ void NotationInteraction::addText(TextStyleType type, EngravingItem* item)
}
}

if (text->hasVoiceAssignmentProperties()) {
text->setInitialTrackAndVoiceAssignment(item->track(), false);
}

apply();
showItem(text);

Expand Down
8 changes: 7 additions & 1 deletion src/notation/internal/notationuiactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/notation/view/noteinputbarmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit 92c997f

Please sign in to comment.