1
0
Fork 0
forked from AbleOS/ableos

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); .for_each(drop);
if !errors.is_empty() { if !errors.is_empty() {
writeln!(errors, "!!! STOPPING DUE TO PREVIOUS ERRORS !!!"); let _ = writeln!(errors, "!!! STOPPING DUE TO PREVIOUS ERRORS !!!");
std::eprint!("{errors}"); std::eprint!("{errors}");
continue; 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; .{Surface} := render;
.{Font} := render.text .{Font} := render.text
UI := struct { UI := struct {raw: ^u8, raw_length: uint, is_dirty: bool, surface: Surface, // Each child has their WidgetType as their first byte
raw: ^u8, // children: ^^u8,
raw_length: uint,
is_dirty: bool,
surface: Surface,
} }
render_ui := fn(surface: Surface, ui: UI): void { render_ui := fn(surface: Surface, ui: UI): void {

View file

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

View file

@ -27,12 +27,13 @@ recieve_mouse_event := fn(): ?MouseEvent {
// Read out of the Mouse buffer here // Read out of the Mouse buffer here
buffer.recv(MouseEvent, buf_id, mem_page) buffer.recv(MouseEvent, buf_id, mem_page)
if *mem_page != 0 { if *mem_page != 0 {
log.info("Mouse events\0")
dx := *mem_page dx := *mem_page
dy := *mem_page + 1 dy := *mem_page + 1
mevent := MouseEvent.(dx, dy, 0, 0, 0) mevent := MouseEvent.(dx, dy, 0, 0, 0)
return mevent return mevent
} }
// log.warn("No mouse events\0") // log.error("No mouse events\0")
return null 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"); render := @use("../../../libraries/render/src/lib.hb");
.{Surface} := render; .{Surface} := render;
.{Font} := render.text .{Font} := render.text
intouch := @use("../../../libraries/intouch/src/lib.hb") intouch := @use("../../../libraries/intouch/src/lib.hb")
Window := struct { Window := struct {
@ -42,30 +43,45 @@ main := fn(): int {
mouse_x := 0 mouse_x := 0
mouse_y := 0 mouse_y := 0
text_label := new_label("Hi\0") text_label := new_label("Hi\0")
widgets := "()\0" // widgets := "()\0"
ui := sexpr_parser(widgets) // 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 { loop {
// Clear the screen // Clear the screen
render.clear(screen, render.black) render.clear(screen, render.black)
// TODO: Read the window buffer here // 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 ret := buffer.recv([u8; 4096], win_buff, mem_buf)
// key_event := intouch.recieve_key_event() // 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() mouse_event := intouch.recieve_mouse_event()
//
if mouse_event != null { if mouse_event != null {
log.info("Mouse event") log.warn("Mouse event recieved\0")
mouse_x += mouse_event.x_change mouse_x += mouse_event.x_change
mouse_y += mouse_event.y_change mouse_y += mouse_event.y_change
set_label_text(text_label, "Mouse Moved\0") set_label_text(text_label, "Mouse Moved\0")

View file

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

View file

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