Define custom Cardinal API for async dialogs

Closes #51

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2021-12-11 21:53:50 +00:00
parent b6ac2766dc
commit ce64476fa4
No known key found for this signature in database
GPG key ID: CDBAA37ABC74FBA0
6 changed files with 242 additions and 8 deletions

View file

@ -30,6 +30,7 @@
#ifndef HEADLESS
# include "DistrhoUI.hpp"
# include "extra/FileBrowserDialog.hpp"
#endif
START_NAMESPACE_DISTRHO
@ -131,15 +132,25 @@ public:
CardinalPluginContext* const context;
bool saving;
// for 3rd party modules
std::function<void(char* path)> filebrowseraction;
FileBrowserHandle filebrowserhandle;
CardinalBaseUI(const uint width, const uint height)
: UI(width, height),
context(getRackContextFromPlugin(getPluginInstancePointer())),
saving(false)
saving(false),
filebrowseraction(),
filebrowserhandle(nullptr)
{
context->ui = this;
}
~CardinalBaseUI() override
{
if (filebrowserhandle != nullptr)
fileBrowserClose(filebrowserhandle);
context->ui = nullptr;
}
};