[SCM] calf/master: + Framework: first foundations of a small plugin GUI framework + Testing: added provisional GUI for msgread_e plugin for testing generic message passing code in hosts (only Ingen for now)
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:37:45 UTC 2013
The following commit has been merged in the master branch:
commit 3f8b14c372db5b104e3502c3c7954f87ba385650
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date: Wed Oct 15 20:49:38 2008 +0000
+ Framework: first foundations of a small plugin GUI framework
+ Testing: added provisional GUI for msgread_e plugin for testing generic message passing code in hosts (only Ingen for now)
git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@334 78b06b96-2940-0410-b7fc-879d825d01d8
diff --git a/src/calf/lv2helpers.h b/src/calf/lv2helpers.h
index c65f059..7f631b8 100644
--- a/src/calf/lv2helpers.h
+++ b/src/calf/lv2helpers.h
@@ -23,6 +23,9 @@
#if USE_LV2
+#include <calf/lv2_event.h>
+#include <calf/lv2_uri_map.h>
+
/// A mixin for adding the event feature and URI map to the small plugin
template<class T>
class event_mixin: public T
diff --git a/src/calf/plugininfo.h b/src/calf/plugininfo.h
index 099011b..0201d8d 100644
--- a/src/calf/plugininfo.h
+++ b/src/calf/plugininfo.h
@@ -68,6 +68,8 @@ struct plugin_info_iface
virtual control_port_info_iface &control_port(const std::string &id, const std::string &name, double def_value, const std::string µname = "N/A")=0;
/// Add arbitrary TTL clauses
virtual void lv2_ttl(const std::string &text) {}
+ /// Add small plugin GUI
+ virtual void has_gui() { lv2_ttl("uiext:ui <http://calf.sourceforge.net/small_plugins/gui/gtk2-gui> ;"); }
/// Called after plugin has reported all the information
virtual void finalize() {}
virtual ~plugin_info_iface() {}
diff --git a/src/lv2gui.cpp b/src/lv2gui.cpp
index 3f5d33a..05d4669 100644
--- a/src/lv2gui.cpp
+++ b/src/lv2gui.cpp
@@ -30,6 +30,7 @@
#include <calf/lv2_ui.h>
#include <calf/preset_gui.h>
#include <calf/utils.h>
+#include <calf/lv2helpers.h>
using namespace std;
using namespace dsp;
@@ -160,8 +161,6 @@ plugin_proxy_base *create_plugin_proxy(const char *effect_name)
return NULL;
}
-LV2UI_Descriptor gui;
-
LV2UI_Handle gui_instantiate(const struct _LV2UI_Descriptor* descriptor,
const char* plugin_uri,
const char* bundle_path,
@@ -229,16 +228,144 @@ void store_preset(GtkWindow *toplevel, plugin_gui *gui)
};
+///////////////////////////////////////////////////////////////////////////////////////
+
+class small_plugin_gui
+{
+public:
+ LV2UI_Write_Function write_function;
+ LV2UI_Controller controller;
+ GtkWidget **widget_ptr;
+
+ void write(int port, const void *data, uint32_t size, uint32_t format)
+ {
+ (*write_function)(controller, port, size, format, &data);
+ }
+
+ virtual void use_feature(const char *URI, void *feature) {
+ }
+
+ virtual void parse_features(const LV2_Feature* const*features) {
+ if (features) {
+ for(;*features;features++)
+ use_feature((*features)->URI, (*features)->data);
+ }
+ }
+
+ virtual GtkWidget *create_widget()=0;
+
+ virtual void init(const char* plugin_uri, const char* bundle_path,
+ LV2UI_Write_Function write_function, LV2UI_Controller controller,
+ LV2UI_Widget* widget, const LV2_Feature* const*features)
+ {
+ this->write_function = write_function;
+ this->controller = controller;
+ widget_ptr = (GtkWidget **)widget;
+ parse_features(features);
+ *widget_ptr = create_widget();
+ }
+
+ virtual ~small_plugin_gui() {}
+};
+
+class msg_read_gui: public message_mixin<small_plugin_gui>
+{
+ GtkWidget *editor;
+ uint32_t set_float_msg, float_type;
+
+ static void bang(GtkWidget *widget, msg_read_gui *gui)
+ {
+ struct payload {
+ uint32_t selector;
+ uint32_t serial_no;
+ uint32_t data_size;
+ uint32_t parg_count;
+ uint32_t data_type;
+ float data_value;
+ uint32_t narg_count;
+ } data;
+ data.selector = gui->set_float_msg;
+ data.serial_no = 1337;
+ data.data_size = 16;
+ data.parg_count = 1;
+ data.data_type = gui->float_type;
+ data.data_value = atof(gtk_entry_get_text(GTK_ENTRY(gui->editor)));
+ data.narg_count = 0;
+ gui->write(0, &data, sizeof(data), gui->message_event_type);
+ }
+ virtual void map_uris()
+ {
+ message_mixin<small_plugin_gui>::map_uris();
+ set_float_msg = map_uri("http://lv2plug.in/ns/dev/msg", "http://foltman.com/garbage/setFloat");
+ float_type = map_uri("http://lv2plug.in/ns/dev/types", "http://lv2plug.in/ns/dev/types#float");
+ }
+ virtual GtkWidget *create_widget()
+ {
+ editor = gtk_entry_new();
+ GtkWidget *button = gtk_button_new_with_label("Bang!");
+ GtkWidget *vbox = gtk_vbox_new(false, 10);
+ gtk_box_pack_start(GTK_BOX(vbox), editor, true, true, 5);
+ gtk_box_pack_start(GTK_BOX(vbox), button, true, true, 5);
+ GtkWidget *frame = gtk_frame_new("GUI");
+ gtk_container_add(GTK_CONTAINER(frame), vbox);
+ gtk_widget_queue_resize(frame);
+ gtk_signal_connect( GTK_OBJECT(button), "clicked", G_CALLBACK(bang), this);
+ return frame;
+ }
+};
+
+LV2UI_Handle sgui_instantiate(const struct _LV2UI_Descriptor* descriptor,
+ const char* plugin_uri,
+ const char* bundle_path,
+ LV2UI_Write_Function write_function,
+ LV2UI_Controller controller,
+ LV2UI_Widget* widget,
+ const LV2_Feature* const* features)
+{
+ small_plugin_gui *gui = NULL;
+ if (!strcmp(plugin_uri, "http://calf.sourceforge.net/small_plugins/msgread_e"))
+ gui = new msg_read_gui;
+ else
+ return NULL;
+ gui->init(plugin_uri, bundle_path, write_function, controller, widget, features);
+ return gui;
+}
+
+void sgui_cleanup(LV2UI_Handle handle)
+{
+ small_plugin_gui *gui = (small_plugin_gui *)handle;
+ delete gui;
+}
+
+void sgui_port_event(LV2UI_Handle handle, uint32_t port, uint32_t buffer_size, uint32_t format, const void *buffer)
+{
+}
+
+const void *sgui_extension(const char *uri)
+{
+ return NULL;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////
+
const LV2UI_Descriptor* lv2ui_descriptor(uint32_t index)
{
+ static LV2UI_Descriptor gui, sgui;
gui.URI = "http://calf.sourceforge.net/plugins/gui/gtk2-gui";
gui.instantiate = gui_instantiate;
gui.cleanup = gui_cleanup;
gui.port_event = gui_port_event;
gui.extension_data = gui_extension;
+ sgui.URI = "http://calf.sourceforge.net/small_plugins/gui/gtk2-gui";
+ sgui.instantiate = sgui_instantiate;
+ sgui.cleanup = sgui_cleanup;
+ sgui.port_event = sgui_port_event;
+ sgui.extension_data = sgui_extension;
switch(index) {
case 0:
return &gui;
+ case 1:
+ return &sgui;
default:
return NULL;
}
diff --git a/src/makerdf.cpp b/src/makerdf.cpp
index c947540..4181896 100644
--- a/src/makerdf.cpp
+++ b/src/makerdf.cpp
@@ -393,7 +393,15 @@ void make_ttl(string path_prefix)
" a uiext:GtkUI ;\n"
" uiext:binary <calflv2gui.so> ;\n"
" uiext:requiredFeature uiext:makeResident .\n"
- " \n";
+ " \n"
+#ifdef ENABLE_EXPERIMENTAL
+ "<http://calf.sourceforge.net/small_plugins/gui/gtk2-gui>\n"
+ " a uiext:GtkUI ;\n"
+ " uiext:binary <calflv2gui.so> ;\n"
+ " uiext:requiredFeature uiext:makeResident .\n"
+ " \n"
+#endif
+ ;
#endif
for (unsigned int i = 0; i < plugins.size(); i++) {
@@ -452,7 +460,7 @@ void make_ttl(string path_prefix)
// Copy-pasted code is the root of all evil, I know!
string uri = string("<http://calf.sourceforge.net/small_plugins/") + string(pi->id) + ">";
string ttl;
- ttl = "@prefix : " + uri + " .\n" + header;
+ ttl = "@prefix : " + uri + " .\n" + header + gui_header;
ttl += uri + " a lv2:Plugin ;\n";
diff --git a/src/modules_small.cpp b/src/modules_small.cpp
index d382828..e71cf2c 100644
--- a/src/modules_small.cpp
+++ b/src/modules_small.cpp
@@ -1753,6 +1753,7 @@ public:
static void plugin_info(plugin_info_iface *pii)
{
pii->names("msgread_e", "Msg Read", "lv2:UtilityPlugin");
+ pii->has_gui();
pii->event_port("in", "In").input();
pii->control_port("out", "Out", 0).output();
}
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list