-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathScale.qml
More file actions
62 lines (55 loc) · 2.7 KB
/
Scale.qml
File metadata and controls
62 lines (55 loc) · 2.7 KB
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
import QtQuick 2.0
import "." 1.0
Item {
id: scaleContainer
width: orientation == "vertical" ? childrenRect.width : 0
height: orientation == "horizontal" ? childrenRect.height : 0
property alias label: label
property alias scaleMap: scaleMap
property int baselineThickness: 2
property alias baselineColor: baseline.color
property alias tickDelegate: scale.delegate
property bool flip: false
property string orientation: "vertical"
Rectangle {
id: baseline
anchors.top: orientation == "vertical" ? scale.top : (!flip ? scale.top : undefined)
anchors.bottom: orientation == "vertical" ? scale.bottom : (flip ? scale.bottom : undefined)
anchors.left: orientation == "horizontal" ? scale.left : (flip ? scale.left : undefined)
anchors.right: orientation == "horizontal" ? scale.right : (!flip ? scale.right : undefined)
width: orientation == "vertical" ? baselineThickness : 0
height: orientation == "horizontal" ? baselineThickness : 0
color: "black"
}
LinearScale {
id: scale
orientation: scaleContainer.orientation == "vertical" ? Qt.Vertical : Qt.Horizontal
anchors.top: orientation == Qt.Vertical ? parent.top : (flip ? labelContainer.bottom : undefined)
anchors.bottom: orientation == Qt.Vertical ? parent.bottom : undefined
anchors.left: orientation == Qt.Horizontal ? parent.left : (!flip ? labelContainer.right : undefined)
anchors.right: orientation == Qt.Horizontal ? parent.right : undefined
width: orientation == Qt.Vertical ? childrenRect.width : undefined
height: orientation == Qt.Horizontal ? childrenRect.height : undefined
scaleMap: ScaleMap {
id: scaleMap
valueMapper: ValueMapper {}
scaleMinimum: 0
scaleMaximum: 1000
}
delegate: ValueTick { flip: scaleContainer.flip; orientation: scaleContainer.orientation }
}
Item {
id: labelContainer
anchors.verticalCenter: scale.orientation == Qt.Vertical ? scale.verticalCenter : undefined
anchors.horizontalCenter: scale.orientation == Qt.Horizontal ? scale.horizontalCenter : undefined
anchors.left: (scale.orientation == Qt.Vertical && flip) ? scale.right : undefined
anchors.top: (scale.orientation == Qt.Horizontal && !flip) ? scale.bottom : undefined
width: scale.orientation == Qt.Vertical ? label.height : label.width
height: scale.orientation == Qt.Vertical ? label.width : label.height
Text {
id: label
rotation: scale.orientation == Qt.Horizontal ? 0 : (scaleContainer.flip ? 90 : -90)
anchors.centerIn: parent
}
}
}