aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-12-20 10:26:12 +0100
committerdec05eba <dec05eba@protonmail.com>2021-12-21 20:22:33 +0100
commit44e987c8521a99519350a42292bcfcd28451dcbd (patch)
tree699015a5dd459e96e0b19f4836f7dcffc1e347de /tests
parent6bb40bf0c5cd8ee8fb87640fd04b2c595f84c1d3 (diff)
Async load images
Diffstat (limited to 'tests')
-rw-r--r--tests/main.c23
1 files changed, 16 insertions, 7 deletions
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 <mgl/mgl.h>
#include <mgl/window/window.h>
#include <mgl/window/event.h>
#include <string.h>
#include <stdio.h>
-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;
}