diff options
author | David Robillard <d@drobilla.net> | 2022-05-20 14:22:01 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-05-21 16:49:47 -0400 |
commit | d8e02dad9e4a19b5b4e5234ea14b6f0f0bef9fab (patch) | |
tree | f212082490a8438aa250d7244f2331cad618023b /src/mac.m | |
parent | c6238d974edbb5ce41f99d8457fe7ce09dd26abf (diff) | |
download | pugl-d8e02dad9e4a19b5b4e5234ea14b6f0f0bef9fab.tar.gz pugl-d8e02dad9e4a19b5b4e5234ea14b6f0f0bef9fab.tar.bz2 pugl-d8e02dad9e4a19b5b4e5234ea14b6f0f0bef9fab.zip |
MacOS: Specify maximum size constraint on draw view
I am not sure why the minimum was only specified before, but it seems like an
oversight.
Diffstat (limited to 'src/mac.m')
-rw-r--r-- | src/mac.m | 52 |
1 files changed, 37 insertions, 15 deletions
@@ -875,16 +875,18 @@ puglInitViewInternals(void) } static NSLayoutConstraint* -puglConstraint(id item, NSLayoutAttribute attribute, float constant) +puglConstraint(const id item, + const NSLayoutAttribute attribute, + const NSLayoutRelation relation, + const float constant) { - return - [NSLayoutConstraint constraintWithItem:item - attribute:attribute - relatedBy:NSLayoutRelationGreaterThanOrEqual - toItem:nil - attribute:NSLayoutAttributeNotAnAttribute - multiplier:1.0 - constant:(CGFloat)constant]; + return [NSLayoutConstraint constraintWithItem:item + attribute:attribute + relatedBy:relation + toItem:nil + attribute:NSLayoutAttributeNotAnAttribute + multiplier:1.0 + constant:(CGFloat)constant]; } PuglStatus @@ -959,12 +961,32 @@ puglRealize(PuglView* view) impl->wrapperView->markedText = [[NSMutableAttributedString alloc] init]; [impl->wrapperView setAutoresizesSubviews:YES]; [impl->wrapperView initWithFrame:framePt]; - [impl->wrapperView addConstraint:puglConstraint(impl->wrapperView, - NSLayoutAttributeWidth, - view->minWidth)]; - [impl->wrapperView addConstraint:puglConstraint(impl->wrapperView, - NSLayoutAttributeHeight, - view->minHeight)]; + + [impl->wrapperView + addConstraint:puglConstraint(impl->wrapperView, + NSLayoutAttributeWidth, + NSLayoutRelationGreaterThanOrEqual, + view->minWidth)]; + + [impl->wrapperView + addConstraint:puglConstraint(impl->wrapperView, + NSLayoutAttributeHeight, + NSLayoutRelationGreaterThanOrEqual, + view->minHeight)]; + + if (view->maxWidth && view->maxHeight) { + [impl->wrapperView + addConstraint:puglConstraint(impl->wrapperView, + NSLayoutAttributeWidth, + NSLayoutRelationLessThanOrEqual, + view->maxWidth)]; + + [impl->wrapperView + addConstraint:puglConstraint(impl->wrapperView, + NSLayoutAttributeHeight, + NSLayoutRelationLessThanOrEqual, + view->maxHeight)]; + } // Create draw view to be rendered to PuglStatus st = PUGL_SUCCESS; |