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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
package main
import "core:fmt"
import t "tafl"
BUTTON_SIZE : [2]int : {120, 40}
main :: proc() {
width, height : int = 1920, 1080
t.start_window(width, height, "tafl test")
for !t.window_should_close() {
if t.resized(){
width, height = t.get_window_size()
}
{
t.tafl( // ROOT tafl
width=width,
height=height,
layout=.LEFT_TO_RIGHT,
color=colors.background,
padding={5,5,5,5},
child_gap=5,
)
{ // Left bar
t.tafl(color=colors.panel_blackground,
width=BUTTON_SIZE.x*3 + 8*4,
cut_from=.START,
layout=.TOP_TO_BOTTOM,
)
{
t.tafl(
height=BUTTON_SIZE.y+8*2,
padding={8,8,8,8},
child_gap=8,
color={.0, .0, .0, 0.4},
cut_from=.END,
)
{
if button("Yeet", "yeet").clicked {
fmt.println("YEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEET!")
}
if button("Bawls", "bawls").clicked {
fmt.println("Baaaaaaaaaaaawwwwwwwwwwwllllllls.")
}
if button("Render", "render").clicked {
fmt.println("Reeeeeennnnnndeeeeeeeeeeeeeeeer!")
}
}
}
slider_h()
}
{ // Right bar
t.tafl(color=colors.panel_blackground,
width=300,
child_gap=20,
layout=.TOP_TO_BOTTOM,
cut_from=.END,)
{
{t.tafl(color={.5, .5, .5, 1},
height=50,
)}
{t.tafl(color={.5, .5, .5, 1},
height=50,
)}
{t.tafl(color={.5, .5, .5, 1},
height=50,
cut_from=.END,
)}
{t.tafl(color={.5, .5, .8, 1},
)}
}
}
{ // Middle section
big_square_size := 300
small_square_size := 200
total_size := big_square_size+small_square_size+5
t.tafl(color=colors.panel_blackground,
layout=.TOP_TO_BOTTOM,)
{
t.tafl(height=total_size,
layout=.TOP_TO_BOTTOM,
align_children=.MIDDLE,
cut_from=.MIDDLE,
child_gap=5,)
{// Red square (BIG)
t.tafl(color={1,0,0,1},
width=big_square_size,
height=big_square_size,
padding={1,1,1,1},)
{
t.tafl(color={0,0,0,0.5},)
}
}
{// Red square (Small)
t.tafl(color={1,0,0,1},
width=small_square_size,
height=small_square_size,
padding={1,1,1,1},)
{
t.tafl(color={0,0,0,0.5},)
}
}
}
}
}
t.render()
free_all(context.temp_allocator)
}
}
button :: proc(text : string, id : string) -> t.Com {
com := t.tafl(width=BUTTON_SIZE.x,
height=BUTTON_SIZE.y,
color=colors.button_outline,
padding={2,2,2,2},
flags={.HIT_CHECK},
align_children=.MIDDLE,
id=id)
color : t.Color = {.1,.1,.1, 1}
if com.hover do color = {.2,.2,.2, 1}
if com.clicked || com.is_down do color = {.05,.05,.05, 1}
t.tafl(color=color,)
t.tafl(text=text,
cut_from=.MIDDLE,
width=0,
height=0,)
return com
}
slider_root : int = 0
slider_delta : int = 0
slider_current : int = 0
slider_grabbed : bool = false
slider_output : f32 = 0
slider_h :: proc(id : string = "a_slider") {
t.tafl(
cut_from=.END,
padding={2,2,2,2},
height=35,
)
outer_com := t.tafl(
layout=.LEFT_TO_RIGHT,
color={.1,.1,.1,1},
padding={2,2,2,2}
)
{// Space before
t.tafl(
width=slider_current,
cut_from=.START)
}
{// Scroll handle
com:=t.tafl(
width=90,
cut_from=.START,
color={.4,.4,.4,1},
padding={2,2,2,2},
flags={.HIT_CHECK},
id=id,
)
if com.pressed_down {
slider_root = slider_current
slider_grabbed = true
}
if t.mouse_left_released {
slider_grabbed = false
}
slider_max := outer_com.tafl.width - com.tafl.width - outer_com.tafl.padding.left - outer_com.tafl.padding.right
if slider_grabbed {
slider_delta = t.mouse_position.x - t.mouse_left_press_position.x
slider_current = slider_root + slider_delta
slider_current = max(slider_current, 0)
slider_current = min(slider_current, slider_max)
slider_output = f32(slider_current)/f32(slider_max)
fmt.printfln("slider_output: {}", slider_output)
}
color : t.Color = {.2,.2,.2,1}
if com.hover do color={.3,.3,.3,1}
if com.is_down do color={.13,.13,.13,1}
t.tafl(
color=color,
)
}
{// Area after
t.tafl(
width=slider_current,
cut_from=.START)
}
}
Color_Scheme :: struct {
background : t.Color,
panel_blackground : t.Color,
panel_border : t.Color,
button_outline : t.Color,
}
colors : Color_Scheme = {
background = {.1, .1, .1, 1},
panel_blackground = {.2, .2, .2, 1},
panel_border = {.35, .35, .35, 1},
button_outline = {.1, .5, 1, 1},
}
panel :: proc() {
}
|