diff --git a/redo/osxaltest/box.m_ b/redo/osxaltest/box.m similarity index 52% rename from redo/osxaltest/box.m_ rename to redo/osxaltest/box.m index 7021e83a..9c3733f7 100644 --- a/redo/osxaltest/box.m_ +++ b/redo/osxaltest/box.m @@ -50,28 +50,39 @@ return n; } -- (NSString *)tBuildAutoLayoutConstraintsKeyNumber:(uintmax_t)nn +- (void)tFillAutoLayoutHorz:(NSMutableArray *)horz + vert:(NSMutableArray *)vert + extra:(NSMutableArray *)extra + extraVert:(NSMutableArray *)extraVert + views:(NSMutableDictionary *)views + first:(uintmax_t *)n { - NSMutableString *constraints; - __block uintmax_t n = nn; + NSMutableArray *subhorz, *subvert; + uintmax_t *first; + NSUInteger i; - if (self->vertical) - constraints = [NSMutableString stringWithString:@"V:"]; - else - constraints = [NSMutableString stringWithString:@"H:"]; - [constraints appendString:@"|"]; - [self->children enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) { - NSString *thisView; + first = (uintmax_t *) malloc([self->children count] * sizeof (uintmax_t)); + if (first == NULL) + abort(); + subhorz = [NSMutableArray new]; + subvert = [NSMutableArray new]; + for (i = 0; i < [self->children count]; i++) { + id cur; - // TODO have every control do this - [constraints appendString:tAutoLayoutKey(n)]; - n++; - }]; - [constraints appendString:@"|"]; - return constraints; - // TODOs: - // - lateral dimension: for each view of n+1, make other dimension next to first n - // this way, subelement views get positioned right + first[i] = *n; + cur = (id) [self->children objectAtIndex:i]; + [cur tFillAutoLayoutHorz:subhorz vert:subvert + extra:extra extraVert:extraVert + views:views first:n]; + } + // TODO combine subhorz/subvert + [subhorz release]; + [subvert release]; + free(first); } +// TODOs: +// - lateral dimension: for each view of n+1, make other dimension next to first n +// this way, subelement views get positioned right + @end diff --git a/redo/osxaltest/button.m b/redo/osxaltest/button.m index 0ad98f7e..3493c5ac 100644 --- a/redo/osxaltest/button.m +++ b/redo/osxaltest/button.m @@ -37,10 +37,15 @@ extra:(NSMutableArray *)extra extraVert:(NSMutableArray *)extraVert views:(NSMutableDictionary *)views + first:(uintmax_t *)n { - [horz addObject:@"[view0]"]; - [vert addObject:@"[view0]"]; - [views setObject:self->b forKey:@"view0"]; + NSString *key; + + key = tAutoLayoutKey(*n); + (*n)++; + [horz addObject:[NSString stringWithFormat:@"[%@]", key]]; + [vert addObject:[NSString stringWithFormat:@"[%@]", key]]; + [views setObject:self->b forKey:key]; } @end diff --git a/redo/osxaltest/osxaltest.h b/redo/osxaltest/osxaltest.h index c9c86912..dbdf7389 100644 --- a/redo/osxaltest/osxaltest.h +++ b/redo/osxaltest/osxaltest.h @@ -10,7 +10,8 @@ vert:(NSMutableArray *)vert extra:(NSMutableArray *)extra extraVert:(NSMutableArray *)extraVert - views:(NSMutableDictionary *)views; + views:(NSMutableDictionary *)views + first:(uintmax_t *)n; @end @interface tWindow : NSObject @@ -21,12 +22,10 @@ - (void)tRelayout; @end -/* @interface tBox : NSObject - (id)tInitVertical:(BOOL)vert; - (void)tAddControl:(id)c stretchy:(BOOL)s; @end -*/ @interface tButton : NSObject - (id)tInitWithText:(NSString *)text; diff --git a/redo/osxaltest/spinbox.m b/redo/osxaltest/spinbox.m index 75f9cf2c..5f1366f7 100644 --- a/redo/osxaltest/spinbox.m +++ b/redo/osxaltest/spinbox.m @@ -49,11 +49,17 @@ extraVert:(NSMutableArray *)extraVert views:(NSMutableDictionary *)views { - [horz addObject:@"[view0]-[view1]"]; - [vert addObject:@"[view0]"]; - [vert addObject:@"[view1]"]; - [views setObject:self->t forKey:@"view0"]; - [views setObject:self->s forKey:@"view1"]; + NSString *keyt; + NSString *keys; + + keyt = tAutoLayoutKey(*n); + keys = tAutoLayoutKey(*n + 1); + *n += 2; + [horz addObject:[NSString stringWithFormat:@"[%@]-[%@]", keyt, keys]]; + [vert addObject:[NSString stringWithFormat:@"[%@]", keyt]]; + [vert addObject:[NSString stringWithFormat:@"[%@]", keys]]; + [views setObject:self->t forKey:keyt]; + [views setObject:self->s forKey:keys]; } @end diff --git a/redo/osxaltest/util.m b/redo/osxaltest/util.m index c5ab8ea2..34635ce7 100644 --- a/redo/osxaltest/util.m +++ b/redo/osxaltest/util.m @@ -3,5 +3,5 @@ NSString *tAutoLayoutKey(uintmax_t n) { - return [NSString stringWithFormat:@"[view%ju]", n]; + return [NSString stringWithFormat:@"view%ju", n]; } diff --git a/redo/osxaltest/window.m b/redo/osxaltest/window.m index 0da07e8a..942e3053 100644 --- a/redo/osxaltest/window.m +++ b/redo/osxaltest/window.m @@ -47,6 +47,7 @@ NSMutableDictionary *views; NSUInteger i; NSString *margin; + uintmax_t n; if (self->c == nil) return; @@ -57,7 +58,8 @@ extra = [NSMutableArray new]; extraVert = [NSMutableArray new]; views = [NSMutableDictionary new]; - [self->c tFillAutoLayoutHorz:horz vert:vert extra:extra extraVert:extraVert views:views]; + n = 0; + [self->c tFillAutoLayoutHorz:horz vert:vert extra:extra extraVert:extraVert views:views first:&n]; margin = @""; if (self->margined) margin = @"-";