From 4cd6d52013dc60d65c2872d9d6e87e83e85cff95 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 21 May 2016 08:34:09 -0400 Subject: make Escape (cancel drag or selection) work in mixer as well as editor --- gtk2_ardour/ardour.keys.in | 4 +++- gtk2_ardour/ardour_ui.h | 8 ++++++++ gtk2_ardour/ardour_ui_ed.cc | 8 ++++++++ gtk2_ardour/editor.cc | 4 ++++ gtk2_ardour/editor_actions.cc | 2 -- gtk2_ardour/mixer.bindings | 1 - gtk2_ardour/mixer_ui.cc | 10 ++++++++++ gtk2_ardour/mixer_ui.h | 2 ++ 8 files changed, 35 insertions(+), 4 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/ardour.keys.in b/gtk2_ardour/ardour.keys.in index a5490ad321..98ae64418a 100644 --- a/gtk2_ardour/ardour.keys.in +++ b/gtk2_ardour/ardour.keys.in @@ -269,7 +269,9 @@ This mode provides many different operations on both regions and control points, @edit|Editor/editor-delete|Delete|delete @edit|Editor/alternate-editor-delete|BackSpace|backspace (delete) -@select|Editor/escape|Escape|break drag or deselect all +;; this one is super-global, so we put it in the session group but don't show +;; it on cheat sheets etc. +@-sess|Main/Escape|Escape|break drag or deselect all ;; keypad diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 53abcd0f17..93dc47ff12 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -202,6 +202,12 @@ public: static ARDOUR_UI *instance () { return theArdourUI; } + /* signal emitted when escape key is pressed. All UI components that + need to respond to Escape in some way (e.g. break drag, clear + selection, etc) should connect to and handle this. + */ + PBD::Signal0 Escape; + PublicEditor& the_editor() { return *editor;} Mixer_UI* the_mixer() { return mixer; } @@ -877,6 +883,8 @@ private: void step_up_through_tabs (); void step_down_through_tabs (); + + void escape (); }; #endif /* __ardour_gui_h__ */ diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index 08529bbe0e..de014b0d34 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -108,6 +108,12 @@ ARDOUR_UI::create_luawindow () return 0; } +void +ARDOUR_UI::escape () +{ + Escape (); /* EMIT SIGNAL */ +} + void ARDOUR_UI::install_actions () { @@ -115,6 +121,8 @@ ARDOUR_UI::install_actions () Glib::RefPtr main_menu_actions = global_actions.create_action_group (X_("Main_menu")); Glib::RefPtr act; + global_actions.register_action (main_actions, X_("Escape"), _("Escape"), sigc::mem_fun (*this, &ARDOUR_UI::escape)); + /* menus + submenus that need action items */ global_actions.register_action (main_menu_actions, X_("Session"), _("Session")); diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 5775dfaf83..6d54f5ca1a 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -804,6 +804,10 @@ Editor::Editor () BasicUI::AccessAction.connect (*this, invalidator (*this), boost::bind (&Editor::access_action, this, _1, _2), gui_context()); + /* handle escape */ + + ARDOUR_UI::instance()->Escape.connect (*this, invalidator (*this), boost::bind (&Editor::escape, this), gui_context()); + /* problematic: has to return a value and thus cannot be x-thread */ Session::AskAboutPlaylistDeletion.connect_same_thread (*this, boost::bind (&Editor::playlist_deletion_dialog, this, _1)); diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index ed928067dc..3924ad25f8 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -153,8 +153,6 @@ Editor::register_actions () /* add named actions for the editor */ - myactions.register_action (editor_actions, "escape", _("Break drag or deselect all"), sigc::mem_fun (*this, &Editor::escape)); - /* We don't bother registering "unlock" because it would be insensitive when required. Editor::unlock() must be invoked directly. */ diff --git a/gtk2_ardour/mixer.bindings b/gtk2_ardour/mixer.bindings index 2189715026..f835655b0a 100644 --- a/gtk2_ardour/mixer.bindings +++ b/gtk2_ardour/mixer.bindings @@ -17,6 +17,5 @@ - diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index 249f34f8ad..a3838707ce 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -308,6 +308,10 @@ Mixer_UI::Mixer_UI () MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_strip, this, _1), gui_context()); + /* handle escape */ + + ARDOUR_UI::instance()->Escape.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::escape, this), gui_context()); + #ifndef DEFER_PLUGIN_SELECTOR_LOAD _plugin_selector = new PluginSelector (PluginManager::instance ()); #else @@ -327,6 +331,12 @@ Mixer_UI::~Mixer_UI () delete _plugin_selector; } +void +Mixer_UI::escape () +{ + select_none (); +} + void Mixer_UI::track_editor_selection () { diff --git a/gtk2_ardour/mixer_ui.h b/gtk2_ardour/mixer_ui.h index 544578c091..ecb7b01912 100644 --- a/gtk2_ardour/mixer_ui.h +++ b/gtk2_ardour/mixer_ui.h @@ -374,6 +374,8 @@ class Mixer_UI : public Gtkmm2ext::Tabbable, public PBD::ScopedConnectionList, p bool _show_mixer_list; mutable boost::weak_ptr spilled_vca; + + void escape (); }; #endif /* __ardour_mixer_ui_h__ */ -- cgit v1.2.3