--- a/ui/cocoa/GridLayout.m Sun Aug 24 15:24:16 2025 +0200 +++ b/ui/cocoa/GridLayout.m Sat Oct 04 14:52:59 2025 +0200 @@ -41,6 +41,8 @@ _columnspacing = 0; _rowspacing = 0; _children = cxArrayListCreateSimple(sizeof(GridElm), 32); + _preferredSize.width = -1; + _preferredSize.height = -1; return self; } @@ -80,12 +82,6 @@ NSSize size = elm->view.intrinsicContentSize; NSSize size2 = elm->view.fittingSize; - NSEdgeInsets alignment = elm->view.alignmentRectInsets; - // TODO: remove alignment - alignment.left = 0; - alignment.right = 0; - alignment.top = 0; - alignment.bottom = 0; if(size.width == NSViewNoIntrinsicMetric) { size.width = size2.width; } @@ -93,14 +89,14 @@ size.height = size2.height; } if(size.width != NSViewNoIntrinsicMetric) { - CGFloat width = size.width + alignment.left + alignment.right; + CGFloat width = size.width; if(width > cols[elm->x].preferred_size && elm->colspan <= 1 && span_max == 1) { cols[elm->x].preferred_size = width; } elm->preferred_width = width; } if(size.height != NSViewNoIntrinsicMetric) { - CGFloat height = size.height + alignment.top + alignment.right; + CGFloat height = size.height; //CGFloat height = size.height; if(height > rows[elm->y].preferred_size && elm->rowspan <= 1 && span_max == 1) { rows[elm->y].preferred_size = height; @@ -290,10 +286,16 @@ - (NSSize)intrinsicContentSize { + if(_preferredSize.width == -1) { + [self layout]; + } return self.preferredSize; } - (void) addView:(NSView*)view { + _preferredSize.width = -1; + _preferredSize.height = -1; + if(_newline) { _y++; _x = 0;