From b528d1ff0cce6f4bda3b05068395307824836d83 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 1 Aug 2015 17:26:56 -0400 Subject: [PATCH] Added multiple primary horizontal and vertical Auto Layout views. This will accomodate tSpinbox. Now we can go back to tBox. --- redo/osxaltest/button.m | 8 ++++---- redo/osxaltest/osxaltest.h | 4 ++-- redo/osxaltest/spinbox.m | 9 +++++---- redo/osxaltest/window.m | 20 ++++++++++++-------- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/redo/osxaltest/button.m b/redo/osxaltest/button.m index 26562ef7..0ad98f7e 100644 --- a/redo/osxaltest/button.m +++ b/redo/osxaltest/button.m @@ -32,14 +32,14 @@ return n; } -- (void)tFillAutoLayoutHorz:(NSMutableString *)horz - vert:(NSMutableString *)vert +- (void)tFillAutoLayoutHorz:(NSMutableArray *)horz + vert:(NSMutableArray *)vert extra:(NSMutableArray *)extra extraVert:(NSMutableArray *)extraVert views:(NSMutableDictionary *)views { - [horz setString:@"[view0]"]; - [vert setString:@"[view0]"]; + [horz addObject:@"[view0]"]; + [vert addObject:@"[view0]"]; [views setObject:self->b forKey:@"view0"]; } diff --git a/redo/osxaltest/osxaltest.h b/redo/osxaltest/osxaltest.h index a0e7d93c..c9c86912 100644 --- a/redo/osxaltest/osxaltest.h +++ b/redo/osxaltest/osxaltest.h @@ -6,8 +6,8 @@ @required - (void)tAddToView:(NSView *)v; //TODO- (uintmax_t)tAddToAutoLayoutDictionary:(NSMutableDictionary *)views keyNumber:(uintmax_t)n; -- (void)tFillAutoLayoutHorz:(NSMutableString *)horz - vert:(NSMutableString *)vert +- (void)tFillAutoLayoutHorz:(NSMutableArray *)horz + vert:(NSMutableArray *)vert extra:(NSMutableArray *)extra extraVert:(NSMutableArray *)extraVert views:(NSMutableDictionary *)views; diff --git a/redo/osxaltest/spinbox.m b/redo/osxaltest/spinbox.m index da6d8570..75f9cf2c 100644 --- a/redo/osxaltest/spinbox.m +++ b/redo/osxaltest/spinbox.m @@ -43,14 +43,15 @@ return n; } -- (void)tFillAutoLayoutHorz:(NSMutableString *)horz - vert:(NSMutableString *)vert +- (void)tFillAutoLayoutHorz:(NSMutableArray *)horz + vert:(NSMutableArray *)vert extra:(NSMutableArray *)extra extraVert:(NSMutableArray *)extraVert views:(NSMutableDictionary *)views { - [horz setString:@"[view0]-[view1]"]; - [vert setString:@"[view0]"]; + [horz addObject:@"[view0]-[view1]"]; + [vert addObject:@"[view0]"]; + [vert addObject:@"[view1]"]; [views setObject:self->t forKey:@"view0"]; [views setObject:self->s forKey:@"view1"]; } diff --git a/redo/osxaltest/window.m b/redo/osxaltest/window.m index d04d9c78..0da07e8a 100644 --- a/redo/osxaltest/window.m +++ b/redo/osxaltest/window.m @@ -42,18 +42,18 @@ - (void)tRelayout { NSView *contentView; - NSMutableString *horz, *vert; + NSMutableArray *horz, *vert; NSMutableArray *extra, *extraVert; NSMutableDictionary *views; - NSInteger i; + NSUInteger i; NSString *margin; if (self->c == nil) return; contentView = [self->w contentView]; [contentView removeConstraints:[contentView constraints]]; - horz = [NSMutableString new]; - vert = [NSMutableString new]; + horz = [NSMutableArray new]; + vert = [NSMutableArray new]; extra = [NSMutableArray new]; extraVert = [NSMutableArray new]; views = [NSMutableDictionary new]; @@ -61,10 +61,14 @@ margin = @""; if (self->margined) margin = @"-"; - [extra addObject:[NSString stringWithFormat:@"|%@%@%@|", margin, horz, margin]]; - [extraVert addObject:@NO]; - [extra addObject:[NSString stringWithFormat:@"|%@%@%@|", margin, vert, margin]]; - [extraVert addObject:@YES]; + [horz enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) { + [extra addObject:[NSString stringWithFormat:@"|%@%@%@|", margin, obj, margin]]; + [extraVert addObject:@NO]; + }]; + [vert enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) { + [extra addObject:[NSString stringWithFormat:@"|%@%@%@|", margin, obj, margin]]; + [extraVert addObject:@YES]; + }]; for (i = 0; i < [extra count]; i++) { NSString *constraint; NSNumber *vertical;