Fixed more problems.

This commit is contained in:
Pietro Gagliardi 2016-05-12 01:49:00 -04:00
parent 63dac7c13a
commit 21f9b9666b
2 changed files with 31 additions and 11 deletions

View File

@ -35,14 +35,14 @@ void singleChildConstraintsEstablish(struct singleChildConstraints *c, NSView *c
c->leadingConstraint = mkConstraint(contentView, NSLayoutAttributeLeading,
NSLayoutRelationEqual,
childView, NSLayoutAttributeLeading,
1, margin,
1, -margin,
[desc stringByAppendingString:@" leading constraint"]);
[contentView addConstraint:c->leadingConstraint];
c->topConstraint = mkConstraint(contentView, NSLayoutAttributeTop,
NSLayoutRelationEqual,
childView, NSLayoutAttributeTop,
1, margin,
1, -margin,
[desc stringByAppendingString:@" top constraint"]);
[contentView addConstraint:c->topConstraint];
@ -52,7 +52,7 @@ void singleChildConstraintsEstablish(struct singleChildConstraints *c, NSView *c
c->trailingConstraint = mkConstraint(contentView, NSLayoutAttributeTrailing,
relation,
childView, NSLayoutAttributeTrailing,
1, -margin,
1, margin,
[desc stringByAppendingString:@" trailing constraint"]);
[contentView addConstraint:c->trailingConstraint];
@ -62,7 +62,7 @@ void singleChildConstraintsEstablish(struct singleChildConstraints *c, NSView *c
c->bottomConstraint = mkConstraint(contentView, NSLayoutAttributeBottom,
relation,
childView, NSLayoutAttributeBottom,
1, -margin,
1, margin,
[desc stringByAppendingString:@" bottom constraint"]);
[contentView addConstraint:c->bottomConstraint];
}
@ -97,11 +97,11 @@ void singleChildConstraintsSetMargined(struct singleChildConstraints *c, int mar
margin = margins(margined);
if (c->leadingConstraint != nil)
[c->leadingConstraint setConstant:margin];
[c->leadingConstraint setConstant:-margin];
if (c->topConstraint != nil)
[c->topConstraint setConstant:margin];
[c->topConstraint setConstant:-margin];
if (c->trailingConstraint != nil)
[c->trailingConstraint setConstant:-margin];
[c->trailingConstraint setConstant:margin];
if (c->bottomConstraint != nil)
[c->bottomConstraint setConstant:-margin];
[c->bottomConstraint setConstant:margin];
}

View File

@ -180,7 +180,7 @@ struct uiBox {
c = mkConstraint(prev, self->primaryEnd,
NSLayoutRelationEqual,
[bc view], self->primaryStart,
1, padding,
1, -padding,
@"uiBox in-between primary constraint");
[self addConstraint:c];
[self->inBetweens addObject:c];
@ -201,16 +201,36 @@ struct uiBox {
[bc view], self->secondaryStart,
1, 0,
@"uiBox secondary start constraint");
[self addConstraint:c];
[self->otherConstraints addObject:c];
c = mkConstraint([bc view], self->secondaryEnd,
NSLayoutRelationEqual,
self, self->secondaryEnd,
1, 0,
@"uiBox secondary end constraint");
[self addConstraint:c];
[self->otherConstraints addObject:c];
}
// TODO stretchies
// and make all stretchy controls the same size
if (self->nStretchy == 0)
return;
prev = nil; // first stretchy view
for (bc in self->children) {
if (!bc.stretchy)
continue;
if (prev == nil) {
prev = [bc view];
continue;
}
c = mkConstraint(prev, self->primarySize,
NSLayoutRelationEqual,
[bc view], self->primarySize,
1, 0,
@"uiBox stretchy size constraint");
[self addConstraint:c];
[self->otherConstraints addObject:c];
}
}
- (void)append:(uiControl *)c stretchy:(int)stretchy
@ -309,7 +329,7 @@ struct uiBox {
self->padded = p;
padding = [self paddingAmount];
for (c in self->inBetweens)
[c setConstant:padding];
[c setConstant:-padding];
// TODO call anything?
}