From 5c4329e0fc572d364a99430f9157d2d907ece99b Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 25 Oct 2018 14:14:28 +0100 Subject: [PATCH] Ensure that setting a plug-in to be non-resizable using AudioProcessorEditor::setResizable() does not overwrite custom bounds constrainers --- .../processors/juce_AudioProcessorEditor.cpp | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp index 3fcac53828..8e44bb29e9 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp @@ -88,18 +88,13 @@ void AudioProcessorEditor::setResizable (const bool shouldBeResizable, const boo { resizable = shouldBeResizable; - if (! resizable) + if (! resizable && constrainer == &defaultConstrainer) { - setConstrainer (&defaultConstrainer); + auto width = getWidth(); + auto height = getHeight(); - if (auto w = getWidth()) - { - if (auto h = getHeight()) - { - defaultConstrainer.setSizeLimits (w, h, w, h); - resized(); - } - } + if (width > 0 && height > 0) + defaultConstrainer.setSizeLimits (width, height, width, height); } } @@ -146,7 +141,10 @@ void AudioProcessorEditor::setConstrainer (ComponentBoundsConstrainer* newConstr { if (constrainer != newConstrainer) { - resizable = true; + if (newConstrainer != nullptr) + resizable = (newConstrainer->getMinimumWidth() != newConstrainer->getMaximumWidth() + || newConstrainer->getMinimumHeight() != newConstrainer->getMaximumHeight()); + attachConstrainer (newConstrainer); } }