diff options
author | Marvin Borner | 2020-10-31 20:26:52 +0100 |
---|---|---|
committer | Marvin Borner | 2020-10-31 20:26:52 +0100 |
commit | 72010e198d1a5841b27a42e50a58a86142eb5cd7 (patch) | |
tree | 203fe702d9e9be99bf7d19a5e09d353b8ea169d4 /libgui/inc | |
parent | 05901d834ec72ac753ba5d16057f907a5aa38fbc (diff) |
Added label, text input and more events
Diffstat (limited to 'libgui/inc')
-rw-r--r-- | libgui/inc/gfx.h | 2 | ||||
-rw-r--r-- | libgui/inc/gui.h | 36 |
2 files changed, 33 insertions, 5 deletions
diff --git a/libgui/inc/gfx.h b/libgui/inc/gfx.h index 5010650..c8e5a29 100644 --- a/libgui/inc/gfx.h +++ b/libgui/inc/gfx.h @@ -13,6 +13,8 @@ #define GET_GREEN(color) ((color >> 8) & 0x000000FF) #define GET_BLUE(color) ((color >> 0) & 0X000000FF) +#define COLOR_TRANSPARENT 0x00000000 +#define COLOR_INVISIBLE 0x00000000 #define COLOR_BLACK 0xff0f0f0f #define COLOR_RED 0xfff07f7f #define COLOR_GREEN 0xff7ff088 diff --git a/libgui/inc/gui.h b/libgui/inc/gui.h index b79db3a..3f74178 100644 --- a/libgui/inc/gui.h +++ b/libgui/inc/gui.h @@ -8,14 +8,28 @@ #include <gfx.h> #include <list.h> +// TODO: Remove limits #define MAX_CHILDS 100 +#define MAX_INPUT_LENGTH 100 // TODO: Improve event types (maybe as struct header) enum window_event_type { GUI_KEYBOARD = GFX_MAX + 1, GUI_MOUSE, GUI_MAX }; -enum element_type { GUI_TYPE_ROOT, GUI_TYPE_CONTAINER, GUI_TYPE_BUTTON, GUI_TYPE_TEXTBOX }; +enum element_type { + GUI_TYPE_ROOT, + GUI_TYPE_CONTAINER, + GUI_TYPE_BUTTON, + GUI_TYPE_LABEL, + GUI_TYPE_TEXT_INPUT +}; enum container_flags { SPLIT }; +struct element_event { + void (*on_click)(); + void (*on_key)(); + void (*on_submit)(); +}; + struct element_container { u32 color_bg; enum container_flags flags; @@ -26,12 +40,19 @@ struct element_button { u32 color_fg; u32 color_bg; enum font_type font_type; - void (*on_click)(); }; -struct element_textbox { - const char *text; - u32 color; +struct element_label { + char *text; + u32 color_fg; + u32 color_bg; + enum font_type font_type; +}; + +struct element_text_input { + char text[MAX_INPUT_LENGTH]; + u32 color_fg; + u32 color_bg; enum font_type font_type; }; @@ -39,6 +60,7 @@ struct element { enum element_type type; u32 window_id; struct context *ctx; // Coordinates are relative to container + struct element_event event; struct list *childs; void *data; // Who needs static types anyways :) }; @@ -68,6 +90,10 @@ struct element *gui_init(const char *title, u32 width, u32 height); void gui_event_loop(struct element *container); struct element *gui_add_button(struct element *container, int x, int y, enum font_type font_type, char *text, u32 color_bg, u32 color_fg); +struct element *gui_add_label(struct element *container, int x, int y, enum font_type font_type, + char *text, u32 color_bg, u32 color_fg); +struct element *gui_add_text_input(struct element *container, int x, int y, u32 width, + enum font_type font_type, u32 color_bg, u32 color_fg); struct element *gui_add_container(struct element *container, int x, int y, u32 width, u32 height, u32 color_bg); |