From 9644f3c05b808a3cac3892aae36ffca2cce9357d Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 2 Dec 2021 16:48:23 +0100 Subject: Resize list widgets to the list width for vertical lists --- include/mgui/button.h | 1 + include/mgui/list.h | 5 ++++- include/mgui/widget.h | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/mgui/button.h b/include/mgui/button.h index 864d3c6..aefc3fe 100644 --- a/include/mgui/button.h +++ b/include/mgui/button.h @@ -16,6 +16,7 @@ mgui_widget* mgui_button_to_widget(mgui_button *list); mgui_button* mgui_widget_to_button(mgui_widget *widget); void mgui_button_set_position(mgui_button *self, mgl_vec2i position); +void mgui_button_set_width(mgui_button *self, int width); void mgui_button_on_event(mgui_button *self, mgl_window *window, mgl_event *event); /* Returns the size of the widget */ mgl_vec2i mgui_button_draw(mgui_button *self, mgl_window *window); diff --git a/include/mgui/list.h b/include/mgui/list.h index 82efaf8..6f359c9 100644 --- a/include/mgui/list.h +++ b/include/mgui/list.h @@ -16,16 +16,19 @@ typedef struct { mgui_widget widget; mgui_list_direction direction; mgl_vec2i position; + mgl_vec2i size; mgui_widget **items; size_t num_items; size_t items_capacity; } mgui_list; -mgui_list* mgui_list_create(mgui_list_direction direction); +mgui_list* mgui_list_create(mgui_list_direction direction, mgl_vec2i size); 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_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 4ff394c..c831325 100644 --- a/include/mgui/widget.h +++ b/include/mgui/widget.h @@ -25,8 +25,11 @@ struct mgui_widget { }; void mgui_widget_init(mgui_widget *self, mgui_widget_type type); + void mgui_widget_set_margin(mgui_widget *self, int left, int top, int right, int bottom); void mgui_widget_set_position(mgui_widget *self, mgl_vec2i position); +void mgui_widget_set_width(mgui_widget *self, int width); + 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); -- cgit v1.2.3