1
0
Fork 0
forked from AbleOS/ableos
ableos/sysdata/libraries/horizon_api/src/ui.hb

44 lines
978 B
Plaintext

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
UI := struct {raw: []u8, is_dirty: bool, surface: Surface, // Each child has their WidgetType as their first byte
// children: ^^u8,
}
render_ui := fn(surface: Surface, ui: UI): void {
if ui.is_dirty {
render.clear(ui.surface, render.black)
ui.is_dirty = false
}
pos := Vec2(uint).(0, 0)
render.put_surface(surface, ui.surface, pos, false)
}
sexpr_parser := fn(sexpr: []u8): UI {
i := 0
paren_balance := 0
loop {
if i == sexpr.len {
if paren_balance != 0 {
log.error("Unbalanced Parens")
}
break
} else if sexpr[i] == '(' {
log.info("Open paren")
paren_balance += 1
} else if sexpr[i] == ')' {
log.info("Closed paren")
paren_balance -= 1
}
i += 1
}
ui_surface := render.new_surface(100, 100)
return UI.(sexpr, true, ui_surface)
}