From d3a5b3d579e30ce02afd5e270dfdd511af195c31 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 4 Dec 2021 01:37:07 +0100 Subject: Add image --- tests/main.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'tests') 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 #include #include +#include + +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); } -- cgit v1.2.3