ui/ui/container.h

changeset 112
c3f2f16fa4b8
parent 110
c00e968d018b
--- a/ui/ui/container.h	Sat Oct 04 14:54:25 2025 +0200
+++ b/ui/ui/container.h	Sun Oct 19 21:20:08 2025 +0200
@@ -65,12 +65,16 @@
     UiBool hfill;
     UiBool vfill;
     UiBool override_defaults;
+    int margin;
+    int margin_left;
+    int margin_right;
+    int margin_top;
+    int margin_bottom;
     int colspan;
     int rowspan;
     const char *name;
     const char *style_class;
 
-    int margin;
     int spacing;
     int columnspacing;
     int rowspacing;
@@ -87,14 +91,19 @@
     UiBool hfill;
     UiBool vfill;
     UiBool override_defaults;
+    int margin;
+    int margin_left;
+    int margin_right;
+    int margin_top;
+    int margin_bottom;
     int colspan;
     int rowspan;
     const char *name;
     const char *style_class;
 
     UiSubContainerType subcontainer;
-
-    int margin;
+    
+    int padding;
     int spacing;
     int columnspacing;
     int rowspacing;
@@ -110,6 +119,11 @@
     UiBool hfill;
     UiBool vfill;
     UiBool override_defaults;
+    int margin;
+    int margin_left;
+    int margin_right;
+    int margin_top;
+    int margin_bottom;
     int colspan;
     int rowspan;
     const char *name;
@@ -124,7 +138,7 @@
     UiInteger *value;
     const char* varname;
 
-    int margin;
+    int padding;
     int spacing;
     int columnspacing;
     int rowspacing;
@@ -137,6 +151,11 @@
     UiBool hfill;
     UiBool vfill;
     UiBool override_defaults;
+    int margin;
+    int margin_left;
+    int margin_right;
+    int margin_top;
+    int margin_bottom;
     int colspan;
     int rowspan;
     const char *name;
@@ -153,6 +172,10 @@
     const char *name;
     const char *style_class;
     int margin;
+    int margin_left;
+    int margin_right;
+    int margin_top;
+    int margin_bottom;
     int spacing;
 } UiSidebarArgs;
 
@@ -163,12 +186,16 @@
     UiBool hfill;
     UiBool vfill;
     UiBool override_defaults;
+    int margin;
+    int margin_left;
+    int margin_right;
+    int margin_top;
+    int margin_bottom;
     int colspan;
     int rowspan;
     const char *name;
     const char *style_class;
 
-    int margin;
     int spacing;
     int columnspacing;
     int rowspacing;
@@ -187,12 +214,16 @@
     UiBool hfill;
     UiBool vfill;
     UiBool override_defaults;
+    int margin;
+    int margin_left;
+    int margin_right;
+    int margin_top;
+    int margin_bottom;
     int colspan;
     int rowspan;
     const char *name;
     const char *style_class;
     
-    int margin;
     int spacing;
     
     int sub_margin;
@@ -225,9 +256,29 @@
     UiSubContainerType subcontainer;
 } UiItemListContainerArgs;
 
+
+typedef struct UiLayout UiLayout;
+struct UiLayout {
+    UiBool       fill;
+    char         *label;
+    UiBool       hexpand;
+    UiBool       vexpand;
+    UiBool       hfill;
+    UiBool       vfill;
+    UiBool       override_defaults;
+    int          margin;
+    int          margin_left;
+    int          margin_right;
+    int          margin_top;
+    int          margin_bottom;
+    int          colspan;
+    int          rowspan;
+};
+
 struct UiContainerX {
     void *container;
-    int close;
+    UiBool close;
+    UiBool newline;
     UiContainerX *prev;
     UiContainerX *next;
 };
@@ -314,18 +365,6 @@
 
 UIEXPORT void ui_splitpane_set_visible(UIWIDGET splitpane, int child_index, UiBool visible);
 
-// box container layout functions
-UIEXPORT void ui_layout_fill(UiObject *obj, UiBool fill);
-// grid container layout functions
-UIEXPORT void ui_layout_hexpand(UiObject *obj, UiBool expand);
-UIEXPORT void ui_layout_vexpand(UiObject *obj, UiBool expand);
-UIEXPORT void ui_layout_hfill(UiObject *obj, UiBool fill);
-UIEXPORT void ui_layout_vfill(UiObject *obj, UiBool fill);
-UIEXPORT void ui_layout_override_defaults(UiObject *obj, UiBool d);
-UIEXPORT void ui_layout_width(UiObject *obj, int width);
-UIEXPORT void ui_layout_height(UiObject* obj, int width);
-UIEXPORT void ui_layout_colspan(UiObject *obj, int cols);
-UIEXPORT void ui_layout_rowspan(UiObject* obj, int rows);
 UIEXPORT void ui_newline(UiObject *obj);
 
 // TODO
@@ -339,7 +378,7 @@
 UIEXPORT int ui_container_finish(UiObject *obj);
 
 #define UI_APPLY_LAYOUT1(obj, args) \
-    if(args.fill != UI_DEFAULT) ui_layout_fill(obj, args.fill == UI_ON ? 1 : 0 ); \
+    if(args.fill) ui_layout_fill(obj, 1); \
     if(args.hexpand) ui_layout_hexpand(obj, 1); \
     if(args.vexpand) ui_layout_vexpand(obj, 1); \
     if(args.hfill) ui_layout_hfill(obj, 1); \
@@ -350,7 +389,7 @@
     /*force caller to add ';'*/(void)0
 
 #define UI_APPLY_LAYOUT2(obj, args) \
-    if(args->fill != UI_DEFAULT) ui_layout_fill(obj, args->fill == UI_ON ? 1 : 0 ); \
+    if(args->fill) ui_layout_fill(obj, 1); \
     if(args->hexpand) ui_layout_hexpand(obj, 1); \
     if(args->vexpand) ui_layout_vexpand(obj, 1); \
     if(args->hfill) ui_layout_hfill(obj, 1); \
@@ -360,7 +399,21 @@
     if(args->rowspan > 0) ui_layout_rowspan(obj, args->rowspan); \
     /*force caller to add ';'*/(void)0
 
-
+#define UI_ARGS2LAYOUT(args) { \
+    .fill = args->fill, \
+    .hexpand = args->hexpand, \
+    .vexpand = args->vexpand, \
+    .hfill = args->hfill, \
+    .vfill = args->vfill, \
+    .override_defaults = args->override_defaults, \
+    .margin = args->margin, \
+    .margin_left = args->margin_left, \
+    .margin_right = args->margin_right, \
+    .margin_top = args->margin_top, \
+    .margin_bottom = args->margin_bottom, \
+    .colspan = args->colspan, \
+    .rowspan = args->rowspan }
+    
 #ifdef __cplusplus
 }
 #endif

mercurial