fix grid margin (Motif)

Tue, 18 Nov 2025 16:47:48 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 18 Nov 2025 16:47:48 +0100
changeset 913
3012ec57d84a
parent 912
06c37c12d149
child 914
4d5aa85bc5ed

fix grid margin (Motif)

ui/motif/Grid.c file | annotate | diff | comparison | revisions
ui/motif/container.c file | annotate | diff | comparison | revisions
--- a/ui/motif/Grid.c	Tue Nov 18 15:56:59 2025 +0100
+++ b/ui/motif/Grid.c	Tue Nov 18 16:47:48 2025 +0100
@@ -438,6 +438,8 @@
     int num_rows_expanding = 0;
     int req_width = w->mywidget.padding_left + w->mywidget.padding_right;
     int req_height = w->mywidget.padding_top + w->mywidget.padding_bottom;
+    int width = w->core.width;
+    int height = w->core.height;
     
     //printf("container width: %d\n", (int)w->core.width);
     
@@ -600,7 +602,7 @@
     
     // how much space can we add to each expanding col/row
     int hexpand = 0;
-    int width_diff = (int)w->core.width - req_width;
+    int width_diff = width - req_width;
     int hexpand2 = 0;
     if(width_diff > 0 && num_cols_expanding > 0) {
         hexpand = width_diff / num_cols_expanding;
@@ -618,7 +620,7 @@
     }
     
     int vexpand = 0;
-    int height_diff = (int)w->core.height - req_height;
+    int height_diff = height - req_height;
     int vexpand2 = 0;
     if(height_diff > 0 && num_rows_expanding > 0) {
         vexpand = height_diff / num_rows_expanding;
@@ -654,7 +656,7 @@
                 }
                 width = cwidth;
             } else {
-                width = c.size - w->mywidget.columnspacing;
+                width = c.size - w->mywidget.columnspacing - constraints->grid.margin_left - constraints->grid.margin_right;
             }
         }
         if(constraints->grid.vfill) {
@@ -667,7 +669,7 @@
                 }
                 height = cheight;
             } else {
-                height = r.size - w->mywidget.rowspacing;
+                height = r.size - w->mywidget.rowspacing - constraints->grid.margin_top - constraints->grid.margin_bottom;
             }
         }
               
--- a/ui/motif/container.c	Tue Nov 18 15:56:59 2025 +0100
+++ b/ui/motif/container.c	Tue Nov 18 16:47:48 2025 +0100
@@ -163,10 +163,6 @@
     UiLayout layout = UI_ARGS2LAYOUT(args);
     
     Widget parent = ui_container_prepare(ctn, &layout, xargs, &n);
-    XtSetArg(xargs[n], gridPaddingLeft, 10); n++;
-    XtSetArg(xargs[n], gridPaddingRight, 10); n++;
-    XtSetArg(xargs[n], gridPaddingTop, 10); n++;
-    XtSetArg(xargs[n], gridPaddingBottom, 10); n++;
     XtSetArg(xargs[n], gridColumnSpacing, args->columnspacing); n++;
     XtSetArg(xargs[n], gridRowSpacing, args->rowspacing); n++;
     Widget grid = XtCreateManagedWidget(args->name ? args->name : "gridcontainer", gridClass, parent, xargs, n);

mercurial