From 483047635cc2eec11f383bdce87c4880a54d0358 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Fri, 16 Dec 2022 13:16:11 -0600 Subject: [PATCH] Rec page: implement Undo actions and shortcuts * undo is not (currently) a Global action, it's an Editor action * ... but we want the ability to undo a recording One option would be to chagne Undo to a Global action, which would have a sizable impact on code and existing shortcuts. Instead I'm choosing to implement a Rec-page-specific Undo action & shortcut It's conceivable that someday we would want the Recorder page to ONLY undo record operations, and the Mixer page to ONLY undo mixer operations, or something like that. This lays the foundation for that. --- gtk2_ardour/ardour.keys.in | 7 +++++-- gtk2_ardour/recorder_ui.cc | 19 +++++++++++++++++++ gtk2_ardour/recorder_ui.h | 4 ++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/ardour.keys.in b/gtk2_ardour/ardour.keys.in index dea619a011..85e5f503fe 100644 --- a/gtk2_ardour/ardour.keys.in +++ b/gtk2_ardour/ardour.keys.in @@ -498,5 +498,8 @@ This mode provides many different operations on both regions and control points, @notes|Notes/invert-selection| <@PRIMARY@>i|Invert note selection @notes|Notes/duplicate-selection| <@PRIMARY@>d|Duplicate note selection -@rec|Recorder/arm-all| <@PRIMARY@>r|record arm all tracks -@rec|Recorder/arm-none| <@PRIMARY@><@TERTIARY@>r|disable record arm of all tracks +@rec|Recorder/arm-all| <@PRIMARY@>r|record arm all tracks +@rec|Recorder/arm-none| <@PRIMARY@><@TERTIARY@>r|disable record arm of all tracks +@rec|Recorder/rec-undo| <@PRIMARY@>z|undo +@rec|Recorder/rec-redo| <@PRIMARY@><@TERTIARY@>z|redo +@rec|Recorder/alternate-rec-redo| <@PRIMARY@>y|redo diff --git a/gtk2_ardour/recorder_ui.cc b/gtk2_ardour/recorder_ui.cc index 89afef6f4f..cbee56d0b1 100644 --- a/gtk2_ardour/recorder_ui.cc +++ b/gtk2_ardour/recorder_ui.cc @@ -393,6 +393,9 @@ RecorderUI::register_actions () ActionManager::register_action (group, "reset-input-peak-hold", _("Reset Input Peak Hold"), sigc::mem_fun (*this, &RecorderUI::peak_reset)); ActionManager::register_action (group, "arm-all", _("Record Arm All Tracks"), sigc::mem_fun (*this, &RecorderUI::arm_all)); ActionManager::register_action (group, "arm-none", _("Disable Record Arm of All Tracks"), sigc::mem_fun (*this, &RecorderUI::arm_none)); + ActionManager::register_action (group, "rec-undo", _("Undo"), sigc::mem_fun (*this, &RecorderUI::rec_undo)); + ActionManager::register_action (group, "rec-redo", _("Redo"), sigc::mem_fun (*this, &RecorderUI::rec_redo)); + ActionManager::register_action (group, "alternate-rec-redo", _("Redo"), sigc::mem_fun (*this, &RecorderUI::rec_redo)); } void @@ -1347,6 +1350,22 @@ RecorderUI::arm_none () } } +void +RecorderUI::rec_undo () +{ + if (_session) { + _session->undo (1); + } +} + +void +RecorderUI::rec_redo () +{ + if (_session) { + _session->redo (1); + } +} + void RecorderUI::peak_reset () { diff --git a/gtk2_ardour/recorder_ui.h b/gtk2_ardour/recorder_ui.h index 2bd833609d..50d96badcc 100644 --- a/gtk2_ardour/recorder_ui.h +++ b/gtk2_ardour/recorder_ui.h @@ -114,6 +114,10 @@ private: void arm_all (); void arm_none (); + + void rec_undo (); + void rec_redo (); + void peak_reset (); void update_sensitivity ();