From 3ad1fce1671c25c5db85977588fd1ceee436e1ba Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Fri, 8 Jan 2021 18:10:36 +0100 Subject: Button "animation" --- apps/window.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'apps') 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 #include -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; -- cgit v1.2.3