Browse Source

Ildaeil: Implement file browser requests, used in internal plugins

Signed-off-by: falkTX <falktx@falktx.com>
tags/22.02
falkTX 4 years ago
parent
commit
da4eca8d20
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
1 changed files with 33 additions and 6 deletions
  1. +33
    -6
      plugins/Cardinal/src/Ildaeil.cpp

+ 33
- 6
plugins/Cardinal/src/Ildaeil.cpp View File

@@ -29,6 +29,7 @@


#ifndef HEADLESS #ifndef HEADLESS
# include "ImGuiWidget.hpp" # include "ImGuiWidget.hpp"
# include "extra/FileBrowserDialog.hpp"
# include "extra/ScopedPointer.hpp" # include "extra/ScopedPointer.hpp"
# include "extra/Thread.hpp" # include "extra/Thread.hpp"
#else #else
@@ -649,6 +650,8 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread {


String fPopupError; String fPopupError;


FileBrowserHandle fileBrowserHandle = nullptr;

bool idleCallbackActive = false; bool idleCallbackActive = false;
IldaeilModule* const module; IldaeilModule* const module;


@@ -680,8 +683,13 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread {
if (module->fCarlaHostHandle != nullptr) if (module->fCarlaHostHandle != nullptr)
{ {
if (idleCallbackActive) if (idleCallbackActive)
{
module->pcontext->removeIdleCallback(this); module->pcontext->removeIdleCallback(this);


if (fileBrowserHandle != nullptr)
fileBrowserClose(fileBrowserHandle);
}

if (fPluginRunning) if (fPluginRunning)
carla_show_custom_ui(module->fCarlaHostHandle, 0, false); carla_show_custom_ui(module->fCarlaHostHandle, 0, false);


@@ -741,13 +749,17 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread {
setDirty(true); setDirty(true);
} }


void openFileFromDSP(const bool isDir, const char* const title, const char* const filter)
void openFileFromDSP(bool /* isDir */, const char* const title, const char* /* filter */)
{ {
/*
Window::FileBrowserOptions opts;
DISTRHO_SAFE_ASSERT_RETURN(idleCallbackActive,);
DISTRHO_SAFE_ASSERT_RETURN(fPluginType == PLUGIN_INTERNAL,);

CardinalPluginContext* const pcontext = module->pcontext;

// FIXME isEmbed
FileBrowserOptions opts;
opts.title = title; opts.title = title;
getWindow().openFileBrowser(opts);
*/
fileBrowserHandle = fileBrowserCreate(true, pcontext->nativeWindowId, pcontext->window->pixelRatio, opts);
} }


void createOrUpdatePluginGenericUI(const CarlaHostHandle handle) void createOrUpdatePluginGenericUI(const CarlaHostHandle handle)
@@ -935,6 +947,12 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread {
{ {
idleCallbackActive = false; idleCallbackActive = false;
pcontext->removeIdleCallback(this); pcontext->removeIdleCallback(this);

if (fileBrowserHandle != nullptr)
{
fileBrowserClose(fileBrowserHandle);
fileBrowserHandle = nullptr;
}
} }
} }
} }
@@ -944,6 +962,15 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread {
const CarlaHostHandle handle = module->fCarlaHostHandle; const CarlaHostHandle handle = module->fCarlaHostHandle;
DISTRHO_SAFE_ASSERT_RETURN(handle != nullptr,); DISTRHO_SAFE_ASSERT_RETURN(handle != nullptr,);


if (fileBrowserHandle != nullptr && fileBrowserIdle(fileBrowserHandle))
{
if (const char* const path = fileBrowserGetPath(fileBrowserHandle))
carla_set_custom_data(handle, 0, CUSTOM_DATA_TYPE_STRING, "file", path);

fileBrowserClose(fileBrowserHandle);
fileBrowserHandle = nullptr;
}

switch (fIdleState) switch (fIdleState)
{ {
case kIdleInit: case kIdleInit:
@@ -1079,7 +1106,7 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread {
continue; continue;
if (info->audioIns != 0 && info->audioIns != 2) if (info->audioIns != 0 && info->audioIns != 2)
continue; continue;
if (info->audioOuts != 0 && info->audioOuts != 2)
if (info->audioOuts > 2)
continue; continue;


j = fPluginCount; j = fPluginCount;


Loading…
Cancel
Save