Fri, 25 Oct 2024 15:44:39 +0200
implement scrolledwindow sub container type (GTK)
application/main.c | file | annotate | diff | comparison | revisions | |
ui/gtk/container.c | file | annotate | diff | comparison | revisions | |
ui/ui/container.h | file | annotate | diff | comparison | revisions |
--- a/application/main.c Fri Oct 25 15:37:02 2024 +0200 +++ b/application/main.c Fri Oct 25 15:44:39 2024 +0200 @@ -309,12 +309,10 @@ ui_tab(obj, "Tab 6") { ui_scrolledwindow(obj, .style_class = "ui_test", .fill = UI_ON) { - ui_vbox(obj, .spacing = 10) { - for(int i=0;i<100;i++) { - char labelstr[32]; - snprintf(labelstr, 32, "button %d", i); - ui_button(obj, .label = labelstr); - } + for(int i=0;i<100;i++) { + char labelstr[32]; + snprintf(labelstr, 32, "button %d", i); + ui_button(obj, .label = labelstr); } } }
--- a/ui/gtk/container.c Fri Oct 25 15:37:02 2024 +0200 +++ b/ui/gtk/container.c Fri Oct 25 15:44:39 2024 +0200 @@ -329,7 +329,40 @@ current->container->add(current->container, widget, TRUE); UiObject *newobj = uic_object_new(obj, sw); - newobj->container = ui_scrolledwindow_container(obj, sw); + GtkWidget *sub; + switch(args.subcontainer) { + default: { + sub = ui_gtk_vbox_new(args.spacing); + GtkWidget *widget = ui_box_set_margin(sub, args.margin); + SCROLLEDWINDOW_SET_CHILD(sw, widget); + + newobj->container = ui_box_container(newobj, sub, args.subcontainer); + break; + } + case UI_CONTAINER_HBOX: { + sub = ui_gtk_hbox_new(args.spacing); + GtkWidget *widget = ui_box_set_margin(sub, args.margin); + SCROLLEDWINDOW_SET_CHILD(sw, widget); + + newobj->container = ui_box_container(newobj, sub, args.subcontainer); + break; + } + case UI_CONTAINER_GRID: { + sub = ui_create_grid_widget(args.columnspacing, args.rowspacing); + GtkWidget *widget = ui_box_set_margin(sub, args.margin); + SCROLLEDWINDOW_SET_CHILD(sw, widget); + + newobj->container = ui_grid_container(newobj, sub); + break; + } + case UI_CONTAINER_NO_SUB: { + sub = sw; + newobj->container = ui_scrolledwindow_container(obj, sw); + } + } + newobj->widget = sub; + + uic_obj_add(obj, newobj); return sw;
--- a/ui/ui/container.h Fri Oct 25 15:37:02 2024 +0200 +++ b/ui/ui/container.h Fri Oct 25 15:44:39 2024 +0200 @@ -38,7 +38,8 @@ typedef enum UiSubContainerType { UI_CONTAINER_VBOX = 0, UI_CONTAINER_HBOX, - UI_CONTAINER_GRID + UI_CONTAINER_GRID, + UI_CONTAINER_NO_SUB } UiSubContainerType; typedef enum UiTabViewType {