diff options
author | Marvin Borner | 2021-01-08 18:10:36 +0100 |
---|---|---|
committer | Marvin Borner | 2021-01-08 18:10:36 +0100 |
commit | 3ad1fce1671c25c5db85977588fd1ceee436e1ba (patch) | |
tree | 243823beb15eee9140966908fcdfd3a827130af6 /apps | |
parent | 01c570789d7f9ccc1521b791903c8a499b0f6323 (diff) |
Button "animation"
Diffstat (limited to 'apps')
-rw-r--r-- | apps/window.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/apps/window.c b/apps/window.c index 835a978..6d738dc 100644 --- a/apps/window.c +++ b/apps/window.c @@ -8,17 +8,30 @@ #include <print.h> #include <str.h> -void on_click() +void on_click(void *e, struct element *elem) { - print("CLICK!\n"); + (void)e; + + struct element_button *b = elem->data; + b->color_bg = COLOR_MAGENTA; + b->color_fg = COLOR_WHITE; + gui_sync(elem); + + u32 time = time(); + while (time + 200 > time()) + yield(); + + b->color_bg = COLOR_WHITE; + b->color_fg = COLOR_BLACK; + gui_sync(elem); } int main() { struct element *root = gui_init("test", 600, 400, COLOR_BG); 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 *button = + gui_add_button(container, 10, 10, FONT_24, "Button", COLOR_WHITE, COLOR_BLACK); struct element *text_input = gui_add_text_input(container, 10, 50, 70, FONT_24, COLOR_WHITE, COLOR_BLACK); (void)text_input; |