diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/main.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/tests/main.c b/tests/main.c index e02d4bb..6261bcd 100644 --- a/tests/main.c +++ b/tests/main.c @@ -12,7 +12,6 @@ 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("button", 6, 30))); mgui_list *list = mgui_list_create(MGUI_LIST_VERTICAL); @@ -32,7 +31,14 @@ int main() { if(mgl_window_create(&window, "mgl", &(mgl_window_create_params){ .size = { 1280, 720 } }) != 0) return 1; + 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_scrollview *scrollview = mgui_scrollview_create(); + mgui_widget_set_expand(mgui_scrollview_to_widget(scrollview), false, true); + 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) { @@ -41,20 +47,21 @@ int main() { mgui_list_append(list, mgui_list_to_widget(create_list_item("User", text))); } + mgui_list_append(root, mgui_list_to_widget(create_list_item("Bottom", "bottom"))); + mgl_event event; while(mgl_window_is_open(&window)) { while(mgl_window_poll_event(&window, &event)) { - if(event.type == MGL_EVENT_RESIZED) - mgui_scrollview_set_size(scrollview, (mgl_vec2i){ event.size.width, event.size.height }); - mgui_scrollview_on_event(scrollview, &window, &event); + mgui_on_event(root_widget, &window, &event); } mgl_window_clear(&window, (mgl_color){ 0, 0, 0, 0 }); - mgui_draw(mgui_scrollview_to_widget(scrollview), &window); + mgui_draw(root_widget, &window); mgl_window_display(&window); } - mgui_widget_destroy(mgui_scrollview_to_widget(scrollview)); + mgui_widget_destroy(root_widget); + mgl_window_deinit(&window); mgl_deinit(); return 0; } |