-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24753 from mathesoncalum/percussions_layout
Percussion panel - layout and interaction basics
- Loading branch information
Showing
14 changed files
with
1,009 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
192 changes: 192 additions & 0 deletions
192
src/notation/qml/MuseScore/NotationScene/PercussionPanel.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
/* | ||
* SPDX-License-Identifier: GPL-3.0-only | ||
* MuseScore-Studio-CLA-applies | ||
* | ||
* MuseScore Studio | ||
* Music Composition & Notation | ||
* | ||
* Copyright (C) 2024 MuseScore Limited | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as | ||
* published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
import QtQuick 2.15 | ||
import QtQuick.Layouts | ||
|
||
import Muse.Ui 1.0 | ||
import Muse.UiComponents 1.0 | ||
import MuseScore.NotationScene 1.0 | ||
|
||
import "internal" | ||
|
||
Item { | ||
id: root | ||
|
||
property NavigationSection navigationSection: null | ||
property int contentNavigationPanelOrderStart: 1 | ||
|
||
anchors.fill: parent | ||
|
||
//TODO: #22050 needed for this | ||
/* | ||
property Component toolbarComponent: PercussionPanelToolBar { | ||
navigation.section: root.navigationSection | ||
navigation.order: root.contentNavigationPanelOrderStart | ||
model: percussionPanelModel | ||
panelWidth: root.width | ||
} | ||
*/ | ||
|
||
Component.onCompleted: { | ||
padGrid.model.load() | ||
} | ||
|
||
PercussionPanelModel { | ||
id: percModel | ||
} | ||
|
||
// TODO: Will live inside percussion panel until #22050 is implemented | ||
PercussionPanelToolBar { | ||
id: toolbar | ||
|
||
anchors.top: parent.top | ||
|
||
width: parent.width | ||
height: 36 | ||
|
||
navigation.section: root.navigationSection | ||
navigation.order: root.contentNavigationPanelOrderStart | ||
|
||
model: percModel | ||
|
||
panelWidth: root.width | ||
} | ||
|
||
StyledFlickable { | ||
id: flickable | ||
|
||
anchors.top: toolbar.bottom | ||
anchors.bottom: parent.bottom | ||
anchors.horizontalCenter: parent.horizontalCenter | ||
|
||
width: Math.min(rowLayout.width, parent.width) | ||
|
||
contentWidth: rowLayout.width | ||
contentHeight: rowLayout.height | ||
|
||
RowLayout { | ||
id: rowLayout | ||
|
||
// side columns being the "delete row" buttons on the left, and the "add row" button on the right | ||
readonly property int sideColumnsWidth: addRowButton.width | ||
|
||
height: padGrid.cellHeight * padGrid.numRows | ||
spacing: padGrid.spacing / 2 | ||
|
||
Column { | ||
id: deleteButtonsColumn | ||
|
||
Layout.alignment: Qt.AlignTop | ||
Layout.fillHeight: true | ||
|
||
width: rowLayout.sideColumnsWidth | ||
|
||
visible: percModel.currentPanelMode === PanelMode.EDIT_LAYOUT | ||
|
||
Repeater { | ||
model: padGrid.numRows | ||
|
||
delegate: Item { | ||
id: deleteButtonArea | ||
|
||
width: parent.width | ||
height: padGrid.cellHeight | ||
|
||
FlatButton { | ||
id: deleteButton | ||
|
||
anchors.verticalCenter: parent.verticalCenter | ||
anchors.right: parent.right | ||
|
||
visible: model.index > 0 | ||
|
||
icon: IconCode.DELETE_TANK | ||
backgroundRadius: deleteButton.width / 2 | ||
|
||
onClicked: { | ||
padGrid.model.deleteRow(model.index) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
GridView { | ||
id: padGrid | ||
|
||
readonly property int numRows: Math.floor(model.numPads / numColumns) | ||
readonly property int numColumns: model.numColumns | ||
readonly property int spacing: 20 | ||
|
||
Layout.alignment: Qt.AlignTop | ||
Layout.fillHeight: true | ||
|
||
width: cellWidth * numColumns | ||
|
||
interactive: false | ||
|
||
cellWidth: 100 + padGrid.spacing | ||
cellHeight: 100 + padGrid.spacing | ||
|
||
model: percModel.padListModel | ||
|
||
delegate: Item { | ||
id: padArea | ||
|
||
width: padGrid.cellWidth | ||
height: padGrid.cellHeight | ||
|
||
PercussionPanelPad { | ||
anchors.centerIn: parent | ||
|
||
width: parent.width - padGrid.spacing | ||
height: parent.height - padGrid.spacing | ||
|
||
padModel: model.padModelRole | ||
panelMode: percModel.currentPanelMode | ||
useNotationPreview: percModel.useNotationPreview | ||
} | ||
} | ||
} | ||
|
||
FlatButton { | ||
id: addRowButton | ||
|
||
// Display to the right of the last pad | ||
Layout.alignment: Qt.AlignBottom | ||
Layout.bottomMargin: (padGrid.cellHeight / 2) - (height / 2) | ||
|
||
visible: percModel.currentPanelMode === PanelMode.EDIT_LAYOUT | ||
|
||
icon: IconCode.PLUS | ||
text: qsTrc("notation", "Add row") | ||
orientation: Qt.Horizontal | ||
onClicked: { | ||
padGrid.model.addRow() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
109 changes: 109 additions & 0 deletions
109
src/notation/qml/MuseScore/NotationScene/internal/PercussionPanelPad.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* SPDX-License-Identifier: GPL-3.0-only | ||
* MuseScore-Studio-CLA-applies | ||
* | ||
* MuseScore Studio | ||
* Music Composition & Notation | ||
* | ||
* Copyright (C) 2024 MuseScore Limited | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as | ||
* published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
import QtQuick 2.15 | ||
|
||
import Muse.Ui 1.0 | ||
import Muse.UiComponents 1.0 | ||
import MuseScore.NotationScene 1.0 | ||
|
||
Rectangle { | ||
id: root | ||
|
||
property var padModel: null | ||
|
||
property int panelMode: -1 | ||
property bool useNotationPreview: false | ||
|
||
radius: root.width / 6 | ||
|
||
color: root.useNotationPreview ? "white" : ui.theme.backgroundSecondaryColor | ||
|
||
border.color: root.panelMode === PanelMode.EDIT_LAYOUT ? ui.theme.accentColor : "transparent" | ||
border.width: 2 | ||
|
||
Item { | ||
id: contentArea | ||
|
||
anchors.fill: parent | ||
|
||
visible: Boolean(root.padModel) ? !root.padModel.isEmptySlot : false | ||
|
||
StyledTextLabel { | ||
id: instrumentNameLabel | ||
|
||
visible: !root.useNotationPreview | ||
|
||
anchors.centerIn: parent | ||
anchors.margins: 5 | ||
|
||
width: parent.width | ||
|
||
wrapMode: Text.WordWrap | ||
|
||
text: Boolean(root.padModel) ? root.padModel.instrumentName : "" | ||
} | ||
|
||
StyledTextLabel { | ||
// placeholder component - reflects the current state of the pad/panel | ||
id: modeLabel | ||
|
||
anchors.horizontalCenter: parent.horizontalCenter | ||
anchors.bottom: parent.bottom | ||
anchors.margins: 5 | ||
|
||
width: parent.width | ||
|
||
color: root.useNotationPreview ? "black" : "white" | ||
|
||
wrapMode: Text.WordWrap | ||
} | ||
} | ||
|
||
states: [ | ||
State { | ||
name: "WRITE" | ||
when: root.panelMode === PanelMode.WRITE | ||
PropertyChanges { | ||
target: modeLabel | ||
|
||
// See modeLabel - these are all placeholder strings | ||
text: "Write mode" | ||
} | ||
}, | ||
State { | ||
name: "SOUND_PREVIEW" | ||
when: root.panelMode === PanelMode.SOUND_PREVIEW | ||
PropertyChanges { | ||
target: modeLabel | ||
text: "Sound preview mode" | ||
} | ||
}, | ||
State { | ||
name: "EDIT_LAYOUT" | ||
when: root.panelMode === PanelMode.EDIT_LAYOUT | ||
PropertyChanges { | ||
target: modeLabel | ||
text: "Edit layout mode" | ||
} | ||
} | ||
] | ||
} |
Oops, something went wrong.