From 3047b2552709c789faffa0d97ff7ccde22012454 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 18 May 2021 18:46:55 -0600 Subject: [PATCH] split out region marker actions to their own submenu; implement remove and clear all --- gtk2_ardour/ardour.menus.in | 5 +++- gtk2_ardour/editor.h | 2 ++ gtk2_ardour/editor_actions.cc | 2 ++ gtk2_ardour/editor_markers.cc | 2 +- gtk2_ardour/editor_ops.cc | 54 ++++++++++++++++++++++++++++++++++- 5 files changed, 62 insertions(+), 3 deletions(-) diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in index 24f4da34d4..5a92987435 100644 --- a/gtk2_ardour/ardour.menus.in +++ b/gtk2_ardour/ardour.menus.in @@ -353,7 +353,6 @@ - @@ -361,6 +360,10 @@ + + + + diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 5868945615..0a8c632d18 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -586,6 +586,8 @@ public: void edit_meter_section (ARDOUR::MeterSection*); void add_region_marker (); + void clear_region_markers (); + void remove_region_marker (ARDOUR::CueMarker&); protected: void map_transport_state (); diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index 9ee3fc3736..4b1633a465 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -137,6 +137,7 @@ Editor::register_actions () ActionManager::register_action (editor_menu_actions, X_("RegionMenu"), _("Region")); ActionManager::register_action (editor_menu_actions, X_("RegionMenuLayering"), _("Layering")); ActionManager::register_action (editor_menu_actions, X_("RegionMenuPosition"), _("Position")); + ActionManager::register_action (editor_menu_actions, X_("RegionMenuMarkers"), _("Markers")); ActionManager::register_action (editor_menu_actions, X_("RegionMenuEdit"), _("Edit")); ActionManager::register_action (editor_menu_actions, X_("RegionMenuTrim"), _("Trim")); ActionManager::register_action (editor_menu_actions, X_("RegionMenuGain"), _("Gain")); @@ -1654,6 +1655,7 @@ Editor::register_region_actions () /* PART 3: actions that operate on the selection and also require the edit point location */ register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "add-region-cue-marker", _("Add Region Cue Marker"), sigc::mem_fun (*this, &Editor::add_region_marker)); + register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "clear-region-cue-markers", _("Clear Region Cue Markers"), sigc::mem_fun (*this, &Editor::clear_region_markers)); register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "set-region-sync-position", _("Set Sync Position"), sigc::mem_fun (*this, &Editor::set_region_sync_position)); register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "place-transient", _("Place Transient"), sigc::mem_fun (*this, &Editor::place_transient)); register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "trim-front", _("Trim Start at Edit Point"), sigc::mem_fun (*this, &Editor::trim_region_front)); diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index 0153972a42..66ec9b6b8f 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -805,7 +805,7 @@ Editor::really_remove_region_marker (ArdourMarker* marker) return FALSE; } - rv->region()->remove_cue_marker (cm); + remove_region_marker (cm); commit_reversible_command (); return FALSE; diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index d3d4f1c644..7780c730d9 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -8761,7 +8761,7 @@ Editor::add_region_marker () CueMarker marker (str, region->start() + (position - region->position())); if (!in_command) { - begin_reversible_command (_("add region marker")); + begin_reversible_command (_("add cue marker")); in_command = true; } @@ -8775,3 +8775,55 @@ Editor::add_region_marker () commit_reversible_command (); } } + +void +Editor::remove_region_marker (CueMarker& cm) +{ + RegionSelection rs = get_regions_from_selection_and_edit_point (); + bool in_command = false; + + for (RegionSelection::iterator r = rs.begin(); r != rs.end(); ++r) { + SourceList & sources = (*r)->region()->sources_for_edit (); + for (SourceList::iterator s = sources.begin(); s != sources.end(); ++s) { + + if ((*s)->remove_cue_marker (cm)) { + if (!in_command) { + begin_reversible_command (_("remove cue marker")); + in_command = true; + } + _session->add_command (new StatefulDiffCommand (*s)); + } + } + } + + if (in_command) { + commit_reversible_command (); + } +} + +void +Editor::clear_region_markers () +{ + + RegionSelection rs = get_regions_from_selection_and_edit_point (); + bool in_command = false; + + for (RegionSelection::iterator r = rs.begin(); r != rs.end(); ++r) { + SourceList & sources = (*r)->region()->sources_for_edit (); + for (SourceList::iterator s = sources.begin(); s != sources.end(); ++s) { + + if ((*s)->clear_cue_markers ()) { + if (!in_command) { + begin_reversible_command (_("clear cue markers")); + in_command = true; + } + _session->add_command (new StatefulDiffCommand (*s)); + } + } + } + + if (in_command) { + commit_reversible_command (); + } +} +