From 44e987c8521a99519350a42292bcfcd28451dcbd Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 20 Dec 2021 10:26:12 +0100 Subject: Async load images --- tests/main.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/main.c b/tests/main.c index 6261bcd..00fcd1f 100644 --- a/tests/main.c +++ b/tests/main.c @@ -4,15 +4,17 @@ #include "../include/mgui/button.h" #include "../include/mgui/label.h" #include "../include/mgui/richtext.h" +#include "../include/mgui/image.h" #include #include #include #include #include -static mgui_list* create_list_item(const char *title, const char *description) { +static mgui_list* create_list_item(const char *image_filepath, const char *title, const char *description) { mgui_list *container = mgui_list_create(MGUI_LIST_HORIZONITAL); - mgui_list_append(container, mgui_button_to_widget(mgui_button_create("button", 6, 30))); + //mgui_list_set_spacing(container, 10); + mgui_list_append(container, mgui_image_to_widget(mgui_image_create(image_filepath))); mgui_list *list = mgui_list_create(MGUI_LIST_VERTICAL); mgui_list_append(container, mgui_list_to_widget(list)); @@ -33,21 +35,27 @@ int main() { mgui_list *root = mgui_list_create(MGUI_LIST_VERTICAL); mgui_widget *root_widget = mgui_list_to_widget(root); - mgui_list_append(root, mgui_list_to_widget(create_list_item("Title", "Description"))); + mgui_list_append(root, mgui_list_to_widget(create_list_item(NULL, "Title", "Description"))); mgui_scrollview *scrollview = mgui_scrollview_create(); mgui_widget_set_expand(mgui_scrollview_to_widget(scrollview), false, true); + //mgui_widget_set_margin(mgui_scrollview_to_widget(scrollview), (mgui_margin){ 20, 20, 20, 20 }); mgui_list_append(root, mgui_scrollview_to_widget(scrollview)); mgui_list *list = mgui_list_create(MGUI_LIST_VERTICAL); mgui_scrollview_set_child(scrollview, mgui_list_to_widget(list)); - for(int i = 0; i < 30; ++i) { + //mgui_list_set_spacing(list, 30); + for(int i = 0; i < 60; ++i) { char text[256]; snprintf(text, sizeof(text), "hello world 東京 %d", i); - mgui_list_append(list, mgui_list_to_widget(create_list_item("User", text))); + mgui_list_append(list, mgui_list_to_widget(create_list_item(NULL, "User", text))); } - mgui_list_append(root, mgui_list_to_widget(create_list_item("Bottom", "bottom"))); + char text[256]; + snprintf(text, sizeof(text), "hello world 東京 %d", 333); + mgui_list_append(list, mgui_list_to_widget(create_list_item("depends/mgl/tests/X11.png", "User", text))); + + mgui_list_append(root, mgui_list_to_widget(create_list_item(NULL, "Bottom", "bottom"))); mgl_event event; while(mgl_window_is_open(&window)) { @@ -55,13 +63,14 @@ int main() { mgui_on_event(root_widget, &window, &event); } - mgl_window_clear(&window, (mgl_color){ 0, 0, 0, 0 }); + mgl_window_clear(&window, (mgl_color){ 18, 21, 26, 255 }); mgui_draw(root_widget, &window); mgl_window_display(&window); } mgui_widget_destroy(root_widget); mgl_window_deinit(&window); + mgui_deinit(); mgl_deinit(); return 0; } -- cgit v1.2.3