Browse Source

Handle custom application class name as needed for modguis

Signed-off-by: falkTX <falktx@falktx.com>
pull/397/head
falkTX 2 years ago
parent
commit
f12d52d9e2
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 49 additions and 21 deletions
  1. +4
    -2
      dgl/src/ApplicationPrivateData.cpp
  2. +3
    -2
      distrho/src/DistrhoUIInternal.hpp
  3. +22
    -3
      distrho/src/DistrhoUILV2.cpp
  4. +20
    -14
      distrho/src/DistrhoUIPrivateData.hpp

+ 4
- 2
dgl/src/ApplicationPrivateData.cpp View File

@@ -67,9 +67,11 @@ Application::PrivateData::PrivateData(const bool standalone)
DISTRHO_SAFE_ASSERT_RETURN(world != nullptr,);

puglSetWorldHandle(world, this);
#ifndef __EMSCRIPTEN__
#ifdef __EMSCRIPTEN__
puglSetClassName(world, "canvas");
#else
puglSetClassName(world, DISTRHO_MACRO_AS_STRING(DGL_NAMESPACE));
#endif
#endif
}

Application::PrivateData::~PrivateData()


+ 3
- 2
distrho/src/DistrhoUIInternal.hpp View File

@@ -57,9 +57,10 @@ public:
void* const dspPtr = nullptr,
const double scaleFactor = 0.0,
const uint32_t bgColor = 0,
const uint32_t fgColor = 0xffffffff)
const uint32_t fgColor = 0xffffffff,
const char* const appClassName = nullptr)
: ui(nullptr),
uiData(new UI::PrivateData())
uiData(new UI::PrivateData(appClassName))
{
uiData->sampleRate = sampleRate;
uiData->bundlePath = bundlePath != nullptr ? strdup(bundlePath) : nullptr;


+ 22
- 3
distrho/src/DistrhoUILV2.cpp View File

@@ -78,7 +78,8 @@ public:
const float sampleRate,
const float scaleFactor,
const uint32_t bgColor,
const uint32_t fgColor)
const uint32_t fgColor,
const char* const appClassName)
: fUridMap(uridMap),
fUridUnmap(getLv2Feature<LV2_URID_Unmap>(features, LV2_URID__unmap)),
fUiPortMap(getLv2Feature<LV2UI_Port_Map>(features, LV2_UI__portMap)),
@@ -97,7 +98,7 @@ public:
sendNoteCallback,
nullptr, // resize is very messy, hosts can do it without extensions
fileRequestCallback,
bundlePath, dspPtr, scaleFactor, bgColor, fgColor)
bundlePath, dspPtr, scaleFactor, bgColor, fgColor, appClassName)
{
if (widget != nullptr)
*widget = (LV2UI_Widget)fUI.getNativeWindowHandle();
@@ -559,17 +560,20 @@ static LV2UI_Handle lv2ui_instantiate(const LV2UI_Descriptor*,
float scaleFactor = 0.0f;
uint32_t bgColor = 0;
uint32_t fgColor = 0xffffffff;
const char* appClassName = nullptr;

if (options != nullptr)
{
const LV2_URID uridAtomInt = uridMap->map(uridMap->handle, LV2_ATOM__Int);
const LV2_URID uridAtomFloat = uridMap->map(uridMap->handle, LV2_ATOM__Float);
const LV2_URID uridAtomString = uridMap->map(uridMap->handle, LV2_ATOM__String);
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
const LV2_URID uridClassName = uridMap->map(uridMap->handle, "urn:distrho:className");

for (int i=0; options[i].key != 0; ++i)
{
@@ -603,6 +607,13 @@ static LV2UI_Handle lv2ui_instantiate(const LV2UI_Descriptor*,
d_stderr("Host provides UI scale factor but has wrong value type");
}
#endif
else if (options[i].key == uridClassName)
{
if (options[i].type == uridAtomString)
appClassName = (const char*)options[i].value;
else
d_stderr("Host provides UI scale factor but has wrong value type");
}
}
}

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

return new UiLv2(bundlePath, winId, options, uridMap, features,
controller, writeFunction, widget, instance,
sampleRate, scaleFactor, bgColor, fgColor);
sampleRate, scaleFactor, bgColor, fgColor, appClassName);
}

#define uiPtr ((UiLv2*)ui)
@@ -823,6 +834,14 @@ LV2UI_Handle modgui_init(const char* const className, _custom_param_set param_se
uridMap.map(uridMap.handle, LV2_ATOM__Float),
&sampleRateValue
},
{
LV2_OPTIONS_INSTANCE,
0,
uridMap.map(uridMap.handle, "urn:distrho:className"),
std::strlen(className) + 1,
uridMap.map(uridMap.handle, LV2_ATOM__String),
className
},
{}
};



+ 20
- 14
distrho/src/DistrhoUIPrivateData.hpp View File

@@ -60,7 +60,7 @@ struct PluginApplication
DGL_NAMESPACE::IdleCallback* idleCallback;
UI* ui;

explicit PluginApplication()
explicit PluginApplication(const char*)
: idleCallback(nullptr),
ui(nullptr) {}

@@ -105,20 +105,26 @@ struct PluginApplication
class PluginApplication : public DGL_NAMESPACE::Application
{
public:
explicit PluginApplication()
explicit PluginApplication(const char* className)
: DGL_NAMESPACE::Application(DISTRHO_UI_IS_STANDALONE)
{
#ifndef DISTRHO_OS_WASM
const char* const className = (
#ifdef DISTRHO_PLUGIN_BRAND
DISTRHO_PLUGIN_BRAND
#else
DISTRHO_MACRO_AS_STRING(DISTRHO_NAMESPACE)
#endif
"-" DISTRHO_PLUGIN_NAME
);
#if defined(__MOD_DEVICES__) || !defined(__EMSCRIPTEN__)
if (className == nullptr)
{
className = (
#ifdef DISTRHO_PLUGIN_BRAND
DISTRHO_PLUGIN_BRAND
#else
DISTRHO_MACRO_AS_STRING(DISTRHO_NAMESPACE)
#endif
"-" DISTRHO_PLUGIN_NAME
);
}
setClassName(className);
#endif
#else
// unused
(void)className;
#endif
}

void triggerIdleCallbacks()
@@ -337,8 +343,8 @@ struct UI::PrivateData {
setSizeFunc setSizeCallbackFunc;
fileRequestFunc fileRequestCallbackFunc;

PrivateData() noexcept
: app(),
PrivateData(const char* const appClassName) noexcept
: app(appClassName),
window(nullptr),
sampleRate(0),
parameterOffset(0),


Loading…
Cancel
Save