From 4bb58c7d5107ba08293f0dbafdf4bb7763c91bcb Mon Sep 17 00:00:00 2001 From: hogliux Date: Thu, 14 Sep 2017 09:59:53 +0100 Subject: [PATCH] VST3: respect the editor's constrainer when resizing --- .../VST3/juce_VST3_Wrapper.cpp | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp index 967d3fd31c..11d91f39f5 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -881,28 +881,22 @@ private: { if (rectToCheck != nullptr && component != nullptr) { - // checkSizeConstraint - auto juceRect = Rectangle::leftTopRightBottom (rectToCheck->left, rectToCheck->top, - rectToCheck->right, rectToCheck->bottom); - if (auto* editor = component->pluginEditor.get()) { + // checkSizeConstraint + auto juceRect = editor->getLocalArea (component, Rectangle::leftTopRightBottom (rectToCheck->left, rectToCheck->top, + rectToCheck->right, rectToCheck->bottom)); if (auto* constrainer = editor->getConstrainer()) { - auto scaledMin = component->getLocalArea (editor, Rectangle (constrainer->getMinimumWidth(), - constrainer->getMinimumHeight())); + Rectangle limits (0, 0, constrainer->getMaximumWidth(), constrainer->getMaximumHeight()); + constrainer->checkBounds (juceRect, editor->getBounds(), limits, false, false, false, false); - auto scaledMax = component->getLocalArea (editor, Rectangle (constrainer->getMaximumWidth(), - constrainer->getMaximumHeight())); - - juceRect.setSize (jlimit (scaledMin.getWidth(), scaledMax.getWidth(), juceRect.getWidth()), - jlimit (scaledMin.getHeight(), scaledMax.getHeight(), juceRect.getHeight())); + juceRect = component->getLocalArea (editor, juceRect); + rectToCheck->right = rectToCheck->left + juceRect.getWidth(); + rectToCheck->bottom = rectToCheck->top + juceRect.getHeight(); } } - rectToCheck->right = rectToCheck->left + juceRect.getWidth(); - rectToCheck->bottom = rectToCheck->top + juceRect.getHeight(); - return kResultTrue; }