Browse Source

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

pull/321/merge
falkTX 3 years ago
parent
commit
94f148a575
1 changed files with 12 additions and 8 deletions
  1. +12
    -8
      distrho/src/DistrhoUILV2.cpp

+ 12
- 8
distrho/src/DistrhoUILV2.cpp View File

@@ -556,7 +556,7 @@ static LV2UI_Handle lv2ui_instantiate(const LV2UI_Descriptor*,


const intptr_t winId = (intptr_t)parentId; const intptr_t winId = (intptr_t)parentId;
float sampleRate = 0.0f; float sampleRate = 0.0f;
float scaleFactor = 1.0f;
float scaleFactor = 0.0f;
uint32_t bgColor = 0; uint32_t bgColor = 0;
uint32_t fgColor = 0xffffffff; 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 uridSampleRate = uridMap->map(uridMap->handle, LV2_PARAMETERS__sampleRate);
const LV2_URID uridBgColor = uridMap->map(uridMap->handle, LV2_UI__backgroundColor); const LV2_URID uridBgColor = uridMap->map(uridMap->handle, LV2_UI__backgroundColor);
const LV2_URID uridFgColor = uridMap->map(uridMap->handle, LV2_UI__foregroundColor); 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); const LV2_URID uridScaleFactor = uridMap->map(uridMap->handle, LV2_UI__scaleFactor);
#endif


for (int i=0; options[i].key != 0; ++i) for (int i=0; options[i].key != 0; ++i)
{ {
@@ -578,13 +580,6 @@ static LV2UI_Handle lv2ui_instantiate(const LV2UI_Descriptor*,
else else
d_stderr("Host provides UI sample-rate but has wrong value type"); 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) else if (options[i].key == uridBgColor)
{ {
if (options[i].type == uridAtomInt) if (options[i].type == uridAtomInt)
@@ -599,6 +594,15 @@ static LV2UI_Handle lv2ui_instantiate(const LV2UI_Descriptor*,
else else
d_stderr("Host provides UI foreground color but has wrong value type"); 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
} }
} }




Loading…
Cancel
Save