From 6015900d6ddfe89e972392aa96f8b69dd9abe259 Mon Sep 17 00:00:00 2001 From: reuk Date: Tue, 23 May 2023 13:53:33 +0100 Subject: [PATCH] VST3 Host: Constrain editor view to prevent it being resized beyond the minimum size recommended by the plugin --- .../format_types/juce_VST3PluginFormat.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index ba3868264698..2e0bfc54f6d9 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -1479,6 +1479,7 @@ static std::shared_ptr getARAFactory (VST3ModuleHandle& m //============================================================================== struct VST3PluginWindow final : public AudioProcessorEditor, private ComponentMovementWatcher, + private ComponentBoundsConstrainer, private IPlugFrame { VST3PluginWindow (AudioPluginInstance* owner, IPlugView* pluginView) @@ -1492,6 +1493,7 @@ struct VST3PluginWindow final : public AudioProcessorEditor, setSize (10, 10); setOpaque (true); setVisible (true); + setConstrainer (this); warnOnFailure (view->setFrame (this)); view->queryInterface (Steinberg::IPlugViewContentScaleSupport::iid, (void**) &scaleInterface); @@ -1565,6 +1567,19 @@ struct VST3PluginWindow final : public AudioProcessorEditor, bool keyPressed (const KeyPress& /*key*/) override { return true; } private: + void checkBounds (Rectangle& bounds, + const Rectangle&, + const Rectangle&, + bool, + bool, + bool, + bool) override + { + auto rect = componentToVST3Rect (bounds); + view->checkSizeConstraint (&rect); + bounds = vst3ToComponentRect (rect); + } + //============================================================================== void componentPeerChanged() override {}