diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/mgui/button.h | 4 | ||||
-rw-r--r-- | include/mgui/image.h | 22 | ||||
-rw-r--r-- | include/mgui/label.h | 27 | ||||
-rw-r--r-- | include/mgui/list.h | 9 | ||||
-rw-r--r-- | include/mgui/widget.h | 4 |
5 files changed, 59 insertions, 7 deletions
diff --git a/include/mgui/button.h b/include/mgui/button.h index aefc3fe..d9e8783 100644 --- a/include/mgui/button.h +++ b/include/mgui/button.h @@ -1,14 +1,14 @@ #ifndef MGUI_BUTTON_H #define MGUI_BUTTON_H +#include "widget.h" #include <mgl/graphics/rectangle.h> #include <mgl/graphics/text.h> -#include "widget.h" typedef struct { mgui_widget widget; mgl_rectangle background; - mgl_text label; + mgl_text text; } mgui_button; mgui_button* mgui_button_create(); diff --git a/include/mgui/image.h b/include/mgui/image.h new file mode 100644 index 0000000..c1072d4 --- /dev/null +++ b/include/mgui/image.h @@ -0,0 +1,22 @@ +#ifndef MGUI_IMAGE_H +#define MGUI_IMAGE_H + +#include "widget.h" +#include <mgl/graphics/sprite.h> + +typedef struct { + mgui_widget widget; + mgl_sprite sprite; +} mgui_image; + +mgui_image* mgui_image_create(const char *filepath); +mgui_widget* mgui_image_to_widget(mgui_image *list); +mgui_image* mgui_widget_to_image(mgui_widget *widget); + +void mgui_image_set_position(mgui_image *self, mgl_vec2i position); +void mgui_image_set_width(mgui_image *self, int width); +void mgui_image_on_event(mgui_image *self, mgl_window *window, mgl_event *event); +/* Returns the size of the widget */ +mgl_vec2i mgui_image_draw(mgui_image *self, mgl_window *window); + +#endif /* MGUI_IMAGE_H */ diff --git a/include/mgui/label.h b/include/mgui/label.h new file mode 100644 index 0000000..920ecf9 --- /dev/null +++ b/include/mgui/label.h @@ -0,0 +1,27 @@ +#ifndef MGUI_LABEL_H +#define MGUI_LABEL_H + +#include "widget.h" +#include <stddef.h> +#include <mgl/graphics/text.h> + +typedef struct { + mgui_widget widget; + char *str; + size_t str_size; + mgl_text text; + mgl_vec2i position; + int width; +} mgui_label; + +mgui_label* mgui_label_create(const char *str, size_t size, unsigned char character_size); +mgui_widget* mgui_label_to_widget(mgui_label *list); +mgui_label* mgui_widget_to_label(mgui_widget *widget); + +void mgui_label_set_position(mgui_label *self, mgl_vec2i position); +void mgui_label_set_width(mgui_label *self, int width); +void mgui_label_on_event(mgui_label *self, mgl_window *window, mgl_event *event); +/* Returns the size of the widget */ +mgl_vec2i mgui_label_draw(mgui_label *self, mgl_window *window); + +#endif /* MGUI_LABEL_H */ diff --git a/include/mgui/list.h b/include/mgui/list.h index 6f359c9..f0080c8 100644 --- a/include/mgui/list.h +++ b/include/mgui/list.h @@ -3,6 +3,7 @@ #include "widget.h" #include <stddef.h> +#include <mgl/graphics/color.h> typedef struct mgl_window mgl_window; typedef struct mgl_event mgl_event; @@ -16,19 +17,19 @@ typedef struct { mgui_widget widget; mgui_list_direction direction; mgl_vec2i position; - mgl_vec2i size; + mgl_color background_color; mgui_widget **items; - size_t num_items; size_t items_capacity; + size_t num_items; } mgui_list; -mgui_list* mgui_list_create(mgui_list_direction direction, mgl_vec2i size); +mgui_list* mgui_list_create(mgui_list_direction direction); mgui_widget* mgui_list_to_widget(mgui_list *list); mgui_list* mgui_widget_to_list(mgui_widget *widget); void mgui_list_set_position(mgui_list *self, mgl_vec2i position); -void mgui_list_set_size(mgui_list *self, mgl_vec2i size); void mgui_list_set_width(mgui_list *self, int width); +void mgui_list_set_background_color(mgui_list *self, mgl_color color); void mgui_list_append(mgui_list *self, mgui_widget *widget); void mgui_list_on_event(mgui_list *self, mgl_window *window, mgl_event *event); /* Returns the size of the widget */ diff --git a/include/mgui/widget.h b/include/mgui/widget.h index c831325..ec19a98 100644 --- a/include/mgui/widget.h +++ b/include/mgui/widget.h @@ -9,7 +9,9 @@ typedef struct mgui_widget mgui_widget; typedef enum { MGUI_WIDGET_LIST, - MGUI_WIDGET_BUTTON + MGUI_WIDGET_BUTTON, + MGUI_WIDGET_LABEL, + MGUI_WIDGET_IMAGE } mgui_widget_type; typedef struct { |