From f8f53a4cae70ee50dd70afa5f6db7fdfd94fc863 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Mon, 14 Mar 2022 19:21:03 -0500 Subject: [PATCH] ripple (gui part) changes to Range + RippleAll behavior on markers Range->Delete is the most common type of ripple-editing imho ... so we need to implement ripple_marks for that common action * markers inside a deleted range should be removed * range markers (start+end) need special handling * remaining markers to the right can be rippled by libardour * implement undo --- gtk2_ardour/editor_ops.cc | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index f4b9fef99f..3c54293325 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -5016,6 +5016,52 @@ Editor::cut_copy_ranges (CutCopyOp op) for (TrackViewList::iterator i = ts.begin(); i != ts.end(); ++i) { (*i)->cut_copy_clear (*selection, op); } + + if (should_ripple_all() && ( + (op == Cut) || + (op == Delete) || + (op == Clear)) ){ + + //set up for undo + bool changed = false; + XMLNode &before = _session->locations()->get_state(); + + /* If markers are inside a deleted range, they must be removed */ + /* TODO: currently we have no Cut-buffer for markers, we can only Delete them */ + Locations::LocationList locs; + _session->locations()->find_all_between (selection->time.start_time(), selection->time.end_time(), locs, Location::Flags(0)); + for (Locations::LocationList::iterator i = locs.begin(); i != locs.end(); ++i) { + if ((*i)->is_mark()) { + /* remove the marks in our Range */ + _session->locations()->remove (*i); + changed = true; + } else if ((*i)->is_range_marker()) { + /* if a named-range is wholly incorporated in our Range: delete it */ + if ((*i)->start() >= selection->time.start_time() && (*i)->end() <= selection->time.end_time() ) { + _session->locations()->remove (*i); + changed = true; + } else if ((*i)->start() >= selection->time.start_time() && (*i)->end() > selection->time.end_time() ) { + /* only the start of a named-range is incorporated in our Range: move it to the start of the selection */ + (*i)->set_start(selection->time.start_time()) ; + changed = true; + } else if ((*i)->end() >= selection->time.start_time() && (*i)->end() > selection->time.end_time() ) { + /* only the end of a named-range is incorporated in our Range: move it to the start of the selection */ + (*i)->set_end(selection->time.start_time()) ; + changed = true; + } + } + } + + //store undo command + if (changed) { + XMLNode &after = _session->locations()->get_state(); + _session->add_command(new MementoCommand(*(_session->locations()), &before, &after)); + } + + /* markers to the right of a deleted range should be rippled to the left */ + /* this stores more undo memento commands */ + ripple_marks(boost::shared_ptr(), selection->time.start_time(), -selection->time.length()); + } } void