-
Notifications
You must be signed in to change notification settings - Fork 3
/
HSVSlider.qml
149 lines (127 loc) · 3.58 KB
/
HSVSlider.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import QtQuick
import QtQuick.Layouts
import ColorPicker
import Origin.Controls
Item {
id: control
required property ColorPickerBackend backend
signal editFinished
implicitWidth: col.implicitWidth
implicitHeight: col.implicitHeight
ColumnLayout {
id: col
anchors.fill: parent
spacing: 1
ColorSlider {
id: hueSlider
Layout.fillWidth: true
Layout.preferredHeight: 32
label: "H"
value: control.backend.currentColor.hsvHue
sliderBackgroundGradient: Gradient {
orientation: Gradient.Horizontal
GradientStop {
position: 0.0
color: "red"
}
GradientStop {
position: (60.0 / 360)
color: "yellow"
}
GradientStop {
position: (120.0 / 360)
color: "green"
}
GradientStop {
position: (180.0 / 360)
color: "cyan"
}
GradientStop {
position: (240.0 / 360)
color: "blue"
}
GradientStop {
position: (300.0 / 360)
color: "magenta"
}
GradientStop {
position: 1.0
color: "red"
}
}
onEditFinished: control.editFinished()
onValueModified: (newValue) => {
control.backend.currentColor.hsvHue = newValue
}
}
ColorSlider {
id: satSlider
Layout.fillWidth: true
Layout.preferredHeight: 32
label: "S"
value: control.backend.currentColor.hsvSaturation
sliderBackgroundGradient: Gradient {
orientation: Gradient.Horizontal
GradientStop {
position: 0.0
color: Qt.hsva(control.backend.currentColor.hsvHue, 0, control.backend.currentColor.hsvValue)
}
GradientStop {
position: 1.0
color: control.backend.currentColor
}
}
onEditFinished: control.editFinished()
onValueModified: (newValue) => {
control.backend.currentColor.hsvSaturation = newValue
}
}
ColorSlider {
id: valSlider
Layout.fillWidth: true
Layout.preferredHeight: 32
label: "V"
value: control.backend.currentColor.hsvValue
sliderBackgroundGradient: Gradient {
orientation: Gradient.Horizontal
GradientStop {
position: 0.0
color: Qt.hsva(control.backend.currentColor.hsvHue, control.backend.currentColor.hsvSaturation, 0)
}
GradientStop {
position: 1.0
color: control.backend.currentColor
}
}
onEditFinished: control.editFinished()
onValueModified: (newValue) => {
control.backend.currentColor.hsvValue = newValue
}
}
ColorSlider {
id: alphaSlider
Layout.fillWidth: true
Layout.preferredHeight: 32
label: "A"
value: control.backend.currentColor.a
sliderBackgroundGradient: Gradient {
orientation: Gradient.Horizontal
GradientStop {
position: 0.0
color: Qt.hsva(control.backend.currentColor.hsvHue, control.backend.currentColor.hsvSaturation, control.backend.currentColor.hsvValue, 0)
}
GradientStop {
position: 1.0
color: control.backend.currentColor
}
}
onEditFinished: control.editFinished()
onValueModified: (newValue) => {
control.backend.currentColor.a = newValue
}
}
Item {
Layout.fillHeight: implicitHeight > 0 ? false : true
}
}
}