diff --git a/redo/osxaltest/box.m b/redo/osxaltest/box.m index cb3a0b8f..999a741f 100644 --- a/redo/osxaltest/box.m +++ b/redo/osxaltest/box.m @@ -57,7 +57,6 @@ [self tRelayout]; } -// TODO custom minimum width for non-stretchy controls - (void)tFillAutoLayout:(tAutoLayoutParams *)p { NSMutableDictionary *views; @@ -67,6 +66,7 @@ BOOL firstStretchy; uintmax_t nStretchy; NSLayoutConstraintOrientation orientation; + __block NSMutableArray *predicates; if ([self->children count] == 0) goto selfOnly; @@ -79,6 +79,7 @@ views = [NSMutableDictionary new]; n = 0; + predicates = [NSMutableArray new]; [self->children enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) { id c; NSNumber *isStretchy; @@ -86,12 +87,18 @@ c = (id) obj; isStretchy = (NSNumber *) [self->stretchy objectAtIndex:n]; + pp.nonStretchyWidthPredicate = @""; + pp.nonStretchyHeightPredicate = @""; // this also resets the hugging priority // TODO do this when adding and removing controls instead [c tFillAutoLayout:&pp]; priority = NSLayoutPriorityDefaultHigh; // forcibly hug; avoid stretching out if ([isStretchy boolValue]) priority = NSLayoutPriorityDefaultLow; // do not forcibly hug; freely stretch out + if (self->vertical) + [predicates addObject:pp.nonStretchyHeightPredicate]; + else + [predicates addObject:pp.nonStretchyWidthPredicate]; [pp.view setContentHuggingPriority:priority forOrientation:orientation]; [views setObject:pp.view forKey:tAutoLayoutKey(n)]; n++; @@ -120,6 +127,8 @@ [constraint appendString:tAutoLayoutKey(nStretchy)]; [constraint appendString:@")"]; } + else + [constraint appendString:[predicates objectAtIndex:i]]; [constraint appendString:@"]"]; } [constraint appendString:@"|"]; @@ -140,6 +149,7 @@ NSLog(@"other dimension %@", constraint); // TODO do not release constraint; it's autoreleased? } + [predicates release]; [views release]; // and now populate for self diff --git a/redo/osxaltest/osxaltest.h b/redo/osxaltest/osxaltest.h index 520e8af1..6fb8f073 100644 --- a/redo/osxaltest/osxaltest.h +++ b/redo/osxaltest/osxaltest.h @@ -12,6 +12,8 @@ struct tAutoLayoutParams { BOOL attachTop; BOOL attachRight; BOOL attachBottom; + NSString *nonStretchyWidthPredicate; + NSString *nonStretchyHeightPredicate; }; @protocol tControl diff --git a/redo/osxaltest/spinbox.m b/redo/osxaltest/spinbox.m index 02f475d1..25f28b47 100644 --- a/redo/osxaltest/spinbox.m +++ b/redo/osxaltest/spinbox.m @@ -93,6 +93,7 @@ nspinbox++; p->attachTop = YES; p->attachRight = YES; p->attachBottom = YES; + p->nonStretchyWidthPredicate = @"(==96)"; // TODO on the text field only } - (void)tRelayout