From dc4a3a2db894e8e7bb0be620b90780d55c74accd Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Wed, 6 Jul 2022 23:46:59 +0200 Subject: Allow multiple button types --- src/gui/inc/gui/button.h | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/gui/inc') diff --git a/src/gui/inc/gui/button.h b/src/gui/inc/gui/button.h index acfc6c1..b712e29 100644 --- a/src/gui/inc/gui/button.h +++ b/src/gui/inc/gui/button.h @@ -15,8 +15,27 @@ extern "C" struct gui_button { struct gui_common common; - struct gui_label label; - short w; + + enum gui_button_type + { + GUI_BUTTON_TYPE_1, + GUI_BUTTON_TYPE_SPRITE + } type; + + union + { + struct + { + short w; + struct gui_label label; + } type1; + + struct + { + const struct sprite *s; + } sprite; + } u; + void *arg; void (*on_pressed)(void *); }; @@ -24,7 +43,7 @@ struct gui_button UTIL_STATIC_ASSERT(!offsetof(struct gui_button, common), "unexpected offset for struct gui_button"); -void gui_button_init(struct gui_button *b); +void gui_button_init(struct gui_button *b, enum gui_button_type t); enum { -- cgit v1.2.3