From ad558bdafde7e40b5de79b47d8586aec53cf3f7e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 19 Sep 2007 23:54:39 +0000 Subject: Toggling of individual node polyphonic state. git-svn-id: http://svn.drobilla.net/lad/ingen@733 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/gui/NodeMenu.cpp | 32 ++++++++++++++++++++++++++++++-- src/libs/gui/NodeMenu.hpp | 11 ++++++----- src/libs/gui/NodeModule.cpp | 18 +++++++++--------- src/libs/gui/NodeModule.hpp | 5 ++--- 4 files changed, 47 insertions(+), 19 deletions(-) (limited to 'src/libs/gui') diff --git a/src/libs/gui/NodeMenu.cpp b/src/libs/gui/NodeMenu.cpp index 3a09e34f..9f99cfe3 100644 --- a/src/libs/gui/NodeMenu.cpp +++ b/src/libs/gui/NodeMenu.cpp @@ -30,8 +30,9 @@ namespace GUI { NodeMenu::NodeMenu(SharedPtr node) -: _node(node) -, _controls_menuitem(NULL) + : _enable_signal(false) + , _node(node) + , _controls_menuitem(NULL) { App& app = App::instance(); @@ -77,6 +78,16 @@ NodeMenu::NodeMenu(SharedPtr node) sigc::bind( sigc::mem_fun(app.window_factory(), &WindowFactory::present_properties), node))); + + Gtk::Menu_Helpers::CheckMenuElem poly_elem = Gtk::Menu_Helpers::CheckMenuElem( + "Polyphonic", sigc::mem_fun(this, &NodeMenu::on_menu_polyphonic)); + items().push_back(poly_elem); + _polyphonic_menuitem = static_cast(&items().back()); + _polyphonic_menuitem->set_active(node->polyphonic()); + + node->polyphonic_sig.connect(sigc::mem_fun(this, &NodeMenu::polyphonic_changed)); + + _enable_signal = true; //model->new_port_sig.connect(sigc::mem_fun(this, &NodeMenu::add_port)); //model->destroyed_sig.connect(sigc::mem_fun(this, &NodeMenu::destroy)); @@ -175,6 +186,23 @@ NodeMenu::on_menu_destroy() } +void +NodeMenu::on_menu_polyphonic() +{ + if (_enable_signal) + App::instance().engine()->set_polyphonic(_node->path(), _polyphonic_menuitem->get_active()); +} + + +void +NodeMenu::polyphonic_changed(bool polyphonic) +{ + _enable_signal = false; + _polyphonic_menuitem->set_active(polyphonic); + _enable_signal = true; +} + + void NodeMenu::on_menu_clone() { diff --git a/src/libs/gui/NodeMenu.hpp b/src/libs/gui/NodeMenu.hpp index 0290d861..e6f63d73 100644 --- a/src/libs/gui/NodeMenu.hpp +++ b/src/libs/gui/NodeMenu.hpp @@ -51,9 +51,6 @@ public: bool has_control_inputs(); - //virtual void show_menu(GdkEventButton* event) - //{ _menu.popup(event->button, event->time); } - protected: virtual void enable_controls_menuitem(); @@ -62,13 +59,17 @@ protected: //virtual void add_port(SharedPtr pm); void on_menu_destroy(); + void on_menu_polyphonic(); void on_menu_clone(); void on_menu_learn(); void on_menu_disconnect_all(); - //Gtk::Menu _menu; - SharedPtr _node; + void polyphonic_changed(bool p); + + bool _enable_signal; + SharedPtr _node; Glib::RefPtr _controls_menuitem; + Gtk::CheckMenuItem* _polyphonic_menuitem; }; diff --git a/src/libs/gui/NodeModule.cpp b/src/libs/gui/NodeModule.cpp index ecaafa65..9cba9abd 100644 --- a/src/libs/gui/NodeModule.cpp +++ b/src/libs/gui/NodeModule.cpp @@ -42,15 +42,15 @@ NodeModule::NodeModule(boost::shared_ptr canvas, SharedPtrpolyphonic()) - set_stacked_border(true); - node->new_port_sig.connect(sigc::bind(sigc::mem_fun(this, &NodeModule::add_port), true)); node->removed_port_sig.connect(sigc::mem_fun(this, &NodeModule::remove_port)); - node->metadata_update_sig.connect(sigc::mem_fun(this, &NodeModule::metadata_update)); - + node->metadata_update_sig.connect(sigc::mem_fun(this, &NodeModule::set_metadata)); + node->polyphonic_sig.connect(sigc::mem_fun(this, &NodeModule::set_stacked_border)); + node->renamed_sig.connect(sigc::mem_fun(this, &NodeModule::rename)); + signal_clicked.connect(sigc::mem_fun(this, &NodeModule::on_click)); - node->renamed_sig.connect(sigc::mem_fun(this, &NodeModule::renamed)); + + set_stacked_border(node->polyphonic()); } @@ -77,7 +77,7 @@ NodeModule::create(boost::shared_ptr canvas, SharedPtr n ret = boost::shared_ptr(new NodeModule(canvas, node)); for (MetadataMap::const_iterator m = node->metadata().begin(); m != node->metadata().end(); ++m) - ret->metadata_update(m->first, m->second); + ret->set_metadata(m->first, m->second); for (PortModelList::const_iterator p = node->ports().begin(); p != node->ports().end(); ++p) ret->add_port(*p, false); @@ -89,7 +89,7 @@ NodeModule::create(boost::shared_ptr canvas, SharedPtr n void -NodeModule::renamed() +NodeModule::rename() { set_name(_node->path().name()); } @@ -157,7 +157,7 @@ NodeModule::on_click(GdkEventButton* event) void -NodeModule::metadata_update(const string& key, const Atom& value) +NodeModule::set_metadata(const string& key, const Atom& value) { if (key == "ingenuity:canvas-x" && value.type() == Atom::FLOAT) move_to(value.get_float(), property_y()); diff --git a/src/libs/gui/NodeModule.hpp b/src/libs/gui/NodeModule.hpp index b554a64c..aa77e780 100644 --- a/src/libs/gui/NodeModule.hpp +++ b/src/libs/gui/NodeModule.hpp @@ -74,13 +74,12 @@ protected: virtual void on_double_click(GdkEventButton* ev) { show_control_window(); } virtual void on_middle_click(GdkEventButton* ev) { show_control_window(); } - void metadata_update(const string& key, const Atom& value); + void rename(); + void set_metadata(const string& key, const Atom& value); void add_port(SharedPtr port, bool resize=true); void remove_port(SharedPtr port); - void renamed(); - SharedPtr _node; NodeMenu _menu; }; -- cgit v1.2.1