Early prototype for _LV2UI_Request_Parameter extension
This commit is contained in:
parent
a4d6f0ea39
commit
07beca2852
|
@ -26,6 +26,8 @@
|
|||
#include "lv2_plugin_ui.h"
|
||||
#include "timers.h"
|
||||
|
||||
#include "gtkmm2ext/utils.h"
|
||||
|
||||
#include "lv2/lv2plug.in/ns/extensions/ui/ui.h"
|
||||
|
||||
#include <lilv/lilv.h>
|
||||
|
@ -112,6 +114,45 @@ LV2PluginUI::touch(void* controller,
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
LV2PluginUI::request_parameter (void* handle, LV2_URID key)
|
||||
{
|
||||
LV2PluginUI* me = (LV2PluginUI*)handle;
|
||||
|
||||
/* This will return `PropertyDescriptors nothing` when not found */
|
||||
const ParameterDescriptor& desc (me->_lv2->get_property_descriptor(key));
|
||||
if (desc.datatype != Variant::PATH) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// TODO: check if window for current URID already exists -> return -1;
|
||||
// Create and show window, subscribe to file-selected signal
|
||||
// then return 0; don't block here.
|
||||
|
||||
Gtk::FileChooserDialog lv2ui_file_dialog (desc.label, FILE_CHOOSER_ACTION_OPEN);
|
||||
Gtkmm2ext::add_volume_shortcuts (lv2ui_file_dialog);
|
||||
|
||||
/* LV2Plugin does not currently save property values and only
|
||||
* emits a PropertyChanged(urid, Variant) signal
|
||||
*/
|
||||
//lv2ui_file_dialog.set_current_folder (TODO)
|
||||
|
||||
#if 0 // TODO mime-type,
|
||||
FileFilter file_ext_filter;
|
||||
file_ext_filter.add_pattern ("*.foo");
|
||||
file_ext_filter.set_name ("Foo File");
|
||||
lv2ui_file_dialog.add_filter (file_ext_filter);
|
||||
#endif
|
||||
int response = lv2ui_file_dialog.run();
|
||||
lv2ui_file_dialog.hide ();
|
||||
|
||||
if (response == Gtk::RESPONSE_OK) {
|
||||
me->plugin->set_property (desc.key, Variant(Variant::PATH, lv2ui_file_dialog.get_filename()));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
LV2PluginUI::update_timeout()
|
||||
{
|
||||
|
@ -259,9 +300,27 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
|
|||
LV2_Feature** features = const_cast<LV2_Feature**>(_lv2->features());
|
||||
size_t features_count = 0;
|
||||
while (*features++) {
|
||||
features_count++;
|
||||
++features_count;
|
||||
}
|
||||
|
||||
if (is_external_ui) {
|
||||
features = (LV2_Feature**)malloc(sizeof(LV2_Feature*) * (features_count + 4));
|
||||
} else {
|
||||
features = (LV2_Feature**)malloc(sizeof(LV2_Feature*) * (features_count + 3));
|
||||
}
|
||||
|
||||
size_t fi = 0;
|
||||
for (; fi < features_count; ++fi) {
|
||||
features[fi] = features_src[fi];
|
||||
}
|
||||
|
||||
_lv2ui_request_paramater.handle = this;
|
||||
_lv2ui_request_paramater.request = LV2PluginUI::request_parameter;
|
||||
_lv2ui_request_feature.URI = LV2_EXTERNAL_UI_URI;
|
||||
_lv2ui_request_feature.data = &_lv2ui_request_paramater;
|
||||
|
||||
features[fi++] = &_lv2ui_request_feature;
|
||||
|
||||
Gtk::Alignment* container = NULL;
|
||||
if (is_external_ui) {
|
||||
_external_ui_host.ui_closed = LV2PluginUI::on_external_ui_closed;
|
||||
|
@ -273,15 +332,8 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
|
|||
_external_kxui_feature.URI = LV2_EXTERNAL_UI_KX__Host;
|
||||
_external_kxui_feature.data = &_external_ui_host;
|
||||
|
||||
++features_count;
|
||||
features = (LV2_Feature**)malloc(
|
||||
sizeof(LV2_Feature*) * (features_count + 2));
|
||||
for (size_t i = 0; i < features_count - 2; ++i) {
|
||||
features[i] = features_src[i];
|
||||
}
|
||||
features[features_count - 2] = &_external_kxui_feature;
|
||||
features[features_count - 1] = &_external_ui_feature;
|
||||
features[features_count] = NULL;
|
||||
features[fi++] = &_external_kxui_feature;
|
||||
features[fi++] = &_external_ui_feature;
|
||||
} else {
|
||||
if (_ardour_buttons_box.get_parent()) {
|
||||
_ardour_buttons_box.get_parent()->remove(_ardour_buttons_box);
|
||||
|
@ -296,16 +348,12 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
|
|||
_parent_feature.URI = LV2_UI__parent;
|
||||
_parent_feature.data = _gui_widget->gobj();
|
||||
|
||||
++features_count;
|
||||
features = (LV2_Feature**)malloc(
|
||||
sizeof(LV2_Feature*) * (features_count + 1));
|
||||
for (size_t i = 0; i < features_count - 1; ++i) {
|
||||
features[i] = features_src[i];
|
||||
}
|
||||
features[features_count - 1] = &_parent_feature;
|
||||
features[features_count] = NULL;
|
||||
features[fi++] = &_parent_feature;
|
||||
}
|
||||
|
||||
features[fi] = NULL;
|
||||
assert (fi == features_count + (is_external_ui ? 3 : 2));
|
||||
|
||||
if (!ui_host) {
|
||||
ui_host = suil_host_new(LV2PluginUI::write_from_ui,
|
||||
LV2PluginUI::port_index,
|
||||
|
|
|
@ -41,6 +41,14 @@
|
|||
|
||||
#include "lv2_external_ui.h"
|
||||
|
||||
#include "lv2/lv2plug.in/ns/extensions/ui/ui.h"
|
||||
#ifndef LV2_1_14_0
|
||||
typedef struct _LV2UI_Request_Parameter {
|
||||
LV2UI_Feature_Handle handle;
|
||||
uint32_t (*request)(LV2UI_Feature_Handle handle, LV2_URID key);
|
||||
}LV2UI_Request_Parameter;
|
||||
#endif
|
||||
|
||||
namespace ARDOUR {
|
||||
class PluginInsert;
|
||||
class LV2Plugin;
|
||||
|
@ -82,6 +90,8 @@ private:
|
|||
struct lv2_external_ui_host _external_ui_host;
|
||||
LV2_Feature _external_ui_feature;
|
||||
LV2_Feature _external_kxui_feature;
|
||||
LV2UI_Request_Parameter _lv2ui_request_paramater;
|
||||
LV2_Feature _lv2ui_request_feature;
|
||||
struct lv2_external_ui* _external_ui_ptr;
|
||||
LV2_Feature _parent_feature;
|
||||
Gtk::Window* _win_ptr;
|
||||
|
@ -109,6 +119,8 @@ private:
|
|||
uint32_t port_index,
|
||||
bool grabbed);
|
||||
|
||||
static uint32_t request_parameter (void* handle, LV2_URID key);
|
||||
|
||||
void update_timeout();
|
||||
|
||||
void lv2ui_instantiate(const std::string& title);
|
||||
|
|
Loading…
Reference in New Issue
Block a user