-
Notifications
You must be signed in to change notification settings - Fork 37
/
DemoWatchObjectDiv01.kt
69 lines (61 loc) · 1.89 KB
/
DemoWatchObjectDiv01.kt
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
import org.openrndr.application
import org.openrndr.extensions.SingleScreenshot
import org.openrndr.panel.controlManager
import org.openrndr.panel.elements.*
import org.openrndr.panel.style.*
fun main() = application {
configure {
width = 900
height = 720
}
// A very simple state
class State {
var x = 0
var y = 0
var z = 0
}
program {
val programState = State()
val cm = controlManager {
layout {
styleSheet(has class_ "matrix") {
this.width = 100.percent
}
styleSheet(has class_ "row") {
this.display = Display.FLEX
this.flexDirection = FlexDirection.Row
this.width = 100.percent
child(has type "slider") {
this.width = 80.px
}
}
slider {
label = "x"
precision = 0
bind(programState::x)
}
slider {
label = "y"
precision = 0
bind(programState::y)
}
watchObjectDiv("matrix", watchObject = object {
// for primitive types we have to use property references
val x = programState::x
val y = programState::y
}) {
for (y in 0 until watchObject.y.get()) {
div("row") {
for (x in 0 until watchObject.x.get()) {
button() {
label = "$x, $y"
}
}
}
}
}
}
}
extend(cm)
}
}