-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtube+cells-test.red
96 lines (89 loc) · 2.27 KB
/
tube+cells-test.red
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
Red [needs: view]
; recycle/off
#include %../everything.red
#process off
do/expand [
#include %../../common/include-once.red
; #include %../../common/assert.red
; #include %../../common/debug.red
#include %../../common/composite.red
#include %../../common/contrast-with.red
svmc: system/view/metrics/colors
bigfont: make font! [size: 20]
set-style 'heading function [self /on canvas [point2D! none!] fill-x fill-y] [
self/font: bigfont
drawn: self/draw/on canvas fill-x fill-y
width: either canvas [canvas/x][self/size/x]
compose [
fill-pen (svmc/text + 0.0.0.200)
pen off box 0x0 (width . self/size/y)
(drawn)
]
]
set-style 'field [[fill-pen (contrast-with svmc/text) pen off box 0x0 (size)]]
; set-style 'field/caret [fill-pen (svmc/text)]
set-style 'tube function [tube /on canvas [point2D! none!] fill-x fill-y] [
drawn: tube/draw/on canvas fill-x fill-y
#assert [drawn]
#assert [tube/size]
compose/only/deep [
push [fill-pen off pen blue box 1x1 (tube/size - 1x1)]
(drawn)
]
]
declare-template 'heading/data-view []
boxes: map-each spec [
[(60,30) "A"]
[(50,40) "B"]
[(40,50) "C"]
[(30,60) "D"]
[(20,20) "E"]
[(30,10) "F"]
[(10,10) "G"]
][
; make-space/name 'rectangle spec
; make-space/name 'field spec
compose/deep [cell [field (spec)]]
]
width: 130
tubes: collect [
; for-each [/i axes] [ [→ ↓] ][;] [→ ↑] ][;] [↓ ←] [↓ →] [← ↑] [← ↓] [↑ →] [↑ ←] ] [
for-each [/i axes] [ [→ ↓] [→ ↑] [↓ ←] [↓ →] [← ↑] [← ↓] [↑ →] [↑ ←] ] [
do with spaces/ctx [
lim2: extend-canvas
lim1: width . width
anchor2axis axes/2
]
keep reshape [
cell none .. 170x200 [
vlist [
heading data= @[#composite "axes: (mold axes)"]
row tight spacing= 5x5 axes= @[axes] limits= @[lim1 .. lim2] @[boxes]
]
]
]
]
]
; system/view/auto-sync?: no
view/no-wait compose/only/deep [
h: host [
vlist [
fps-meter ;-- constantly forces redraws which can be CPU intensive (due to Draw mostly)
;; list-view doesn't work here because it accepts data, not spaces
scrollable 540x500 [
tube spacing= 5x10 (tubes)
]
]
]
on-over [
status/text: mold hittest face/space event/offset
]
return status: text 500x40
]
; dump-tree
prof/show
prof/reset
; debug-draw
do-events
prof/show
]