Skip to content

Commit 793f50b

Browse files
committed
Use the new Window method for auto-scaled plugin UIs
Signed-off-by: falkTX <[email protected]>
1 parent 4d05c7a commit 793f50b

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

distrho/DistrhoUI.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ class PluginWindow;
7272
class UI : public UIWidget
7373
{
7474
public:
75+
enum InternalScalingMode {
76+
kNoInternalScaling,
77+
kInternalScalingMatchingHost,
78+
};
79+
7580
/**
7681
UI class constructor.
7782
The UI should be initialized to a default state that matches the plugin side.
@@ -82,7 +87,7 @@ class UI : public UIWidget
8287
@see getScaleFactor
8388
@see setGeometryConstraints
8489
*/
85-
UI(uint width = 0, uint height = 0);
90+
UI(uint width = 0, uint height = 0, InternalScalingMode internalScalingMode = kNoInternalScaling);
8691

8792
#if DGL_ALLOW_DEPRECATED_METHODS
8893
/** DEPRECATED DO NOT USE.

distrho/src/DistrhoUI.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ PluginWindow& UI::PrivateData::createNextWindow(UI* const ui, uint width, uint h
180180
UI::PrivateData* const uiData = s_nextPrivateData;
181181
const double scaleFactor = d_isNotZero(uiData->scaleFactor) ? uiData->scaleFactor : getDesktopScaleFactor(uiData->winId);
182182

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

325-
UI::UI(const uint width, const uint height)
325+
UI::UI(const uint width, const uint height, const InternalScalingMode internalScalingMode)
326326
: UIWidget(UI::PrivateData::createNextWindow(this,
327327
// width
328328
#ifdef DISTRHO_UI_DEFAULT_WIDTH
@@ -339,14 +339,15 @@ UI::UI(const uint width, const uint height)
339339
{
340340
if (width != 0 && height != 0)
341341
{
342-
Widget::setSize(width, height);
343-
}
344-
#ifdef DISTRHO_UI_DEFAULT_WIDTH
345-
else
346-
{
347-
Widget::setSize(DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT);
342+
if (internalScalingMode == kInternalScalingMatchingHost)
343+
{
344+
d_stdout("enableInternalScalingWithSize %u %u", width, height);
345+
getWindow().enableInternalScalingWithSize(width, height, true);
346+
return;
347+
}
348348
}
349-
#endif
349+
350+
Widget::setSize(getWindow().getSize());
350351
}
351352

352353
#if DGL_ALLOW_DEPRECATED_METHODS

0 commit comments

Comments
 (0)