-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbox.odin
More file actions
64 lines (52 loc) · 1.4 KB
/
box.odin
File metadata and controls
64 lines (52 loc) · 1.4 KB
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
package syl
Box :: struct {
using box: Layout_Box,
style: ^Box_Style_Override,
}
update_box :: proc(box: ^Box) {
for child in box.children do element_update(child)
}
// Style ______________________________________________________________________
Box_Style:: struct {
text_color: [4]u8,
font_size: int,
background_color: [4]u8,
border_color: [4][4]u8,
border_thickness: [4]f32,
border_radius: [4]f32,
padding: [4]f32,
transitions: Box_Transitions,
gap: f32,
}
Box_Style_Override :: struct {
text_color: Maybe([4]u8),
font_size: Maybe(int),
background_color: Maybe([4]u8),
border_color: Maybe([4][4]u8),
border_thickness: Maybe([4]f32),
border_radius: Maybe([4]f32),
padding: Maybe([4]f32),
transitions: Maybe(Box_Transitions),
gap: Maybe(f32),
}
Box_Transitions:: struct {
background_color: Transition,
padding: Transition,
}
box_destroy:: proc(box: ^Box) {
box_deinit(box)
free(box)
}
box_deinit:: proc(box: ^Box) {
if box == nil do return
layout_box_deinit(&box.box)
}
// Style
box_set_style :: proc(box: ^Box, style: ^Box_Style_Override, use_transitions: bool = true) {
default := box.style_sheet.box
fallback := box.style
layout_box_set_style(box, style, fallback, default, use_transitions)
}
box_apply_style :: proc(box: ^Box, style: Box_Style_Override, use_transitions: bool = true) {
layout_box_apply_style(box, style, use_transitions)
}