changes + lui examples

This commit is contained in:
Able 2024-11-08 10:16:24 -06:00
parent 2676bd7b62
commit d2b5f09511
9 changed files with 55 additions and 34 deletions

View file

@ -237,7 +237,7 @@ TERM_BACKDROP={}
.for_each(drop);
if !errors.is_empty() {
writeln!(errors, "!!! STOPPING DUE TO PREVIOUS ERRORS !!!");
let _ = writeln!(errors, "!!! STOPPING DUE TO PREVIOUS ERRORS !!!");
std::eprint!("{errors}");
continue;
}

View file

@ -0,0 +1 @@
(label "hello")

View file

@ -0,0 +1,3 @@
(vertical
(label "hello")
(label "hello" color:red))

View file

@ -6,11 +6,8 @@ render := @use("../../../libraries/render/src/lib.hb");
.{Surface} := render;
.{Font} := render.text
UI := struct {
raw: ^u8,
raw_length: uint,
is_dirty: bool,
surface: Surface,
UI := struct {raw: ^u8, raw_length: uint, is_dirty: bool, surface: Surface, // Each child has their WidgetType as their first byte
// children: ^^u8,
}
render_ui := fn(surface: Surface, ui: UI): void {

View file

@ -23,6 +23,7 @@ Vertical := packed struct {
magic: uint,
// array of children, idk
// use a vec or linked list or whatever
children: ^^u8,
}

View file

@ -27,12 +27,13 @@ recieve_mouse_event := fn(): ?MouseEvent {
// Read out of the Mouse buffer here
buffer.recv(MouseEvent, buf_id, mem_page)
if *mem_page != 0 {
log.info("Mouse events\0")
dx := *mem_page
dy := *mem_page + 1
mevent := MouseEvent.(dx, dy, 0, 0, 0)
return mevent
}
// log.warn("No mouse events\0")
return null
// log.error("No mouse events\0")
return MouseEvent.(0, 0, 0, 0, 0)
}

View file

@ -9,6 +9,7 @@ horizon_api := @use("../../../libraries/horizon_api/src/lib.hb");
render := @use("../../../libraries/render/src/lib.hb");
.{Surface} := render;
.{Font} := render.text
intouch := @use("../../../libraries/intouch/src/lib.hb")
Window := struct {
@ -42,30 +43,45 @@ main := fn(): int {
mouse_x := 0
mouse_y := 0
text_label := new_label("Hi\0")
widgets := "()\0"
ui := sexpr_parser(widgets)
// widgets := "()\0"
// ui := sexpr_parser(widgets)
mouse_event := intouch.recieve_mouse_event()
if mouse_event == null {
log.warn("null\0")
} else {
log.warn("not null\0")
}
loop {
// Clear the screen
render.clear(screen, render.black)
// TODO: Read the window buffer here
// {
// ret := buffer.recv([u8; 4096], win_buff, mem_buf)
// // for some reason this null check causes the compiler to spin forever
// // if ret == null {
// // log.info("No messages\0")
// // } else {
// // log.info("Handle Messages\0")
// // }
// }
{
// get input events from drivers via intouch
// key_event := intouch.recieve_key_event()
ret := buffer.recv([u8; 4096], win_buff, mem_buf)
// for some reason this null check causes the compiler to spin forever
// if ret == null {
// log.info("No messages\0")
// } else {
// log.info("Handle Messages\0")
// }
}
// get input events from drivers via intouch
// key_event := intouch.recieve_key_event();
// log.info("before mouse event check\0");
{
// Note: MLokis, this inline halts the compiler forever
// mouse_event := @inline(intouch.recieve_mouse_event)
// Note: MLokis, this function returns null unless the mouse is moving
mouse_event := intouch.recieve_mouse_event()
//
if mouse_event != null {
log.info("Mouse event")
log.warn("Mouse event recieved\0")
mouse_x += mouse_event.x_change
mouse_y += mouse_event.y_change
set_label_text(text_label, "Mouse Moved\0")

View file

@ -13,13 +13,13 @@ Button4 := Button.(8)
Button5 := Button.(16)
mouse_moved := fn(delta: Vec2(i9)): void {
log.info("Mouse movement.\0")
// log.info("Mouse movement.\0")
}
button_event := fn(button: Button, pressed: bool): void {
if pressed {
log.info("Mouse-button pressed.\0")
// log.info("Mouse-button pressed.\0")
} else {
log.info("Mouse-button released.\0")
// log.info("Mouse-button released.\0")
}
}
@ -132,7 +132,7 @@ main := fn(): int {
button_states ^= changes
log.info(string.display_int(status, format_page, 10))
// log.info(string.display_int(status, format_page, 10))
dx := i9.(false, 0)
dy := i9.(false, 0)
@ -144,7 +144,9 @@ main := fn(): int {
dy.sign = (status & 0x20) == 0
if dy.value != 0 & dx.value != 0 {
event := MouseEvent.(dx.value, dy.value, 0, 0, 0)
y_change := dy.value
x_change := dx.value
event := MouseEvent.(x_change, y_change, 0, 0, 0)
buffer.write(MouseEvent, &event, mouse_buffer)
// mouse_moved(.(dx, dy))

View file

@ -28,8 +28,8 @@ resolution = "1024x768x24"
# [boot.limine.ableos.modules.diskio_driver]
# path = "boot:///diskio_driver.hbf"
[boot.limine.ableos.modules.render_example]
path = "boot:///render_example.hbf"
# [boot.limine.ableos.modules.render_example]
# path = "boot:///render_example.hbf"
# [boot.limine.ableos.modules.serial_driver]
# path = "boot:///serial_driver.hbf"
@ -37,8 +37,8 @@ path = "boot:///render_example.hbf"
# [boot.limine.ableos.modules.serial_driver_test]
# path = "boot:///serial_driver_test.hbf"
# [boot.limine.ableos.modules.horizon]
# path = "boot:///horizon.hbf"
[boot.limine.ableos.modules.horizon]
path = "boot:///horizon.hbf"
# [boot.limine.ableos.modules.horizon_testing_program]
# path = "boot:///horizon_testing_program.hbf"
@ -58,8 +58,8 @@ path = "boot:///render_example.hbf"
# [boot.limine.ableos.modules.pumpkin_print]
# path = "boot:///pumpkin_print.hbf"
# [boot.limine.ableos.modules.ps2_mouse_driver]
# path = "boot:///ps2_mouse_driver.hbf"
[boot.limine.ableos.modules.ps2_mouse_driver]
path = "boot:///ps2_mouse_driver.hbf"
# [boot.limine.ableos.modules.app_bar]
# path = "boot:///app_bar.hbf"