From 5bc53f937dc3021d2f9095b0b51ec738480cf646 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 2 Aug 2015 12:52:24 -0400 Subject: [PATCH] More stretchiness work. --- redo/osxaltest/box.m | 6 +++--- redo/osxaltest/button.m | 20 ++++++++++++++++++-- redo/osxaltest/spinbox.m | 19 +++++++++++++++++-- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/redo/osxaltest/box.m b/redo/osxaltest/box.m index ab56fd55..6f37eaf8 100644 --- a/redo/osxaltest/box.m +++ b/redo/osxaltest/box.m @@ -71,12 +71,12 @@ pp.firstStretchy = TRUE; for (i = 0; i < [self->children count]; i++) { id cur; - NSNumber *stretchy; + NSNumber *isStretchy; first[i] = pp.n; cur = (id) [self->children objectAtIndex:i]; - stretchy = (NSNumber *) [self->stretchy objectAtIndex:i]; - pp.stretchy = [stretchy boolValue]; + isStretchy = (NSNumber *) [self->stretchy objectAtIndex:i]; + pp.stretchy = [isStretchy boolValue]; [cur tFillAutoLayout:&pp]; if (pp.stretchy && pp.firstStretchy) { pp.firstStretchy = FALSE; diff --git a/redo/osxaltest/button.m b/redo/osxaltest/button.m index 6eb1ced6..1bf0d8e2 100644 --- a/redo/osxaltest/button.m +++ b/redo/osxaltest/button.m @@ -33,11 +33,27 @@ - (void)tFillAutoLayout:(tAutoLayoutParams *)p { NSString *key; + NSString *horzpred, *vertpred; key = tAutoLayoutKey(p->n); p->n++; - [p->horz addObject:[NSString stringWithFormat:@"[%@]", key]]; - [p->vert addObject:[NSString stringWithFormat:@"[%@]", key]]; + horzpred = @""; + vertpred = @""; + if (p->stretchy) { + NSString *predicate; + + if (p->firstStretchy) + // TODO is this unnecessary? it seems like I need to do other things instead of this to ensure stretchiness... + predicate = @"(>=0)"; + else + predicate = [NSString stringWithFormat:@"(==%@)", tAutoLayoutKey(p->stretchyTo)]; + if (p->stretchyVert) + vertpred = predicate; + else + horzpred = predicate; + } + [p->horz addObject:[NSString stringWithFormat:@"[%@%@]", key, horzpred]]; + [p->vert addObject:[NSString stringWithFormat:@"[%@%@]", key, vertpred]]; [p->views setObject:self->b forKey:key]; } diff --git a/redo/osxaltest/spinbox.m b/redo/osxaltest/spinbox.m index 5971332a..0ccdaf55 100644 --- a/redo/osxaltest/spinbox.m +++ b/redo/osxaltest/spinbox.m @@ -76,11 +76,26 @@ - (void)tFillAutoLayout:(tAutoLayoutParams *)p { NSString *key; + NSString *horzpred, *vertpred; key = tAutoLayoutKey(p->n); p->n++; - [p->horz addObject:[NSString stringWithFormat:@"[%@]", key]]; - [p->vert addObject:[NSString stringWithFormat:@"[%@]", key]]; + horzpred = @"(==96)"; // TODO only the entry + vertpred = @""; + if (p->stretchy) { + NSString *predicate; + + if (p->firstStretchy) + predicate = @"(>=0)"; + else + predicate = [NSString stringWithFormat:@"(==%@)", tAutoLayoutKey(p->stretchyTo)]; + if (p->stretchyVert) + vertpred = predicate; + else + horzpred = predicate; + } + [p->horz addObject:[NSString stringWithFormat:@"[%@%@]", key, horzpred]]; + [p->vert addObject:[NSString stringWithFormat:@"[%@%@]", key, vertpred]]; [p->views setObject:self->c forKey:key]; }