diff options
author | Marvin Borner | 2020-08-25 23:37:09 +0200 |
---|---|---|
committer | Marvin Borner | 2020-08-25 23:37:09 +0200 |
commit | 2b26af8325b9492948cb7fe516638537e4e58337 (patch) | |
tree | 6640f28efa106fa682dd5578ac70633039a682a0 /apps | |
parent | ec5c4a7398fcfcfb5a809292cbe029b1bb69a320 (diff) |
Some GUI things
Diffstat (limited to 'apps')
-rw-r--r-- | apps/test.c | 14 | ||||
-rw-r--r-- | apps/wm.c | 24 |
2 files changed, 28 insertions, 10 deletions
diff --git a/apps/test.c b/apps/test.c index efc7432..93ee07a 100644 --- a/apps/test.c +++ b/apps/test.c @@ -1,16 +1,26 @@ // MIT License, Copyright (c) 2020 Marvin Borner +#include <conv.h> #include <def.h> #include <gui.h> #include <print.h> +#include <str.h> int main() { print("[test loaded]\n"); struct window *win = gui_new_window(); - u32 color[3] = { 0xff, 0xff, 0xff }; - gui_fill(win, color); + + const u32 background[3] = { 0x28, 0x2c, 0x34 }; + gui_fill(win, background); + const u32 border[3] = { 0xab, 0xb2, 0xbf }; + gui_border(win, border, 2); + const u32 text[3] = { 0xab, 0xb2, 0xbf }; + + gui_init("/font/spleen-12x24.psfu"); + char *hello = "Hello, world!"; + gui_write(win, win->width / 2 - (strlen(hello) * 12) / 2, 5, text, hello); while (1) { yield(); @@ -65,12 +65,13 @@ int main(int argc, char **argv) direct->fb = vbe->fb; list_add(windows, root); - const u32 background[3] = { 0x0, 0x0, 0x0 }; + const u32 background[3] = { 0x28, 0x2c, 0x34 }; gui_fill(root, background); - const u32 border[3] = { 0xff, 0xff, 0xff }; + const u32 border[3] = { 0xab, 0xb2, 0xbf }; gui_border(root, border, 2); // TODO: Fix wallpaper /* gui_load_wallpaper(root, "/wall.bmp"); */ + redraw_all(); event_register(EVENT_KEYBOARD); event_register(EVENT_MOUSE); @@ -86,23 +87,31 @@ int main(int argc, char **argv) case MSG_NEW_WINDOW: printf("New window for pid %d\n", msg->src); struct window *win = - new_window(vbe->width / 2 - 100, vbe->height / 2 - 100, 200, 200); + new_window(vbe->width / 2 - 100, vbe->height / 2 - 100, 500, 300); msg_send(msg->src, MSG_NEW_WINDOW, win); list_add(windows, win); focused = win; + redraw_all(); + break; + case MSG_REDRAW: + redraw_all(); break; case EVENT_KEYBOARD: { struct event_keyboard *event = msg->data; - assert(event->magic == KEYBOARD_MAGIC); + if (event->magic != KEYBOARD_MAGIC) + break; printf("Keypress %d %s!\n", event->scancode, event->press ? "pressed" : "released"); - /* focused->x += 50; */ - /* redraw_all(); */ + if (event->press) { + focused->x += 50; + redraw_all(); + } break; } case EVENT_MOUSE: { struct event_mouse *event = msg->data; - assert(event->magic == MOUSE_MAGIC); + if (event->magic != MOUSE_MAGIC) + break; mouse_x += event->diff_x; mouse_y -= event->diff_y; @@ -119,7 +128,6 @@ int main(int argc, char **argv) focused->x = mouse_x; focused->y = mouse_y; redraw_all(); - printf("%d %d\n", mouse_x, mouse_y); break; } default: |