Implemented the proper hugging constraints for stretchy controls in tBox.
This commit is contained in:
parent
1d2880895d
commit
167ea85f6e
|
@ -75,11 +75,18 @@
|
||||||
n = 0;
|
n = 0;
|
||||||
[self->children enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
|
[self->children enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
|
||||||
id<tControl> c;
|
id<tControl> c;
|
||||||
|
NSNumber *isStretchy;
|
||||||
|
NSLayoutPriority priority;
|
||||||
|
|
||||||
c = (id<tControl>) obj;
|
c = (id<tControl>) obj;
|
||||||
|
isStretchy = (NSNumber *) [self->stretchy objectAtIndex:n];
|
||||||
// this also resets the hugging priority
|
// this also resets the hugging priority
|
||||||
// TODO do this when adding and removing controls instead
|
// TODO do this when adding and removing controls instead
|
||||||
[c tFillAutoLayout:&pp];
|
[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)];
|
[views setObject:pp.view forKey:tAutoLayoutKey(n)];
|
||||||
n++;
|
n++;
|
||||||
}];
|
}];
|
||||||
|
|
Loading…
Reference in New Issue