Browse Source

Use the new Window method for auto-scaled plugin UIs

Signed-off-by: falkTX <falktx@falktx.com>
pull/517/head
falkTX 1 month ago
parent
commit
793f50bd96
2 changed files with 16 additions and 10 deletions
  1. +6
    -1
      distrho/DistrhoUI.hpp
  2. +10
    -9
      distrho/src/DistrhoUI.cpp

+ 6
- 1
distrho/DistrhoUI.hpp View File

@@ -72,6 +72,11 @@ class PluginWindow;
class UI : public UIWidget
{
public:
enum InternalScalingMode {
kNoInternalScaling,
kInternalScalingMatchingHost,
};

/**
UI class constructor.
The UI should be initialized to a default state that matches the plugin side.
@@ -82,7 +87,7 @@ public:
@see getScaleFactor
@see setGeometryConstraints
*/
UI(uint width = 0, uint height = 0);
UI(uint width = 0, uint height = 0, InternalScalingMode internalScalingMode = kNoInternalScaling);

#if DGL_ALLOW_DEPRECATED_METHODS
/** DEPRECATED DO NOT USE.


+ 10
- 9
distrho/src/DistrhoUI.cpp View File

@@ -180,7 +180,7 @@ PluginWindow& UI::PrivateData::createNextWindow(UI* const ui, uint width, uint h
UI::PrivateData* const uiData = s_nextPrivateData;
const double scaleFactor = d_isNotZero(uiData->scaleFactor) ? uiData->scaleFactor : getDesktopScaleFactor(uiData->winId);

if (d_isNotZero(scaleFactor) && d_isNotEqual(scaleFactor, 1.0))
if (d_isNotEqual(scaleFactor, 1.0))
{
width *= scaleFactor;
height *= scaleFactor;
@@ -322,7 +322,7 @@ void UI::PrivateData::webViewMessageCallback(void* const arg, char* const msg)
/* ------------------------------------------------------------------------------------------------------------
* UI */

UI::UI(const uint width, const uint height)
UI::UI(const uint width, const uint height, const InternalScalingMode internalScalingMode)
: UIWidget(UI::PrivateData::createNextWindow(this,
// width
#ifdef DISTRHO_UI_DEFAULT_WIDTH
@@ -339,14 +339,15 @@ UI::UI(const uint width, const uint height)
{
if (width != 0 && height != 0)
{
Widget::setSize(width, height);
}
#ifdef DISTRHO_UI_DEFAULT_WIDTH
else
{
Widget::setSize(DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT);
if (internalScalingMode == kInternalScalingMatchingHost)
{
d_stdout("enableInternalScalingWithSize %u %u", width, height);
getWindow().enableInternalScalingWithSize(width, height, true);
return;
}
}
#endif

Widget::setSize(getWindow().getSize());
}

#if DGL_ALLOW_DEPRECATED_METHODS


Loading…
Cancel
Save