DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit 1e029513f628a424918e55ef314f635aa30f0d08
parent 1b7e47742ca4fea2a030bd630d44f76be2231b04
Author: falkTX <falktx@falktx.com>
Date:   Sat, 14 Aug 2021 14:25:47 +0100

Add automaticallyScale argument to UI constructor

Signed-off-by: falkTX <falktx@falktx.com>

Diffstat:
Mdistrho/DistrhoUI.hpp | 7++++++-
Mdistrho/src/DistrhoUI.cpp | 7++++++-
2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/distrho/DistrhoUI.hpp b/distrho/DistrhoUI.hpp @@ -74,8 +74,13 @@ public: /** UI class constructor. The UI should be initialized to a default state that matches the plugin side. + + When @a automaticallyScale is set to true, DPF will automatically scale up the UI + to fit the host/desktop scale factor.@n + It assumes aspect ratio is meant to be kept. + Manually call setGeometryConstraints instead if keeping UI aspect ratio is not required. */ - UI(uint width = 0, uint height = 0); + UI(uint width = 0, uint height = 0, bool automaticallyScale = false); /** Destructor. diff --git a/distrho/src/DistrhoUI.cpp b/distrho/src/DistrhoUI.cpp @@ -46,13 +46,18 @@ PluginWindow& UI::PrivateData::createNextWindow(UI* const ui, const uint width, /* ------------------------------------------------------------------------------------------------------------ * UI */ -UI::UI(const uint width, const uint height) +UI::UI(const uint width, const uint height, const bool automaticallyScale) : UIWidget(UI::PrivateData::createNextWindow(this, width, height)), uiData(UI::PrivateData::s_nextPrivateData) { #if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI if (width > 0 && height > 0) + { Widget::setSize(width, height); + + if (automaticallyScale) + setGeometryConstraints(width, height, true, true); + } #endif }