forked from AbleOS/ableos
Mouse updates
This commit is contained in:
parent
d5f4ce18a3
commit
b0f6aa53bd
|
@ -2,13 +2,33 @@ sunset := @use("../../../libraries/sunset_proto/src/lib.hb")
|
|||
render := @use("../../../libraries/render/src/lib.hb")
|
||||
intouch := @use("../../../libraries/intouch/src/lib.hb")
|
||||
|
||||
main := fn(): void {
|
||||
screen := render.init(true)
|
||||
horizon_api := @use("../../../libraries/horizon_api/src/lib.hb");
|
||||
.{new_label, render_label_to_surface, set_label_text} := horizon_api.widgets.label
|
||||
|
||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{Vec2} := stn.math
|
||||
|
||||
psf := @embed("../../../assets/consolefonts/tamsyn/10x20r.psf")
|
||||
img := @embed("../../../assets/wallpaper.qoi")
|
||||
|
||||
main := fn(): int {
|
||||
sunset.server.start()
|
||||
|
||||
screen := render.init(true)
|
||||
render.clear(screen, render.black)
|
||||
|
||||
mouse_x := 0
|
||||
mouse_y := 0
|
||||
font := @unwrap(render.text.font_from_psf2(@bitcast(&psf), false))
|
||||
|
||||
wallpaper := render.image.from(@bitcast(&img))
|
||||
if wallpaper == null {
|
||||
// stn.panic("Wallpaper not loaded\0")
|
||||
return 1
|
||||
}
|
||||
|
||||
mouse_x := 100
|
||||
mouse_y := 100
|
||||
|
||||
text_label := new_label("Hi\0")
|
||||
|
||||
loop {
|
||||
mouse_event := intouch.recieve_mouse_event()
|
||||
|
@ -38,26 +58,33 @@ main := fn(): void {
|
|||
mouse_y -= change_y
|
||||
|
||||
if mouse_event.left {
|
||||
// set_label_text(text_label, "LEFT CLICK\0")
|
||||
set_label_text(text_label, "LEFT CLICK\0")
|
||||
}
|
||||
if mouse_event.middle {
|
||||
// set_label_text(text_label, "MIDDLE CLICK\0")
|
||||
set_label_text(text_label, "MIDDLE CLICK\0")
|
||||
}
|
||||
if mouse_event.right {
|
||||
// set_label_text(text_label, "RIGHT CLICK\0")
|
||||
set_label_text(text_label, "RIGHT CLICK\0")
|
||||
}
|
||||
}
|
||||
{
|
||||
// render.clear(screen, render.black)
|
||||
render.clear(screen, render.black)
|
||||
render.put_surface(screen, wallpaper, .(0, 0), false)
|
||||
|
||||
render.put_rect(screen, .(0, 0), .(screen.width - 1, screen.height - 1), render.white)
|
||||
}
|
||||
|
||||
if sunset.server.incoming() {
|
||||
// render.clear(screen, render.black)
|
||||
//
|
||||
sunset.server.collect_frames()
|
||||
sunset.server.render_clients(screen)
|
||||
}
|
||||
|
||||
{
|
||||
pos := Vec2(uint).(1, screen.height - 21)
|
||||
render_label_to_surface(screen, text_label, font, pos)
|
||||
render.put_rect(screen, .(0, screen.height - 21), .(screen.width - 1, 20), render.white)
|
||||
}
|
||||
|
||||
// Mouse cursor
|
||||
{
|
||||
render.put_filled_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.black)
|
||||
|
@ -66,4 +93,6 @@ main := fn(): void {
|
|||
|
||||
render.sync(screen)
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
Loading…
Reference in a new issue