widgeting work

This commit is contained in:
Able 2024-11-06 19:57:43 -06:00
parent 6a8d92d2c2
commit b6b097a872
2 changed files with 17 additions and 2 deletions

View file

@ -40,12 +40,18 @@ render_label_to_surface := fn(surface: Surface, label: Label, font: Font, pos: V
render.put_text(label.surface, font, .(0, 0), render.white, label.text) render.put_text(label.surface, font, .(0, 0), render.white, label.text)
} }
render.put_surface(surface, label.surface, pos, false) render.put_surface(surface, label.surface, pos, false)
render.sync(surface)
} }
new_label := fn(text: ^u8): Label { new_label := fn(text: ^u8): Label {
text_surface := render.new_surface(100, 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) label := Label.(true, text_surface, text, text_length)
return label return label
}
VerticalLayout := 0
HorizontalLayout := 1
Container := struct {
layout: uint,
} }

View file

@ -77,6 +77,15 @@ main := fn(): int {
// TODO: Get windows out of a collection and iter through // TODO: Get windows out of a collection and iter through
render.put_rect(screen, .(0, 0), .(screen.width - 1, screen.height - 1), render.white) render.put_rect(screen, .(0, 0), .(screen.width - 1, screen.height - 1), render.white)
{
// Scroll bar :ThumbsUp:
render.put_rect(screen, .(100, 100), .(100, 10), render.white)
render.put_filled_rect(screen, .(110, 100), .(20, 10), render.white)
render.put_rect(screen, .(90, 110), .(10, 100), render.white)
render.put_filled_rect(screen, .(90, 120), .(10, 20), render.white)
}
{ {
pos := Vec2(uint).(1, screen.height - 21) pos := Vec2(uint).(1, screen.height - 21)
render_label_to_surface(screen, text_label, font, pos) render_label_to_surface(screen, text_label, font, pos)