1
0
Fork 0
forked from AbleOS/ableos

push changes

This commit is contained in:
Able 2024-11-14 18:09:54 -06:00
parent 907c0d0dd4
commit d5f4ce18a3
3 changed files with 76 additions and 9 deletions

View file

@ -1,5 +1,5 @@
.{math, log, string, random, buffer, memory} := @use("../../stn/src/lib.hb"); .{math, log, string, random, buffer, memory} := @use("../../stn/src/lib.hb");
.{Color, Surface, new_surface, put_surface, sync, put_rect, put_filled_rect, text, put_text} := @use("../../render/src/lib.hb"); .{Color, Surface, new_surface, put_surface, sync, put_rect, put_filled_rect, text, put_text, clear, white, black} := @use("../../render/src/lib.hb");
.{Channel, Window, WindowProps, WindowData, MessageHeader, BUFFER_SERVER, BUFFER_CLIENT, message, permissions, recv_header, recv_message, send_message, send_header, await_message} := @use("./lib.hb") .{Channel, Window, WindowProps, WindowData, MessageHeader, BUFFER_SERVER, BUFFER_CLIENT, message, permissions, recv_header, recv_message, send_message, send_header, await_message} := @use("./lib.hb")
WindowServer := struct { WindowServer := struct {
@ -50,8 +50,17 @@ incoming := fn(): bool {
surface := new_window_decorations(data.props.dimensions) surface := new_window_decorations(data.props.dimensions)
// decorations // decorations
{ {
put_filled_rect(surface, .(0, 0), data.props.dimensions + .(DECO_WIDTH, DECO_HEIGHT_TOP + DECO_HEIGHT_BOTTOM), DECO_COLOUR) title := data.props.title
put_filled_rect(surface, .(0, 0), .(data.props.dimensions.x + DECO_WIDTH, DECO_HEIGHT_TOP), DECO_COLOUR) title_length := string.length(title)
deco_length := title_length * 10
// draw the window tab bar
put_filled_rect(surface, .(0, 0), .(data.props.dimensions.x + DECO_WIDTH + deco_length, DECO_HEIGHT_TOP), DECO_COLOUR)
// Draw the window tab
put_filled_rect(surface, .(0, 0), .(deco_length, DECO_HEIGHT_TOP - 1), DECO_COLOUR_DARKER)
// Draw the outside box
put_rect(surface, .(0, 0), data.props.dimensions + .(DECO_WIDTH - 1, DECO_HEIGHT_TOP + DECO_HEIGHT_BOTTOM - 1), DECO_COLOUR)
put_text(surface, server.font, .(2, 1), .(0, 0, 0, 255), data.props.title) put_text(surface, server.font, .(2, 1), .(0, 0, 0, 255), data.props.title)
} }
server.windows[server.window_count] = .(data, surface) server.windows[server.window_count] = .(data, surface)
@ -64,6 +73,7 @@ $DECO_WIDTH := 2
$DECO_HEIGHT_TOP := 20 $DECO_HEIGHT_TOP := 20
$DECO_HEIGHT_BOTTOM := 1 $DECO_HEIGHT_BOTTOM := 1
$DECO_COLOUR := Color.(100, 200, 255, 255) $DECO_COLOUR := Color.(100, 200, 255, 255)
$DECO_COLOUR_DARKER := Color.(89, 57, 89, 255)
new_window_decorations := fn(dimensions: math.Vec2(uint)): Surface { new_window_decorations := fn(dimensions: math.Vec2(uint)): Surface {
return new_surface( return new_surface(
@ -122,5 +132,4 @@ render_clients := fn(screen: Surface): void {
put_surface(screen, window.surface, window.data.props.position, false) put_surface(screen, window.surface, window.data.props.position, false)
i += 1 i += 1
} }
sync(screen)
} }

View file

@ -1,11 +1,69 @@
sunset := @use("../../../libraries/sunset_proto/src/lib.hb") sunset := @use("../../../libraries/sunset_proto/src/lib.hb")
render := @use("../../../libraries/render/src/lib.hb") render := @use("../../../libraries/render/src/lib.hb")
intouch := @use("../../../libraries/intouch/src/lib.hb")
main := fn(): void { main := fn(): void {
screen := render.init(true) screen := render.init(true)
sunset.server.start() sunset.server.start()
loop if sunset.server.incoming() { render.clear(screen, render.black)
sunset.server.collect_frames()
sunset.server.render_clients(screen) mouse_x := 0
mouse_y := 0
loop {
mouse_event := intouch.recieve_mouse_event()
if mouse_event != null {
change_x := @as(i16, mouse_event.x_change)
change_x = change_x << 8
change_x = change_x >> 8
mouse_x += change_x
if mouse_x < 0 {
mouse_x = 0
}
if mouse_x >= screen.width - 20 {
mouse_x = @intcast(screen.width - 21)
}
change_y := @as(i16, mouse_event.y_change)
change_y = change_y << 8
change_y = change_y >> 8
if mouse_y < 0 {
mouse_y = 0
}
if mouse_y >= screen.height - 20 {
mouse_y = @intcast(screen.height - 21)
}
mouse_y -= change_y
if mouse_event.left {
// set_label_text(text_label, "LEFT CLICK\0")
}
if mouse_event.middle {
// set_label_text(text_label, "MIDDLE CLICK\0")
}
if mouse_event.right {
// set_label_text(text_label, "RIGHT CLICK\0")
}
}
{
// render.clear(screen, render.black)
}
if sunset.server.incoming() {
// render.clear(screen, render.black)
//
sunset.server.collect_frames()
sunset.server.render_clients(screen)
}
// Mouse cursor
{
render.put_filled_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.black)
render.put_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.white)
}
render.sync(screen)
} }
} }

View file

@ -28,8 +28,8 @@ resolution = "1024x768x24"
# [boot.limine.ableos.modules.horizon] # [boot.limine.ableos.modules.horizon]
# path = "boot:///horizon.hbf" # path = "boot:///horizon.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.ps2_keyboard_driver] # [boot.limine.ableos.modules.ps2_keyboard_driver]
# path = "boot:///ps2_keyboard_driver.hbf" # path = "boot:///ps2_keyboard_driver.hbf"