From 87b5849a7b75fc9b84f5ae37658f90627ea6b79c Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 25 Apr 2023 11:38:16 -0600 Subject: [PATCH] kbd bindings: fix issues with delete & backspace bindings in draw/i-edit mode We now use the same actions in all modes, and the logic is: 1. is there a selected mixer strip and are we in it: if so, delete selected processors 2. are we in draw or internal mode? if so .. 2a. if there are selected control points, delete them 2b. if not, attempt to delete MIDI notes 2c. done 3. continue with delete operation as before --- gtk2_ardour/ardour.keys.in | 4 +--- gtk2_ardour/editor.h | 1 + gtk2_ardour/editor_actions.cc | 3 --- gtk2_ardour/editor_ops.cc | 27 ++++++++++++++++++++++++--- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/gtk2_ardour/ardour.keys.in b/gtk2_ardour/ardour.keys.in index 85e5f503fe..913159c1c8 100644 --- a/gtk2_ardour/ardour.keys.in +++ b/gtk2_ardour/ardour.keys.in @@ -484,9 +484,7 @@ This mode provides many different operations on both regions and control points, @notes|Notes/quantize-selected-notes|q|Quantize Selected Notes -@notes|Notes/delete| Backspace|Delete Note Selection -@notes|Notes/alt-delete| Delete|Delete Note Selection -@notes|Main/Escape|Clear selection +@notes|Main/Escape| Clear selection @notes|Notes/select-next| Tab|Select next note @notes|Notes/select-previous| <@PRIMARY@>Tab|Select previous note diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 43bb2c7e91..06142df30f 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -1408,6 +1408,7 @@ private: void split_region (); void delete_ (); + void alt_delete_ (); void cut (); void copy (); void paste (float times, bool from_context_menu); diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index e6e7ca2b7b..2f0e0bc7dd 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -821,9 +821,6 @@ Editor::register_midi_actions (Bindings* midi_bindings) /* two versions to allow same action for Delete and Backspace */ - ActionManager::register_action (_midi_actions, X_("delete"), _("Delete Selection"), sigc::bind (sigc::mem_fun (*this, &Editor::midi_action), &MidiRegionView::delete_selection)); - ActionManager::register_action (_midi_actions, X_("alt-delete"), _("Delete Selection (alternate)"), sigc::bind (sigc::mem_fun (*this, &Editor::midi_action), &MidiRegionView::delete_selection)); - ActionManager::register_action (_midi_actions, X_("clear-selection"), _("Clear Note Selection"), sigc::bind (sigc::mem_fun (*this, &Editor::midi_action), &MidiRegionView::clear_note_selection)); ActionManager::register_action (_midi_actions, X_("invert-selection"), _("Invert Note Selection"), sigc::bind (sigc::mem_fun (*this, &Editor::midi_action), &MidiRegionView::invert_selection)); ActionManager::register_action (_midi_actions, X_("extend-selection"), _("Extend Note Selection"), sigc::bind (sigc::mem_fun (*this, &Editor::midi_action), &MidiRegionView::extend_selection)); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 767ec9ec63..ce5c890e6d 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -4418,11 +4418,32 @@ Editor::delete_ () //special case: if the user is pointing in the editor/mixer strip, they may be trying to delete a plugin. //we need this because the editor-mixer strip is in the editor window, so it doesn't get the bindings from the mix window bool deleted = false; - if (current_mixer_strip && current_mixer_strip == MixerStrip::entered_mixer_strip()) - deleted = current_mixer_strip->delete_processors (); - if (!deleted) + if (current_mixer_strip && current_mixer_strip == MixerStrip::entered_mixer_strip()) { + deleted = current_mixer_strip->delete_processors (); + } + + if (internal_editing()) { + if (!selection->points.empty()) { + begin_reversible_command (_("delete control points")); + cut_copy_points (Delete, timepos_t (Temporal::AudioTime)); + selection->clear_points (); + commit_reversible_command (); + } else { + midi_action (&MidiRegionView::delete_selection); + } + return; + } + + if (!deleted) { cut_copy (Delete); + } +} + +void +Editor::alt_delete_ () +{ + delete_ (); } /** Cut selected regions, automation points or a time range */