From 30a30cb5bee08ccbe556eabc1f4ff8035d729769 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 1 Aug 2015 22:13:41 -0400 Subject: [PATCH] Added tRelayout to all controls. Also changed the order of stretchy controls in main.m because Auto Layout's defaults aren't optimal. --- redo/osxaltest/box.m | 8 ++++++++ redo/osxaltest/button.m | 7 +++++++ redo/osxaltest/main.m | 4 ++-- redo/osxaltest/osxaltest.h | 3 +-- redo/osxaltest/spinbox.m | 6 ++++++ 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/redo/osxaltest/box.m b/redo/osxaltest/box.m index 77a6694b..413ae323 100644 --- a/redo/osxaltest/box.m +++ b/redo/osxaltest/box.m @@ -26,6 +26,7 @@ [c tSetParent:self->parent addToView:self->sv]; [self->children addObject:c]; // TODO mark as needing relayout + [self tRelayout]; } - (void)tSetParent:(id)p addToView:(NSView *)v @@ -38,6 +39,7 @@ c = (id) obj; [c tSetParent:self->parent addToView:self->sv]; }]; + [self tRelayout]; } - (void)tFillAutoLayoutHorz:(NSMutableArray *)horz @@ -84,4 +86,10 @@ // - lateral dimension: for each view of n+1, make other dimension next to first n // this way, subelement views get positioned right +- (void)tRelayout +{ + if (self->parent != nil) + [self->parent tRelayout]; +} + @end diff --git a/redo/osxaltest/button.m b/redo/osxaltest/button.m index 1229cbd8..4598e93a 100644 --- a/redo/osxaltest/button.m +++ b/redo/osxaltest/button.m @@ -27,6 +27,7 @@ { self->parent = p; [v addSubview:self->b]; + [self tRelayout]; } - (void)tFillAutoLayoutHorz:(NSMutableArray *)horz @@ -45,4 +46,10 @@ [views setObject:self->b forKey:key]; } +- (void)tRelayout +{ + if (self->parent != nil) + [self->parent tRelayout]; +} + @end diff --git a/redo/osxaltest/main.m b/redo/osxaltest/main.m index a5f019a8..a8fb1b80 100644 --- a/redo/osxaltest/main.m +++ b/redo/osxaltest/main.m @@ -23,12 +23,12 @@ BOOL margined = NO; box = [[tBox alloc] tInitVertical:NO]; button = [[tButton alloc] tInitWithText:@"Button"]; - [box tAddControl:button stretchy:NO]; + [box tAddControl:button stretchy:YES]; [mainwin tSetControl:box]; spinbox = [[tSpinbox alloc] init]; - [box tAddControl:spinbox stretchy:YES]; + [box tAddControl:spinbox stretchy:NO]; [mainwin tShow]; } diff --git a/redo/osxaltest/osxaltest.h b/redo/osxaltest/osxaltest.h index 1253cd1c..5dbb282a 100644 --- a/redo/osxaltest/osxaltest.h +++ b/redo/osxaltest/osxaltest.h @@ -11,14 +11,13 @@ extraVert:(NSMutableArray *)extraVert views:(NSMutableDictionary *)views first:(uintmax_t *)n; +- (void)tRelayout; @end @interface tWindow : NSObject - (void)tSetControl:(id)cc; - (void)tSetMargined:(BOOL)m; - (void)tShow; -// TODO this should probably in tControl -- (void)tRelayout; @end @interface tBox : NSObject diff --git a/redo/osxaltest/spinbox.m b/redo/osxaltest/spinbox.m index 3b3ea54e..7c18570b 100644 --- a/redo/osxaltest/spinbox.m +++ b/redo/osxaltest/spinbox.m @@ -59,4 +59,10 @@ [views setObject:self->s forKey:keys]; } +- (void)tRelayout +{ + if (self->parent != nil) + [self->parent tRelayout]; +} + @end