Implemented the proper hugging constraints for stretchy controls in tBox.

This commit is contained in:
Pietro Gagliardi 2015-08-03 01:10:27 -04:00
parent 1d2880895d
commit 167ea85f6e
1 changed files with 7 additions and 0 deletions

View File

@ -75,11 +75,18 @@
n = 0;
[self->children enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
id<tControl> c;
NSNumber *isStretchy;
NSLayoutPriority priority;
c = (id<tControl>) obj;
isStretchy = (NSNumber *) [self->stretchy objectAtIndex:n];
// 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
[pp.view setContentHuggingPriority:priority forOrientation:orientation];
[views setObject:pp.view forKey:tAutoLayoutKey(n)];
n++;
}];