--- a/ui/cocoa/GridLayout.m Sat Oct 04 18:33:58 2025 +0200 +++ b/ui/cocoa/GridLayout.m Sun Oct 05 12:34:42 2025 +0200 @@ -184,17 +184,23 @@ int preferred_width = 0; int preferred_height = 0; for(int j=0;j<ncols;j++) { - preferred_width += cols[j].preferred_size + colspacing; + preferred_width += cols[j].preferred_size; if(cols[j].expand) { col_ext++; } } for(int j=0;j<nrows;j++) { - preferred_height += rows[j].preferred_size + rowspacing; + preferred_height += rows[j].preferred_size; if(rows[j].expand) { row_ext++; } } + if(ncols > 0) { + preferred_width += (ncols-1) * colspacing; + } + if(nrows > 0) { + preferred_height += (nrows-1) * rowspacing; + } _preferredSize.width = preferred_width; _preferredSize.height = preferred_height; @@ -292,7 +298,7 @@ return self.preferredSize; } -- (void) addView:(NSView*)view { +- (void) addView:(NSView*)view margin:(NSEdgeInsets)margin { _preferredSize.width = -1; _preferredSize.height = -1; @@ -305,7 +311,7 @@ GridElm elm; elm.x = _x; elm.y = _y; - elm.margin = 0; + elm.margin = margin; elm.colspan = _uilayout.colspan; elm.rowspan = _uilayout.rowspan; if(_uilayout.fill) {