This repository has been archived by the owner on Feb 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ABitmapParameter.qml
83 lines (78 loc) · 3.12 KB
/
ABitmapParameter.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
import QtQuick 2.0
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
Flow {
property var eeParameterData
spacing: globStyle.size * 0.4
flow: Flow.LeftToRight
Repeater {
id: repeaterBitmap
model: eeParameterData.count
GridLayout {
property real dotSize: globStyle.size * 0.5
flow: eeParameterData.horizontaldata ? GridLayout.LeftToRight : GridLayout.TopToBottom
rows: eeParameterData.rows
columns: eeParameterData.columns
rowSpacing: globStyle.size * 0.05
columnSpacing: rowSpacing
width: (dotSize + rowSpacing) * columns
height: (dotSize + columnSpacing) * rows
property alias repeaterDot: repeaterDot
Repeater {
id: repeaterDot
model: eeParameterData.rows * eeParameterData.columns
Rectangle {
property bool on: false
width: dotSize
height: width
radius: width / 2
color: {
if (enabled) {
if (on)
return mouseArea.containsMouse ? globStyle.accentLight : globStyle.accent
else
return mouseArea.containsMouse ? globStyle.foreground : globStyle.backgroundFaded
}
else
return on ? globStyle.accentFaded : globStyle.backgroundFaded
}
border.width: globStyle.thickness
border.color: mouseArea.pressed ? globStyle.background : color
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
on = !on
}
}
}
}
}
}
function getParameterValue() {
var vals = []
var dotsPerBitmap = eeParameterData.rows * eeParameterData.columns;
vals.length = dotsPerBitmap * eeParameterData.count / 8
for (var vi = 0; vi < vals.length; vi++)
vals[vi] = 0
for (var bm = 0; bm < eeParameterData.count; bm++){
var repeaterDot = repeaterBitmap.itemAt(bm).repeaterDot
for (var d = 0; d < dotsPerBitmap; d++){
var valIndex = Math.floor(d / 8) + (dotsPerBitmap / 8) * bm
vals[valIndex] |= repeaterDot.itemAt(d).on << (7 - d % 8)
}
}
return vals
}
function setParameterValue(vals) {
var dotsPerBitmap = eeParameterData.rows * eeParameterData.columns;
for (var bm = 0; bm < eeParameterData.count; bm++){
var repeaterDot = repeaterBitmap.itemAt(bm).repeaterDot
for (var d = 0; d < dotsPerBitmap; d++){
var valIndex = Math.floor(d / 8) + (dotsPerBitmap / 8) * bm
repeaterDot.itemAt(d).on = (vals[valIndex] << (d % 8)) & (1 << 7)
}
}
}
}