From 64f36f8e74b581fe7e01e57c35b0cf84131f4e20 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 3 Aug 2015 12:09:31 -0400 Subject: [PATCH] Added a debug hook for constraints. --- redo/osxaltest/box.m | 1 + redo/osxaltest/window.m | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/redo/osxaltest/box.m b/redo/osxaltest/box.m index 40a80920..3a6c7520 100644 --- a/redo/osxaltest/box.m +++ b/redo/osxaltest/box.m @@ -25,6 +25,7 @@ BOOL spaced; } +// TODO rename to padded - (id)tInitVertical:(BOOL)vert spaced:(BOOL)sp { self = [super init]; diff --git a/redo/osxaltest/window.m b/redo/osxaltest/window.m index 196f1058..89c9b763 100644 --- a/redo/osxaltest/window.m +++ b/redo/osxaltest/window.m @@ -1,6 +1,24 @@ // 1 august 2015 #include "osxaltest.h" +@implementation NSView (AutoLayoutHelpers) +- (void)tIsAmbiguous:(uintmax_t)indent +{ + NSMutableString *s; + uintmax_t i; + NSUInteger j; + + s = [NSMutableString new]; + for (i = 0; i < indent; i++) + [s appendString:@" "]; + NSLog(@"%@%@ %d", s, [self className], (int) [self hasAmbiguousLayout]); + if ([self hasAmbiguousLayout]) + [[self window] visualizeConstraints:[[self superview] constraints]]; + for (j = 0; j < [[self subviews] count]; j++) + [[[self subviews] objectAtIndex:j] tIsAmbiguous:(indent + 1)]; +} +@end + @implementation tWindow { NSWindow *w; id c; @@ -37,6 +55,7 @@ { [self->w cascadeTopLeftFromPoint:NSMakePoint(20, 20)]; [self->w makeKeyAndOrderFront:self]; + [[self->w contentView] tIsAmbiguous:0]; } - (void)tRelayout