From e7d608aa48dd76399eb9435313a01baaece2f631 Mon Sep 17 00:00:00 2001 From: reuk Date: Wed, 28 Jul 2021 17:32:24 +0100 Subject: [PATCH] VST3 Host: Ensure that editors open correctly on monitors with non-unity scaling --- .../format_types/juce_VST3PluginFormat.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index 39d5bedf27..cc5f29f053 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -1505,12 +1505,12 @@ struct VST3PluginWindow : public AudioProcessorEditor, void nativeScaleFactorChanged (double newScaleFactor) override { - if (pluginHandle == HandleFormat{} || approximatelyEqual ((float) newScaleFactor, nativeScaleFactor)) + if (approximatelyEqual ((float) newScaleFactor, nativeScaleFactor)) return; nativeScaleFactor = (float) newScaleFactor; - if (scaleInterface != nullptr) + if (pluginHandle != HandleFormat{} && scaleInterface != nullptr) scaleInterface->setContentScaleFactor ((Steinberg::IPlugViewContentScaleSupport::ScaleFactor) nativeScaleFactor); } @@ -1530,6 +1530,13 @@ struct VST3PluginWindow : public AudioProcessorEditor, resizeWithRect (embeddedComponent, *newSize, nativeScaleFactor); setSize (embeddedComponent.getWidth(), embeddedComponent.getHeight()); + // According to the VST3 Workflow Diagrams, a resizeView from the plugin should + // always trigger a response from the host which confirms the new size. + ViewRect rect; + rect.right = (Steinberg::int32) roundToInt ((float) getWidth() * nativeScaleFactor); + rect.bottom = (Steinberg::int32) roundToInt ((float) getHeight() * nativeScaleFactor); + view->onSize (&rect); + return kResultTrue; } @@ -1597,7 +1604,7 @@ private: #if JUCE_WINDOWS struct ChildComponent : public Component { - ChildComponent() {} + ChildComponent() { setOpaque (true); } void paint (Graphics& g) override { g.fillAll (Colours::cornflowerblue); } using Component::createNewPeer;