Skip to content

Commit

Permalink
Percussion panel - layout and interaction basics
Browse files Browse the repository at this point in the history
  • Loading branch information
mathesoncalum committed Sep 26, 2024
1 parent d7a9ce4 commit 1ee6840
Show file tree
Hide file tree
Showing 14 changed files with 996 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/appshell/qml/NotationPage/NotationPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,25 @@ DockPage {
dropDestinations: root.horizontalPanelDropDestinations

navigationSection: root.navigationPanelSec(percussionPanel.location)

PercussionPanel {
navigationSection: percussionPanel.navigationSection

// TODO: #22050 needed for this
/*
// contentNavigationPanelOrderStart: percussionPanel.contentNavigationPanelOrderStart
Component.onCompleted: {
percussionPanel.contextMenuModel = contextMenuModel
percussionPanel.toolbarComponent = toolbarComponent
}
Component.onDestruction: {
percussionPanel.contextMenuModel = null
percussionPanel.toolbarComponent = null
}
*/
}
}
]

Expand Down
7 changes: 7 additions & 0 deletions src/notation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/view/editgridsizedialogmodel.cpp
${CMAKE_CURRENT_LIST_DIR}/view/editgridsizedialogmodel.h

${CMAKE_CURRENT_LIST_DIR}/view/percussionpanel/percussionpanelmodel.cpp
${CMAKE_CURRENT_LIST_DIR}/view/percussionpanel/percussionpanelmodel.h
${CMAKE_CURRENT_LIST_DIR}/view/percussionpanel/percussionpanelpadlistmodel.cpp
${CMAKE_CURRENT_LIST_DIR}/view/percussionpanel/percussionpanelpadlistmodel.h
${CMAKE_CURRENT_LIST_DIR}/view/percussionpanel/percussionpanelpadmodel.cpp
${CMAKE_CURRENT_LIST_DIR}/view/percussionpanel/percussionpanelpadmodel.h

${CMAKE_CURRENT_LIST_DIR}/view/pianokeyboard/pianokeyboardtypes.h
${CMAKE_CURRENT_LIST_DIR}/view/pianokeyboard/pianokeyboardcontroller.cpp
${CMAKE_CURRENT_LIST_DIR}/view/pianokeyboard/pianokeyboardcontroller.h
Expand Down
5 changes: 5 additions & 0 deletions src/notation/notationmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
#include "view/internal/caposettingsmodel.h"
#include "view/internal/stringtuningssettingsmodel.h"

#include "view/percussionpanel/percussionpanelmodel.h"

#include "view/styledialog/styleitem.h"
#include "view/styledialog/notespagemodel.h"
#include "view/styledialog/restspagemodel.h"
Expand Down Expand Up @@ -183,6 +185,9 @@ void NotationModule::registerUiTypes()
qmlRegisterType<CapoSettingsModel>("MuseScore.NotationScene", 1, 0, "CapoSettingsModel");
qmlRegisterType<StringTuningsSettingsModel>("MuseScore.NotationScene", 1, 0, "StringTuningsSettingsModel");

qmlRegisterType<PercussionPanelModel>("MuseScore.NotationScene", 1, 0, "PercussionPanelModel");
qmlRegisterUncreatableType<PanelMode>("MuseScore.NotationScene", 1, 0, "PanelMode", "Cannot create");

qmlRegisterUncreatableType<StyleItem>("MuseScore.NotationScene", 1, 0, "StyleItem", "Cannot create StyleItem from QML");
qmlRegisterType<NotesPageModel>("MuseScore.NotationScene", 1, 0, "NotesPageModel");
qmlRegisterType<RestsPageModel>("MuseScore.NotationScene", 1, 0, "RestsPageModel");
Expand Down
3 changes: 3 additions & 0 deletions src/notation/notationscene.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,8 @@
<file>qml/MuseScore/NotationScene/internal/EditStyle/accidentalImages/octaveOffset-ON.png</file>
<file>qml/MuseScore/NotationScene/internal/EditStyle/FretboardsPage.qml</file>
<file>qml/MuseScore/NotationScene/internal/EditStyle/BasicStyleSelectorWithSpinboxAndReset.qml</file>
<file>qml/MuseScore/NotationScene/PercussionPanel.qml</file>
<file>qml/MuseScore/NotationScene/internal/PercussionPanelToolBar.qml</file>
<file>qml/MuseScore/NotationScene/internal/PercussionPanelPad.qml</file>
</qresource>
</RCC>
189 changes: 189 additions & 0 deletions src/notation/qml/MuseScore/NotationScene/PercussionPanel.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
/*
* 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
}
*/

PercussionPanelModel {
id: percModel
}

// TODO: Will live inside percussion panel until #22050 is implemented
PercussionPanelToolBar {
id: toolbar

anchors.top: parent.top

width: parent.width
height: 35

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

ColumnLayout {
id: deleteButtonsColumn

Layout.alignment: Qt.AlignTop
Layout.fillHeight: true

width: rowLayout.sideColumnsWidth

visible: percModel.currentPanelMode === PanelMode.EDIT_LAYOUT

spacing: 0

Repeater {
model: padGrid.numRows

delegate: Item {
id: deleteButtonArea

Layout.fillHeight: true
Layout.fillWidth: true

FlatButton {
id: deleteButton

anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right

visible: model.index > 0

icon: IconCode.DELETE_TANK
backgroundRadius: 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 + spacing
cellHeight: 100 + 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()
}
}
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* 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: 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: root.padModel ? root.padModel.instrumentName : ""
}

StyledTextLabel {
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
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"
}
}
]
}
Loading

0 comments on commit 1ee6840

Please sign in to comment.