Resolved that TODO.
This commit is contained in:
parent
03212b6b02
commit
2fe193563e
|
@ -76,8 +76,15 @@
|
|||
pp.vertAttachBottom = subvertbottom;
|
||||
pp.views = p->views;
|
||||
pp.n = p->n;
|
||||
pp.stretchyVert = self->vertical;
|
||||
pp.firstStretchy = TRUE;
|
||||
if (self->vertical) {
|
||||
pp.vertFirstStretchy = YES;
|
||||
pp.horzStretchy = YES;
|
||||
pp.horzFirstStretchy = YES;
|
||||
} else {
|
||||
pp.horzFirstStretchy = YES;
|
||||
pp.vertStretchy = YES;
|
||||
pp.vertFirstStretchy = YES;
|
||||
}
|
||||
for (i = 0; i < [self->children count]; i++) {
|
||||
id<tControl> cur;
|
||||
NSNumber *isStretchy;
|
||||
|
@ -85,22 +92,30 @@
|
|||
first[i] = pp.n;
|
||||
cur = (id<tControl>) [self->children objectAtIndex:i];
|
||||
isStretchy = (NSNumber *) [self->stretchy objectAtIndex:i];
|
||||
pp.stretchy = [isStretchy boolValue];
|
||||
if (self->vertical) {
|
||||
pp.vertStretchy = [isStretchy boolValue];
|
||||
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.horzStretchy = [isStretchy boolValue];
|
||||
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;
|
||||
pp.stretchyTo = first[i];
|
||||
if (self->vertical) {
|
||||
if (pp.vertStretchy && pp.vertFirstStretchy) {
|
||||
pp.vertFirstStretchy = NO;
|
||||
pp.vertStretchyTo = first[i];
|
||||
}
|
||||
} else {
|
||||
if (pp.horzStretchy && pp.horzFirstStretchy) {
|
||||
pp.horzFirstStretchy = NO;
|
||||
pp.horzStretchyTo = first[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
p->n = pp.n;
|
||||
|
@ -146,6 +161,7 @@
|
|||
// TODOs:
|
||||
// - lateral dimension: for each view of n+1, make other dimension next to first n
|
||||
// this way, subelement views get positioned right
|
||||
// - don't pin to end if no controls are stretchy
|
||||
|
||||
- (void)tRelayout
|
||||
{
|
||||
|
|
|
@ -39,20 +39,19 @@
|
|||
key = tAutoLayoutKey(p->n);
|
||||
p->n++;
|
||||
horzpred = @"";
|
||||
vertpred = @"";
|
||||
if (p->stretchy) {
|
||||
NSString *predicate;
|
||||
|
||||
if (p->firstStretchy)
|
||||
if (p->horzStretchy)
|
||||
if (p->horzFirstStretchy)
|
||||
// TODO is this unnecessary? it seems like I need to do other things instead of this to ensure stretchiness...
|
||||
predicate = @"(>=0)";
|
||||
horzpred = @"(>=0)";
|
||||
else
|
||||
predicate = [NSString stringWithFormat:@"(==%@)", tAutoLayoutKey(p->stretchyTo)];
|
||||
if (p->stretchyVert)
|
||||
vertpred = predicate;
|
||||
horzpred = [NSString stringWithFormat:@"(==%@)", tAutoLayoutKey(p->horzStretchyTo)];
|
||||
vertpred = @"";
|
||||
if (p->vertStretchy)
|
||||
if (p->vertFirstStretchy)
|
||||
// TODO is this unnecessary? it seems like I need to do other things instead of this to ensure stretchiness...
|
||||
vertpred = @"(>=0)";
|
||||
else
|
||||
horzpred = predicate;
|
||||
}
|
||||
vertpred = [NSString stringWithFormat:@"(==%@)", tAutoLayoutKey(p->vertStretchyTo)];
|
||||
[p->horz addObject:[NSString stringWithFormat:@"[%@%@]", key, horzpred]];
|
||||
[p->horzAttachLeft addObject:[NSNumber numberWithBool:p->horzFirst]];
|
||||
[p->horzAttachRight addObject:[NSNumber numberWithBool:p->horzLast]];
|
||||
|
|
|
@ -19,10 +19,12 @@ struct tAutoLayoutParams {
|
|||
BOOL vertLast;
|
||||
NSMutableDictionary *views;
|
||||
uintmax_t n;
|
||||
BOOL stretchy;
|
||||
BOOL stretchyVert;
|
||||
BOOL firstStretchy;
|
||||
uintmax_t stretchyTo;
|
||||
BOOL horzStretchy;
|
||||
BOOL horzFirstStretchy;
|
||||
uintmax_t horzStretchyTo;
|
||||
BOOL vertStretchy;
|
||||
BOOL vertFirstStretchy;
|
||||
uintmax_t vertStretchyTo;
|
||||
};
|
||||
|
||||
@protocol tControl
|
||||
|
|
|
@ -83,19 +83,19 @@
|
|||
key = tAutoLayoutKey(p->n);
|
||||
p->n++;
|
||||
horzpred = @"(==96)"; // TODO only the entry
|
||||
if (p->horzStretchy)
|
||||
if (p->horzFirstStretchy)
|
||||
// TODO is this unnecessary? it seems like I need to do other things instead of this to ensure stretchiness...
|
||||
horzpred = @"(>=0)";
|
||||
else
|
||||
horzpred = [NSString stringWithFormat:@"(==%@)", tAutoLayoutKey(p->horzStretchyTo)];
|
||||
vertpred = @"";
|
||||
if (p->stretchy) {
|
||||
NSString *predicate;
|
||||
|
||||
if (p->firstStretchy)
|
||||
predicate = @"(>=0)";
|
||||
if (p->vertStretchy)
|
||||
if (p->vertFirstStretchy)
|
||||
// TODO is this unnecessary? it seems like I need to do other things instead of this to ensure stretchiness...
|
||||
vertpred = @"(>=0)";
|
||||
else
|
||||
predicate = [NSString stringWithFormat:@"(==%@)", tAutoLayoutKey(p->stretchyTo)];
|
||||
if (p->stretchyVert)
|
||||
vertpred = predicate;
|
||||
else
|
||||
horzpred = predicate;
|
||||
}
|
||||
vertpred = [NSString stringWithFormat:@"(==%@)", tAutoLayoutKey(p->vertStretchyTo)];
|
||||
[p->horz addObject:[NSString stringWithFormat:@"[%@%@]", key, horzpred]];
|
||||
[p->horzAttachLeft addObject:[NSNumber numberWithBool:p->horzFirst]];
|
||||
[p->horzAttachRight addObject:[NSNumber numberWithBool:p->horzLast]];
|
||||
|
|
|
@ -64,6 +64,10 @@
|
|||
p.vertLast = YES;
|
||||
p.views = [NSMutableDictionary new];
|
||||
p.n = 0;
|
||||
p.horzStretchy = YES; // assumption for the sole control to avoid fixed size hacks
|
||||
p.horzFirstStretchy = YES;
|
||||
p.vertStretchy = YES;
|
||||
p.vertFirstStretchy = YES;
|
||||
[self->c tFillAutoLayout:&p];
|
||||
|
||||
margin = @"";
|
||||
|
|
Loading…
Reference in New Issue