clap

CLAP Audio Plugin API
Log | Files | Refs | README | LICENSE

commit 453be48122938cf131ded00c5e16c888e73d86ab
parent 727b9d6f7480e3701c75b1c6f2a1420107373d4e
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date:   Sun,  1 Aug 2021 13:40:29 +0200

Refactoring

Diffstat:
Mexamples/glue/clap-plugin.cc | 6+++---
Mexamples/glue/clap-plugin.hh | 16++++++++--------
Mexamples/host/plugin-host.cc | 2+-
Mexamples/io/messages.hh | 5+++++
Mexamples/plugins/abstract-gui.hh | 2+-
Mexamples/plugins/plugin-helper.cc | 4++--
Mexamples/plugins/plugin-helper.hh | 2+-
Mexamples/plugins/remote-gui.cc | 7+++++++
Mexamples/plugins/remote-gui.hh | 2+-
Minclude/clap/ext/gui.h | 2+-
10 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/examples/glue/clap-plugin.cc b/examples/glue/clap-plugin.cc @@ -631,11 +631,11 @@ namespace clap { return self.guiCreate(); } - void Plugin::clapGuiClose(const clap_plugin *plugin) noexcept { + void Plugin::clapGuiDestroy(const clap_plugin *plugin) noexcept { auto &self = from(plugin); - self.ensureMainThread("clap_plugin_gui.close"); + self.ensureMainThread("clap_plugin_gui.destroy"); - self.guiClose(); + self.guiDestroy(); } //---------------------// diff --git a/examples/glue/clap-plugin.hh b/examples/glue/clap-plugin.hh @@ -148,16 +148,16 @@ namespace clap { //-----------------// virtual bool implementsGui() const noexcept { return false; } virtual bool guiCreate() noexcept { return false; } - virtual bool guiCanResize() const noexcept { return false; } + virtual void guiDestroy() noexcept {} + virtual void guiSetScale(double scale) noexcept {} + virtual void guiShow() noexcept {} + virtual void guiHide() noexcept {} virtual bool guiSize(uint32_t *width, uint32_t *height) noexcept { return false; } - virtual bool guiSetSize(uint32_t width, uint32_t height) noexcept { return false; } + virtual bool guiCanResize() const noexcept { return false; } virtual void guiRoundSize(uint32_t *width, uint32_t *height) noexcept { guiSize(width, height); } - virtual void guiSetScale(double scale) noexcept {} - virtual void guiShow() noexcept {} - virtual void guiHide() noexcept {} - virtual void guiClose() noexcept {} + virtual bool guiSetSize(uint32_t width, uint32_t height) noexcept { return false; } //---------------------// // clap_plugin_gui_x11 // @@ -335,6 +335,7 @@ namespace clap { // clap_plugin_gui static bool clapGuiCreate(const clap_plugin *plugin) noexcept; + static void clapGuiDestroy(const clap_plugin *plugin) noexcept; static void clapGuiSetScale(const clap_plugin *plugin, double scale) noexcept; static bool clapGuiSize(const clap_plugin *plugin, uint32_t *width, uint32_t *height) noexcept; @@ -345,7 +346,6 @@ namespace clap { static void clapGuiRoundSize(const clap_plugin *plugin, uint32_t *width, uint32_t *height) noexcept; static void clapGuiHide(const clap_plugin *plugin) noexcept; - static void clapGuiClose(const clap_plugin *plugin) noexcept; // clap_plugin_gui_x11 static bool clapGuiX11Attach(const clap_plugin *plugin, @@ -422,7 +422,7 @@ namespace clap { static const constexpr clap_plugin_gui pluginGui_ = { clapGuiCreate, - clapGuiClose, + clapGuiDestroy, clapGuiSetScale, clapGuiSize, clapGuiCanResize, diff --git a/examples/host/plugin-host.cc b/examples/host/plugin-host.cc @@ -182,7 +182,7 @@ void PluginHost::unload() { return; if (pluginGui_) - pluginGui_->close(plugin_); + pluginGui_->destroy(plugin_); if (isPluginActive()) { plugin_->deactivate(plugin_); diff --git a/examples/io/messages.hh b/examples/io/messages.hh @@ -22,6 +22,7 @@ namespace clap::messages { kShowRequest, kShowResponse, kHideRequest, + kHideResponse, kCloseRequest, // Gui, Plugin->Host @@ -78,6 +79,10 @@ namespace clap::messages { static const constexpr Type type = kHideRequest; }; + struct HideResponse final { + static const constexpr Type type = kHideResponse; + }; + struct CloseRequest final { static const constexpr Type type = kCloseRequest; }; diff --git a/examples/plugins/abstract-gui.hh b/examples/plugins/abstract-gui.hh @@ -20,7 +20,7 @@ namespace clap { virtual bool show() noexcept = 0; virtual bool hide() noexcept = 0; - virtual void close() noexcept = 0; + virtual void destroy() noexcept = 0; protected: PluginHelper &plugin_; diff --git a/examples/plugins/plugin-helper.cc b/examples/plugins/plugin-helper.cc @@ -102,8 +102,8 @@ namespace clap { remoteGui_->hide(); } - void PluginHelper::guiClose() noexcept { + void PluginHelper::guiDestroy() noexcept { if (remoteGui_) - remoteGui_->close(); + remoteGui_->destroy(); } } // namespace clap \ No newline at end of file diff --git a/examples/plugins/plugin-helper.hh b/examples/plugins/plugin-helper.hh @@ -87,7 +87,7 @@ namespace clap { void guiSetScale(double scale) noexcept override; void guiShow() noexcept override; void guiHide() noexcept override; - void guiClose() noexcept override; + void guiDestroy() noexcept override; //---------------------// // clap_plugin_gui_x11 // diff --git a/examples/plugins/remote-gui.cc b/examples/plugins/remote-gui.cc @@ -73,4 +73,11 @@ namespace clap { return channel_->sendMessageSync(request, response); } + bool RemoteGui::hide() noexcept { + messages::HideRequest request; + messages::HideResponse response; + + return channel_->sendMessageSync(request, response); + } + } // namespace clap \ No newline at end of file diff --git a/examples/plugins/remote-gui.hh b/examples/plugins/remote-gui.hh @@ -26,7 +26,7 @@ namespace clap { bool show() noexcept override; bool hide() noexcept override; - void close() noexcept override; + void destroy() noexcept override; // RemoteChannel::EventControl void modifyFd(clap_fd_flags flags) override; diff --git a/include/clap/ext/gui.h b/include/clap/ext/gui.h @@ -37,7 +37,7 @@ typedef struct clap_plugin_gui { // Free all resources associated with the gui. // [main-thread] - void (*close)(const clap_plugin *plugin); + void (*destroy)(const clap_plugin *plugin); // Set the absolute GUI scaling factor. // [main-thread]