-
Notifications
You must be signed in to change notification settings - Fork 1
/
element.fs
75 lines (66 loc) · 1.68 KB
/
element.fs
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
\ RilouwShell 0.1.0
\ Copyright (c) 2019 Jerome Martin
\ Released under the terms of the GNU GPL version 3
\ http://rilouw.eu/project/rilouwshell
(
struct
cell% field input-label
cell% field input-text
cell% field input-x
cell% field input-y
cell% field input-w
end-struct input%
struct
cell% field area-content
cell% field area-x
cell% field area-y
cell% field area-w
cell% field area-h
end-struct area%
struct
cell% field toggle-on-label
cell% field toggle-off-label
cell% field toggle-x
cell% field toggle-y
cell% field toggle-w
end-struct toggle%
)
0 constant TYPE-LABEL
1 constant TYPE-BUTTON
2 constant TYPE-INPUT
3 constant TYPE-AREA
4 constant TYPE-TOGGLE
defer render-label ( surface label -- )
defer render-button ( surface button -- )
defer render-input ( surface input -- )
defer render-area ( surface area -- )
defer render-toggle ( surface toggle -- )
defer get-label-rect ( label -- x y w h )
defer get-button-rect ( button -- x y w h )
defer get-input-rect ( input -- x y w h )
defer get-area-rect ( area -- x y w h )
defer get-toggle-rect ( toggle -- x y w h )
: render-element ( surface element type -- )
case
TYPE-LABEL of render-label endof
TYPE-BUTTON of render-button endof
TYPE-INPUT of render-input endof
TYPE-AREA of render-area endof
TYPE-TOGGLE of render-toggle endof
2drop
endcase
;
: click-element ( element -- )
dup if ." clicked" then
drop
;
: get-element-rect ( element type -- )
case
TYPE-LABEL of get-label-rect endof
TYPE-BUTTON of get-button-rect endof
TYPE-INPUT of get-input-rect endof
TYPE-AREA of get-area-rect endof
TYPE-TOGGLE of get-toggle-rect endof
drop
endcase
;