From 8fec1b41d286f8163d343633a030a7cf80e7e830 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 16 Aug 2015 11:43:51 -0400 Subject: [PATCH] Some more Auto Layout utility functions. --- redo/reredo/darwin/autolayout.m | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/redo/reredo/darwin/autolayout.m b/redo/reredo/darwin/autolayout.m index 85f9590d..ff0ed89d 100644 --- a/redo/reredo/darwin/autolayout.m +++ b/redo/reredo/darwin/autolayout.m @@ -46,3 +46,16 @@ void layoutSingleView(NSView *superview, NSView *subview, int margined) constraint = @"V:|-[subview]-|"; addConstraint(superview, constraint, nil, views); } + +// use the fitting size, not the intrinsic content size, for the case of recursive views without an intrinsic content size +NSSize fittingAlignmentSize(NSView *view) +{ + NSSize s; + NSRect r; + + s = [view fittingSize]; + // the fitting size is for a frame rect; we need an alignment rect + r = NSMakeRect(0, 0, s.width, s.height); + r = [view alignmentRectForFrame:r]; + return r.size; +}