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

Percussion panel - refinements round 4 #25958

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mathesoncalum
Copy link
Contributor

@mathesoncalum mathesoncalum commented Dec 31, 2024

This PR contains an assortment of small fixes for the percussion panel, alongside two more substantial changes.

Small Fixes

The small fixes (ce17022) are as follows:

  1. Corrected the background colour for notation preview (paintNotationPreview)
  2. Fixed the vertical alignment of the "disabled state" text (PercussionPanel.qml)
  3. Fixed a bug (and assertion failure) when selecting an unpitched staff during layout edit (finishEditing)
  4. Keyboard focus now moves to pads when starting layout edit (handleMenuItem)
  5. Fixed clipped navigation border on "add row" button (PercussionPanel.qml)
  6. Fixed sounds not previewing properly (this was a placeholder before, we simply need to use getDrumNoteForPreview so that the playback controller receives the correct noteheads, etc.)
  7. Added forgotten overrides from recent refinements PR (notationconfiguration.h)
  8. Tweaked ChangeDrumset (see comment)

Footer Context Menus

One of the "substantial changes" (89156ff) was to implement "footer context menus" for the pads (see image), with associated "duplicate" and "delete" actions. A menu option for assigning keyboard shortcuts to the pads has also been included, but the logic for this action does not exist yet (will be included in a future PR).

Screenshot 2024-12-31 at 09 21 24

This commit also includes a quick refactor to PercussionPanelModel::layoutMenuItems. The "checkable" logic has been simplified, and the definition of translatable strings has been corrected (per this comment).

Fixing undo, redo, and reset

The other substantial change (7335c37) isn't substantial LOC-wise, but has implications beyond the new percussion panel and requires some explanation. This seeks to resolve a bug where the panel doesn't always update visually on undo, redo, and reset layout.

The underlying cause was that NotationNoteInput::stateChanged (the main notification that the percussion panel uses to update) was not being triggered on undo/redo. To my eye, this seems incorrect as NotationInteraction::undo does eventually lead to a Score::setInputState call (inside UndoMacro::undo).

The second part of this commit (the changes the finishEditing) are mostly academic. The idea is to make PercussionPanelPadListModel::drumset const so that the drumset can only be modified through the sanctioned setter.

@mathesoncalum mathesoncalum force-pushed the percussions_refinements_4 branch 2 times, most recently from 5ac593c to ce17022 Compare January 3, 2025 10:42
@mathesoncalum
Copy link
Contributor Author

Cheers @cbjeukendrup - that should be everything addressed now

? TranslatableString("notation/percussion", "Finish editing")
: TranslatableString("notation/percussion", "Edit layout");
const int editLayoutIcon = static_cast<int>(IconCode::Code::CONFIGURE);
static const auto editLayoutTitle = m_currentPanelMode == PanelMode::Mode::EDIT_LAYOUT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This static depends on the non-static m_currentPanelMode

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, in this method, there is no need to use TranslatableString, because the only thing you do with it, is calling .qTranslated(). So it should be possible to use just qtrc.

@@ -224,8 +224,7 @@ void PercussionPanelModel::finishEditing(bool discardChanges)
}

// Return if nothing changed after edit...
if (inst->drumset() && updatedDrumset
&& *inst->drumset() == *updatedDrumset) {
if (inst->drumset() && *inst->drumset() == updatedDrumset) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point we're already certain that inst->drumset() is not nullptr, because of the check above, right?

@@ -74,7 +81,45 @@ const QVariant PercussionPanelPadModel::notationPreviewItemVariant() const
return QVariant::fromValue(m_notationPreviewItem);
}

QList<QVariantMap> PercussionPanelPadModel::footerContextMenuItems() const
{
static const auto duplicatePadTitle = muse::TranslatableString("global", "Duplicate");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Same about using qtrc instead of TranslatableString)

Also includes a small refactor to PercussionPanelModel::layoutMenuItems (fixed translatable strings and simplified checkables)
- Fixed notation preview background colour
- Fixed alignment of disabled state text
- Fixed panel not updating properly after selecting an unpitched stave
- Ensured keyboard focus moves to pads when entering/exiting edit layout mode
- Fixed clipped navigation outline for add row button
- Fixed sounds not previewing properly
- Added missing overrides
- Make the Drumset argument in ChangeDrumset const
@mathesoncalum mathesoncalum force-pushed the percussions_refinements_4 branch from ce17022 to 16cb93c Compare January 3, 2025 16:53
@mathesoncalum
Copy link
Contributor Author

Thanks @cbjeukendrup - pushed those tweaks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants