diff options
Diffstat (limited to 'src/libs/gui')
-rw-r--r-- | src/libs/gui/LoadPluginWindow.cpp | 8 | ||||
-rw-r--r-- | src/libs/gui/LoadPluginWindow.hpp | 3 | ||||
-rw-r--r-- | src/libs/gui/NodeModule.cpp | 18 | ||||
-rw-r--r-- | src/libs/gui/PatchCanvas.cpp | 40 | ||||
-rw-r--r-- | src/libs/gui/PatchCanvas.hpp | 1 | ||||
-rw-r--r-- | src/libs/gui/PatchWindow.cpp | 21 | ||||
-rw-r--r-- | src/libs/gui/PatchWindow.hpp | 2 | ||||
-rw-r--r-- | src/libs/gui/ThreadedLoader.cpp | 24 | ||||
-rw-r--r-- | src/libs/gui/ThreadedLoader.hpp | 6 |
9 files changed, 92 insertions, 31 deletions
diff --git a/src/libs/gui/LoadPluginWindow.cpp b/src/libs/gui/LoadPluginWindow.cpp index 92fcb221..436de188 100644 --- a/src/libs/gui/LoadPluginWindow.cpp +++ b/src/libs/gui/LoadPluginWindow.cpp @@ -211,11 +211,11 @@ LoadPluginWindow::plugin_compare(const Gtk::TreeModel::iterator& a_i, void -LoadPluginWindow::set_plugins(const Raul::Table<string, SharedPtr<PluginModel> >& m) +LoadPluginWindow::set_plugins(SharedPtr<const ClientStore::Plugins> m) { _plugins_liststore->clear(); - for (Raul::Table<string, SharedPtr<PluginModel> >::const_iterator i = m.begin(); i != m.end(); ++i) { + for (ClientStore::Plugins::const_iterator i = m->begin(); i != m->end(); ++i) { SharedPtr<PluginModel> plugin = (*i).second; Gtk::TreeModel::iterator iter = _plugins_liststore->append(); @@ -396,8 +396,8 @@ LoadPluginWindow::filter_changed() size_t num_visible = 0; - for (Raul::Table<string, SharedPtr<PluginModel> >::const_iterator i = App::instance().store()->plugins().begin(); - i != App::instance().store()->plugins().end(); ++i) { + for (ClientStore::Plugins::const_iterator i = App::instance().store()->plugins()->begin(); + i != App::instance().store()->plugins()->end(); ++i) { const SharedPtr<PluginModel> plugin = (*i).second; diff --git a/src/libs/gui/LoadPluginWindow.hpp b/src/libs/gui/LoadPluginWindow.hpp index ef1420a0..a5246c39 100644 --- a/src/libs/gui/LoadPluginWindow.hpp +++ b/src/libs/gui/LoadPluginWindow.hpp @@ -26,6 +26,7 @@ #include "interface/GraphObject.hpp" #include "client/PatchModel.hpp" #include "client/PluginModel.hpp" +#include "client/ClientStore.hpp" using Ingen::Client::PluginModel; using Ingen::Client::PatchModel; using namespace Ingen::Shared; @@ -93,7 +94,7 @@ public: LoadPluginWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& xml); void set_patch(SharedPtr<PatchModel> patch); - void set_plugins(const Raul::Table<string, SharedPtr<PluginModel> >& m); + void set_plugins(SharedPtr<const ClientStore::Plugins> plugins); void add_plugin(SharedPtr<PluginModel> plugin); diff --git a/src/libs/gui/NodeModule.cpp b/src/libs/gui/NodeModule.cpp index fe71dd2f..7ac86e40 100644 --- a/src/libs/gui/NodeModule.cpp +++ b/src/libs/gui/NodeModule.cpp @@ -104,13 +104,17 @@ NodeModule::create(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<NodeModel> n void NodeModule::value_changed(uint32_t index, const Atom& value) { - float control = value.get_float(); - if (_plugin_ui) { - SLV2UIInstance inst = _plugin_ui->instance(); - const LV2UI_Descriptor* ui_descriptor = slv2_ui_instance_get_descriptor(inst); - LV2UI_Handle ui_handle = slv2_ui_instance_get_handle(inst); - if (ui_descriptor->port_event) - ui_descriptor->port_event(ui_handle, index, 4, 0, &control); + if (value.type() == Atom::FLOAT) { + float control = value.get_float(); + if (_plugin_ui) { + SLV2UIInstance inst = _plugin_ui->instance(); + const LV2UI_Descriptor* ui_descriptor = slv2_ui_instance_get_descriptor(inst); + LV2UI_Handle ui_handle = slv2_ui_instance_get_handle(inst); + if (ui_descriptor->port_event) + ui_descriptor->port_event(ui_handle, index, 4, 0, &control); + } + } else { + cerr << "WARNING: Unknown value type " << (int)value.type() << endl; } } diff --git a/src/libs/gui/PatchCanvas.cpp b/src/libs/gui/PatchCanvas.cpp index 019851f0..d625d2cd 100644 --- a/src/libs/gui/PatchCanvas.cpp +++ b/src/libs/gui/PatchCanvas.cpp @@ -23,6 +23,7 @@ #include <flowcanvas/Canvas.hpp> #include <flowcanvas/Ellipse.hpp> #include "interface/EngineInterface.hpp" +#include "shared/Builder.hpp" #include "serialisation/Serialiser.hpp" #include "client/PluginModel.hpp" #include "client/PatchModel.hpp" @@ -41,6 +42,7 @@ #include "SubpatchModule.hpp" #include "GladeFactory.hpp" #include "WindowFactory.hpp" +#include "ThreadedLoader.hpp" using Ingen::Client::ClientStore; using Ingen::Serialisation::Serialiser; using Ingen::Client::PluginModel; @@ -159,10 +161,10 @@ PatchCanvas::build_internal_menu() _menu->reorder_child(*internal_menu_item, 2); } - const ClientStore::Plugins& plugins = App::instance().store()->plugins(); + SharedPtr<const ClientStore::Plugins> plugins = App::instance().store()->plugins(); // Add Internal plugins - for (ClientStore::Plugins::const_iterator i = plugins.begin(); i != plugins.end(); ++i) { + for (ClientStore::Plugins::const_iterator i = plugins->begin(); i != plugins->end(); ++i) { SharedPtr<PluginModel> p = i->second; if (p->type() == Plugin::Internal) { _internal_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(p->name(), @@ -200,10 +202,10 @@ PatchCanvas::build_plugin_class_menu(Gtk::Menu* menu, } } - const ClientStore::Plugins& plugins = App::instance().store()->plugins(); + SharedPtr<const ClientStore::Plugins> plugins = App::instance().store()->plugins(); // Add LV2 plugins - for (ClientStore::Plugins::const_iterator i = plugins.begin(); i != plugins.end(); ++i) { + for (ClientStore::Plugins::const_iterator i = plugins->begin(); i != plugins->end(); ++i) { SLV2Plugin p = i->second->slv2_plugin(); if (p && slv2_plugin_get_class(p) == plugin_class) { @@ -565,6 +567,36 @@ PatchCanvas::copy_selection() Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); clipboard->set_text(result); } + + +void +PatchCanvas::paste() +{ + Glib::ustring str = Gtk::Clipboard::get()->wait_for_text(); + SharedPtr<Parser> parser = App::instance().loader()->parser(); + if (!parser) { + cerr << "Unable to load parser, paste unavailable" << endl; + return; + } + + Builder builder(*App::instance().engine()); + ClientStore clipboard; + clipboard.new_patch("/", _patch->poly()); + clipboard.set_plugins(App::instance().store()->plugins()); + parser->parse_string(App::instance().world(), &clipboard, str, "/"); + for (Store::iterator i = clipboard.begin(); i != clipboard.end(); ++i) { + /*GraphObject::Properties::iterator s = i->second->properties().find("ingen:symbol"); + const string sym = string(s->second.get_string()) + "_copy"; + s->second = sym;*/ + GraphObject::Variables::iterator x = i->second->variables().find("ingenuity:canvas-x"); + if (x != i->second->variables().end()) + x->second = x->second.get_float() + 20.0f; + GraphObject::Variables::iterator y = i->second->variables().find("ingenuity:canvas-y"); + if (y != i->second->variables().end()) + y->second = y->second.get_float() + 20.0f; + builder.build(i->second); + } +} string diff --git a/src/libs/gui/PatchCanvas.hpp b/src/libs/gui/PatchCanvas.hpp index 3998532d..f596c97b 100644 --- a/src/libs/gui/PatchCanvas.hpp +++ b/src/libs/gui/PatchCanvas.hpp @@ -79,6 +79,7 @@ public: void destroy_selection(); void copy_selection(); + void paste(); void show_menu(GdkEvent* event); diff --git a/src/libs/gui/PatchWindow.cpp b/src/libs/gui/PatchWindow.cpp index ad558903..125adeea 100644 --- a/src/libs/gui/PatchWindow.cpp +++ b/src/libs/gui/PatchWindow.cpp @@ -98,6 +98,8 @@ PatchWindow::PatchWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad sigc::mem_fun(this, &PatchWindow::event_upload)); _menu_copy->signal_activate().connect( sigc::mem_fun(this, &PatchWindow::event_copy)); + _menu_paste->signal_activate().connect( + sigc::mem_fun(this, &PatchWindow::event_paste)); _menu_delete->signal_activate().connect( sigc::mem_fun(this, &PatchWindow::event_delete)); _menu_quit->signal_activate().connect( @@ -130,6 +132,9 @@ PatchWindow::PatchWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad #ifndef HAVE_CURL _menu_upload->hide(); #endif + + Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); + clipboard->signal_owner_change().connect(sigc::mem_fun(this, &PatchWindow::event_clipboard_changed)); } @@ -274,6 +279,14 @@ PatchWindow::event_show_engine() void +PatchWindow::event_clipboard_changed(GdkEventOwnerChange* ev) +{ + Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); + _menu_paste->set_sensitive(clipboard->wait_is_text_available()); +} + + +void PatchWindow::event_show_controls() { App::instance().window_factory()->present_controls(_patch); @@ -386,6 +399,14 @@ PatchWindow::event_copy() void +PatchWindow::event_paste() +{ + if (_view) + _view->canvas()->paste(); +} + + +void PatchWindow::event_delete() { if (_view) diff --git a/src/libs/gui/PatchWindow.hpp b/src/libs/gui/PatchWindow.hpp index a3851dc1..2b5a90be 100644 --- a/src/libs/gui/PatchWindow.hpp +++ b/src/libs/gui/PatchWindow.hpp @@ -89,6 +89,7 @@ private: void event_save_as(); void event_upload(); void event_copy(); + void event_paste(); void event_delete(); void event_quit(); void event_destroy(); @@ -98,6 +99,7 @@ private: void event_show_properties(); void event_show_controls(); void event_show_engine(); + void event_clipboard_changed(GdkEventOwnerChange* ev); SharedPtr<PatchModel> _patch; SharedPtr<PatchView> _view; diff --git a/src/libs/gui/ThreadedLoader.cpp b/src/libs/gui/ThreadedLoader.cpp index d85d54a3..88dd4b1a 100644 --- a/src/libs/gui/ThreadedLoader.cpp +++ b/src/libs/gui/ThreadedLoader.cpp @@ -36,8 +36,18 @@ ThreadedLoader::ThreadedLoader(SharedPtr<EngineInterface> engine) { set_name("Loader"); - // FIXME: rework this so the thread is only present when it's doing something (save mem) - // and module isn't loaded until required + if (parser()) + start(); + else + cerr << "WARNING: Failed to load ingen_serialisation module, load disabled." << endl; +} + + +SharedPtr<Parser> +ThreadedLoader::parser() +{ + if (_parser) + return _parser; World* world = App::instance().world(); if (!world->serialisation_module) @@ -53,15 +63,7 @@ ThreadedLoader::ThreadedLoader(SharedPtr<EngineInterface> engine) _parser = SharedPtr<Parser>(new_parser()); } - if (_parser) - start(); - else - cerr << "WARNING: Failed to load ingen_serialisation module, load disabled." << endl; -} - - -ThreadedLoader::~ThreadedLoader() -{ + return _parser; } diff --git a/src/libs/gui/ThreadedLoader.hpp b/src/libs/gui/ThreadedLoader.hpp index dd5909fe..3cf88cf9 100644 --- a/src/libs/gui/ThreadedLoader.hpp +++ b/src/libs/gui/ThreadedLoader.hpp @@ -56,11 +56,7 @@ class ThreadedLoader : public Raul::Slave { public: ThreadedLoader(SharedPtr<EngineInterface> engine); - ~ThreadedLoader(); - // FIXME: there's a pattern here.... - // (same core interface as Loader/Serialiser) - void load_patch(bool merge, const Glib::ustring& data_base_uri, const Path& data_path, @@ -70,6 +66,8 @@ public: void save_patch(SharedPtr<PatchModel> model, const string& filename); + SharedPtr<Parser> parser(); + private: void save_patch_event(SharedPtr<PatchModel> model, const string& filename); |