Skip to content

Commit

Permalink
Fix incorrect non-scaled UIs for hosts requesting size early
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Feb 10, 2024
1 parent 7ce973b commit ce3f6c1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
8 changes: 4 additions & 4 deletions distrho/src/DistrhoPluginCLAP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,10 @@ class ClapUI : public DGL_NAMESPACE::IdleCallback

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,
Expand Down Expand Up @@ -371,10 +371,10 @@ class ClapUI : public DGL_NAMESPACE::IdleCallback
{
// 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);
}
}

Expand Down
4 changes: 2 additions & 2 deletions distrho/src/DistrhoPluginVST2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,10 +602,10 @@ class PluginVst : public ParameterAndNotesHelper
{
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,
Expand Down
9 changes: 5 additions & 4 deletions distrho/src/DistrhoUIVST3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit ce3f6c1

Please sign in to comment.