diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-12-14 23:48:34 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-12-15 10:30:34 +0100 |
commit | 0417619b36dc7f4b004caa64a65570f1344d1c8d (patch) | |
tree | 10c4b9bbe5bd7c16322495890c3324cd76d584c8 /include/mgui/widget.h | |
parent | 396686a09ef471499c11256b8516c2702f761060 (diff) |
Layout, expand, etc
Diffstat (limited to 'include/mgui/widget.h')
-rw-r--r-- | include/mgui/widget.h | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/include/mgui/widget.h b/include/mgui/widget.h index 679e4ad..d425c11 100644 --- a/include/mgui/widget.h +++ b/include/mgui/widget.h @@ -2,6 +2,8 @@ #define MGUI_WIDGET_H #include <mgl/system/vec.h> +#include <stdint.h> +#include <stdbool.h> typedef struct mgl_window mgl_window; typedef struct mgl_event mgl_event; @@ -16,27 +18,55 @@ typedef enum { MGUI_WIDGET_IMAGE } mgui_widget_type; +typedef enum { + MGUI_WIDGET_ALIGN_TOP_LEFT, + MGUI_WIDGET_ALIGN_TOP_CENTER, + MGUI_WIDGET_ALIGN_TOP_RIGHT, + + MGUI_WIDGET_ALIGN_CENTER_LEFT, + MGUI_WIDGET_ALIGN_CENTER_CENTER, + MGUI_WIDGET_ALIGN_CENTER_RIGHT, + + MGUI_WIDGET_ALIGN_BOTTOM_LEFT, + MGUI_WIDGET_ALIGN_BOTTOM_CENTER, + MGUI_WIDGET_ALIGN_BOTTOM_RIGHT, +} mgui_alignment; + +typedef enum { + MGUI_WIDGET_VISIBLE = 1 << 0, + MGUI_WIDGET_EXPAND_HORIZONTAL = 1 << 1, + MGUI_WIDGET_EXPAND_VERTICAL = 1 << 2, + MGUI_WIDGET_DEBUG_HAS_PARENT = 1 << 3 +} mgui_widget_flags; + typedef struct { int left; - int top; int right; + int top; int bottom; } mgui_margin; struct mgui_widget { - mgui_widget_type type; + uint8_t type; /* mgui_widget_type */ + uint8_t flags; /* mgui_widget_flags */ + uint8_t alignment; /* mgui_alignment, MGUI_WIDGET_ALIGN_TOP_LEFT by default */ mgui_margin margin; + mgl_vec2i size; }; void mgui_widget_init(mgui_widget *self, mgui_widget_type type); void mgui_widget_destroy(mgui_widget *widget); -void mgui_widget_set_margin(mgui_widget *self, int left, int top, int right, int bottom); +void mgui_widget_set_visible(mgui_widget *self, bool visible); +void mgui_widget_set_expand(mgui_widget *self, bool horizontal, bool vertical); +void mgui_widget_set_alignment(mgui_widget *self, mgui_alignment alignment); +void mgui_widget_set_margin(mgui_widget *self, mgui_margin margin); +void mgui_widget_set_size(mgui_widget *self, mgl_vec2i size); void mgui_widget_set_position(mgui_widget *self, mgl_vec2i position); -void mgui_widget_set_width(mgui_widget *self, int width); +void mgui_widget_calculate_size(mgui_widget *self, mgl_vec2i max_size); +void mgui_widget_set_has_parent(mgui_widget *self); void mgui_widget_on_event(mgui_widget *self, mgl_window *window, mgl_event *event); -/* Returns the size of the widget */ -mgl_vec2i mgui_widget_draw(mgui_widget *self, mgl_window *window); +void mgui_widget_draw(mgui_widget *self, mgl_window *window); #endif /* MGUI_WIDGET_H */ |