From d4227b6ca41675ac6c292c5f75b3a0fe21955024 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 31 Jul 2024 22:38:38 -0600 Subject: [PATCH] add actions for region lock/unlock (from Mark Knoop < mark@opus11.net> --- gtk2_ardour/editor.h | 2 ++ gtk2_ardour/editor_actions.cc | 6 ++++- gtk2_ardour/editor_ops.cc | 48 +++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 52e2b22bb8..bbf24a82a4 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -1336,6 +1336,8 @@ private: /* EDITING OPERATIONS */ void reset_point_selection (); + void region_lock (); + void region_unlock (); void toggle_region_lock (); void toggle_opaque_region (); void toggle_record_enable (); diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index 5bdd8105cd..16ad1ab137 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -1871,8 +1871,12 @@ Editor::register_region_actions () /* Move selected regions to their original (`natural') position */ register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "naturalize-region", _("Move to Original Position"), sigc::mem_fun (*this, &Editor::naturalize_region)); + /* Change `locked' status of selected regions */ + register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "region-lock", _("Lock"), sigc::mem_fun(*this, &Editor::region_lock)); + register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "region-unlock", _("Unlock"), sigc::mem_fun(*this, &Editor::region_unlock)); + /* Toggle `locked' status of selected regions */ - register_toggle_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "toggle-region-lock", _("Lock"), sigc::mem_fun(*this, &Editor::toggle_region_lock)); + register_toggle_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "toggle-region-lock", _("Lock (toggle)"), sigc::mem_fun(*this, &Editor::toggle_region_lock)); register_toggle_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "toggle-region-video-lock", _("Lock to Video"), sigc::mem_fun(*this, &Editor::toggle_region_video_lock)); /* Remove sync points from selected regions */ diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 65b5025ce1..2c0293e662 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -6753,6 +6753,54 @@ Editor::toggle_gain_envelope_active () } } +void +Editor::region_lock () +{ + if (_ignore_region_action) { + return; + } + + RegionSelection rs = get_regions_from_selection_and_entered (); + + if (!_session || rs.empty()) { + return; + } + + begin_reversible_command (_("region lock")); + + for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) { + (*i)->region()->clear_changes (); + (*i)->region()->set_locked (true); + _session->add_command (new StatefulDiffCommand ((*i)->region())); + } + + commit_reversible_command (); +} + +void +Editor::region_unlock () +{ + if (_ignore_region_action) { + return; + } + + RegionSelection rs = get_regions_from_selection_and_entered (); + + if (!_session || rs.empty()) { + return; + } + + begin_reversible_command (_("region unlock")); + + for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) { + (*i)->region()->clear_changes (); + (*i)->region()->set_locked (false); + _session->add_command (new StatefulDiffCommand ((*i)->region())); + } + + commit_reversible_command (); +} + void Editor::toggle_region_lock () {