Skip to content

Commit 1150e52

Browse files
committed
Percussion panel - assorted small fixes:
- 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
1 parent 694f94a commit 1150e52

File tree

6 files changed

+30
-22
lines changed

6 files changed

+30
-22
lines changed

src/notation/internal/notationconfiguration.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,11 @@ class NotationConfiguration : public INotationConfiguration, public muse::async:
207207
muse::async::Notification autoShowPercussionPanelChanged() const override;
208208

209209
bool showPercussionPanelPadSwapDialog() const override;
210-
void setShowPercussionPanelPadSwapDialog(bool show);
210+
void setShowPercussionPanelPadSwapDialog(bool show) override;
211211
muse::async::Notification showPercussionPanelPadSwapDialogChanged() const override;
212212

213213
bool percussionPanelMoveMidiNotesAndShortcuts() const override;
214-
void setPercussionPanelMoveMidiNotesAndShortcuts(bool move);
214+
void setPercussionPanelMoveMidiNotesAndShortcuts(bool move) override;
215215
muse::async::Notification percussionPanelMoveMidiNotesAndShortcutsChanged() const override;
216216

217217
muse::io::path_t styleFileImportPath() const override;

src/notation/qml/MuseScore/NotationScene/PercussionPanel.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ Item {
415415
orientation: Qt.Horizontal
416416

417417
navigation.panel: addRowButtonPanel
418+
drawFocusBorderInsideRect: true
418419

419420
onClicked: {
420421
padGrid.model.addEmptyRow()
@@ -434,6 +435,7 @@ Item {
434435

435436
font: ui.theme.bodyFont
436437
text: qsTrc("notation/percussion", "Select an unpitched percussion staff to see available sounds")
438+
verticalAlignment: Text.AlignVCenter
437439
}
438440
}
439441

src/notation/view/paintedengravingitem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void PaintedEngravingItem::paintNotationPreview(muse::draw::Painter& painter, qr
8888

8989
params.drawStaff = true;
9090

91-
painter.fillRect(params.rect, configuration()->scoreInversionColor());
91+
painter.fillRect(params.rect, configuration()->noteBackgroundColor());
9292

9393
EngravingItemPreviewPainter::paintPreview(m_item.get(), params);
9494
}

src/notation/view/percussionpanel/percussionpanelmodel.cpp

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
*/
2222

2323
#include "percussionpanelmodel.h"
24+
25+
#include "notation/utilities/percussionutilities.h"
26+
2427
#include "types/translatablestring.h"
2528
#include "ui/view/iconcodes.h"
2629

@@ -169,6 +172,7 @@ void PercussionPanelModel::handleMenuItem(const QString& itemId)
169172
} else if (itemId == EDIT_LAYOUT_CODE) {
170173
const bool currentlyEditing = m_currentPanelMode == PanelMode::Mode::EDIT_LAYOUT;
171174
currentlyEditing ? finishEditing() : setCurrentPanelMode(PanelMode::Mode::EDIT_LAYOUT);
175+
currentlyEditing ? m_padListModel->focusFirstActivePad() : m_padListModel->padFocusRequested(0);
172176
} else if (itemId == RESET_LAYOUT_CODE) {
173177
resetLayout();
174178
}
@@ -190,13 +194,13 @@ void PercussionPanelModel::finishEditing(bool discardChanges)
190194
Instrument* inst = instAndPart.first;
191195
Part* part = instAndPart.second;
192196

193-
IF_ASSERT_FAILED(inst && inst->drumset() && part) {
197+
if (discardChanges) {
198+
m_padListModel->setDrumset(inst ? inst->drumset() : nullptr);
199+
setCurrentPanelMode(m_panelModeToRestore);
194200
return;
195201
}
196202

197-
if (discardChanges) {
198-
m_padListModel->setDrumset(inst->drumset());
199-
setCurrentPanelMode(m_panelModeToRestore);
203+
IF_ASSERT_FAILED(inst && inst->drumset() && part) {
200204
return;
201205
}
202206

@@ -435,26 +439,17 @@ void PercussionPanelModel::writePitch(int pitch)
435439

436440
void PercussionPanelModel::playPitch(int pitch)
437441
{
438-
const mu::engraving::InputState& inputState = score()->inputState();
439-
if (!inputState.cr()) {
442+
if (!interaction()) {
440443
return;
441444
}
442445

443-
Chord* chord = mu::engraving::Factory::createChord(inputState.lastSegment());
444-
chord->setParent(inputState.lastSegment());
445-
446-
Note* note = mu::engraving::Factory::createNote(chord);
447-
note->setParent(chord);
448-
449-
note->setStaffIdx(mu::engraving::track2staff(inputState.cr()->track()));
450-
451-
const mu::engraving::NoteVal nval = score()->noteVal(pitch, /*transpose*/ false);
452-
note->setNval(nval);
446+
const NoteInputState inputState = interaction()->noteInput()->state();
447+
std::shared_ptr<Chord> chord = PercussionUtilities::getDrumNoteForPreview(m_padListModel->drumset(), pitch);
453448

454-
playbackController()->playElements({ note });
449+
chord->setParent(inputState.segment);
450+
chord->setTrack(inputState.currentTrack);
455451

456-
note->setParent(nullptr);
457-
delete note;
452+
playbackController()->playElements({ chord.get() });
458453
}
459454

460455
void PercussionPanelModel::resetLayout()

src/notation/view/percussionpanel/percussionpanelpadlistmodel.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,16 @@ mu::engraving::Drumset PercussionPanelPadListModel::constructDefaultLayout(const
225225
return defaultLayout;
226226
}
227227

228+
void PercussionPanelPadListModel::focusFirstActivePad()
229+
{
230+
for (int i = 0; i < m_padModels.size(); i++) {
231+
if (m_padModels.at(i)) {
232+
emit padFocusRequested(i);
233+
return;
234+
}
235+
}
236+
}
237+
228238
void PercussionPanelPadListModel::focusLastActivePad()
229239
{
230240
for (int i = m_padModels.size() - 1; i >= 0; --i) {

src/notation/view/percussionpanel/percussionpanelpadlistmodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class PercussionPanelPadListModel : public QAbstractListModel, public muse::Inje
8181
int nextAvailableIndex(int pitch) const; //! NOTE: This may be equal to m_padModels.size()
8282
int nextAvailablePitch(int pitch) const;
8383

84+
void focusFirstActivePad();
8485
void focusLastActivePad();
8586

8687
muse::async::Notification hasActivePadsChanged() const { return m_hasActivePadsChanged; }

0 commit comments

Comments
 (0)