Browse Source

Allow DPF_SCALE_FACTOR env var for quickly testing scale factors

Signed-off-by: falkTX <falktx@falktx.com>
pull/272/head
falkTX 4 years ago
parent
commit
04032b02e3
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
7 changed files with 28 additions and 22 deletions
  1. +1
    -0
      dgl/TopLevelWidget.hpp
  2. +2
    -2
      dgl/Window.hpp
  3. +5
    -0
      dgl/src/TopLevelWidget.cpp
  4. +4
    -4
      dgl/src/Window.cpp
  5. +14
    -4
      dgl/src/WindowPrivateData.cpp
  6. +1
    -11
      distrho/src/DistrhoPluginJack.cpp
  7. +1
    -1
      distrho/src/DistrhoUIInternal.hpp

+ 1
- 0
dgl/TopLevelWidget.hpp View File

@@ -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,


+ 2
- 2
dgl/Window.hpp View File

@@ -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);

/**


+ 5
- 0
dgl/src/TopLevelWidget.cpp View File

@@ -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();


+ 4
- 4
dgl/src/Window.cpp View File

@@ -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()
{


+ 14
- 4
dgl/src/WindowPrivateData.cpp View File

@@ -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),


+ 1
- 11
distrho/src/DistrhoPluginJack.cpp View File

@@ -82,16 +82,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
@@ -111,7 +101,7 @@ public:
nullptr, // file request
nullptr, // bundle
fPlugin.getInstancePointer(),
getDesktopScaleFactor()),
0.0),
#endif
fClient(client)
{


+ 1
- 1
distrho/src/DistrhoUIInternal.hpp View File

@@ -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


Loading…
Cancel
Save