Compare commits
2 commits
6a319c55b0
...
a49ac7bca0
Author | SHA1 | Date | |
---|---|---|---|
Able | a49ac7bca0 | ||
Able | 12883ac926 |
|
@ -4,9 +4,35 @@ stn := @use("../../../libraries/stn/src/lib.hb");
|
||||||
|
|
||||||
horizon_api := @use("../../../libraries/horizon_api/src/lib.hb")
|
horizon_api := @use("../../../libraries/horizon_api/src/lib.hb")
|
||||||
|
|
||||||
render := @use("../../../libraries/render/src/lib.hb")
|
render := @use("../../../libraries/render/src/lib.hb");
|
||||||
|
.{Surface} := render;
|
||||||
|
.{Font} := render.text
|
||||||
intouch := @use("../../../libraries/intouch/src/lib.hb")
|
intouch := @use("../../../libraries/intouch/src/lib.hb")
|
||||||
|
|
||||||
|
Label := struct {is_dirty: bool, surface: Surface, text: ^u8, text_length: uint}
|
||||||
|
set_label_text := fn(label: Label, text: ^u8, text_length: uint): void {
|
||||||
|
label.is_dirty = true
|
||||||
|
label.text = text
|
||||||
|
label.text_length = text_length
|
||||||
|
}
|
||||||
|
|
||||||
|
render_label_to_surface := fn(surface: Surface, label: Label, font: Font): void {
|
||||||
|
if label.is_dirty {
|
||||||
|
render.clear(label.surface, render.blue)
|
||||||
|
render.put_text(label.surface, font, .(0, 0), render.red, "hi\0")
|
||||||
|
}
|
||||||
|
pos := Vec2(uint).(100, 100)
|
||||||
|
render.put_surface(surface, label.surface, pos, false)
|
||||||
|
render.sync(surface)
|
||||||
|
}
|
||||||
|
|
||||||
|
new_label := fn(text: ^u8): Label {
|
||||||
|
text_surface := render.new_surface(100, 16)
|
||||||
|
text_length := string.length(text)
|
||||||
|
label := Label.(true, text_surface, text, text_length)
|
||||||
|
return label
|
||||||
|
}
|
||||||
|
|
||||||
Window := struct {
|
Window := struct {
|
||||||
// TODO: Replace this with widgets
|
// TODO: Replace this with widgets
|
||||||
implicit_framebuffer: render.Surface,
|
implicit_framebuffer: render.Surface,
|
||||||
|
@ -19,13 +45,6 @@ Window := struct {
|
||||||
psf := @embed("../../../consolefonts/tamsyn/10x20r.psf")
|
psf := @embed("../../../consolefonts/tamsyn/10x20r.psf")
|
||||||
|
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
I_LOOP := 10000
|
|
||||||
loop {
|
|
||||||
if I_LOOP >= 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
I_LOOP += 1
|
|
||||||
}
|
|
||||||
win_buff := buffer.create("XHorizon\0")
|
win_buff := buffer.create("XHorizon\0")
|
||||||
|
|
||||||
screen := render.init(true)
|
screen := render.init(true)
|
||||||
|
@ -35,20 +54,16 @@ main := fn(): int {
|
||||||
|
|
||||||
window := render.new_surface(screen.width / 3, screen.height / 3)
|
window := render.new_surface(screen.width / 3, screen.height / 3)
|
||||||
|
|
||||||
x := 0
|
|
||||||
|
|
||||||
mem_buf := memory.request_page(1)
|
mem_buf := memory.request_page(1)
|
||||||
color := random.any(render.Color)
|
color := random.any(render.Color)
|
||||||
side := window.width / 8
|
side := window.width / 8
|
||||||
|
|
||||||
vel_inner := Vec2(int).(1, 1)
|
|
||||||
pos_inner := Vec2(uint).((window.width - side) / 2, (window.height - side) / 2)
|
|
||||||
str := "Window Title Bar\0"
|
|
||||||
// really we should null check but it is a bit broked
|
// really we should null check but it is a bit broked
|
||||||
font := @unwrap(render.text.font_from_psf2(@bitcast(&psf), false))
|
font := @unwrap(render.text.font_from_psf2(@bitcast(&psf), false))
|
||||||
|
|
||||||
mouse_x := 0
|
mouse_x := 0
|
||||||
mouse_y := 0
|
mouse_y := 0
|
||||||
|
text_label := new_label("Hi\0")
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
// Clear the screen
|
// Clear the screen
|
||||||
|
@ -78,41 +93,11 @@ main := fn(): int {
|
||||||
// Send events to focused window
|
// Send events to focused window
|
||||||
}
|
}
|
||||||
|
|
||||||
if pos_inner.x == 0 | pos_inner.x == window.width - side {
|
|
||||||
vel_inner.x = -vel_inner.x
|
|
||||||
color = random.any(render.Color)
|
|
||||||
}
|
|
||||||
if pos_inner.y == 20 | pos_inner.y == window.height - side {
|
|
||||||
vel_inner.y = -vel_inner.y
|
|
||||||
color = random.any(render.Color)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Get windows out of a collection and iter through
|
// TODO: Get windows out of a collection and iter through
|
||||||
window_count := 0
|
|
||||||
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)
|
||||||
// loop {
|
|
||||||
// render.clear(window, render.black)
|
|
||||||
|
|
||||||
// // Draw the decorators
|
render_label_to_surface(screen, text_label, font)
|
||||||
// {
|
|
||||||
// render.put_rect(window, .(0, 0), .(window.width - 1, window.height - 1), render.white)
|
|
||||||
// render.put_rect(window, .(0, 0), .(window.width - 1, 20), render.white)
|
|
||||||
// render.put_text(window, font, .(window.width / 2, 1), render.white, str)
|
|
||||||
// }
|
|
||||||
// render.put_filled_rect(window, pos_inner, .(side, side), color)
|
|
||||||
|
|
||||||
// // Apply the image to the screen
|
|
||||||
// pos := Vec2(uint).(x, 100)
|
|
||||||
|
|
||||||
// render.put_surface(screen, window, pos, false)
|
|
||||||
// if window_count >= 1 {
|
|
||||||
// x = 0
|
|
||||||
// break
|
|
||||||
// }
|
|
||||||
// window_count += 1
|
|
||||||
// x += screen.width / 2
|
|
||||||
// }
|
|
||||||
pos_inner += @bitcast(vel_inner)
|
|
||||||
|
|
||||||
// Sync the screen
|
// Sync the screen
|
||||||
render.sync(screen)
|
render.sync(screen)
|
||||||
|
|
Loading…
Reference in a new issue