From 75024944e81dbe22c2d00c8d5f386545ebf70a50 Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 14 Oct 2021 02:24:04 +0100 Subject: [PATCH] Add Reset button Signed-off-by: falkTX --- plugins/Common/IldaeilUI.cpp | 45 ++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/plugins/Common/IldaeilUI.cpp b/plugins/Common/IldaeilUI.cpp index 30e0b3a..2d6a3b6 100644 --- a/plugins/Common/IldaeilUI.cpp +++ b/plugins/Common/IldaeilUI.cpp @@ -323,6 +323,25 @@ public: } } + bool loadPlugin(const CarlaHostHandle handle, const char* const label) + { + if (carla_get_current_plugin_count(handle) != 0) + { + hidePluginUI(); + carla_replace_plugin(handle, 0); + } + + if (carla_add_plugin(handle, BINARY_NATIVE, PLUGIN_LV2, nullptr, nullptr, + label, 0, 0x0, PLUGIN_OPTIONS_NULL)) + { + fPluginGenericUI = nullptr; + showPluginUI(handle); + return true; + } + + return false; + } + protected: void pluginWindowResized(uint width, uint height) override { @@ -444,6 +463,13 @@ protected: setSize(kInitialWidth * scaleFactor, kInitialHeight * scaleFactor); } + ImGui::SameLine(); + + if (ImGui::Button("Reset")) + { + loadPlugin(handle, carla_get_plugin_info(handle, 0)->label); + } + if (fDrawingState == kDrawingPluginGenericUI && fPluginHasCustomUI) { ImGui::SameLine(); @@ -574,7 +600,6 @@ protected: setupMainWindowPos(); const CarlaHostHandle handle = fPlugin->fCarlaHostHandle; - const bool pluginIsRunning = carla_get_current_plugin_count(handle) != 0; if (ImGui::Begin("Plugin List", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize)) { @@ -585,12 +610,6 @@ protected: if (ImGui::Button("Load Plugin")) { - if (pluginIsRunning) - { - hidePluginUI(); - carla_replace_plugin(handle, 0); - } - do { const PluginInfoCache& info(fPlugins[fPluginSelected]); @@ -599,22 +618,16 @@ protected: d_stdout("Loading %s...", info.name); - if (carla_add_plugin(handle, BINARY_NATIVE, PLUGIN_LV2, nullptr, nullptr, - slash+1, 0, 0x0, PLUGIN_OPTIONS_NULL)) + if (loadPlugin(handle, slash+1)) { - fPluginGenericUI = nullptr; - showPluginUI(handle); ImGui::EndDisabled(); ImGui::End(); return; } - } while (false); } - ImGui::EndDisabled(); - - if (pluginIsRunning) + if (carla_get_current_plugin_count(handle) != 0) { ImGui::SameLine(); @@ -624,6 +637,8 @@ protected: } } + ImGui::EndDisabled(); + if (ImGui::BeginChild("pluginlistwindow")) { if (ImGui::BeginTable("pluginlist", 3, ImGuiTableFlags_NoSavedSettings|ImGuiTableFlags_NoClip))