From 6630dacd37d23d69017441b88717060912aec3ea Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 15 Nov 2021 22:55:47 +0000 Subject: [PATCH] Ildaeil: Show plugin generic GUI after loading patch Signed-off-by: falkTX --- plugins/Cardinal/src/Ildaeil.cpp | 53 ++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/plugins/Cardinal/src/Ildaeil.cpp b/plugins/Cardinal/src/Ildaeil.cpp index 65e72b4..f56aa72 100644 --- a/plugins/Cardinal/src/Ildaeil.cpp +++ b/plugins/Cardinal/src/Ildaeil.cpp @@ -205,6 +205,7 @@ static void host_ui_closed(NativeHostHandle handle); static const char* host_ui_open_file(NativeHostHandle handle, bool isDir, const char* title, const char* filter); static const char* host_ui_save_file(NativeHostHandle handle, bool isDir, const char* title, const char* filter); static intptr_t host_dispatcher(NativeHostHandle handle, NativeHostDispatcherOpcode opcode, int32_t index, intptr_t value, void* ptr, float opt); +static void projectLoadedFromDSP(void* ui); // -------------------------------------------------------------------------------------------------------------------- @@ -418,8 +419,13 @@ struct IldaeilModule : Module { CarlaEngine* const engine = carla_get_engine_from_handle(fCarlaHostHandle); water::XmlDocument xml(projectState); - const MutexLocker cml(sPluginInfoLoadMutex); - engine->loadProjectInternal(xml, true); + + { + const MutexLocker cml(sPluginInfoLoadMutex); + engine->loadProjectInternal(xml, true); + } + + projectLoadedFromDSP(fUI); } void process(const ProcessArgs& args) override @@ -617,6 +623,7 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread { kIdleInit, kIdleInitPluginAlreadyLoaded, kIdleLoadSelectedPlugin, + kIdlePluginLoadedFromDSP, kIdleResetPlugin, kIdleShowCustomUI, kIdleHidePluginUI, @@ -660,15 +667,8 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread { ImGuiStyle& style(ImGui::GetStyle()); style.FrameRounding = 4; - const CarlaHostHandle handle = module->fCarlaHostHandle; - - if (carla_get_current_plugin_count(handle) != 0) - { - const uint hints = carla_get_plugin_info(handle, 0)->hints; + if (checkIfPluginIsLoaded()) fIdleState = kIdleInitPluginAlreadyLoaded; - fPluginRunning = true; - fPluginHasCustomUI = hints & PLUGIN_HAS_CUSTOM_UI; - } module->fUI = this; } @@ -696,6 +696,28 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread { delete[] fPlugins; } + bool checkIfPluginIsLoaded() + { + const CarlaHostHandle handle = module->fCarlaHostHandle; + + if (carla_get_current_plugin_count(handle) != 0) + { + const uint hints = carla_get_plugin_info(handle, 0)->hints; + + fPluginRunning = true; + fPluginHasCustomUI = hints & PLUGIN_HAS_CUSTOM_UI; + return true; + } + + return false; + } + + void projectLoadedFromDSP() + { + if (checkIfPluginIsLoaded()) + fIdleState = kIdlePluginLoadedFromDSP; + } + void changeParameterFromDSP(const uint32_t index, const float value) { if (PluginGenericUI* const ui = fPluginGenericUI) @@ -933,6 +955,11 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread { startThread(); break; + case kIdlePluginLoadedFromDSP: + fIdleState = kIdleNothing; + createOrUpdatePluginGenericUI(handle); + break; + case kIdleLoadSelectedPlugin: fIdleState = kIdleNothing; loadSelectedPlugin(handle); @@ -1403,6 +1430,12 @@ static const char* host_ui_open_file(const NativeHostHandle handle, return nullptr; } +static void projectLoadedFromDSP(void* const ui) +{ + if (IldaeilWidget* const uiw = static_cast(ui)) + uiw->projectLoadedFromDSP(); +} + // -------------------------------------------------------------------------------------------------------------------- struct IldaeilModuleWidget : ModuleWidget {