More stretchiness work.

This commit is contained in:
Pietro Gagliardi 2015-08-02 12:52:24 -04:00
parent 88f137aa80
commit 5bc53f937d
3 changed files with 38 additions and 7 deletions

View File

@ -71,12 +71,12 @@
pp.firstStretchy = TRUE; pp.firstStretchy = TRUE;
for (i = 0; i < [self->children count]; i++) { for (i = 0; i < [self->children count]; i++) {
id<tControl> cur; id<tControl> cur;
NSNumber *stretchy; NSNumber *isStretchy;
first[i] = pp.n; first[i] = pp.n;
cur = (id<tControl>) [self->children objectAtIndex:i]; cur = (id<tControl>) [self->children objectAtIndex:i];
stretchy = (NSNumber *) [self->stretchy objectAtIndex:i]; isStretchy = (NSNumber *) [self->stretchy objectAtIndex:i];
pp.stretchy = [stretchy boolValue]; pp.stretchy = [isStretchy boolValue];
[cur tFillAutoLayout:&pp]; [cur tFillAutoLayout:&pp];
if (pp.stretchy && pp.firstStretchy) { if (pp.stretchy && pp.firstStretchy) {
pp.firstStretchy = FALSE; pp.firstStretchy = FALSE;

View File

@ -33,11 +33,27 @@
- (void)tFillAutoLayout:(tAutoLayoutParams *)p - (void)tFillAutoLayout:(tAutoLayoutParams *)p
{ {
NSString *key; NSString *key;
NSString *horzpred, *vertpred;
key = tAutoLayoutKey(p->n); key = tAutoLayoutKey(p->n);
p->n++; p->n++;
[p->horz addObject:[NSString stringWithFormat:@"[%@]", key]]; horzpred = @"";
[p->vert addObject:[NSString stringWithFormat:@"[%@]", key]]; vertpred = @"";
if (p->stretchy) {
NSString *predicate;
if (p->firstStretchy)
// TODO is this unnecessary? it seems like I need to do other things instead of this to ensure stretchiness...
predicate = @"(>=0)";
else
predicate = [NSString stringWithFormat:@"(==%@)", tAutoLayoutKey(p->stretchyTo)];
if (p->stretchyVert)
vertpred = predicate;
else
horzpred = predicate;
}
[p->horz addObject:[NSString stringWithFormat:@"[%@%@]", key, horzpred]];
[p->vert addObject:[NSString stringWithFormat:@"[%@%@]", key, vertpred]];
[p->views setObject:self->b forKey:key]; [p->views setObject:self->b forKey:key];
} }

View File

@ -76,11 +76,26 @@
- (void)tFillAutoLayout:(tAutoLayoutParams *)p - (void)tFillAutoLayout:(tAutoLayoutParams *)p
{ {
NSString *key; NSString *key;
NSString *horzpred, *vertpred;
key = tAutoLayoutKey(p->n); key = tAutoLayoutKey(p->n);
p->n++; p->n++;
[p->horz addObject:[NSString stringWithFormat:@"[%@]", key]]; horzpred = @"(==96)"; // TODO only the entry
[p->vert addObject:[NSString stringWithFormat:@"[%@]", key]]; vertpred = @"";
if (p->stretchy) {
NSString *predicate;
if (p->firstStretchy)
predicate = @"(>=0)";
else
predicate = [NSString stringWithFormat:@"(==%@)", tAutoLayoutKey(p->stretchyTo)];
if (p->stretchyVert)
vertpred = predicate;
else
horzpred = predicate;
}
[p->horz addObject:[NSString stringWithFormat:@"[%@%@]", key, horzpred]];
[p->vert addObject:[NSString stringWithFormat:@"[%@%@]", key, vertpred]];
[p->views setObject:self->c forKey:key]; [p->views setObject:self->c forKey:key];
} }