|
|
|
@@ -1786,8 +1786,7 @@ private: |
|
|
|
// constructor, we don't have a host plugFrame, so
|
|
|
|
// ContentWrapperComponent::resizeHostWindow() won't do anything, and the content
|
|
|
|
// wrapper component will be left at the wrong size.
|
|
|
|
if (! approximatelyEqual (editorScaleFactor, owner->lastScaleFactorReceived))
|
|
|
|
setContentScaleFactor (owner->lastScaleFactorReceived);
|
|
|
|
applyScaleFactor (StoredScaleFactor{}.withInternal (owner->lastScaleFactorReceived));
|
|
|
|
|
|
|
|
// Check the host scale factor *before* calling addToDesktop, so that the initial
|
|
|
|
// window size during addToDesktop is correct for the current platform scale factor.
|
|
|
|
@@ -1990,35 +1989,28 @@ private: |
|
|
|
return kResultFalse;
|
|
|
|
}
|
|
|
|
|
|
|
|
tresult PLUGIN_API setContentScaleFactor (Steinberg::IPlugViewContentScaleSupport::ScaleFactor factor) override
|
|
|
|
tresult PLUGIN_API setContentScaleFactor (const Steinberg::IPlugViewContentScaleSupport::ScaleFactor factor) override
|
|
|
|
{
|
|
|
|
#if ! JUCE_MAC
|
|
|
|
if (! approximatelyEqual ((float) factor, editorScaleFactor))
|
|
|
|
const auto scaleToApply = [&]
|
|
|
|
{
|
|
|
|
#if JUCE_WINDOWS && JUCE_WIN_PER_MONITOR_DPI_AWARE
|
|
|
|
// Cubase 10 only sends integer scale factors, so correct this for fractional scales
|
|
|
|
if (getHostType().type == PluginHostType::SteinbergCubase10)
|
|
|
|
{
|
|
|
|
auto hostWindowScale = (Steinberg::IPlugViewContentScaleSupport::ScaleFactor) getScaleFactorForWindow ((HWND) systemWindow);
|
|
|
|
if (getHostType().type != PluginHostType::SteinbergCubase10)
|
|
|
|
return factor;
|
|
|
|
|
|
|
|
if (hostWindowScale > 0.0 && ! approximatelyEqual (factor, hostWindowScale))
|
|
|
|
factor = hostWindowScale;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
const auto hostWindowScale = (Steinberg::IPlugViewContentScaleSupport::ScaleFactor) getScaleFactorForWindow (static_cast<HWND> (systemWindow));
|
|
|
|
|
|
|
|
editorScaleFactor = (float) factor;
|
|
|
|
if (hostWindowScale <= 0.0 || approximatelyEqual (factor, hostWindowScale))
|
|
|
|
return factor;
|
|
|
|
|
|
|
|
if (owner != nullptr)
|
|
|
|
owner->lastScaleFactorReceived = editorScaleFactor;
|
|
|
|
return hostWindowScale;
|
|
|
|
#else
|
|
|
|
return factor;
|
|
|
|
#endif
|
|
|
|
}();
|
|
|
|
|
|
|
|
if (component != nullptr)
|
|
|
|
{
|
|
|
|
#if JUCE_LINUX || JUCE_BSD
|
|
|
|
const MessageManagerLock mmLock;
|
|
|
|
#endif
|
|
|
|
component->setEditorScaleFactor (editorScaleFactor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
applyScaleFactor (scaleFactor.withHost (scaleToApply));
|
|
|
|
|
|
|
|
return kResultTrue;
|
|
|
|
#else
|
|
|
|
@@ -2103,7 +2095,7 @@ private: |
|
|
|
|
|
|
|
pluginEditor->setHostContext (editorHostContext.get());
|
|
|
|
#if ! JUCE_MAC
|
|
|
|
pluginEditor->setScaleFactor (owner.editorScaleFactor);
|
|
|
|
pluginEditor->setScaleFactor (owner.scaleFactor.get());
|
|
|
|
#endif
|
|
|
|
|
|
|
|
addAndMakeVisible (pluginEditor.get());
|
|
|
|
@@ -2234,10 +2226,10 @@ private: |
|
|
|
#if JUCE_WINDOWS && JUCE_WIN_PER_MONITOR_DPI_AWARE
|
|
|
|
void checkHostWindowScaleFactor()
|
|
|
|
{
|
|
|
|
auto hostWindowScale = (float) getScaleFactorForWindow ((HWND) owner.systemWindow);
|
|
|
|
const auto estimatedScale = (float) getScaleFactorForWindow (static_cast<HWND> (owner.systemWindow));
|
|
|
|
|
|
|
|
if (hostWindowScale > 0.0 && ! approximatelyEqual (hostWindowScale, owner.editorScaleFactor))
|
|
|
|
owner.setContentScaleFactor (hostWindowScale);
|
|
|
|
if (estimatedScale > 0.0)
|
|
|
|
owner.applyScaleFactor (owner.scaleFactor.withInternal (estimatedScale));
|
|
|
|
}
|
|
|
|
|
|
|
|
void timerCallback() override
|
|
|
|
@@ -2321,7 +2313,38 @@ private: |
|
|
|
|
|
|
|
std::unique_ptr<Cubase10WindowResizeWorkaround> cubase10Workaround;
|
|
|
|
#else
|
|
|
|
float editorScaleFactor = 1.0f;
|
|
|
|
class StoredScaleFactor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
StoredScaleFactor withHost (float x) const { return withMember (*this, &StoredScaleFactor::host, x); }
|
|
|
|
StoredScaleFactor withInternal (float x) const { return withMember (*this, &StoredScaleFactor::internal, x); }
|
|
|
|
float get() const { return host.value_or (internal); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::optional<float> host;
|
|
|
|
float internal = 1.0f;
|
|
|
|
};
|
|
|
|
|
|
|
|
void applyScaleFactor (const StoredScaleFactor newFactor)
|
|
|
|
{
|
|
|
|
const auto previous = std::exchange (scaleFactor, newFactor).get();
|
|
|
|
|
|
|
|
if (previous == scaleFactor.get())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (owner != nullptr)
|
|
|
|
owner->lastScaleFactorReceived = scaleFactor.get();
|
|
|
|
|
|
|
|
if (component != nullptr)
|
|
|
|
{
|
|
|
|
#if JUCE_LINUX || JUCE_BSD
|
|
|
|
const MessageManagerLock mmLock;
|
|
|
|
#endif
|
|
|
|
component->setEditorScaleFactor (scaleFactor.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StoredScaleFactor scaleFactor;
|
|
|
|
|
|
|
|
#if JUCE_WINDOWS
|
|
|
|
WindowsHooks hooks;
|
|
|
|
|