From f1390ca7f73fb1ce86f2a055a20acbafb299905a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 14 May 2021 13:26:36 -0600 Subject: [PATCH] add (theoretical) undo-ability for region markers and use source API instead of region --- gtk2_ardour/editor_ops.cc | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index b8ff15a10d..64388555cc 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -8736,8 +8736,32 @@ Editor::add_region_marker () RegionSelection rs = get_regions_from_selection_and_edit_point (); samplepos_t position = get_preferred_edit_position (); + bool in_command = false; for (RegionSelection::iterator r = rs.begin(); r != rs.end(); ++r) { - (*r)->region()->add_cue_marker ("foo", position); + + boost::shared_ptr region ((*r)->region()); + + if (position < region->position() || position >= region->position() + region->length()) { + continue; + } + + SourceList & sources = region->sources_for_edit (); + + CueMarker marker ("foo", region->start() + (position - region->position())); + + if (!in_command) { + begin_reversible_command (_("add region marker")); + in_command = true; + } + + for (SourceList::iterator s = sources.begin(); s != sources.end(); ++s) { + (*s)->add_cue_marker (marker); + _session->add_command (new StatefulDiffCommand (*s)); + } + } + + if (in_command) { + commit_reversible_command (); } }