Skip to content

Commit

Permalink
Merge pull request #4003 from Swiftb0y/qml-improve-knob-dx
Browse files Browse the repository at this point in the history
QMLDemo: Add enum for specifing knob arc start position
  • Loading branch information
Holzhaus committed Jun 18, 2021
2 parents ff2b9a0 + 7cf26ef commit de3bde2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
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

0 comments on commit de3bde2

Please sign in to comment.