From 72e5ec2c5eab426ce66f70e8a66fba24ff3ae86f Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 6 Oct 2021 05:04:57 +0200 Subject: [PATCH] Prototype LV2 dialog-message feature extension --- gtk2_ardour/lv2_plugin_ui.cc | 26 ++++++++++++++++++++++++-- libs/ardour/ardour/lv2_extensions.h | 25 +++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/lv2_plugin_ui.cc b/gtk2_ardour/lv2_plugin_ui.cc index dbb3973b52..ae7f5b76ea 100644 --- a/gtk2_ardour/lv2_plugin_ui.cc +++ b/gtk2_ardour/lv2_plugin_ui.cc @@ -140,7 +140,9 @@ LV2PluginUI::request_response (int response, } break; case Variant::BOOL: - set_path_property (desc.key, Variant (Variant::BOOL, response == Gtk::RESPONSE_YES)); + if (response != Gtk::BUTTONS_OK) { + set_path_property (desc.key, Variant (Variant::BOOL, response == Gtk::RESPONSE_YES)); + } break; default: break; @@ -197,7 +199,27 @@ LV2PluginUI::request_value(void* handle, case Variant::BOOL: { - ArdourMessageDialog* msg = new ArdourMessageDialog (desc.label, false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO, false); + std::string message = desc.label; + Gtk::MessageType type = Gtk::MESSAGE_QUESTION; + Gtk::ButtonsType buttons = Gtk::BUTTONS_YES_NO; + +#ifdef LV2_EXTENDED + for (int i = 0; features && features[i]; ++i) { + if (!strcmp (features[i]->URI, LV2_DIALOGMESSAGE_URI)) { + LV2_Dialog_Message* mt = NULL; + mt = (LV2_Dialog_Message*) features[i]->data; + if (mt->msg) { + message = mt->msg; + mt->free_msg (mt->msg); + } + if (!mt->requires_return) { + type = Gtk::MESSAGE_INFO; + buttons = Gtk::BUTTONS_OK; + } + } + } +#endif + ArdourMessageDialog* msg = new ArdourMessageDialog (message, false, type, buttons, false); msg->signal_response().connect (sigc::bind (sigc::mem_fun (*me, &LV2PluginUI::request_response), desc, msg)); msg->present(); } diff --git a/libs/ardour/ardour/lv2_extensions.h b/libs/ardour/ardour/lv2_extensions.h index 26223c3d33..6c94e7369e 100644 --- a/libs/ardour/ardour/lv2_extensions.h +++ b/libs/ardour/ardour/lv2_extensions.h @@ -276,6 +276,31 @@ typedef struct { void (*notify)(LV2_BankPatch_Handle handle, uint8_t channel, uint32_t bank, uint8_t pgm); } LV2_BankPatch; +/** + @} +*/ + +/** + @defgroup LV2_Dialog_Message + + LV2 extension to allow a plugin to ask a host to display + a dedicated dialog message when requesting a value + + @{ +*/ + + +#define LV2_DIALOGMESSAGE_URI "http://ardour.org/lv2/dialog_message" + +/** a LV2 Feature provided by the Plugin, passed as optional feature to LV2_UI__requestValue */ +typedef struct { + void (*free_msg)(char const* msg); + + char const* msg; + bool requires_return; + +} LV2_Dialog_Message; + /** @} */