diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/main.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/tests/main.c b/tests/main.c index 5f07558..2356cb3 100644 --- a/tests/main.c +++ b/tests/main.c @@ -1,8 +1,22 @@ #include "../include/mgui/list.h" #include "../include/mgui/button.h" +#include "../include/mgui/label.h" #include <mgl/mgl.h> #include <mgl/window/window.h> #include <mgl/window/event.h> +#include <string.h> + +static mgui_list* create_list_item(const char *title, const char *description) { + mgui_list *container = mgui_list_create(MGUI_LIST_HORIZONITAL); + mgui_list_set_background_color(container, (mgl_color){ 255, 0, 0, 255 }); + mgui_list_append(container, mgui_button_to_widget(mgui_button_create())); + + mgui_list *list = mgui_list_create(MGUI_LIST_VERTICAL); + mgui_list_append(container, mgui_list_to_widget(list)); + mgui_list_append(list, mgui_label_to_widget(mgui_label_create(title, strlen(title), 30))); + mgui_list_append(list, mgui_label_to_widget(mgui_label_create(description, strlen(description), 24))); + return container; +} int main() { if(mgl_init() != 0) @@ -12,20 +26,21 @@ int main() { if(mgl_window_create(&window, "mgl", &(mgl_window_create_params){ .size = { 1280, 720 } }) != 0) return 1; - mgui_list *list = mgui_list_create(MGUI_LIST_VERTICAL, (mgl_vec2i){ 1280, 720 }); - mgui_list_append(list, mgui_button_to_widget(mgui_button_create())); - mgui_list_append(list, mgui_button_to_widget(mgui_button_create())); + mgui_list *list = mgui_list_create(MGUI_LIST_VERTICAL); + mgui_list_append(list, mgui_list_to_widget(create_list_item("Slashbash", "A government has a duty to its own people, first and foremost. If they don't protect their people, they are failing their duties and should be removed."))); + mgui_list_append(list, mgui_list_to_widget(create_list_item("Andy F.", "Immigration to ANY nation is a privilege given by that nation, not a right."))); mgl_event event; while(mgl_window_is_open(&window)) { while(mgl_window_poll_event(&window, &event)) { + /* TODO: if(event.type == MGL_EVENT_RESIZED) { mgui_list_set_size(list, (mgl_vec2i){ event.size.width, event.size.height }); - } + }*/ mgui_list_on_event(list, &window, &event); } - mgl_window_clear(&window, (mgl_color){0, 0, 0, 0}); + mgl_window_clear(&window, (mgl_color){ 0, 0, 0, 0 }); mgui_list_draw(list, &window); mgl_window_display(&window); } |