From 485832aff30132f2e8139719c96a97057aa0fe62 Mon Sep 17 00:00:00 2001 From: falkTX Date: Fri, 11 Feb 2022 01:25:19 +0000 Subject: [PATCH] Get rid of the old DISTRHO_PLUGIN_WANT_STATEFILES Signed-off-by: falkTX --- distrho/DistrhoPlugin.hpp | 6 ++---- distrho/DistrhoUI.hpp | 4 +--- distrho/src/DistrhoPlugin.cpp | 2 -- distrho/src/DistrhoPluginChecks.h | 18 +++++++++--------- distrho/src/DistrhoPluginLV2export.cpp | 17 ++++++++++------- distrho/src/DistrhoUI.cpp | 2 +- distrho/src/DistrhoUIPrivateData.hpp | 4 ++-- examples/FileHandling/DistrhoPluginInfo.h | 1 - 8 files changed, 25 insertions(+), 29 deletions(-) diff --git a/distrho/DistrhoPlugin.hpp b/distrho/DistrhoPlugin.hpp index 98912de6..138caeaa 100644 --- a/distrho/DistrhoPlugin.hpp +++ b/distrho/DistrhoPlugin.hpp @@ -1096,12 +1096,10 @@ protected: */ 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&) {} -#endif -#if DISTRHO_PLUGIN_WANT_STATEFILES - DISTRHO_DEPRECATED_BY("getStateHints") + DISTRHO_DEPRECATED_BY("initState(uint32_t,State&)") virtual bool isStateFile(uint32_t) { return false; } #endif diff --git a/distrho/DistrhoUI.hpp b/distrho/DistrhoUI.hpp index dc09efda..e22a656b 100644 --- a/distrho/DistrhoUI.hpp +++ b/distrho/DistrhoUI.hpp @@ -164,9 +164,7 @@ public: @TODO Document this. */ 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 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. 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); #endif diff --git a/distrho/src/DistrhoPlugin.cpp b/distrho/src/DistrhoPlugin.cpp index b0fa0ae4..9c4c9b65 100644 --- a/distrho/src/DistrhoPlugin.cpp +++ b/distrho/src/DistrhoPlugin.cpp @@ -197,10 +197,8 @@ void Plugin::initState(const uint32_t index, State& state) #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif initState(index, stateKey, defaultStateValue); - #if DISTRHO_PLUGIN_WANT_STATEFILES if (isStateFile(index)) hints = kStateIsFilenamePath; - #endif #if defined(__clang__) #pragma clang diagnostic pop #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) diff --git a/distrho/src/DistrhoPluginChecks.h b/distrho/src/DistrhoPluginChecks.h index dfcda68b..d3d4b174 100644 --- a/distrho/src/DistrhoPluginChecks.h +++ b/distrho/src/DistrhoPluginChecks.h @@ -81,10 +81,6 @@ # define DISTRHO_PLUGIN_WANT_STATE 0 #endif -#ifndef DISTRHO_PLUGIN_WANT_STATEFILES -# define DISTRHO_PLUGIN_WANT_STATEFILES 0 -#endif - #ifndef DISTRHO_PLUGIN_WANT_FULL_STATE # define DISTRHO_PLUGIN_WANT_FULL_STATE 0 # define DISTRHO_PLUGIN_WANT_FULL_STATE_WAS_NOT_SET @@ -137,11 +133,15 @@ #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 // ----------------------------------------------------------------------- diff --git a/distrho/src/DistrhoPluginLV2export.cpp b/distrho/src/DistrhoPluginLV2export.cpp index 9a8f74e4..e1e0fc65 100644 --- a/distrho/src/DistrhoPluginLV2export.cpp +++ b/distrho/src/DistrhoPluginLV2export.cpp @@ -641,8 +641,9 @@ void lv2_generate_ttl(const char* const basename) # if DISTRHO_PLUGIN_WANT_MIDI_INPUT pluginString += " atom:supports midi:MidiEvent ;\n"; # 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 # if DISTRHO_PLUGIN_WANT_TIMEPOS 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 pluginString += " atom:supports midi:MidiEvent ;\n"; # 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 pluginString += " ] ;\n\n"; ++portIndex; @@ -1262,10 +1264,11 @@ void lv2_generate_ttl(const char* const basename) # if DISTRHO_PLUGIN_WANT_FULL_STATE for (uint32_t i=0; i\n"; presetString += " a owl:DatatypeProperty ;\n"; presetString += " rdfs:label \"Plugin state key-value string pair\" ;\n"; diff --git a/distrho/src/DistrhoUI.cpp b/distrho/src/DistrhoUI.cpp index 7366be34..5e98c289 100644 --- a/distrho/src/DistrhoUI.cpp +++ b/distrho/src/DistrhoUI.cpp @@ -264,7 +264,7 @@ void UI::setState(const char* key, const char* value) } #endif -#if DISTRHO_PLUGIN_WANT_STATEFILES +#if DISTRHO_PLUGIN_WANT_STATE bool UI::requestStateFile(const char* key) { return uiData->fileRequestCallback(key); diff --git a/distrho/src/DistrhoUIPrivateData.hpp b/distrho/src/DistrhoUIPrivateData.hpp index e3e846d4..5d56586b 100644 --- a/distrho/src/DistrhoUIPrivateData.hpp +++ b/distrho/src/DistrhoUIPrivateData.hpp @@ -441,7 +441,7 @@ inline bool UI::PrivateData::fileRequestCallback(const char* const key) if (fileRequestCallbackFunc != nullptr) 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); uiStateFileKeyRequest = strdup(key); DISTRHO_SAFE_ASSERT_RETURN(uiStateFileKeyRequest != nullptr, false); @@ -473,7 +473,7 @@ inline void PluginWindow::onFileSelected(const char* const filename) if (initializing) return; -# if DISTRHO_PLUGIN_WANT_STATEFILES +# if DISTRHO_PLUGIN_WANT_STATE if (char* const key = ui->uiData->uiStateFileKeyRequest) { ui->uiData->uiStateFileKeyRequest = nullptr; diff --git a/examples/FileHandling/DistrhoPluginInfo.h b/examples/FileHandling/DistrhoPluginInfo.h index 4b840dfd..cf155408 100644 --- a/examples/FileHandling/DistrhoPluginInfo.h +++ b/examples/FileHandling/DistrhoPluginInfo.h @@ -26,7 +26,6 @@ #define DISTRHO_PLUGIN_NUM_INPUTS 1 #define DISTRHO_PLUGIN_NUM_OUTPUTS 1 #define DISTRHO_PLUGIN_WANT_STATE 1 -#define DISTRHO_PLUGIN_WANT_STATEFILES 1 #define DISTRHO_UI_USER_RESIZABLE 1 #define DISTRHO_UI_USE_NANOVG 1