1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-15 00:24:19 +00:00

VST3 Host: Correctly size unscalable editors when DPI changes

This commit is contained in:
reuk 2021-09-27 20:19:35 +01:00
parent 9bec8e633a
commit ebf86b5f35
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -1355,17 +1355,17 @@ private:
//==============================================================================
struct VST3PluginWindow : public AudioProcessorEditor,
public ComponentMovementWatcher,
public ComponentPeer::ScaleFactorListener,
public IPlugFrame
private ComponentMovementWatcher,
private ComponentPeer::ScaleFactorListener,
private IPlugFrame
{
VST3PluginWindow (AudioPluginInstance* owner, IPlugView* pluginView)
: AudioProcessorEditor (owner),
ComponentMovementWatcher (this),
view (pluginView, false)
#if JUCE_MAC
, embeddedComponent (*owner)
#endif
: AudioProcessorEditor (owner),
ComponentMovementWatcher (this),
view (pluginView, false)
#if JUCE_MAC
, embeddedComponent (*owner)
#endif
{
setSize (10, 10);
setOpaque (true);
@ -1437,6 +1437,7 @@ struct VST3PluginWindow : public AudioProcessorEditor,
bool keyStateChanged (bool /*isKeyDown*/) override { return true; }
bool keyPressed (const KeyPress& /*key*/) override { return true; }
private:
//==============================================================================
void componentPeerChanged() override
{
@ -1508,15 +1509,9 @@ struct VST3PluginWindow : public AudioProcessorEditor,
void nativeScaleFactorChanged (double newScaleFactor) override
{
if (approximatelyEqual ((float) newScaleFactor, nativeScaleFactor))
return;
nativeScaleFactor = (float) newScaleFactor;
if (pluginHandle != HandleFormat{} && scaleInterface != nullptr)
scaleInterface->setContentScaleFactor ((Steinberg::IPlugViewContentScaleSupport::ScaleFactor) nativeScaleFactor);
else
resizeToFit();
updatePluginScale();
componentMovedOrResized (false, true);
}
void resizeToFit()
@ -1564,7 +1559,6 @@ struct VST3PluginWindow : public AudioProcessorEditor,
return kInvalidArgument;
}
private:
//==============================================================================
static void resizeWithRect (Component& comp, const ViewRect& rect, float scaleFactor)
{
@ -1599,11 +1593,7 @@ private:
}
warnOnFailure (view->attached ((void*) pluginHandle, defaultVST3WindowType));
if (scaleInterface != nullptr)
scaleInterface->setContentScaleFactor ((Steinberg::IPlugViewContentScaleSupport::ScaleFactor) nativeScaleFactor);
else
resizeToFit();
updatePluginScale();
}
}
@ -1617,6 +1607,14 @@ private:
currentPeer->removeScaleFactorListener (this);
}
void updatePluginScale()
{
if (scaleInterface != nullptr)
warnOnFailure (scaleInterface->setContentScaleFactor ((Steinberg::IPlugViewContentScaleSupport::ScaleFactor) nativeScaleFactor));
else
resizeToFit();
}
//==============================================================================
Atomic<int> refCount { 1 };
VSTComSmartPtr<IPlugView> view;