summaryrefslogtreecommitdiffstats
path: root/src/libs/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/client')
-rw-r--r--src/libs/client/Makefile.am2
-rw-r--r--src/libs/client/PluginModel.cpp65
-rw-r--r--src/libs/client/PluginModel.hpp4
-rw-r--r--src/libs/client/PluginUI.cpp115
-rw-r--r--src/libs/client/PluginUI.hpp65
5 files changed, 190 insertions, 61 deletions
diff --git a/src/libs/client/Makefile.am b/src/libs/client/Makefile.am
index e9314c55..60f5c509 100644
--- a/src/libs/client/Makefile.am
+++ b/src/libs/client/Makefile.am
@@ -50,6 +50,8 @@ libingen_client_la_SOURCES = \
PatchModel.hpp \
PluginModel.cpp \
PluginModel.hpp \
+ PluginUI.hpp \
+ PluginUI.cpp \
PortModel.cpp \
PortModel.hpp \
PresetModel.hpp \
diff --git a/src/libs/client/PluginModel.cpp b/src/libs/client/PluginModel.cpp
index 8c2ad71c..83762566 100644
--- a/src/libs/client/PluginModel.cpp
+++ b/src/libs/client/PluginModel.cpp
@@ -20,6 +20,7 @@
//#include "lv2_osc_print.h"
#include "PluginModel.hpp"
#include "PatchModel.hpp"
+#include "PluginUI.hpp"
using namespace std;
using Ingen::Shared::EngineInterface;
@@ -91,73 +92,17 @@ lv2_ui_write(LV2UI_Controller controller,
port->type().uri(), buffer_size, buffer);
}
-
-void
-lv2_ui_command(LV2UI_Controller controller,
- uint32_t argc,
- const char* const* argv)
-{
- cerr << "********* LV2 UI COMMAND" << endl;
-}
-
-
-void
-lv2_ui_program_change(LV2UI_Controller controller,
- unsigned char program)
-{
- cerr << "********* LV2 UI PROGRAM CHANGE" << endl;
-}
-
-
-void
-lv2_ui_program_save(LV2UI_Controller controller,
- unsigned char program,
- const char* name)
-{
- cerr << "********* LV2 UI PROGRAM SAVE" << endl;
-}
-
#ifdef HAVE_SLV2
-SLV2UIInstance
-PluginModel::ui(EngineInterface* engine, NodeModel* node) const
+SharedPtr<PluginUI>
+PluginModel::ui(SharedPtr<EngineInterface> engine, SharedPtr<NodeModel> node) const
{
if (_type != LV2)
- return NULL;
+ return SharedPtr<PluginUI>();
Glib::Mutex::Lock(_rdf_world->mutex());
- // FIXME: leak
- NodeController* controller = new NodeController();
- controller->engine = engine;
- controller->node = node;
-
- SLV2UIInstance ret = NULL;
-
- const char* gtk_gui_uri = "http://ll-plugins.nongnu.org/lv2/ext/gui#GtkGUI";
-
- SLV2UIs uis = slv2_plugin_get_uis(_slv2_plugin);
- SLV2UI ui = NULL;
-
- if (slv2_values_size(uis) > 0) {
- for (unsigned i=0; i < slv2_uis_size(uis); ++i) {
- ui = slv2_uis_get_at(uis, i);
-
- if (slv2_ui_is_type(ui, gtk_gui_uri)) {
- break;
- } else {
- ui = NULL;
- }
- }
- }
-
- if (ui) {
- cout << "Found GTK Plugin UI " << slv2_ui_get_uri(ui) << endl;
- ret = slv2_ui_instantiate(_slv2_plugin, ui, lv2_ui_write, controller, NULL);
- //slv2_ui_free(ui);
- }
-
- return ret;
+ return PluginUI::create(engine, node, _slv2_plugin);
}
diff --git a/src/libs/client/PluginModel.hpp b/src/libs/client/PluginModel.hpp
index 25dd2d9c..de90bba2 100644
--- a/src/libs/client/PluginModel.hpp
+++ b/src/libs/client/PluginModel.hpp
@@ -37,6 +37,7 @@ namespace Client {
class PatchModel;
class NodeModel;
+class PluginUI;
/** Model for a plugin available for loading.
@@ -89,7 +90,8 @@ public:
_slv2_plugins = slv2_world_get_all_plugins(_slv2_world);
}
- SLV2UIInstance ui(Ingen::Shared::EngineInterface* engine, NodeModel* node) const;
+ SharedPtr<PluginUI> ui(SharedPtr<Shared::EngineInterface> engine,
+ SharedPtr<NodeModel> node) const;
const string& icon_path() const;
static string get_lv2_icon_path(SLV2Plugin plugin);
diff --git a/src/libs/client/PluginUI.cpp b/src/libs/client/PluginUI.cpp
new file mode 100644
index 00000000..3c15b15e
--- /dev/null
+++ b/src/libs/client/PluginUI.cpp
@@ -0,0 +1,115 @@
+/* This file is part of Ingen.
+ * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
+ *
+ * Ingen is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <iostream>
+#include "PluginUI.hpp"
+#include "NodeModel.hpp"
+#include "PortModel.hpp"
+
+using namespace std;
+using Ingen::Shared::EngineInterface;
+
+namespace Ingen {
+namespace Client {
+
+static void
+lv2_ui_write(LV2UI_Controller controller,
+ uint32_t port_index,
+ uint32_t buffer_size,
+ const void* buffer)
+{
+ /*cerr << "********* LV2 UI WRITE:" << endl;
+ lv2_osc_message_print((const LV2Message*)buffer);
+
+ fprintf(stderr, "RAW:\n");
+ for (uint32_t i=0; i < buffer_size; ++i) {
+ unsigned char byte = ((unsigned char*)buffer)[i];
+ if (byte >= 32 && byte <= 126)
+ fprintf(stderr, "%c ", ((unsigned char*)buffer)[i]);
+ else
+ fprintf(stderr, "%2X ", ((unsigned char*)buffer)[i]);
+ }
+
+ fprintf(stderr, "\n");
+ */
+
+ PluginUI* ui = (PluginUI*)controller;
+
+ SharedPtr<PortModel> port = ui->node()->ports()[port_index];
+
+ ui->engine()->set_port_value_immediate(port->path(),
+ port->type().uri(), buffer_size, buffer);
+}
+
+
+PluginUI::PluginUI(SharedPtr<EngineInterface> engine,
+ SharedPtr<NodeModel> node)
+ : _engine(engine)
+ , _node(node)
+ , _instance(NULL)
+{
+}
+
+
+PluginUI::~PluginUI()
+{
+ slv2_ui_instance_free(_instance);
+}
+
+
+SharedPtr<PluginUI>
+PluginUI::create(SharedPtr<EngineInterface> engine,
+ SharedPtr<NodeModel> node,
+ SLV2Plugin plugin)
+{
+ SharedPtr<PluginUI> ret;
+
+ static const char* gtk_gui_uri = "http://ll-plugins.nongnu.org/lv2/ext/gui#GtkGUI";
+
+ SLV2UIs uis = slv2_plugin_get_uis(plugin);
+ SLV2UI ui = NULL;
+
+ if (slv2_values_size(uis) > 0) {
+ for (unsigned i=0; i < slv2_uis_size(uis); ++i) {
+ SLV2UI this_ui = slv2_uis_get_at(uis, i);
+ if (slv2_ui_is_type(this_ui, gtk_gui_uri)) {
+ ui = this_ui;
+ break;
+ }
+ }
+ }
+
+ if (ui) {
+ cout << "Found GTK Plugin UI: " << slv2_ui_get_uri(ui) << endl;
+ ret = SharedPtr<PluginUI>(new PluginUI(engine, node));
+ SLV2UIInstance inst = slv2_ui_instantiate(
+ plugin, ui, lv2_ui_write, ret.get(), NULL);
+
+ if (inst) {
+ ret->set_instance(inst);
+ } else {
+ cerr << "ERROR: Failed to instantiate Plugin UI" << endl;
+ ret = SharedPtr<PluginUI>();
+ }
+ }
+
+ return ret;
+}
+
+
+} // namespace Client
+} // namespace Ingen
diff --git a/src/libs/client/PluginUI.hpp b/src/libs/client/PluginUI.hpp
new file mode 100644
index 00000000..62bbf9af
--- /dev/null
+++ b/src/libs/client/PluginUI.hpp
@@ -0,0 +1,65 @@
+/* This file is part of Ingen.
+ * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
+ *
+ * Ingen is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef PLUGINUI_H
+#define PLUGINUI_H
+
+#include <slv2/slv2.h>
+#include <raul/SharedPtr.hpp>
+
+namespace Ingen {
+namespace Shared { class EngineInterface; }
+namespace Client {
+
+class NodeModel;
+
+
+/** Model for a plugin available for loading.
+ *
+ * \ingroup IngenClient
+ */
+class PluginUI {
+public:
+ ~PluginUI();
+
+ static SharedPtr<PluginUI>
+ create(SharedPtr<Shared::EngineInterface> engine,
+ SharedPtr<NodeModel> node,
+ SLV2Plugin plugin);
+
+ SharedPtr<Shared::EngineInterface> engine() { return _engine; }
+ SharedPtr<NodeModel> node() { return _node; }
+ SLV2UIInstance instance() { return _instance; }
+
+private:
+ PluginUI(SharedPtr<Ingen::Shared::EngineInterface> engine,
+ SharedPtr<NodeModel> node);
+
+ void set_instance(SLV2UIInstance instance) { _instance = instance; }
+
+ SharedPtr<Shared::EngineInterface> _engine;
+ SharedPtr<NodeModel> _node;
+ SLV2UIInstance _instance;
+};
+
+
+} // namespace Client
+} // namespace Ingen
+
+#endif // PLUGINUI_H
+
+