refactor and widgeting magic

This commit is contained in:
Able 2024-11-06 20:11:36 -06:00
parent b6b097a872
commit f13c682171
5 changed files with 39 additions and 25 deletions

View file

@ -5,7 +5,7 @@ render := @use("../../../libraries/render/src/lib.hb")
input := @use("../../intouch/src/lib.hb") input := @use("../../intouch/src/lib.hb")
widgets := @use("widgets.hb") widgets := @use("widgets/widgets.hb")
ui := @use("ui.hb") ui := @use("ui.hb")
WindowID := struct { WindowID := struct {

View file

@ -1,25 +1,13 @@
// Widget types stn := @use("../../../../libraries/stn/src/lib.hb");
// End types
stn := @use("../../../libraries/stn/src/lib.hb");
.{string, log} := stn; .{string, log} := stn;
.{Vec2} := stn.math .{Vec2} := stn.math
render := @use("../../../libraries/render/src/lib.hb"); render := @use("../../../../libraries/render/src/lib.hb");
.{Surface} := render; .{Surface} := render;
.{Font} := render.text .{Font} := render.text
LayoutChildHorizontalFirst := 0
LayoutChildVerticalFirst := 1
Size := struct {
min_width: int,
max_width: int,
min_height: int,
max_height: int,
}
Label := struct { Label := struct {
magic: uint,
is_dirty: bool, is_dirty: bool,
surface: Surface, surface: Surface,
text: ^u8, text: ^u8,
@ -45,13 +33,7 @@ render_label_to_surface := fn(surface: Surface, label: Label, font: Font, pos: V
new_label := fn(text: ^u8): Label { new_label := fn(text: ^u8): Label {
text_surface := render.new_surface(1000, 20) text_surface := render.new_surface(1000, 20)
text_length := string.length(text) text_length := string.length(text)
label := Label.(true, text_surface, text, text_length) widget_type := 3
label := Label.(widget_type, true, text_surface, text, text_length)
return label return label
}
VerticalLayout := 0
HorizontalLayout := 1
Container := struct {
layout: uint,
} }

View file

@ -0,0 +1,4 @@
VerticalWidgetType := 1
HorizontalWidgetType := 2
LabelWidgetType := 3

View file

@ -0,0 +1,28 @@
// Widget types
// End types
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
widget_types := @use("widget_types.hb")
label := @use("label.hb")
// .{Label, render_label_to_surface, set_label_text} := label
Size := struct {
min_width: int,
max_width: int,
min_height: int,
max_height: int,
}
Vertical := packed struct {
magic: uint,
// array of children, idk
// use a vec or linked list or whatever
children: ^^u8,
}

View file

@ -3,7 +3,7 @@ stn := @use("../../../libraries/stn/src/lib.hb");
.{Vec2} := stn.math .{Vec2} := stn.math
horizon_api := @use("../../../libraries/horizon_api/src/lib.hb"); horizon_api := @use("../../../libraries/horizon_api/src/lib.hb");
.{new_label, render_label_to_surface, set_label_text} := horizon_api.widgets; .{new_label, render_label_to_surface, set_label_text} := horizon_api.widgets.label;
.{sexpr_parser, render_ui} := horizon_api.ui .{sexpr_parser, render_ui} := horizon_api.ui
render := @use("../../../libraries/render/src/lib.hb"); render := @use("../../../libraries/render/src/lib.hb");