DPF

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

commit 94f148a575dc7a2282fc4de733cc97dfd41196f8
parent bb33ac67bc3713a1fe2dd85104f93e466e04b806
Author: falkTX <falktx@falktx.com>
Date:   Sun, 11 Sep 2022 15:51:18 +0100

LV2: use desktop scale factor if not provided by host or in macOS

Diffstat:
Mdistrho/src/DistrhoUILV2.cpp | 20++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/distrho/src/DistrhoUILV2.cpp b/distrho/src/DistrhoUILV2.cpp @@ -556,7 +556,7 @@ static LV2UI_Handle lv2ui_instantiate(const LV2UI_Descriptor*, const intptr_t winId = (intptr_t)parentId; float sampleRate = 0.0f; - float scaleFactor = 1.0f; + float scaleFactor = 0.0f; uint32_t bgColor = 0; uint32_t fgColor = 0xffffffff; @@ -567,7 +567,9 @@ static LV2UI_Handle lv2ui_instantiate(const LV2UI_Descriptor*, const LV2_URID uridSampleRate = uridMap->map(uridMap->handle, LV2_PARAMETERS__sampleRate); const LV2_URID uridBgColor = uridMap->map(uridMap->handle, LV2_UI__backgroundColor); const LV2_URID uridFgColor = uridMap->map(uridMap->handle, LV2_UI__foregroundColor); + #ifndef DISTRHO_OS_MAC const LV2_URID uridScaleFactor = uridMap->map(uridMap->handle, LV2_UI__scaleFactor); + #endif for (int i=0; options[i].key != 0; ++i) { @@ -578,13 +580,6 @@ static LV2UI_Handle lv2ui_instantiate(const LV2UI_Descriptor*, else d_stderr("Host provides UI sample-rate but has wrong value type"); } - else if (options[i].key == uridScaleFactor) - { - if (options[i].type == uridAtomFloat) - scaleFactor = *(const float*)options[i].value; - else - d_stderr("Host provides UI scale factor but has wrong value type"); - } else if (options[i].key == uridBgColor) { if (options[i].type == uridAtomInt) @@ -599,6 +594,15 @@ static LV2UI_Handle lv2ui_instantiate(const LV2UI_Descriptor*, else d_stderr("Host provides UI foreground color but has wrong value type"); } + #ifndef DISTRHO_OS_MAC + else if (options[i].key == uridScaleFactor) + { + if (options[i].type == uridAtomFloat) + scaleFactor = *(const float*)options[i].value; + else + d_stderr("Host provides UI scale factor but has wrong value type"); + } + #endif } }