Separated the presence of a no-stretchy view from the presence of a stretchy control. This will make experimenting easier.
This commit is contained in:
parent
09a7fb7123
commit
ac84b66724
14
darwin/box.m
14
darwin/box.m
|
@ -119,15 +119,16 @@ static NSView *boxView(uiBox *b, uintmax_t n)
|
||||||
return (NSView *) uiControlHandle(c);
|
return (NSView *) uiControlHandle(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addRemoveNoStretchyView(uiBox *b, BOOL hasStretchy)
|
static BOOL addRemoveNoStretchyView(uiBox *b, BOOL hasStretchy)
|
||||||
{
|
{
|
||||||
if (!hasStretchy) {
|
if (!hasStretchy) {
|
||||||
if ([b->noStretchyView superview] == nil)
|
if ([b->noStretchyView superview] == nil)
|
||||||
[b->view addSubview:b->noStretchyView];
|
[b->view addSubview:b->noStretchyView];
|
||||||
} else {
|
return YES;
|
||||||
|
}
|
||||||
if ([b->noStretchyView superview] != nil)
|
if ([b->noStretchyView superview] != nil)
|
||||||
[b->noStretchyView removeFromSuperview];
|
[b->noStretchyView removeFromSuperview];
|
||||||
}
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO do we still need to set hugging? I think we do for stretchy controls...
|
// TODO do we still need to set hugging? I think we do for stretchy controls...
|
||||||
|
@ -139,6 +140,7 @@ static void relayout(uiBox *b)
|
||||||
NSView *firstStretchy = nil;
|
NSView *firstStretchy = nil;
|
||||||
CGFloat padding;
|
CGFloat padding;
|
||||||
NSView *prev, *next;
|
NSView *prev, *next;
|
||||||
|
BOOL hasNoStretchyView;
|
||||||
|
|
||||||
n = [b->children count];
|
n = [b->children count];
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
|
@ -180,8 +182,8 @@ static void relayout(uiBox *b)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there is a stretchy control, add the no-stretchy view
|
// if there is a stretchy control, add the no-stretchy view
|
||||||
addRemoveNoStretchyView(b, hasStretchy);
|
hasNoStretchyView = addRemoveNoStretchyView(b, hasStretchy);
|
||||||
if (!hasStretchy) {
|
if (hasNoStretchyView) {
|
||||||
[b->view addConstraint:mkConstraint(b->noStretchyView, b->primaryStart,
|
[b->view addConstraint:mkConstraint(b->noStretchyView, b->primaryStart,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
prev, b->primaryEnd,
|
prev, b->primaryEnd,
|
||||||
|
@ -211,7 +213,7 @@ static void relayout(uiBox *b)
|
||||||
1, 0,
|
1, 0,
|
||||||
@"uiBox start secondary constraint")];
|
@"uiBox start secondary constraint")];
|
||||||
}
|
}
|
||||||
if (!hasStretchy) { // and again to the no-stretchy view
|
if (hasNoStretchyView) { // and again to the no-stretchy view
|
||||||
[b->view addConstraint:mkConstraint(b->noStretchyView, b->secondaryStart,
|
[b->view addConstraint:mkConstraint(b->noStretchyView, b->secondaryStart,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
b->view, b->secondaryStart,
|
b->view, b->secondaryStart,
|
||||||
|
|
Loading…
Reference in New Issue