commit ce3f6c1147a82efd50107aa3ae9f4f99df6f2e53
parent 7ce973b0cc9ad15188f6549b0ee36e3c8465845d
Author: falkTX <falktx@falktx.com>
Date: Sat, 10 Feb 2024 16:12:24 +0100
Fix incorrect non-scaled UIs for hosts requesting size early
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
3 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/distrho/src/DistrhoPluginCLAP.cpp b/distrho/src/DistrhoPluginCLAP.cpp
@@ -280,10 +280,10 @@ public:
double scaleFactor = fScaleFactor;
#if defined(DISTRHO_UI_DEFAULT_WIDTH) && defined(DISTRHO_UI_DEFAULT_HEIGHT)
- *width = DISTRHO_UI_DEFAULT_WIDTH;
- *height = DISTRHO_UI_DEFAULT_HEIGHT;
if (d_isZero(scaleFactor))
scaleFactor = 1.0;
+ *width = DISTRHO_UI_DEFAULT_WIDTH * scaleFactor;
+ *height = DISTRHO_UI_DEFAULT_HEIGHT * scaleFactor;
#else
UIExporter tmpUI(nullptr, 0, fPlugin.getSampleRate(),
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, d_nextBundlePath,
@@ -371,10 +371,10 @@ public:
{
// fix width
if (reqRatio > ratio)
- *width = static_cast<int32_t>(*height * ratio + 0.5);
+ *width = d_roundToIntPositive(*height * ratio);
// fix height
else
- *height = static_cast<int32_t>(static_cast<double>(*width) / ratio + 0.5);
+ *height = d_roundToIntPositive(static_cast<double>(*width) / ratio);
}
}
diff --git a/distrho/src/DistrhoPluginVST2.cpp b/distrho/src/DistrhoPluginVST2.cpp
@@ -602,10 +602,10 @@ public:
{
double scaleFactor = fLastScaleFactor;
#if defined(DISTRHO_UI_DEFAULT_WIDTH) && defined(DISTRHO_UI_DEFAULT_HEIGHT)
- fVstRect.right = DISTRHO_UI_DEFAULT_WIDTH;
- fVstRect.bottom = DISTRHO_UI_DEFAULT_HEIGHT;
if (d_isZero(scaleFactor))
scaleFactor = 1.0;
+ fVstRect.right = DISTRHO_UI_DEFAULT_WIDTH * scaleFactor;
+ fVstRect.bottom = DISTRHO_UI_DEFAULT_HEIGHT * scaleFactor;
#else
UIExporter tmpUI(nullptr, 0, fPlugin.getSampleRate(),
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, d_nextBundlePath,
diff --git a/distrho/src/DistrhoUIVST3.cpp b/distrho/src/DistrhoUIVST3.cpp
@@ -92,10 +92,10 @@ static void applyGeometryConstraints(const uint minimumWidth,
{
// fix width
if (reqRatio > ratio)
- rect->right = static_cast<int32_t>(rect->bottom * ratio + 0.5);
+ rect->right = d_roundToIntPositive(rect->bottom * ratio);
// fix height
else
- rect->bottom = static_cast<int32_t>(static_cast<double>(rect->right) / ratio + 0.5);
+ rect->bottom = d_roundToIntPositive(static_cast<double>(rect->right) / ratio);
}
}
@@ -1527,10 +1527,10 @@ struct dpf_plugin_view : v3_plugin_view_cpp {
double scaleFactor = view->scale != nullptr ? view->scale->scaleFactor : 0.0;
#if defined(DISTRHO_UI_DEFAULT_WIDTH) && defined(DISTRHO_UI_DEFAULT_HEIGHT)
- rect->right = DISTRHO_UI_DEFAULT_WIDTH;
- rect->bottom = DISTRHO_UI_DEFAULT_HEIGHT;
if (d_isZero(scaleFactor))
scaleFactor = 1.0;
+ rect->right = DISTRHO_UI_DEFAULT_WIDTH * scaleFactor;
+ rect->bottom = DISTRHO_UI_DEFAULT_HEIGHT * scaleFactor;
#else
UIExporter tmpUI(nullptr, 0, view->sampleRate,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, d_nextBundlePath,
@@ -1540,6 +1540,7 @@ struct dpf_plugin_view : v3_plugin_view_cpp {
scaleFactor = tmpUI.getScaleFactor();
tmpUI.quit();
#endif
+
rect->left = rect->top = 0;
#ifdef DISTRHO_OS_MAC
rect->right /= scaleFactor;