|
|
@@ -1078,7 +1078,15 @@ public: |
|
|
|
}
|
|
|
|
|
|
|
|
if (editorComp != nullptr)
|
|
|
|
{
|
|
|
|
editorComp->checkVisibility();
|
|
|
|
|
|
|
|
#if JUCE_WINDOWS && JUCE_WIN_PER_MONITOR_DPI_AWARE
|
|
|
|
if (getHostType().isWavelab())
|
|
|
|
if (auto* peer = editorComp->getTopLevelComponent()->getPeer())
|
|
|
|
handleSetContentScaleFactor ((float) peer->getPlatformScaleFactor());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void createEditorComp()
|
|
|
@@ -1092,10 +1100,6 @@ public: |
|
|
|
{
|
|
|
|
vstEffect.flags |= Vst2::effFlagsHasEditor;
|
|
|
|
editorComp.reset (new EditorCompWrapper (*this, *ed));
|
|
|
|
|
|
|
|
#if ! (JUCE_MAC || JUCE_IOS)
|
|
|
|
ed->setScaleFactor (editorScaleFactor);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
@@ -1215,8 +1219,17 @@ public: |
|
|
|
// A component to hold the AudioProcessorEditor, and cope with some housekeeping
|
|
|
|
// chores when it changes or repaints.
|
|
|
|
struct EditorCompWrapper : public Component
|
|
|
|
{
|
|
|
|
EditorCompWrapper (JuceVSTWrapper& w, AudioProcessorEditor& editor) : wrapper (w)
|
|
|
|
#if ! JUCE_MAC
|
|
|
|
, public ComponentPeer::ScaleFactorListener,
|
|
|
|
public ComponentMovementWatcher
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
EditorCompWrapper (JuceVSTWrapper& w, AudioProcessorEditor& editor)
|
|
|
|
:
|
|
|
|
#if ! JUCE_MAC
|
|
|
|
ComponentMovementWatcher (this),
|
|
|
|
#endif
|
|
|
|
wrapper (w)
|
|
|
|
{
|
|
|
|
editor.setOpaque (true);
|
|
|
|
editor.setVisible (true);
|
|
|
@@ -1241,6 +1254,11 @@ public: |
|
|
|
{
|
|
|
|
deleteAllChildren(); // note that we can't use a std::unique_ptr because the editor may
|
|
|
|
// have been transferred to another parent which takes over ownership.
|
|
|
|
#if ! JUCE_MAC
|
|
|
|
for (int i = 0; i < ComponentPeer::getNumPeers(); ++i)
|
|
|
|
if (auto* peer = ComponentPeer::getPeer (i))
|
|
|
|
peer->removeScaleFactorListener (this);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void paint (Graphics&) override {}
|
|
|
@@ -1249,10 +1267,10 @@ public: |
|
|
|
{
|
|
|
|
auto b = getSizeToContainChild();
|
|
|
|
|
|
|
|
bounds.top = 0;
|
|
|
|
bounds.left = 0;
|
|
|
|
bounds.bottom = (int16) b.getHeight();
|
|
|
|
bounds.right = (int16) b.getWidth();
|
|
|
|
bounds.top = 0;
|
|
|
|
bounds.left = 0;
|
|
|
|
bounds.bottom = (int16) b.getHeight();
|
|
|
|
bounds.right = (int16) b.getWidth();
|
|
|
|
}
|
|
|
|
|
|
|
|
void attachToHost (VstOpCodeArguments args)
|
|
|
@@ -1263,6 +1281,10 @@ public: |
|
|
|
#if JUCE_WINDOWS
|
|
|
|
addToDesktop (0, args.ptr);
|
|
|
|
hostWindow = (HWND) args.ptr;
|
|
|
|
#if JUCE_WIN_PER_MONITOR_DPI_AWARE
|
|
|
|
// workaround for plug-ins opening on an auxiliary monitor
|
|
|
|
Timer::callAfterDelay (250, [this] { updateWindowSize (false); });
|
|
|
|
#endif
|
|
|
|
#elif JUCE_LINUX
|
|
|
|
addToDesktop (0, args.ptr);
|
|
|
|
hostWindow = (Window) args.ptr;
|
|
|
@@ -1302,6 +1324,32 @@ public: |
|
|
|
return dynamic_cast<AudioProcessorEditor*> (getChildComponent(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
float getNativeEditorScaleFactor() const noexcept { return nativeScaleFactor; }
|
|
|
|
|
|
|
|
#if ! JUCE_MAC
|
|
|
|
void componentMovedOrResized (bool, bool) override {}
|
|
|
|
|
|
|
|
void componentPeerChanged() override
|
|
|
|
{
|
|
|
|
if (auto* peer = getTopLevelComponent()->getPeer())
|
|
|
|
peer->addScaleFactorListener (this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void componentVisibilityChanged() override
|
|
|
|
{
|
|
|
|
if (auto* peer = getTopLevelComponent()->getPeer())
|
|
|
|
nativeScaleFactorChanged (peer->getPlatformScaleFactor());
|
|
|
|
}
|
|
|
|
|
|
|
|
void nativeScaleFactorChanged (double newScaleFactor) override
|
|
|
|
{
|
|
|
|
nativeScaleFactor = (float) newScaleFactor;
|
|
|
|
|
|
|
|
if (getHostType().isBitwigStudio())
|
|
|
|
updateWindowSize (true);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void resized() override
|
|
|
|
{
|
|
|
|
if (auto* ed = getEditorComp())
|
|
|
@@ -1359,7 +1407,9 @@ public: |
|
|
|
shouldResizeEditor = true;
|
|
|
|
#else
|
|
|
|
ignoreUnused (resizeEditor);
|
|
|
|
XResizeWindow (display.display, (Window) getWindowHandle(), pos.getWidth(), pos.getHeight());
|
|
|
|
XResizeWindow (display.display, (Window) getWindowHandle(),
|
|
|
|
static_cast<unsigned int> (roundToInt (pos.getWidth() * nativeScaleFactor)),
|
|
|
|
static_cast<unsigned int> (roundToInt (pos.getHeight() * nativeScaleFactor)));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if JUCE_MAC
|
|
|
@@ -1380,7 +1430,9 @@ public: |
|
|
|
if (status == (pointer_sized_int) 1 || getHostType().isAbletonLive())
|
|
|
|
{
|
|
|
|
isInSizeWindow = true;
|
|
|
|
sizeWasSuccessful = (host (wrapper.getAEffect(), Vst2::audioMasterSizeWindow, newWidth, newHeight, 0, 0) != 0);
|
|
|
|
sizeWasSuccessful = (host (wrapper.getAEffect(), Vst2::audioMasterSizeWindow,
|
|
|
|
roundToInt (newWidth * nativeScaleFactor),
|
|
|
|
roundToInt (newHeight * nativeScaleFactor), 0, 0) != 0);
|
|
|
|
isInSizeWindow = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -1478,6 +1530,8 @@ public: |
|
|
|
bool isInSizeWindow = false;
|
|
|
|
bool shouldResizeEditor = true;
|
|
|
|
|
|
|
|
float nativeScaleFactor = 1.0f;
|
|
|
|
|
|
|
|
#if JUCE_MAC
|
|
|
|
void* hostWindow = {};
|
|
|
|
#elif JUCE_LINUX
|
|
|
@@ -2115,21 +2169,36 @@ private: |
|
|
|
|
|
|
|
pointer_sized_int handleSetContentScaleFactor (float scale)
|
|
|
|
{
|
|
|
|
if (editorScaleFactor != scale)
|
|
|
|
#if ! JUCE_MAC
|
|
|
|
if (editorComp != nullptr)
|
|
|
|
{
|
|
|
|
editorScaleFactor = scale;
|
|
|
|
|
|
|
|
#if ! (JUCE_MAC || JUCE_IOS)
|
|
|
|
if (editorComp != nullptr)
|
|
|
|
#if JUCE_WINDOWS && ! JUCE_WIN_PER_MONITOR_DPI_AWARE
|
|
|
|
if (auto* ed = editorComp->getEditorComp())
|
|
|
|
{
|
|
|
|
if (auto* ed = editorComp->getEditorComp())
|
|
|
|
ed->setScaleFactor (editorScaleFactor);
|
|
|
|
ed->setScaleFactor (scale);
|
|
|
|
editorComp->updateWindowSize (true);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (! approximatelyEqual (scale, (float) editorComp->getNativeEditorScaleFactor()))
|
|
|
|
{
|
|
|
|
editorComp->nativeScaleFactorChanged ((double) scale);
|
|
|
|
|
|
|
|
if (editorComp != nullptr)
|
|
|
|
editorComp->updateWindowSize (true);
|
|
|
|
#if JUCE_LINUX
|
|
|
|
MessageManager::callAsync ([this] { if (editorComp != nullptr) editorComp->updateWindowSize (true); });
|
|
|
|
#else
|
|
|
|
editorComp->updateWindowSize (true);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if JUCE_WINDOWS && JUCE_WIN_PER_MONITOR_DPI_AWARE
|
|
|
|
if (getHostType().isStudioOne())
|
|
|
|
Timer::callAfterDelay (100, [this] { if (editorComp != nullptr) editorComp->updateWindowSize (false); });
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
ignoreUnused (scale);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
@@ -2185,7 +2254,6 @@ private: |
|
|
|
Vst2::ERect editorBounds;
|
|
|
|
MidiBuffer midiEvents;
|
|
|
|
VSTMidiEventList outgoingEvents;
|
|
|
|
float editorScaleFactor = 1.0f;
|
|
|
|
|
|
|
|
LegacyAudioParametersWrapper juceParameters;
|
|
|
|
|
|
|
|