aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-05-20 14:22:01 -0400
committerDavid Robillard <d@drobilla.net>2022-05-21 16:49:47 -0400
commitd8e02dad9e4a19b5b4e5234ea14b6f0f0bef9fab (patch)
treef212082490a8438aa250d7244f2331cad618023b /src
parentc6238d974edbb5ce41f99d8457fe7ce09dd26abf (diff)
downloadpugl-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')
-rw-r--r--src/mac.m52
1 files changed, 37 insertions, 15 deletions
diff --git a/src/mac.m b/src/mac.m
index 136680e..865355a 100644
--- a/src/mac.m
+++ b/src/mac.m
@@ -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;