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

QMLDemo: Add enum for specifing knob arc start position #4003

Merged
merged 1 commit into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion res/skins/QMLDemo/AuxiliaryUnit.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Row {
anchors.centerIn: parent
width: 48
height: width
arcStart: 0
arcStart: Knob.ArcStart.Minimum
group: root.group
key: "pregain"
color: Theme.gainKnobColor
Expand Down
4 changes: 2 additions & 2 deletions res/skins/QMLDemo/EffectUnit.qml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Item {
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.margins: 5
arcStart: 0
arcStart: Knob.ArcStart.Minimum
width: 40
group: effect.group
key: "meta"
Expand Down Expand Up @@ -93,7 +93,7 @@ Item {
anchors.centerIn: parent
width: 48
height: 48
arcStart: 0
arcStart: Knob.ArcStart.Minimum
group: "[EffectRack1_EffectUnit" + unitNumber + "]"
key: "super1"
color: Theme.effectUnitColor
Expand Down
2 changes: 1 addition & 1 deletion res/skins/QMLDemo/MicrophoneUnit.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Row {
anchors.centerIn: parent
width: 48
height: width
arcStart: 0
arcStart: Knob.ArcStart.Minimum
group: root.group
key: "pregain"
color: Theme.gainKnobColor
Expand Down
22 changes: 19 additions & 3 deletions res/skins/QMLDemo/Mixxx/Controls/Knob.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import QtQuick.Shapes 1.12
Item {
id: root

enum ArcStart {
Minimum,
Center,
Maximum
}

property real value: min
property alias background: background.data
property alias foreground: foreground.data
Expand All @@ -14,8 +20,18 @@ Item {
property real wheelStepSize: (root.max - root.min) / 10
property real angle: 130
property bool arc: false
property int arcStart: Knob.Center
property real arcRadius: width / 2
property real arcStart: (max - min) / 2
readonly property real arcStartValue: {
switch (arcStart) {
case Knob.ArcStart.Minimum:
return min;
case Knob.ArcStart.Maximum:
return max;
default:
return valueCenter;
}
}
property real arcOffsetX: 0
property real arcOffsetY: 0
property alias arcColor: arcPath.strokeColor
Expand Down Expand Up @@ -56,8 +72,8 @@ Item {
fillColor: "transparent"

PathAngleArc {
startAngle: root.angleFrom(root.arcStart - root.valueCenter) - 90
sweepAngle: root.angleFrom(root.value - root.arcStart)
startAngle: root.angleFrom(root.arcStartValue - root.valueCenter) - 90
sweepAngle: root.angleFrom(root.value - root.arcStartValue)
radiusX: root.arcRadius
radiusY: root.arcRadius
centerX: root.width / 2 + root.arcOffsetX
Expand Down