diff options
author | David Robillard <d@drobilla.net> | 2006-10-04 04:47:30 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2006-10-04 04:47:30 +0000 |
commit | 1e01da451b279943ed51999ee06d64aba7c8faa2 (patch) | |
tree | f97067381f13b11a9e8f90284ac429b302f4d7a7 /src/progs/ingenuity/PatchCanvas.cpp | |
parent | 91d5cb109563c67bdad5f3ebeaafc8e1e8f7e14a (diff) | |
download | ingen-1e01da451b279943ed51999ee06d64aba7c8faa2.tar.gz ingen-1e01da451b279943ed51999ee06d64aba7c8faa2.tar.bz2 ingen-1e01da451b279943ed51999ee06d64aba7c8faa2.zip |
Bug fixes.
Added copy to ingen (no cut or paste yet).
Serialization work.
git-svn-id: http://svn.drobilla.net/lad/ingen@153 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/progs/ingenuity/PatchCanvas.cpp')
-rw-r--r-- | src/progs/ingenuity/PatchCanvas.cpp | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/src/progs/ingenuity/PatchCanvas.cpp b/src/progs/ingenuity/PatchCanvas.cpp index 6d8403eb..3f9c97fa 100644 --- a/src/progs/ingenuity/PatchCanvas.cpp +++ b/src/progs/ingenuity/PatchCanvas.cpp @@ -26,11 +26,14 @@ #include "LoadSubpatchWindow.h" #include "NewSubpatchWindow.h" #include "Port.h" +#include "Connection.h" #include "NodeModel.h" #include "NodeModule.h" #include "SubpatchModule.h" #include "GladeFactory.h" #include "WindowFactory.h" +#include "Serializer.h" +using Ingen::Client::Serializer; namespace Ingenuity { @@ -170,10 +173,14 @@ PatchCanvas::connection(CountedPtr<ConnectionModel> cm) boost::shared_ptr<LibFlowCanvas::Port> src = get_port(src_parent_name, cm->src_port_path().name()); boost::shared_ptr<LibFlowCanvas::Port> dst = get_port(dst_parent_name, cm->dst_port_path().name()); - if (src && dst) - add_connection(src, dst); - else + if (src && dst) { + boost::shared_ptr<Connection> c(new Connection(shared_from_this(), cm, src, dst)); + src->add_connection(c); + dst->add_connection(c); + add_connection(c); + } else { cerr << "[Canvas] ERROR: Unable to find ports to create connection." << endl; + } } @@ -293,7 +300,7 @@ PatchCanvas::canvas_event(GdkEvent* event) void -PatchCanvas::destroy_selected() +PatchCanvas::destroy_selection() { for (list<boost::shared_ptr<Module> >::iterator m = m_selected_modules.begin(); m != m_selected_modules.end(); ++m) { boost::shared_ptr<NodeModule> module = boost::dynamic_pointer_cast<NodeModule>(*m); @@ -303,6 +310,32 @@ PatchCanvas::destroy_selected() } +void +PatchCanvas::copy_selection() +{ + Serializer serializer(App::instance().engine()); + serializer.start_to_string(); + + for (list<boost::shared_ptr<Module> >::iterator m = m_selected_modules.begin(); m != m_selected_modules.end(); ++m) { + boost::shared_ptr<NodeModule> module = boost::dynamic_pointer_cast<NodeModule>(*m); + if (module) + serializer.serialize(module->node()); + } + + for (list<boost::shared_ptr<LibFlowCanvas::Connection> >::iterator c = m_selected_connections.begin(); + c != m_selected_connections.end(); ++c) { + boost::shared_ptr<Connection> connection = boost::dynamic_pointer_cast<Connection>(*c); + if (connection) + serializer.serialize_connection(connection->model()); + } + + string result = serializer.finish(); + + Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); + clipboard->set_text(result); +} + + string PatchCanvas::generate_port_name(const string& base) { string name = base; |