Browse Source

VST3: Fixed a resizing bug when a plug-in has a fixed aspect ratio

tags/2021-05-28
Tom Poole 7 years ago
parent
commit
5011c47447
1 changed files with 16 additions and 0 deletions
  1. +16
    -0
      modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp

+ 16
- 0
modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp View File

@@ -1020,6 +1020,22 @@ private:
{ {
lastBounds = getLocalBounds(); lastBounds = getLocalBounds();
isResizingChildToFitParent = true; isResizingChildToFitParent = true;
if (auto* constrainer = pluginEditor->getConstrainer())
{
auto aspectRatio = constrainer->getFixedAspectRatio();
auto width = (double) lastBounds.getWidth();
auto height = (double) lastBounds.getHeight();
if (aspectRatio != 0)
{
if (width / height > aspectRatio)
setBounds ({ 0, 0, roundToInt (height * aspectRatio), lastBounds.getHeight() });
else
setBounds ({ 0, 0, lastBounds.getWidth(), roundToInt (width / aspectRatio) });
}
}
pluginEditor->setTopLeftPosition (0, 0); pluginEditor->setTopLeftPosition (0, 0);
pluginEditor->setBounds (pluginEditor->getLocalArea (this, getLocalBounds())); pluginEditor->setBounds (pluginEditor->getLocalArea (this, getLocalBounds()));
isResizingChildToFitParent = false; isResizingChildToFitParent = false;


Loading…
Cancel
Save