aboutsummaryrefslogtreecommitdiff
path: root/include/mgui/widget.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/mgui/widget.h')
-rw-r--r--include/mgui/widget.h42
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 */