fix wrong child height in grid layout (win32)

Mon, 13 Oct 2025 21:07:59 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 13 Oct 2025 21:07:59 +0200
changeset 844
3106d9ca2f9c
parent 843
9d958108c415
child 845
f3ab28ed22e5

fix wrong child height in grid layout (win32)

application/main.c file | annotate | diff | comparison | revisions
ui/win32/container.c file | annotate | diff | comparison | revisions
ui/win32/grid.c file | annotate | diff | comparison | revisions
--- a/application/main.c	Sun Oct 12 17:37:54 2025 +0200
+++ b/application/main.c	Mon Oct 13 21:07:59 2025 +0200
@@ -1152,6 +1152,9 @@
         ui_newline(obj);
 
         ui_button(obj, .label = "Test 3XX", .colspan = 3, .fill = TRUE, .onclick = action_button);
+        ui_newline(obj);
+
+        ui_button(obj, .label = "End");
     }
 
 
@@ -1160,6 +1163,7 @@
 }
 
 int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
+//int main() {
     ui_init("app1", 0, NULL);
     ui_onstartup(application_startup, NULL);
 
--- a/ui/win32/container.c	Sun Oct 12 17:37:54 2025 +0200
+++ b/ui/win32/container.c	Mon Oct 13 21:07:59 2025 +0200
@@ -133,7 +133,7 @@
             0,
             TEXT("STATIC"),
             NULL,
-            WS_CHILD | WS_VISIBLE | WS_BORDER,
+            WS_CHILD | WS_VISIBLE,
             0, 0, 100, 100,
             parent,
             NULL,
--- a/ui/win32/grid.c	Sun Oct 12 17:37:54 2025 +0200
+++ b/ui/win32/grid.c	Mon Oct 13 21:07:59 2025 +0200
@@ -67,6 +67,10 @@
 }
 
 void ui_grid_layout(UiGridLayout *grid, int width, int height) {
+    if (width == 0 || height == 0) {
+        return;
+    }
+
     int ncols = grid->max_column+1;
     int nrows = grid->max_row+1;
 
@@ -260,10 +264,10 @@
             } else {
                 child_width = col->size;
             }
+            child_width -= elm->layout.margin.left + elm->layout.margin.right;
         } else {
             child_width = elm->layout.preferred_width;
         }
-        child_width -= elm->layout.margin.left + elm->layout.margin.right;
 
         if(elm->layout.vfill) {
             if(elm->layout.rowspan > 1) {
@@ -282,7 +286,7 @@
                 }
                 child_height = rheight;
             }
-            child_height = row->size;
+            child_height = row->size - elm->layout.margin.top - elm->layout.margin.bottom;
         } else {
             child_height = elm->layout.preferred_height;
         }

mercurial