Re-establishing uiForm constraints: vertical constraints.
This commit is contained in:
parent
7f05b796aa
commit
95fcceef2f
|
@ -20,10 +20,6 @@
|
||||||
NSLayoutConstraint *first;
|
NSLayoutConstraint *first;
|
||||||
NSMutableArray *inBetweens;
|
NSMutableArray *inBetweens;
|
||||||
NSLayoutConstraint *last;
|
NSLayoutConstraint *last;
|
||||||
NSMutableArray *widths;
|
|
||||||
NSMutableArray *leadings;
|
|
||||||
NSMutableArray *middles;
|
|
||||||
NSMutableArray *trailings;
|
|
||||||
}
|
}
|
||||||
- (id)initWithF:(uiForm *)ff;
|
- (id)initWithF:(uiForm *)ff;
|
||||||
- (void)onDestroy;
|
- (void)onDestroy;
|
||||||
|
@ -65,10 +61,6 @@ struct uiForm {
|
||||||
self->nStretchy = 0;
|
self->nStretchy = 0;
|
||||||
|
|
||||||
self->inBetweens = [NSMutableArray new];
|
self->inBetweens = [NSMutableArray new];
|
||||||
self->widths = [NSMutableArray new];
|
|
||||||
self->leadings = [NSMutableArray new];
|
|
||||||
self->middles = [NSMutableArray new];
|
|
||||||
self->trailings = [NSMutableArray new];
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -79,10 +71,6 @@ struct uiForm {
|
||||||
|
|
||||||
[self removeOurConstraints];
|
[self removeOurConstraints];
|
||||||
[self->inBetweens release];
|
[self->inBetweens release];
|
||||||
[self->widths release];
|
|
||||||
[self->leadings release];
|
|
||||||
[self->middles release];
|
|
||||||
[self->trailings release];
|
|
||||||
|
|
||||||
for (fc in self->children) {
|
for (fc in self->children) {
|
||||||
[self removeConstraint:fc.baseline];
|
[self removeConstraint:fc.baseline];
|
||||||
|
@ -112,22 +100,6 @@ struct uiForm {
|
||||||
[self->last release];
|
[self->last release];
|
||||||
self->last = nil;
|
self->last = nil;
|
||||||
}
|
}
|
||||||
if ([self->widths count] != 0) {
|
|
||||||
[self removeConstraints:self->widths];
|
|
||||||
[self->widths removeAllObjects];
|
|
||||||
}
|
|
||||||
if ([self->leadings count] != 0) {
|
|
||||||
[self removeConstraints:self->leadings];
|
|
||||||
[self->leadings removeAllObjects];
|
|
||||||
}
|
|
||||||
if ([self->middles count] != 0) {
|
|
||||||
[self removeConstraints:self->middles];
|
|
||||||
[self->middles removeAllObjects];
|
|
||||||
}
|
|
||||||
if ([self->trailings count] != 0) {
|
|
||||||
[self removeConstraints:self->trailings];
|
|
||||||
[self->trailings removeAllObjects];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)syncEnableStates:(int)enabled
|
- (void)syncEnableStates:(int)enabled
|
||||||
|
@ -158,6 +130,39 @@ struct uiForm {
|
||||||
return;
|
return;
|
||||||
padding = [self paddingAmount];
|
padding = [self paddingAmount];
|
||||||
|
|
||||||
|
// first arrange the main controls vertically
|
||||||
|
prev = nil;
|
||||||
|
for (fc in self->children) {
|
||||||
|
if (prev == nil) { // first control; tie to top
|
||||||
|
self->first = mkConstraint(self, NSLayoutAttributeTop,
|
||||||
|
NSLayoutRelationEqual,
|
||||||
|
[fc view], NSLayoutAttributeTop,
|
||||||
|
1, 0,
|
||||||
|
@"uiForm first child top constraint");
|
||||||
|
[self addConstraint:self->first];
|
||||||
|
[self->first retain];
|
||||||
|
prev = [fc view];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// not first; tie to previous
|
||||||
|
c = mkConstraint(prev, NSLayoutAttributeBottom,
|
||||||
|
NSLayoutRelationEqual,
|
||||||
|
[fc view], NSLayoutAttributeTop,
|
||||||
|
1, -padding,
|
||||||
|
@"uiForm middle vertical constraint");
|
||||||
|
[self addConstraint:c];
|
||||||
|
[self->inBetweens addObject:c];
|
||||||
|
prev = [fc view];
|
||||||
|
}
|
||||||
|
// and the last one
|
||||||
|
self->last = mkConstraint(prev, NSLayoutAttributeBottom,
|
||||||
|
NSLayoutRelationEqual,
|
||||||
|
self, NSLayoutAttributeBottom,
|
||||||
|
1, 0,
|
||||||
|
@"uiForm last child bottom constraint");
|
||||||
|
[self addConstraint:self->last];
|
||||||
|
[self->last retain];
|
||||||
|
|
||||||
// we don't arrange the labels vertically; that's done when we add the control since those constraints don't need to change (they just need to be at their baseline)
|
// we don't arrange the labels vertically; that's done when we add the control since those constraints don't need to change (they just need to be at their baseline)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,8 +242,6 @@ struct uiForm {
|
||||||
padding = [self paddingAmount];
|
padding = [self paddingAmount];
|
||||||
for (c in self->inBetweens)
|
for (c in self->inBetweens)
|
||||||
[c setConstant:-padding];
|
[c setConstant:-padding];
|
||||||
for (c in self->middles)
|
|
||||||
[c setConstant:-padding];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)hugsTrailing
|
- (BOOL)hugsTrailing
|
||||||
|
|
Loading…
Reference in New Issue