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

View File

@ -53,7 +53,7 @@
horzpred = predicate;
}
[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->vert addObject:[NSString stringWithFormat:@"[%@%@]", key, vertpred]];
[p->vertAttachTop addObject:[NSNumber numberWithBool:p->vertFirst]];

View File

@ -95,7 +95,7 @@
horzpred = predicate;
}
[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->vert addObject:[NSString stringWithFormat:@"[%@%@]", key, vertpred]];
[p->vertAttachTop addObject:[NSNumber numberWithBool:p->vertFirst]];