DPF

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

commit 04032b02e3aef7f176bba86b729ef93b3e99f9c0
parent aa897a365a4d1796f6f456ee88593b972f683017
Author: falkTX <falktx@falktx.com>
Date:   Fri, 14 May 2021 22:48:08 +0100

Allow DPF_SCALE_FACTOR env var for quickly testing scale factors

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

Diffstat:
Mdgl/TopLevelWidget.hpp | 1+
Mdgl/Window.hpp | 4++--
Mdgl/src/TopLevelWidget.cpp | 5+++++
Mdgl/src/Window.cpp | 8++++----
Mdgl/src/WindowPrivateData.cpp | 18++++++++++++++----
Mdistrho/src/DistrhoPluginJack.cpp | 12+-----------
Mdistrho/src/DistrhoUIInternal.hpp | 2+-
7 files changed, 28 insertions(+), 22 deletions(-)

diff --git a/dgl/TopLevelWidget.hpp b/dgl/TopLevelWidget.hpp @@ -67,6 +67,7 @@ public: Window& getWindow() const noexcept; // TODO group stuff after here, convenience functions present in Window class + double getScaleFactor() const noexcept; void repaint() noexcept; void repaint(const Rectangle<uint>& rect) noexcept; void setGeometryConstraints(uint minimumWidth, diff --git a/dgl/Window.hpp b/dgl/Window.hpp @@ -61,7 +61,7 @@ public: */ explicit Window(Application& app, uintptr_t parentWindowHandle, - double scaling, + double scaleFactor, bool resizable); /** @@ -72,7 +72,7 @@ public: uintptr_t parentWindowHandle, uint width, uint height, - double scaling, + double scaleFactor, bool resizable); /** diff --git a/dgl/src/TopLevelWidget.cpp b/dgl/src/TopLevelWidget.cpp @@ -40,6 +40,11 @@ Window& TopLevelWidget::getWindow() const noexcept return pData->window; } +double TopLevelWidget::getScaleFactor() const noexcept +{ + return pData->window.getScaleFactor(); +} + void TopLevelWidget::repaint() noexcept { pData->window.repaint(); diff --git a/dgl/src/Window.cpp b/dgl/src/Window.cpp @@ -31,17 +31,17 @@ Window::Window(Application& app) Window::Window(Application& app, const uintptr_t parentWindowHandle, - const double scaling, + const double scaleFactor, const bool resizable) - : pData(new PrivateData(app, this, parentWindowHandle, scaling, resizable)) {} + : pData(new PrivateData(app, this, parentWindowHandle, scaleFactor, resizable)) {} Window::Window(Application& app, const uintptr_t parentWindowHandle, const uint width, const uint height, - const double scaling, + const double scaleFactor, const bool resizable) - : pData(new PrivateData(app, this, parentWindowHandle, width, height, scaling, resizable)) {} + : pData(new PrivateData(app, this, parentWindowHandle, width, height, scaleFactor, resizable)) {} Window::~Window() { diff --git a/dgl/src/WindowPrivateData.cpp b/dgl/src/WindowPrivateData.cpp @@ -40,6 +40,16 @@ START_NAMESPACE_DGL // ----------------------------------------------------------------------- +static double getDesktopScaleFactor() +{ + if (const char* const scale = getenv("DPF_SCALE_FACTOR")) + return std::max(1.0, std::atof(scale)); + + return 1.0; +} + +// ----------------------------------------------------------------------- + Window::PrivateData::PrivateData(Application& a, Window* const s) : app(a), appData(a.pData), @@ -49,7 +59,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s) isClosed(true), isVisible(false), isEmbed(false), - scaleFactor(1.0), + scaleFactor(getDesktopScaleFactor()), autoScaling(false), autoScaleFactor(1.0), minWidth(0), @@ -68,7 +78,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, Window& transi isClosed(true), isVisible(false), isEmbed(false), - scaleFactor(1.0), + scaleFactor(getDesktopScaleFactor()), autoScaling(false), autoScaleFactor(1.0), minWidth(0), @@ -91,7 +101,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, isClosed(parentWindowHandle == 0), isVisible(parentWindowHandle != 0), isEmbed(parentWindowHandle != 0), - scaleFactor(scale), + scaleFactor(scale != 0.0 ? scale : getDesktopScaleFactor()), autoScaling(false), autoScaleFactor(1.0), minWidth(0), @@ -125,7 +135,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, isClosed(parentWindowHandle == 0), isVisible(parentWindowHandle != 0), isEmbed(parentWindowHandle != 0), - scaleFactor(scale), + scaleFactor(scale != 0.0 ? scale : getDesktopScaleFactor()), autoScaling(false), autoScaleFactor(1.0), minWidth(0), diff --git a/distrho/src/DistrhoPluginJack.cpp b/distrho/src/DistrhoPluginJack.cpp @@ -83,16 +83,6 @@ static void initSignalHandler() // ----------------------------------------------------------------------- #if DISTRHO_PLUGIN_HAS_UI -// TODO -static double getDesktopScaleFactor() noexcept -{ - return 1.0; -} -#endif - -// ----------------------------------------------------------------------- - -#if DISTRHO_PLUGIN_HAS_UI class PluginJack : public IdleCallback #else class PluginJack @@ -111,7 +101,7 @@ public: nullptr, // file request nullptr, // bundle fPlugin.getInstancePointer(), - getDesktopScaleFactor()), + 0.0), #endif fClient(client) { diff --git a/distrho/src/DistrhoUIInternal.hpp b/distrho/src/DistrhoUIInternal.hpp @@ -137,7 +137,7 @@ public: const fileRequestFunc fileRequestCall, const char* const bundlePath = nullptr, void* const dspPtr = nullptr, - const float scaleFactor = 1.0f, + const double scaleFactor = 1.0, const uint32_t bgColor = 0, const uint32_t fgColor = 0xffffffff) #if DISTRHO_PLUGIN_HAS_EXTERNAL_UI