Wrote the tBox code to deal with starts and ends and attachments. It doesn't quite work yet...

This commit is contained in:
Pietro Gagliardi 2015-08-02 16:55:21 -04:00
parent f72b47c4dc
commit 4a97a3cdb9
3 changed files with 38 additions and 2 deletions

View File

@ -45,6 +45,7 @@
[self tRelayout]; [self tRelayout];
} }
// TODO MASSIVE CLEANUP and comments everywhere too
- (void)tFillAutoLayout:(tAutoLayoutParams *)p - (void)tFillAutoLayout:(tAutoLayoutParams *)p
{ {
NSMutableArray *subhorz, *subvert; NSMutableArray *subhorz, *subvert;
@ -55,7 +56,11 @@
NSMutableString *out; NSMutableString *out;
tAutoLayoutParams pp; tAutoLayoutParams pp;
NSMutableArray *primaryin, *primaryout; NSMutableArray *primaryin, *primaryout;
BOOL primaryinstart, primaryinend;
NSMutableArray *primaryoutstart, *primaryoutend;
NSMutableArray *secondaryin, *secondaryout; NSMutableArray *secondaryin, *secondaryout;
NSMutableArray *secondaryinstart, *secondaryinend;
NSMutableArray *secondaryoutstart, *secondaryoutend;
first = (uintmax_t *) malloc([self->children count] * sizeof (uintmax_t)); first = (uintmax_t *) malloc([self->children count] * sizeof (uintmax_t));
if (first == NULL) if (first == NULL)
@ -85,6 +90,17 @@
cur = (id<tControl>) [self->children objectAtIndex:i]; cur = (id<tControl>) [self->children objectAtIndex:i];
isStretchy = (NSNumber *) [self->stretchy objectAtIndex:i]; isStretchy = (NSNumber *) [self->stretchy objectAtIndex:i];
pp.stretchy = [isStretchy boolValue]; pp.stretchy = [isStretchy boolValue];
if (self->vertical) {
pp.vertFirst = p->vertFirst && i == 0;
pp.vertLast = p->vertLast && i == ([self->children count] - 1);
pp.horzFirst = p->horzFirst;
pp.horzLast = p->horzLast;
} else {
pp.horzFirst = p->horzFirst && i == 0;
pp.horzLast = p->horzLast && i == ([self->children count] - 1);
pp.vertFirst = p->vertFirst;
pp.vertLast = p->vertLast;
}
[cur tFillAutoLayout:&pp]; [cur tFillAutoLayout:&pp];
if (pp.stretchy && pp.firstStretchy) { if (pp.stretchy && pp.firstStretchy) {
pp.firstStretchy = FALSE; pp.firstStretchy = FALSE;
@ -95,14 +111,30 @@
out = [NSMutableString new]; out = [NSMutableString new];
primaryin = subhorz; primaryin = subhorz;
primaryinstart = p->horzFirst;
primaryinend = p->horzLast;
primaryout = p->horz; primaryout = p->horz;
primaryoutstart = p->horzAttachLeft;
primaryoutend = p->horzAttachRight;
secondaryin = subvert; secondaryin = subvert;
secondaryinstart = subverttop;
secondaryinend = subvertbottom;
secondaryout = p->vert; secondaryout = p->vert;
secondaryoutstart = p->vertAttachTop;
secondaryoutend = p->vertAttachBottom;
if (self->vertical) { if (self->vertical) {
primaryin = subvert; primaryin = subvert;
primaryinstart = p->vertFirst;
primaryinend = p->vertLast;
primaryout = p->vert; primaryout = p->vert;
primaryoutstart = p->vertAttachTop;
primaryoutend = p->vertAttachBottom;
secondaryin = subhorz; secondaryin = subhorz;
secondaryinstart = subhorzleft;
secondaryinend = subhorzright;
secondaryout = p->horz; secondaryout = p->horz;
secondaryoutstart = p->horzAttachLeft;
secondaryoutend = p->horzAttachRight;
} }
[primaryin enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) { [primaryin enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
//TODO if (index != 0) //TODO if (index != 0)
@ -110,7 +142,11 @@
[out appendString:((NSString *) obj)]; [out appendString:((NSString *) obj)];
}]; }];
[primaryout addObject:out]; [primaryout addObject:out];
[primaryoutstart addObject:[NSNumber numberWithBool:primaryinstart]];
[primaryoutend addObject:[NSNumber numberWithBool:primaryinend]];
[secondaryout addObjectsFromArray:secondaryin]; [secondaryout addObjectsFromArray:secondaryin];
[secondaryoutstart addObjectsFromArray:secondaryinstart];
[secondaryoutend addObjectsFromArray:secondaryinend];
[subhorz release]; [subhorz release];
[subhorzleft release]; [subhorzleft release];

View File

@ -53,7 +53,7 @@
horzpred = predicate; horzpred = predicate;
} }
[p->horz addObject:[NSString stringWithFormat:@"[%@%@]", key, horzpred]]; [p->horz addObject:[NSString stringWithFormat:@"[%@%@]", key, horzpred]];
[p->horzAttachLeft addObject:[NSNumtber numberWithBool:p->horzFirst]]; [p->horzAttachLeft addObject:[NSNumber numberWithBool:p->horzFirst]];
[p->horzAttachRight addObject:[NSNumber numberWithBool:p->horzLast]]; [p->horzAttachRight addObject:[NSNumber numberWithBool:p->horzLast]];
[p->vert addObject:[NSString stringWithFormat:@"[%@%@]", key, vertpred]]; [p->vert addObject:[NSString stringWithFormat:@"[%@%@]", key, vertpred]];
[p->vertAttachTop addObject:[NSNumber numberWithBool:p->vertFirst]]; [p->vertAttachTop addObject:[NSNumber numberWithBool:p->vertFirst]];

View File

@ -95,7 +95,7 @@
horzpred = predicate; horzpred = predicate;
} }
[p->horz addObject:[NSString stringWithFormat:@"[%@%@]", key, horzpred]]; [p->horz addObject:[NSString stringWithFormat:@"[%@%@]", key, horzpred]];
[p->horzAttachLeft addObject:[NSNumtber numberWithBool:p->horzFirst]]; [p->horzAttachLeft addObject:[NSNumber numberWithBool:p->horzFirst]];
[p->horzAttachRight addObject:[NSNumber numberWithBool:p->horzLast]]; [p->horzAttachRight addObject:[NSNumber numberWithBool:p->horzLast]];
[p->vert addObject:[NSString stringWithFormat:@"[%@%@]", key, vertpred]]; [p->vert addObject:[NSString stringWithFormat:@"[%@%@]", key, vertpred]];
[p->vertAttachTop addObject:[NSNumber numberWithBool:p->vertFirst]]; [p->vertAttachTop addObject:[NSNumber numberWithBool:p->vertFirst]];