From 1a725c0811fd15900464e1eff429c6ead90805d4 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 16 Nov 2009 04:57:33 +0000 Subject: Add edit checkbutton to canvas menu for fast mouse based control. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2271 a436a847-0d15-0410-975c-d299462d15a1 --- src/client/PatchModel.hpp | 10 ++++++---- src/gui/PatchCanvas.cpp | 31 ++++++++++++++++++++++--------- src/gui/PatchCanvas.hpp | 35 ++++++++++++++++++----------------- src/gui/ingen_gui.glade | 19 +++++++++++++++++++ 4 files changed, 65 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/client/PatchModel.hpp b/src/client/PatchModel.hpp index 6b8398ae..8245ee5a 100644 --- a/src/client/PatchModel.hpp +++ b/src/client/PatchModel.hpp @@ -55,10 +55,12 @@ public: * not editable (control mode) you can just change controllers (performing) */ bool get_editable() const { return _editable; } - void set_editable(bool e) { if (_editable != e) { - _editable = e; - signal_editable.emit(e); - } } + void set_editable(bool e) { + if (_editable != e) { + _editable = e; + signal_editable.emit(e); + } + } virtual Raul::Atom& set_meta_property(const Raul::URI& key, const Raul::Atom& value); diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp index 0f071334..46a1c003 100644 --- a/src/gui/PatchCanvas.cpp +++ b/src/gui/PatchCanvas.cpp @@ -72,8 +72,6 @@ PatchCanvas::PatchCanvas(SharedPtr patch, int width, int height) Glib::RefPtr xml = GladeFactory::new_glade_reference(); xml->get_widget("canvas_menu", _menu); - /*xml->get_widget("canvas_menu_add_number_control", _menu_add_number_control); - xml->get_widget("canvas_menu_add_button_control", _menu_add_button_control);*/ xml->get_widget("canvas_menu_add_audio_input", _menu_add_audio_input); xml->get_widget("canvas_menu_add_audio_output", _menu_add_audio_output); xml->get_widget("canvas_menu_add_control_input", _menu_add_control_input); @@ -83,6 +81,7 @@ PatchCanvas::PatchCanvas(SharedPtr patch, int width, int height) xml->get_widget("canvas_menu_load_plugin", _menu_load_plugin); xml->get_widget("canvas_menu_load_patch", _menu_load_patch); xml->get_widget("canvas_menu_new_patch", _menu_new_patch); + xml->get_widget("canvas_menu_edit", _menu_edit); // Add port menu items _menu_add_audio_input->signal_activate().connect( @@ -118,6 +117,9 @@ PatchCanvas::PatchCanvas(SharedPtr patch, int width, int height) _menu_load_plugin->signal_activate().connect(sigc::mem_fun(this, &PatchCanvas::menu_load_plugin)); _menu_load_patch->signal_activate().connect(sigc::mem_fun(this, &PatchCanvas::menu_load_patch)); _menu_new_patch->signal_activate().connect(sigc::mem_fun(this, &PatchCanvas::menu_new_patch)); + _menu_edit->signal_activate().connect(sigc::mem_fun(this, &PatchCanvas::menu_edit_toggled)); + + _patch->signal_editable.connect(sigc::mem_fun(this, &PatchCanvas::patch_editable_changed)); } @@ -143,7 +145,7 @@ PatchCanvas::build_menus() Gtk::MenuItem* internal_menu_item = &(_menu->items().back()); _internal_menu = Gtk::manage(new Gtk::Menu()); internal_menu_item->set_submenu(*_internal_menu); - _menu->reorder_child(*internal_menu_item, 2); + _menu->reorder_child(*internal_menu_item, 4); } // Build skeleton LV2 plugin class heirarchy for 'Plugin' menu @@ -225,7 +227,7 @@ PatchCanvas::build_plugin_menu() Gtk::MenuItem* plugin_menu_item = &(_menu->items().back()); _plugin_menu = Gtk::manage(new Gtk::Menu()); plugin_menu_item->set_submenu(*_plugin_menu); - _menu->reorder_child(*plugin_menu_item, 3); + _menu->reorder_child(*plugin_menu_item, 5); } Glib::Mutex::Lock lock(PluginModel::rdf_world()->mutex()); @@ -527,7 +529,6 @@ PatchCanvas::canvas_event(GdkEvent* event) bool ret = false; switch (event->type) { - case GDK_BUTTON_PRESS: if (event->button.button == 3) { _last_click_x = (int)event->button.x; @@ -560,10 +561,7 @@ PatchCanvas::canvas_key_event(GdkEventKey* event) return true; case GDK_e: if (event->state == 0) { - if (_patch->get_editable() == true) - _patch->set_editable(false); - else - _patch->set_editable(true); + _patch->set_editable(!_patch->get_editable()); return true; } else { return false; @@ -829,5 +827,20 @@ PatchCanvas::menu_new_patch() } +void +PatchCanvas::menu_edit_toggled() +{ + _patch->set_editable(_menu_edit->get_active()); +} + + +void +PatchCanvas::patch_editable_changed(bool editable) +{ + if (_menu_edit->get_active() != editable) + _menu_edit->set_active(editable); +} + + } // namespace GUI } // namespace Ingen diff --git a/src/gui/PatchCanvas.hpp b/src/gui/PatchCanvas.hpp index d8a1cbe7..41787929 100644 --- a/src/gui/PatchCanvas.hpp +++ b/src/gui/PatchCanvas.hpp @@ -98,6 +98,8 @@ private: void menu_load_plugin(); void menu_new_patch(); void menu_load_patch(); + void menu_edit_toggled(); + void patch_editable_changed(bool editable); void load_plugin(WeakPtr plugin); void build_menus(); @@ -146,23 +148,22 @@ private: ClassMenus _class_menus; - bool _human_names; - bool _show_port_names; - Gtk::Menu* _menu; - Gtk::Menu* _internal_menu; - Gtk::Menu* _classless_menu; - Gtk::Menu* _plugin_menu; - /*Gtk::MenuItem* _menu_add_number_control; - Gtk::MenuItem* _menu_add_button_control;*/ - Gtk::MenuItem* _menu_add_audio_input; - Gtk::MenuItem* _menu_add_audio_output; - Gtk::MenuItem* _menu_add_control_input; - Gtk::MenuItem* _menu_add_control_output; - Gtk::MenuItem* _menu_add_event_input; - Gtk::MenuItem* _menu_add_event_output; - Gtk::MenuItem* _menu_load_plugin; - Gtk::MenuItem* _menu_load_patch; - Gtk::MenuItem* _menu_new_patch; + bool _human_names; + bool _show_port_names; + Gtk::Menu* _menu; + Gtk::Menu* _internal_menu; + Gtk::Menu* _classless_menu; + Gtk::Menu* _plugin_menu; + Gtk::MenuItem* _menu_add_audio_input; + Gtk::MenuItem* _menu_add_audio_output; + Gtk::MenuItem* _menu_add_control_input; + Gtk::MenuItem* _menu_add_control_output; + Gtk::MenuItem* _menu_add_event_input; + Gtk::MenuItem* _menu_add_event_output; + Gtk::MenuItem* _menu_load_plugin; + Gtk::MenuItem* _menu_load_patch; + Gtk::MenuItem* _menu_new_patch; + Gtk::CheckMenuItem* _menu_edit; }; diff --git a/src/gui/ingen_gui.glade b/src/gui/ingen_gui.glade index e2ab7354..462b3273 100644 --- a/src/gui/ingen_gui.glade +++ b/src/gui/ingen_gui.glade @@ -2860,6 +2860,20 @@ Contributors: True + + + True + Toggle edit mode + _Edit + True + True + + + + + True + + _Input @@ -2948,6 +2962,11 @@ Contributors: + + + True + + _Load Patch... -- cgit v1.2.1