aboutsummaryrefslogtreecommitdiff
path: root/tests/main.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-12-04 01:37:07 +0100
committerdec05eba <dec05eba@protonmail.com>2021-12-04 01:37:07 +0100
commitd3a5b3d579e30ce02afd5e270dfdd511af195c31 (patch)
tree7d5aaa9d8289e7f8af2d62f796336f207375b610 /tests/main.c
parent9644f3c05b808a3cac3892aae36ffca2cce9357d (diff)
Add image
Diffstat (limited to 'tests/main.c')
-rw-r--r--tests/main.c25
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);
}