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

QML: Add support for selecting/loading effects #4000

Merged
merged 26 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8cab623
QML: Add EffectManager proxy and visibleEffectModel
Holzhaus Jun 15, 2021
9a797ee
skins/QMLDemo: Use actual visibleEffectList from EffectManager
Holzhaus Jun 15, 2021
2b9f3e2
QML: Add a way to load effects via effect manager
Holzhaus Jun 15, 2021
dea4f22
skins/QMLDemo: Enable switching effects via comboboxes
Holzhaus Jun 15, 2021
5855308
QML: Add QmlEffectSlotProxy
Holzhaus Jun 15, 2021
58ed35d
skins/QMLDemo: Listen to effect changes via COs and update ComboBox
Holzhaus Jun 15, 2021
79e555b
skins/QMLDemo: Move EffectSlot to separate file
Holzhaus Jun 20, 2021
2d0234e
skins/QMLDemo: Ensure that the correct effect is selected after start
Holzhaus Jun 20, 2021
9e7756e
skins/QMLDemo: Make EffectUnit expandable
Holzhaus Jun 20, 2021
8775193
QML: Expose Effect slot parameters as model
Holzhaus Jun 21, 2021
66e33f2
skin/QMLDemo: Display EffectSlot parameters using ListView
Holzhaus Jun 21, 2021
7098d11
Merge branch 'main' of github.com:mixxxdj/mixxx into qml-effects
Holzhaus Jun 21, 2021
7486a67
skins/QMLDemo: Fix broken EffectUnit bg when single unit is expanded
Holzhaus Jun 21, 2021
534df61
skins/QMLDemo: Use actual type instead var for property declaration
Holzhaus Jun 21, 2021
8b5eeef
skins/QMLDemo: Remove obsolete TODO comment
Holzhaus Jun 21, 2021
aa271d8
QML: Add TODO for enum usage to QmlEffectManifestParametersModel
Holzhaus Jun 21, 2021
93dec8e
skins/QMLDemo: Use JS template strings instead of concatenation
Holzhaus Jun 21, 2021
c8cb59a
skins/QMLDemo: Fix MiniKnob indicator and reduce duplication
Holzhaus Jun 21, 2021
f58eabc
skins/QMLDemo: Use fixed width for knob indicator
Holzhaus Jun 21, 2021
ae7408f
skins/QMLDemo: Fix label for FX parameters where shortName is not set
Holzhaus Jun 21, 2021
c20b1e2
skins/QMLDemo: Increase effect parameter width to prevent elided text
Holzhaus Jun 21, 2021
fdb46c0
skins/QMLDemo: Add TODO regarding null coalescing
Holzhaus Jun 22, 2021
77650d1
skins/QMLDemo: Make effect param buttons toggleable and add label
Holzhaus Jun 22, 2021
3265842
skins/QMLDemo: Show dryWet/superKnob only when EffectUnit is expanded
Holzhaus Jun 22, 2021
a99bd50
QML: Add a way to retrieve the Effect parameter control key from model
Holzhaus Jun 22, 2021
c8cfefa
skins/QMLDemo: Fix wrong effect parameter control keys
Holzhaus Jun 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -771,9 +771,13 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
src/skin/qml/asyncimageprovider.cpp
src/skin/qml/qmlcontrolproxy.cpp
src/skin/qml/qmlconfigproxy.cpp
src/skin/qml/qmleffectmanifestparametersmodel.cpp
src/skin/qml/qmleffectsmanagerproxy.cpp
src/skin/qml/qmleffectslotproxy.cpp
src/skin/qml/qmlplayermanagerproxy.cpp
src/skin/qml/qmlplayerproxy.cpp
src/skin/qml/qmlskin.cpp
src/skin/qml/qmlvisibleeffectsmodel.cpp
src/skin/qml/qmlwaveformoverview.cpp
src/skin/legacy/skincontext.cpp
src/skin/legacy/tooltips.cpp
Expand Down
3 changes: 2 additions & 1 deletion res/skins/QMLDemo/ComboBox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ ComboBox {
delegate: ItemDelegate {
width: parent.width
highlighted: root.highlightedIndex === index
text: root.textAt(index)

contentItem: Text {
text: modelData
text: parent.text
color: Theme.deckTextColor
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
Expand Down
42 changes: 30 additions & 12 deletions res/skins/QMLDemo/EffectRow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,43 @@ import "." as Skin
import QtQuick 2.12
import QtQuick.Controls 2.12

Row {
Item {
id: root

height: 60
width: positioner.width
height: positioner.height

Skin.EffectUnit {
id: effectUnit1
Row {
id: positioner

Skin.EffectUnit {
id: effectUnit1

width: root.width / 2
unitNumber: 1
}

Skin.EffectUnit {
id: effectUnit2

width: root.width / 2
unitNumber: 2
}

width: root.width / 2
height: root.height
unitNumber: 1
}

Skin.EffectUnit {
id: effectUnit2
Skin.SectionBackground {
Holzhaus marked this conversation as resolved.
Show resolved Hide resolved
anchors.top: parent.top
anchors.left: parent.left
anchors.bottom: parent.bottom
anchors.right: parent.horizontalCenter
}

width: root.width / 2
height: root.height
unitNumber: 2
Skin.SectionBackground {
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: parent.horizontalCenter
anchors.right: parent.right
}

}
199 changes: 199 additions & 0 deletions res/skins/QMLDemo/EffectSlot.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
import "." as Skin
import Mixxx 0.1 as Mixxx
import QtQuick 2.12
import "Theme"

Item {
id: root

property Mixxx.EffectSlotProxy slot: Mixxx.EffectsManager.getEffectSlot(1, unitNumber, effectNumber)
property int unitNumber // required
property int effectNumber // required
property bool expanded: false
readonly property string group: slot.group
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
readonly property string group: slot.group
property alias group: slot.group

I assume this doesn't work?

Copy link
Member Author

Choose a reason for hiding this comment

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

Didn't try, maybe the readonly flag from the slot property is also applying to the alias. I can check.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, doesn't work. Maybe because the order of property initializiation is not defined or something:

warning [Main] file:///home/jan/Projects/mixxx/res/skins/QMLDemo/main.qml:120:9: Type EffectRow unavailable
             EffectRow {
             ^
warning [Main] file:///home/jan/Projects/mixxx/res/skins/QMLDemo/EffectRow.qml:14:9: Type Skin.EffectUnit unavailable
             Skin.EffectUnit {
             ^
warning [Main] file:///home/jan/Projects/mixxx/res/skins/QMLDemo/EffectUnit.qml:24:9: Type EffectSlot unavailable
             EffectSlot {
             ^
warning [Main] file:///home/jan/Projects/mixxx/res/skins/QMLDemo/EffectSlot.qml:13:27: Invalid alias reference. Unable to find id "slot"
         property alias group: slot.group
                               ^
warning [Main] Skin "QMLDemo" failed to load!

Copy link
Member

Choose a reason for hiding this comment

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

Mhmm thats strange. I guess I'm misinterpreting the Qt docs section https://doc.qt.io/qt-5/qtqml-syntax-objectattributes.html#considerations-for-property-aliases

property real maxSelectorWidth: 300

height: 50

Item {
id: selector

anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
width: Math.min(root.width, root.maxSelectorWidth)

Skin.ControlButton {
id: effectEnableButton

anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.margins: 5
width: 40
group: root.group
key: "enabled"
toggleable: true
text: "ON"
activeColor: Theme.effectColor
}

Skin.ComboBox {
id: effectSelector

anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: effectEnableButton.right
anchors.right: effectMetaKnob.left
anchors.margins: 5
textRole: "display"
model: Mixxx.EffectsManager.visibleEffectsModel
onActivated: {
const effectId = model.get(index).effectId;
if (root.slot.effectId != effectId)
root.slot.effectId = effectId;

}
Component.onCompleted: root.slot.onEffectIdChanged()

Swiftb0y marked this conversation as resolved.
Show resolved Hide resolved
Connections {
function onEffectIdChanged() {
const rowCount = effectSelector.model.rowCount();
// TODO: Consider using an additional QHash in the
// model and provide a more efficient lookup method
for (let i = 0; i < rowCount; i++) {
if (effectSelector.model.get(i).effectId === target.effectId) {
effectSelector.currentIndex = i;
break;
}
}
}

target: root.slot
}

}

Skin.ControlMiniKnob {
id: effectMetaKnob

anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.margins: 5
arcStart: Knob.ArcStart.Minimum
width: 40
group: root.group
key: "meta"
color: Theme.effectColor
}

}

ListView {
id: parametersView

visible: root.expanded
anchors.leftMargin: 10
anchors.top: parent.top
anchors.left: selector.right
anchors.right: parent.right
anchors.bottom: parent.bottom
clip: true
spacing: 5
model: root.slot.parametersModel
orientation: ListView.Horizontal

delegate: Item {
id: parameter

property int number: index + 1
// TODO: Use null coalescing when we switch to Qt >= 5.15
property string label: shortName ? shortName : name
Holzhaus marked this conversation as resolved.
Show resolved Hide resolved
property string key: controlKey
property bool isButton: controlHint > 0 && controlHint == 6
property bool isKnob: controlHint > 0 && controlHint < 6

width: 50
height: 50

EmbeddedText {
anchors.fill: parent
verticalAlignment: Text.AlignBottom
text: parameter.label
font.bold: false
}

Skin.ControlMiniKnob {
id: parameterKnob

width: 30
height: 30
anchors.centerIn: parent
arcStart: 0
group: root.group
key: parameter.key
color: Theme.effectColor
visible: parameter.isKnob

Mixxx.ControlProxy {
id: parameterLoadedControl

property bool loaded: value != 0

group: root.group
key: parameter.key + "_loaded"
}

}

Skin.ControlButton {
id: buttonParameterButton

height: 22
width: parent.width
anchors.centerIn: parent
group: root.group
key: parameter.key
activeColor: Theme.effectColor
visible: parameter.isButton
toggleable: true
text: "ON"

Mixxx.ControlProxy {
id: buttonParameterLoadedControl

property bool loaded: value != 0

group: root.group
key: parameter.key + "_loaded"
}

}

}

populate: Transition {
NumberAnimation {
property: "opacity"
from: 0
to: 1
duration: 200
}

NumberAnimation {
property: "scale"
from: 0
to: 1
duration: 200
}

}

Skin.FadeBehavior on opacity {
fadeTarget: parametersView
}

}

}
Loading