2024-10-13 22:34:33 -05:00
|
|
|
// Widget types
|
|
|
|
|
|
|
|
// End types
|
2024-11-06 11:43:40 -06:00
|
|
|
stn := @use("../../../libraries/stn/src/lib.hb");
|
|
|
|
.{string, log} := stn;
|
|
|
|
.{Vec2} := stn.math
|
|
|
|
|
|
|
|
render := @use("../../../libraries/render/src/lib.hb");
|
|
|
|
.{Surface} := render;
|
|
|
|
.{Font} := render.text
|
2024-10-13 22:34:33 -05:00
|
|
|
|
|
|
|
LayoutChildHorizontalFirst := 0
|
|
|
|
LayoutChildVerticalFirst := 1
|
|
|
|
|
|
|
|
Size := struct {
|
|
|
|
min_width: int,
|
|
|
|
max_width: int,
|
|
|
|
min_height: int,
|
|
|
|
max_height: int,
|
|
|
|
}
|
|
|
|
|
2024-11-06 11:43:40 -06:00
|
|
|
Label := struct {
|
|
|
|
is_dirty: bool,
|
|
|
|
surface: Surface,
|
|
|
|
text: ^u8,
|
|
|
|
text_length: uint,
|
|
|
|
}
|
|
|
|
|
|
|
|
set_label_text := fn(label: Label, text: ^u8): void {
|
|
|
|
text_length := string.length(text)
|
|
|
|
|
|
|
|
label.is_dirty = true
|
|
|
|
label.text = text
|
|
|
|
label.text_length = text_length
|
|
|
|
}
|
|
|
|
|
|
|
|
render_label_to_surface := fn(surface: Surface, label: Label, font: Font, pos: Vec2(uint)): void {
|
|
|
|
if label.is_dirty {
|
|
|
|
render.clear(label.surface, render.black)
|
|
|
|
render.put_text(label.surface, font, .(0, 0), render.white, label.text)
|
|
|
|
}
|
|
|
|
render.put_surface(surface, label.surface, pos, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
new_label := fn(text: ^u8): Label {
|
2024-11-06 19:57:43 -06:00
|
|
|
text_surface := render.new_surface(1000, 20)
|
2024-11-06 11:43:40 -06:00
|
|
|
text_length := string.length(text)
|
|
|
|
label := Label.(true, text_surface, text, text_length)
|
|
|
|
return label
|
2024-11-06 19:57:43 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
VerticalLayout := 0
|
|
|
|
HorizontalLayout := 1
|
|
|
|
|
|
|
|
Container := struct {
|
|
|
|
layout: uint,
|
2024-10-13 22:34:33 -05:00
|
|
|
}
|