diff --git a/redo/osxaltest/box.m b/redo/osxaltest/box.m index c1ceee9a..40a80920 100644 --- a/redo/osxaltest/box.m +++ b/redo/osxaltest/box.m @@ -22,9 +22,10 @@ NSMutableArray *stretchy; BOOL vertical; id parent; + BOOL spaced; } -- (id)tInitVertical:(BOOL)vert +- (id)tInitVertical:(BOOL)vert spaced:(BOOL)sp { self = [super init]; if (self) { @@ -34,6 +35,7 @@ self->stretchy = [NSMutableArray new]; self->vertical = vert; self->parent = nil; + self->spaced = sp; } return self; } @@ -54,7 +56,6 @@ [self tRelayout]; } -// TODO spaced // TODO custom minimum width for non-stretchy controls - (void)tFillAutoLayout:(tAutoLayoutParams *)p { @@ -101,6 +102,8 @@ for (i = 0; i < n; i++) { NSNumber *isStretchy; + if (self->spaced && i != 0) + [constraint appendString:@"-"]; [constraint appendString:@"["]; [constraint appendString:tAutoLayoutKey(i)]; isStretchy = (NSNumber *) [self->stretchy objectAtIndex:i]; diff --git a/redo/osxaltest/main.m b/redo/osxaltest/main.m index db7aa268..0d899a90 100644 --- a/redo/osxaltest/main.m +++ b/redo/osxaltest/main.m @@ -22,28 +22,28 @@ BOOL firstvert = YES; mainwin = [[tWindow alloc] init]; [mainwin tSetMargined:spaced]; - box = [[tBox alloc] tInitVertical:firstvert]; + box = [[tBox alloc] tInitVertical:firstvert spaced:spaced]; spinbox = [[tSpinbox alloc] init]; [box tAddControl:spinbox stretchy:NO]; [mainwin tSetControl:box]; - hbox = [[tBox alloc] tInitVertical:!firstvert]; + hbox = [[tBox alloc] tInitVertical:!firstvert spaced:spaced]; button = [[tButton alloc] tInitWithText:@"Button"]; [hbox tAddControl:button stretchy:YES]; button = [[tButton alloc] tInitWithText:@"Button"]; [hbox tAddControl:button stretchy:YES]; [box tAddControl:hbox stretchy:NO]; - hbox = [[tBox alloc] tInitVertical:!firstvert]; + hbox = [[tBox alloc] tInitVertical:!firstvert spaced:spaced]; button = [[tButton alloc] tInitWithText:@"Button"]; [hbox tAddControl:button stretchy:YES]; button = [[tButton alloc] tInitWithText:@"Button"]; [hbox tAddControl:button stretchy:YES]; [box tAddControl:hbox stretchy:NO]; - hbox = [[tBox alloc] tInitVertical:!firstvert]; + hbox = [[tBox alloc] tInitVertical:!firstvert spaced:spaced]; button = [[tButton alloc] tInitWithText:@"Button"]; [hbox tAddControl:button stretchy:YES]; button = [[tButton alloc] tInitWithText:@"A"]; @@ -55,14 +55,14 @@ BOOL firstvert = YES; [box tAddControl:hbox stretchy:NO]; // TODO this isn't stretchy in the proper order - hbox = [[tBox alloc] tInitVertical:!firstvert]; + hbox = [[tBox alloc] tInitVertical:!firstvert spaced:spaced]; spinbox = [[tSpinbox alloc] init]; [hbox tAddControl:spinbox stretchy:NO]; spinbox = [[tSpinbox alloc] init]; [hbox tAddControl:spinbox stretchy:YES]; [box tAddControl:hbox stretchy:NO]; - hbox = [[tBox alloc] tInitVertical:!firstvert]; + hbox = [[tBox alloc] tInitVertical:!firstvert spaced:spaced]; entry = [[tEntry alloc] init]; [hbox tAddControl:entry stretchy:NO]; entry = [[tEntry alloc] init]; diff --git a/redo/osxaltest/osxaltest.h b/redo/osxaltest/osxaltest.h index 19d01c20..520e8af1 100644 --- a/redo/osxaltest/osxaltest.h +++ b/redo/osxaltest/osxaltest.h @@ -28,7 +28,7 @@ struct tAutoLayoutParams { @end @interface tBox : NSObject -- (id)tInitVertical:(BOOL)vert; +- (id)tInitVertical:(BOOL)vert spaced:(BOOL)sp; - (void)tAddControl:(id)c stretchy:(BOOL)s; @end