Skip to content

Commit

Permalink
Bring Ildaeil fixes from the other side
Browse files Browse the repository at this point in the history
  • Loading branch information
falkTX committed Jul 15, 2022
1 parent e840ca0 commit 3b3f155
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 13 deletions.
57 changes: 45 additions & 12 deletions plugins/Cardinal/src/Ildaeil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Runner {
kIdleLoadSelectedPlugin,
kIdlePluginLoadedFromDSP,
kIdleResetPlugin,
kIdleOpenFileUI,
kIdleShowCustomUI,
kIdleHidePluginUI,
kIdleGiveIdleToUI,
Expand Down Expand Up @@ -693,6 +694,7 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Runner {
int fPluginSelected = -1;
bool fPluginScanningFinished = false;
bool fPluginHasCustomUI = false;
bool fPluginHasFileOpen = false;
bool fPluginHasOutputParameters = false;
bool fPluginRunning = false;
bool fPluginWillRunInBridgeMode = false;
Expand Down Expand Up @@ -762,16 +764,28 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Runner {
{
const CarlaHostHandle handle = module->fCarlaHostHandle;

if (carla_get_current_plugin_count(handle) != 0)
{
const uint hints = carla_get_plugin_info(handle, 0)->hints;
if (carla_get_current_plugin_count(handle) == 0)
return false;

fPluginRunning = true;
const uint hints = carla_get_plugin_info(handle, 0)->hints;
updatePluginFlags(hints);

fPluginRunning = true;
return true;
}

void updatePluginFlags(const uint hints) noexcept
{
if (hints & PLUGIN_HAS_CUSTOM_UI_USING_FILE_OPEN)
{
fPluginHasCustomUI = false;
fPluginHasFileOpen = true;
}
else
{
fPluginHasCustomUI = hints & PLUGIN_HAS_CUSTOM_UI;
return true;
fPluginHasFileOpen = false;
}

return false;
}

void projectLoadedFromDSP()
Expand Down Expand Up @@ -828,7 +842,8 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Runner {
const CarlaPluginInfo* const info = carla_get_plugin_info(handle, 0);

fDrawingState = kDrawingPluginGenericUI;
fPluginHasCustomUI = info->hints & PLUGIN_HAS_CUSTOM_UI;
updatePluginFlags(info->hints);

if (fPluginGenericUI == nullptr)
createPluginGenericUI(handle, info);
else
Expand Down Expand Up @@ -1061,6 +1076,8 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Runner {
case kIdlePluginLoadedFromDSP:
fIdleState = kIdleNothing;
createOrUpdatePluginGenericUI(handle);
if (fRunnerData.needsReinit)
initAndStartRunner();
break;

case kIdleLoadSelectedPlugin:
Expand All @@ -1073,6 +1090,11 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Runner {
loadPlugin(handle, carla_get_plugin_info(handle, 0)->label);
break;

case kIdleOpenFileUI:
fIdleState = kIdleNothing;
carla_show_custom_ui(handle, 0, true);
break;

case kIdleShowCustomUI:
fIdleState = kIdleGiveIdleToUI;
carla_show_custom_ui(handle, 0, true);
Expand Down Expand Up @@ -1338,12 +1360,23 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Runner {
if (ImGui::Button("Reset"))
fIdleState = kIdleResetPlugin;

if (fDrawingState == kDrawingPluginGenericUI && fPluginHasCustomUI)
if (fDrawingState == kDrawingPluginGenericUI)
{
ImGui::SameLine();
if (fPluginHasCustomUI)
{
ImGui::SameLine();

if (ImGui::Button("Show Custom GUI"))
fIdleState = kIdleShowCustomUI;
}

if (ImGui::Button("Show Custom GUI"))
fIdleState = kIdleShowCustomUI;
if (fPluginHasFileOpen)
{
ImGui::SameLine();

if (ImGui::Button("Open File..."))
fIdleState = kIdleOpenFileUI;
}
}
}

Expand Down

0 comments on commit 3b3f155

Please sign in to comment.