Signed-off-by: falkTX <falktx@falktx.com>pull/375/head
@@ -1096,12 +1096,10 @@ protected: | |||||
*/ | */ | ||||
virtual void initState(uint32_t index, State& state); | virtual void initState(uint32_t index, State& state); | ||||
DISTRHO_DEPRECATED_BY("getStateHints(uint32_t,State&)") | |||||
DISTRHO_DEPRECATED_BY("initState(uint32_t,State&)") | |||||
virtual void initState(uint32_t, String&, String&) {} | virtual void initState(uint32_t, String&, String&) {} | ||||
#endif | |||||
#if DISTRHO_PLUGIN_WANT_STATEFILES | |||||
DISTRHO_DEPRECATED_BY("getStateHints") | |||||
DISTRHO_DEPRECATED_BY("initState(uint32_t,State&)") | |||||
virtual bool isStateFile(uint32_t) { return false; } | virtual bool isStateFile(uint32_t) { return false; } | ||||
#endif | #endif | ||||
@@ -164,9 +164,7 @@ public: | |||||
@TODO Document this. | @TODO Document this. | ||||
*/ | */ | ||||
void setState(const char* key, const char* value); | void setState(const char* key, const char* value); | ||||
#endif | |||||
#if DISTRHO_PLUGIN_WANT_STATEFILES | |||||
/** | /** | ||||
Request a new file from the host, matching the properties of a state key.@n | Request a new file from the host, matching the properties of a state key.@n | ||||
This will use the native host file browser if available, otherwise a DPF built-in file browser is used.@n | This will use the native host file browser if available, otherwise a DPF built-in file browser is used.@n | ||||
@@ -327,7 +325,7 @@ protected: | |||||
This action happens after the user confirms the action, so the file browser dialog will be closed at this point. | This action happens after the user confirms the action, so the file browser dialog will be closed at this point. | ||||
The default implementation does nothing. | The default implementation does nothing. | ||||
If you need to use files as plugin state, please setup and use DISTRHO_PLUGIN_WANT_STATEFILES instead. | |||||
If you need to use files as plugin state, please setup and use states with kStateIsFilenamePath instead. | |||||
*/ | */ | ||||
virtual void uiFileBrowserSelected(const char* filename); | virtual void uiFileBrowserSelected(const char* filename); | ||||
#endif | #endif | ||||
@@ -197,10 +197,8 @@ void Plugin::initState(const uint32_t index, State& state) | |||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | ||||
#endif | #endif | ||||
initState(index, stateKey, defaultStateValue); | initState(index, stateKey, defaultStateValue); | ||||
#if DISTRHO_PLUGIN_WANT_STATEFILES | |||||
if (isStateFile(index)) | if (isStateFile(index)) | ||||
hints = kStateIsFilenamePath; | hints = kStateIsFilenamePath; | ||||
#endif | |||||
#if defined(__clang__) | #if defined(__clang__) | ||||
#pragma clang diagnostic pop | #pragma clang diagnostic pop | ||||
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) | #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) | ||||
@@ -81,10 +81,6 @@ | |||||
# define DISTRHO_PLUGIN_WANT_STATE 0 | # define DISTRHO_PLUGIN_WANT_STATE 0 | ||||
#endif | #endif | ||||
#ifndef DISTRHO_PLUGIN_WANT_STATEFILES | |||||
# define DISTRHO_PLUGIN_WANT_STATEFILES 0 | |||||
#endif | |||||
#ifndef DISTRHO_PLUGIN_WANT_FULL_STATE | #ifndef DISTRHO_PLUGIN_WANT_FULL_STATE | ||||
# define DISTRHO_PLUGIN_WANT_FULL_STATE 0 | # define DISTRHO_PLUGIN_WANT_FULL_STATE 0 | ||||
# define DISTRHO_PLUGIN_WANT_FULL_STATE_WAS_NOT_SET | # define DISTRHO_PLUGIN_WANT_FULL_STATE_WAS_NOT_SET | ||||
@@ -137,11 +133,15 @@ | |||||
#endif | #endif | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
// Enable state if plugin wants state files | |||||
#if DISTRHO_PLUGIN_WANT_STATEFILES && ! DISTRHO_PLUGIN_WANT_STATE | |||||
# undef DISTRHO_PLUGIN_WANT_STATE | |||||
# define DISTRHO_PLUGIN_WANT_STATE 1 | |||||
// Enable state if plugin wants state files (deprecated) | |||||
#ifdef DISTRHO_PLUGIN_WANT_STATEFILES | |||||
# warning DISTRHO_PLUGIN_WANT_STATEFILES is deprecated | |||||
# undef DISTRHO_PLUGIN_WANT_STATEFILES | |||||
# if ! DISTRHO_PLUGIN_WANT_STATE | |||||
# undef DISTRHO_PLUGIN_WANT_STATE | |||||
# define DISTRHO_PLUGIN_WANT_STATE 1 | |||||
# endif | |||||
#endif | #endif | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
@@ -641,8 +641,9 @@ void lv2_generate_ttl(const char* const basename) | |||||
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT | # if DISTRHO_PLUGIN_WANT_MIDI_INPUT | ||||
pluginString += " atom:supports midi:MidiEvent ;\n"; | pluginString += " atom:supports midi:MidiEvent ;\n"; | ||||
# endif | # endif | ||||
# if DISTRHO_PLUGIN_WANT_STATEFILES | |||||
pluginString += " atom:supports <" LV2_PATCH__Message "> ;\n"; | |||||
# if DISTRHO_PLUGIN_WANT_STATE | |||||
if (hasHostVisibleState) | |||||
pluginString += " atom:supports <" LV2_PATCH__Message "> ;\n"; | |||||
# endif | # endif | ||||
# if DISTRHO_PLUGIN_WANT_TIMEPOS | # if DISTRHO_PLUGIN_WANT_TIMEPOS | ||||
pluginString += " atom:supports <" LV2_TIME__Position "> ;\n"; | pluginString += " atom:supports <" LV2_TIME__Position "> ;\n"; | ||||
@@ -665,8 +666,9 @@ void lv2_generate_ttl(const char* const basename) | |||||
# if DISTRHO_PLUGIN_WANT_MIDI_OUTPUT | # if DISTRHO_PLUGIN_WANT_MIDI_OUTPUT | ||||
pluginString += " atom:supports midi:MidiEvent ;\n"; | pluginString += " atom:supports midi:MidiEvent ;\n"; | ||||
# endif | # endif | ||||
# if DISTRHO_PLUGIN_WANT_STATEFILES | |||||
pluginString += " atom:supports <" LV2_PATCH__Message "> ;\n"; | |||||
# if DISTRHO_PLUGIN_WANT_STATE | |||||
if (hasHostVisibleState) | |||||
pluginString += " atom:supports <" LV2_PATCH__Message "> ;\n"; | |||||
# endif | # endif | ||||
pluginString += " ] ;\n\n"; | pluginString += " ] ;\n\n"; | ||||
++portIndex; | ++portIndex; | ||||
@@ -1262,10 +1264,11 @@ void lv2_generate_ttl(const char* const basename) | |||||
# if DISTRHO_PLUGIN_WANT_FULL_STATE | # if DISTRHO_PLUGIN_WANT_FULL_STATE | ||||
for (uint32_t i=0; i<numStates; ++i) | for (uint32_t i=0; i<numStates; ++i) | ||||
{ | { | ||||
# if DISTRHO_PLUGIN_WANT_STATEFILES | |||||
if (plugin.isStateFile(i)) | |||||
if (plugin.getStateHints(i) & kStateIsHostReadable) | |||||
continue; | continue; | ||||
# endif | |||||
// readable states are defined as lv2 parameters. | |||||
// non-readable states have no definition, but one is needed for presets and ttl validation. | |||||
presetString = "<" DISTRHO_PLUGIN_LV2_STATE_PREFIX + plugin.getStateKey(i) + ">\n"; | presetString = "<" DISTRHO_PLUGIN_LV2_STATE_PREFIX + plugin.getStateKey(i) + ">\n"; | ||||
presetString += " a owl:DatatypeProperty ;\n"; | presetString += " a owl:DatatypeProperty ;\n"; | ||||
presetString += " rdfs:label \"Plugin state key-value string pair\" ;\n"; | presetString += " rdfs:label \"Plugin state key-value string pair\" ;\n"; | ||||
@@ -264,7 +264,7 @@ void UI::setState(const char* key, const char* value) | |||||
} | } | ||||
#endif | #endif | ||||
#if DISTRHO_PLUGIN_WANT_STATEFILES | |||||
#if DISTRHO_PLUGIN_WANT_STATE | |||||
bool UI::requestStateFile(const char* key) | bool UI::requestStateFile(const char* key) | ||||
{ | { | ||||
return uiData->fileRequestCallback(key); | return uiData->fileRequestCallback(key); | ||||
@@ -441,7 +441,7 @@ inline bool UI::PrivateData::fileRequestCallback(const char* const key) | |||||
if (fileRequestCallbackFunc != nullptr) | if (fileRequestCallbackFunc != nullptr) | ||||
return fileRequestCallbackFunc(callbacksPtr, key); | return fileRequestCallbackFunc(callbacksPtr, key); | ||||
#if DISTRHO_PLUGIN_WANT_STATEFILES && !DISTRHO_PLUGIN_HAS_EXTERNAL_UI && !defined(DGL_FILE_BROWSER_DISABLED) | |||||
#if DISTRHO_PLUGIN_WANT_STATE && !DISTRHO_PLUGIN_HAS_EXTERNAL_UI && !defined(DGL_FILE_BROWSER_DISABLED) | |||||
std::free(uiStateFileKeyRequest); | std::free(uiStateFileKeyRequest); | ||||
uiStateFileKeyRequest = strdup(key); | uiStateFileKeyRequest = strdup(key); | ||||
DISTRHO_SAFE_ASSERT_RETURN(uiStateFileKeyRequest != nullptr, false); | DISTRHO_SAFE_ASSERT_RETURN(uiStateFileKeyRequest != nullptr, false); | ||||
@@ -473,7 +473,7 @@ inline void PluginWindow::onFileSelected(const char* const filename) | |||||
if (initializing) | if (initializing) | ||||
return; | return; | ||||
# if DISTRHO_PLUGIN_WANT_STATEFILES | |||||
# if DISTRHO_PLUGIN_WANT_STATE | |||||
if (char* const key = ui->uiData->uiStateFileKeyRequest) | if (char* const key = ui->uiData->uiStateFileKeyRequest) | ||||
{ | { | ||||
ui->uiData->uiStateFileKeyRequest = nullptr; | ui->uiData->uiStateFileKeyRequest = nullptr; | ||||
@@ -26,7 +26,6 @@ | |||||
#define DISTRHO_PLUGIN_NUM_INPUTS 1 | #define DISTRHO_PLUGIN_NUM_INPUTS 1 | ||||
#define DISTRHO_PLUGIN_NUM_OUTPUTS 1 | #define DISTRHO_PLUGIN_NUM_OUTPUTS 1 | ||||
#define DISTRHO_PLUGIN_WANT_STATE 1 | #define DISTRHO_PLUGIN_WANT_STATE 1 | ||||
#define DISTRHO_PLUGIN_WANT_STATEFILES 1 | |||||
#define DISTRHO_UI_USER_RESIZABLE 1 | #define DISTRHO_UI_USER_RESIZABLE 1 | ||||
#define DISTRHO_UI_USE_NANOVG 1 | #define DISTRHO_UI_USE_NANOVG 1 | ||||