diff options
author | Marvin Borner | 2020-11-22 12:51:10 +0100 |
---|---|---|
committer | Marvin Borner | 2020-11-22 12:51:10 +0100 |
commit | 11568b08115cd0a7fe17608599abdc8a80a4ec50 (patch) | |
tree | 82df8168992fe1f938ff41dcbc661981b398ff6a /apps | |
parent | c0decce503f945ac5883b811443ddca44a7525b9 (diff) |
Added percentage-based GUI system
Diffstat (limited to 'apps')
-rw-r--r-- | apps/browser.c | 23 | ||||
-rw-r--r-- | apps/exec.c | 6 | ||||
-rw-r--r-- | apps/window.c | 7 |
3 files changed, 8 insertions, 28 deletions
diff --git a/apps/browser.c b/apps/browser.c index c51b0a4..bdc7b14 100644 --- a/apps/browser.c +++ b/apps/browser.c @@ -14,24 +14,11 @@ #define HEIGHT 400 #define FONT_HEIGHT 24 #define LABEL_WIDTH 36 // Thx Lars -#define BORDER 2 static struct element *root; static struct element *code_label; static struct element *output; -// Temporary: Will be moved to libnet -char **dns_split(char *url, char **buf) -{ - strchr(url, '.')[0] = '\0'; - char *first = url; - char *second = url + strlen(url) + 1; - buf[0] = first; - buf[1] = second; - - return buf; -} - u32 status_color(char *http_code) { u32 c = 0; @@ -99,13 +86,11 @@ void on_submit(void *event, struct element *box) int main() { // TODO: Dynamic element positioning - root = gui_init("browser", WIDTH + 2 * BORDER, HEIGHT + 2 * BORDER, COLOR_BG); - code_label = gui_add_label(root, BORDER, BORDER, FONT_24, "000", COLOR_BLACK, COLOR_WHITE); + root = gui_init("browser", WIDTH, HEIGHT, COLOR_BG); + code_label = gui_add_label(root, 0, 0, FONT_24, "000", COLOR_BLACK, COLOR_WHITE); struct element *text_input = - gui_add_text_input(root, LABEL_WIDTH + 2 * BORDER, BORDER, - WIDTH - LABEL_WIDTH - BORDER, FONT_24, COLOR_WHITE, COLOR_BLACK); - output = gui_add_text_box(root, BORDER, FONT_HEIGHT + 2 * BORDER, WIDTH, - HEIGHT - FONT_HEIGHT - BORDER, FONT_16, + gui_add_text_input(root, LABEL_WIDTH, 0, 100, FONT_24, COLOR_WHITE, COLOR_BLACK); + output = gui_add_text_box(root, 0, FONT_HEIGHT + 2, 100, 100, FONT_16, "Enter URL and press Enter :)", COLOR_WHITE, COLOR_BLACK); text_input->event.on_submit = on_submit; diff --git a/apps/exec.c b/apps/exec.c index 68f9e63..51aef91 100644 --- a/apps/exec.c +++ b/apps/exec.c @@ -10,7 +10,6 @@ #define HEIGHT 32 #define WIDTH 300 -#define BORDER 2 void on_submit(struct gui_event_keyboard *event, struct element *elem) { @@ -37,10 +36,9 @@ void on_submit(struct gui_event_keyboard *event, struct element *elem) int main() { - struct element *root = - gui_init("Exec", WIDTH + BORDER * 2, HEIGHT + BORDER * 2, COLOR_BLACK); + struct element *root = gui_init("Exec", WIDTH, HEIGHT, COLOR_BLACK); struct element *input = - gui_add_text_input(root, BORDER, BORDER, WIDTH, FONT_32, COLOR_WHITE, COLOR_BLACK); + gui_add_text_input(root, 0, 0, 100, FONT_32, COLOR_WHITE, COLOR_BLACK); input->event.on_submit = on_submit; diff --git a/apps/window.c b/apps/window.c index 7e1b4be..835a978 100644 --- a/apps/window.c +++ b/apps/window.c @@ -15,15 +15,12 @@ void on_click() int main() { - /* print("[test context loaded]\n"); */ - struct element *root = gui_init("test", 600, 400, COLOR_BG); - struct element *container = - gui_add_container(root, 0, 0, root->ctx->width / 2, root->ctx->height, COLOR_RED); + struct element *container = gui_add_container(root, 0, 0, 50, 100, COLOR_RED); struct element *button = gui_add_button(container, 10, 10, FONT_24, strdup("Button"), COLOR_WHITE, COLOR_BLACK); struct element *text_input = - gui_add_text_input(container, 10, 50, 200, FONT_24, COLOR_WHITE, COLOR_BLACK); + gui_add_text_input(container, 10, 50, 70, FONT_24, COLOR_WHITE, COLOR_BLACK); (void)text_input; button->event.on_click = on_click; |