diff --git a/redo/osxaltest/box.m b/redo/osxaltest/box.m index 4ef7fc6c..a49cc6fc 100644 --- a/redo/osxaltest/box.m +++ b/redo/osxaltest/box.m @@ -77,6 +77,8 @@ id c; c = (id) obj; + // this also resets the hugging priority + // TODO do this when adding and removing controls instead [c tFillAutoLayout:&pp]; [views setObject:pp.view forKey:tAutoLayoutKey(n)]; n++; diff --git a/redo/osxaltest/button.m b/redo/osxaltest/button.m index 3a8d77fa..669e8bf5 100644 --- a/redo/osxaltest/button.m +++ b/redo/osxaltest/button.m @@ -4,6 +4,7 @@ @implementation tButton { NSButton *b; id parent; + NSLayoutPriority horzpri, vertpri; } - (id)tInitWithText:(NSString *)text @@ -19,6 +20,9 @@ [self->b setTranslatesAutoresizingMaskIntoConstraints:NO]; self->parent = nil; + + self->horzpri = [self->b contentHuggingPriorityForOrientation:NSLayoutConstraintOrientationHorizontal]; + self->vertpri = [self->b contentHuggingPriorityForOrientation:NSLayoutConstraintOrientationVertical]; } return self; } @@ -33,6 +37,9 @@ - (void)tFillAutoLayout:(tAutoLayoutParams *)p { + // reset the hugging priority + [self->b setContentHuggingPriority:self->horzpri forOrientation:NSLayoutConstraintOrientationHorizontal]; + [self->b setContentHuggingPriority:self->vertpri forOrientation:NSLayoutConstraintOrientationVertical]; p->view = self->b; p->attachLeft = YES; p->attachTop = YES; diff --git a/redo/osxaltest/spinbox.m b/redo/osxaltest/spinbox.m index 4c443dd8..1e04d693 100644 --- a/redo/osxaltest/spinbox.m +++ b/redo/osxaltest/spinbox.m @@ -19,6 +19,7 @@ NSTextField *t; NSStepper *s; id parent; + NSLayoutPriority horzpri, vertpri; } - (id)init @@ -63,6 +64,9 @@ [views release]; self->parent = nil; + + self->horzpri = [self->c contentHuggingPriorityForOrientation:NSLayoutConstraintOrientationHorizontal]; + self->vertpri = [self->c contentHuggingPriorityForOrientation:NSLayoutConstraintOrientationVertical]; } return self; } @@ -77,6 +81,9 @@ - (void)tFillAutoLayout:(tAutoLayoutParams *)p { + // reset the hugging priority + [self->c setContentHuggingPriority:self->horzpri forOrientation:NSLayoutConstraintOrientationHorizontal]; + [self->c setContentHuggingPriority:self->vertpri forOrientation:NSLayoutConstraintOrientationVertical]; p->view = self->c; p->attachLeft = YES; p->attachTop = YES;