diff options
Diffstat (limited to 'src/progs/ingenuity')
-rw-r--r-- | src/progs/ingenuity/Connection.h | 56 | ||||
-rw-r--r-- | src/progs/ingenuity/Loader.cpp | 2 | ||||
-rw-r--r-- | src/progs/ingenuity/Makefile.am | 1 | ||||
-rw-r--r-- | src/progs/ingenuity/NodeModule.cpp | 3 | ||||
-rw-r--r-- | src/progs/ingenuity/PatchCanvas.cpp | 41 | ||||
-rw-r--r-- | src/progs/ingenuity/PatchCanvas.h | 3 | ||||
-rw-r--r-- | src/progs/ingenuity/PatchWindow.cpp | 24 | ||||
-rw-r--r-- | src/progs/ingenuity/PatchWindow.h | 6 | ||||
-rw-r--r-- | src/progs/ingenuity/ingenuity.glade | 67 |
9 files changed, 186 insertions, 17 deletions
diff --git a/src/progs/ingenuity/Connection.h b/src/progs/ingenuity/Connection.h new file mode 100644 index 00000000..08e37e57 --- /dev/null +++ b/src/progs/ingenuity/Connection.h @@ -0,0 +1,56 @@ +/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. + * + * 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 CONNECTION_H +#define CONNECTION_H + +#include <cassert> +#include <string> +#include <flowcanvas/Connection.h> +#include "ConnectionModel.h" +#include "util/CountedPtr.h" +using Ingen::Client::ConnectionModel; + +namespace Ingenuity { + + +/** A Connection on an Module. + * + * \ingroup Ingenuity + */ +class Connection : public LibFlowCanvas::Connection +{ +public: + Connection(boost::shared_ptr<LibFlowCanvas::FlowCanvas> canvas, + boost::shared_ptr<ConnectionModel> model, + boost::shared_ptr<LibFlowCanvas::Port> src, + boost::shared_ptr<LibFlowCanvas::Port> dst) + : LibFlowCanvas::Connection(canvas, src, dst) + , m_connection_model(model) + {} + + virtual ~Connection() {} + + CountedPtr<ConnectionModel> model() const { return m_connection_model; } + +private: + CountedPtr<ConnectionModel> m_connection_model; +}; + + +} // namespace Ingenuity + +#endif // CONNECTION_H diff --git a/src/progs/ingenuity/Loader.cpp b/src/progs/ingenuity/Loader.cpp index c07d99bf..b22669ec 100644 --- a/src/progs/ingenuity/Loader.cpp +++ b/src/progs/ingenuity/Loader.cpp @@ -97,7 +97,7 @@ Loader::save_patch_event(CountedPtr<PatchModel> model, const string& filename, b cerr << "FIXME: Recursive save." << endl; _serializer->start_to_filename(filename); - _serializer->serialize_patch(model); + _serializer->serialize(model); _serializer->finish(); } diff --git a/src/progs/ingenuity/Makefile.am b/src/progs/ingenuity/Makefile.am index 3044a2fc..753980b8 100644 --- a/src/progs/ingenuity/Makefile.am +++ b/src/progs/ingenuity/Makefile.am @@ -70,6 +70,7 @@ ingenuity_SOURCES = \ SubpatchModule.cpp \ Port.h \ Port.cpp \ + Connection.h \ NewSubpatchWindow.h \ NewSubpatchWindow.cpp \ ConfigWindow.h \ diff --git a/src/progs/ingenuity/NodeModule.cpp b/src/progs/ingenuity/NodeModule.cpp index 6d4e54de..d9d91193 100644 --- a/src/progs/ingenuity/NodeModule.cpp +++ b/src/progs/ingenuity/NodeModule.cpp @@ -85,8 +85,6 @@ NodeModule::show_control_window() void NodeModule::store_location() { - cerr << "FIXME: store_location\n"; -#if 0 const float x = static_cast<float>(property_x()); const float y = static_cast<float>(property_y()); @@ -98,7 +96,6 @@ NodeModule::store_location() App::instance().engine()->set_metadata(m_node->path(), "ingenuity:canvas-x", Atom(x)); App::instance().engine()->set_metadata(m_node->path(), "ingenuity:canvas-y", Atom(y)); } -#endif } 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; diff --git a/src/progs/ingenuity/PatchCanvas.h b/src/progs/ingenuity/PatchCanvas.h index 15312367..7074c785 100644 --- a/src/progs/ingenuity/PatchCanvas.h +++ b/src/progs/ingenuity/PatchCanvas.h @@ -69,7 +69,8 @@ public: void get_new_module_location(double& x, double& y); - void destroy_selected(); + void destroy_selection(); + void copy_selection(); void show_menu(GdkEvent* event) { m_menu->popup(event->button.button, event->button.time); } diff --git a/src/progs/ingenuity/PatchWindow.cpp b/src/progs/ingenuity/PatchWindow.cpp index e429d136..2ca3da14 100644 --- a/src/progs/ingenuity/PatchWindow.cpp +++ b/src/progs/ingenuity/PatchWindow.cpp @@ -59,6 +59,10 @@ PatchWindow::PatchWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad //xml->get_widget("patch_open_into_menuitem", m_menu_open_into); xml->get_widget("patch_save_menuitem", m_menu_save); xml->get_widget("patch_save_as_menuitem", m_menu_save_as); + xml->get_widget("patch_cut_menuitem", m_menu_cut); + xml->get_widget("patch_copy_menuitem", m_menu_copy); + xml->get_widget("patch_paste_menuitem", m_menu_paste); + xml->get_widget("patch_delete_menuitem", m_menu_delete); xml->get_widget("patch_close_menuitem", m_menu_close); xml->get_widget("patch_configuration_menuitem", m_menu_configuration); xml->get_widget("patch_quit_menuitem", m_menu_quit); @@ -84,6 +88,10 @@ PatchWindow::PatchWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad sigc::mem_fun(this, &PatchWindow::event_save)); m_menu_save_as->signal_activate().connect( sigc::mem_fun(this, &PatchWindow::event_save_as)); + m_menu_copy->signal_activate().connect( + sigc::mem_fun(this, &PatchWindow::event_copy)); + m_menu_delete->signal_activate().connect( + sigc::mem_fun(this, &PatchWindow::event_delete)); m_menu_quit->signal_activate().connect( sigc::mem_fun(this, &PatchWindow::event_quit)); m_menu_configuration->signal_activate().connect( @@ -307,6 +315,22 @@ PatchWindow::event_save_as() void +PatchWindow::event_copy() +{ + if (m_view) + m_view->canvas()->copy_selection(); +} + + +void +PatchWindow::event_delete() +{ + if (m_view) + m_view->canvas()->destroy_selection(); +} + + +void PatchWindow::on_show() { if (m_position_stored) diff --git a/src/progs/ingenuity/PatchWindow.h b/src/progs/ingenuity/PatchWindow.h index b957c420..3f9331ec 100644 --- a/src/progs/ingenuity/PatchWindow.h +++ b/src/progs/ingenuity/PatchWindow.h @@ -81,6 +81,8 @@ private: void event_import(); void event_save(); void event_save_as(); + void event_copy(); + void event_delete(); void event_quit(); void event_destroy(); void event_clear(); @@ -100,6 +102,10 @@ private: Gtk::MenuItem* m_menu_import; Gtk::MenuItem* m_menu_save; Gtk::MenuItem* m_menu_save_as; + Gtk::MenuItem* m_menu_cut; + Gtk::MenuItem* m_menu_copy; + Gtk::MenuItem* m_menu_paste; + Gtk::MenuItem* m_menu_delete; Gtk::MenuItem* m_menu_configuration; Gtk::MenuItem* m_menu_close; Gtk::MenuItem* m_menu_quit; diff --git a/src/progs/ingenuity/ingenuity.glade b/src/progs/ingenuity/ingenuity.glade index 7f18f954..7d24d2e8 100644 --- a/src/progs/ingenuity/ingenuity.glade +++ b/src/progs/ingenuity/ingenuity.glade @@ -51,7 +51,7 @@ <signal name="activate" handler="on_patch_import_menuitem_activate" last_modification_time="Mon, 06 Feb 2006 06:20:27 GMT"/> <child internal-child="image"> - <widget class="GtkImage" id="image1925"> + <widget class="GtkImage" id="image1970"> <property name="visible">True</property> <property name="stock">gtk-open</property> <property name="icon_size">1</property> @@ -106,7 +106,7 @@ <accelerator key="G" modifiers="GDK_CONTROL_MASK" signal="activate"/> <child internal-child="image"> - <widget class="GtkImage" id="image1926"> + <widget class="GtkImage" id="image1971"> <property name="visible">True</property> <property name="stock">gtk-preferences</property> <property name="icon_size">1</property> @@ -156,6 +156,57 @@ </child> <child> + <widget class="GtkMenuItem" id="edit2"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Edit</property> + <property name="use_underline">True</property> + + <child> + <widget class="GtkMenu" id="edit2_menu"> + + <child> + <widget class="GtkImageMenuItem" id="patch_cut_menuitem"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="label">gtk-cut</property> + <property name="use_stock">True</property> + <signal name="activate" handler="on_patch_cut_menuitem_activate" last_modification_time="Tue, 03 Oct 2006 23:55:43 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkImageMenuItem" id="patch_copy_menuitem"> + <property name="visible">True</property> + <property name="label">gtk-copy</property> + <property name="use_stock">True</property> + <signal name="activate" handler="on_patch_copy_menuitem_activate" last_modification_time="Tue, 03 Oct 2006 23:55:43 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkImageMenuItem" id="patch_paste_menuitem"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="label">gtk-paste</property> + <property name="use_stock">True</property> + <signal name="activate" handler="on_patch_paste_menuitem_activate" last_modification_time="Tue, 03 Oct 2006 23:55:43 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkImageMenuItem" id="patch_delete_menuitem"> + <property name="visible">True</property> + <property name="label">gtk-delete</property> + <property name="use_stock">True</property> + <signal name="activate" handler="on_patch_delete_menuitem_activate" last_modification_time="Tue, 03 Oct 2006 23:55:43 GMT"/> + </widget> + </child> + </widget> + </child> + </widget> + </child> + + <child> <widget class="GtkMenuItem" id="patch_patch_menu"> <property name="visible">True</property> <property name="label" translatable="yes">_Patch</property> @@ -189,7 +240,7 @@ <accelerator key="C" modifiers="GDK_CONTROL_MASK" signal="activate"/> <child internal-child="image"> - <widget class="GtkImage" id="image1927"> + <widget class="GtkImage" id="image1972"> <property name="visible">True</property> <property name="stock">gtk-preferences</property> <property name="icon_size">1</property> @@ -231,7 +282,7 @@ <signal name="activate" handler="on_patch_destroy_menuitem_activate" last_modification_time="Wed, 25 May 2005 00:22:00 GMT"/> <child internal-child="image"> - <widget class="GtkImage" id="image1928"> + <widget class="GtkImage" id="image1973"> <property name="visible">True</property> <property name="stock">gtk-delete</property> <property name="icon_size">1</property> @@ -268,7 +319,7 @@ <accelerator key="E" modifiers="GDK_CONTROL_MASK" signal="activate"/> <child internal-child="image"> - <widget class="GtkImage" id="image1929"> + <widget class="GtkImage" id="image1974"> <property name="visible">True</property> <property name="stock">gtk-connect</property> <property name="icon_size">1</property> @@ -291,7 +342,7 @@ <accelerator key="T" modifiers="GDK_CONTROL_MASK" signal="activate"/> <child internal-child="image"> - <widget class="GtkImage" id="image1930"> + <widget class="GtkImage" id="image1975"> <property name="visible">True</property> <property name="stock">gtk-index</property> <property name="icon_size">1</property> @@ -314,7 +365,7 @@ <accelerator key="M" modifiers="GDK_CONTROL_MASK" signal="activate"/> <child internal-child="image"> - <widget class="GtkImage" id="image1931"> + <widget class="GtkImage" id="image1976"> <property name="visible">True</property> <property name="stock">gtk-dialog-error</property> <property name="icon_size">1</property> @@ -349,7 +400,7 @@ <signal name="activate" handler="on_right-click_the_canvas_to_add_objects1_activate" last_modification_time="Fri, 16 Jun 2006 17:51:05 GMT"/> <child internal-child="image"> - <widget class="GtkImage" id="image1932"> + <widget class="GtkImage" id="image1977"> <property name="visible">True</property> <property name="stock">gtk-info</property> <property name="icon_size">1</property> |