From 9f137bfd56762501c71491c3a24c1278b721e197 Mon Sep 17 00:00:00 2001 From: Johannes Mueller Date: Thu, 9 Jul 2020 17:52:27 +0200 Subject: [PATCH] Ripple move simplifications Dropping the feature of rippling across tracks makes things simpler and allows removal of a quite a few lines of code. As we no longer ripple move regions from one track to another, we no longer need to keep track which regions are selected during the drag and which regions are moved due to rippling. We can treat all regions after the first selected one in one track as if they were selected as well. This also fixes properly what was already addressed in 9b2228d6fd. Unfortunately that did only fix the behavior when ripple moving forwards. This fix also works ripple moving backwards. --- gtk2_ardour/editor_drag.cc | 55 +------------------------------------- gtk2_ardour/editor_drag.h | 1 - 2 files changed, 1 insertion(+), 55 deletions(-) diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 63abd11e83..6686af216a 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -2193,7 +2193,7 @@ RegionRippleDrag::add_all_after_to_views(TimeAxisView *tav, samplepos_t where, c } } - for (RegionSelection::reverse_iterator i = to_ripple.rbegin(); i != to_ripple.rend(); ++i) { + for (RegionSelection::iterator i = to_ripple.begin(); i != to_ripple.end(); ++i) { if (!exclude.contains (*i)) { // the selection has already been added to _views _views.push_back (DraggingView (*i, this, tav)); @@ -2201,43 +2201,6 @@ RegionRippleDrag::add_all_after_to_views(TimeAxisView *tav, samplepos_t where, c } } -void -RegionRippleDrag::remove_unselected_from_views(samplecnt_t amount, bool move_regions) -{ - - for (std::list::iterator i = _views.begin(); i != _views.end(); ) { - // we added all the regions after the selection - - std::list::iterator to_erase = i++; - if (!_editor->selection->regions.contains (to_erase->view)) { - // restore the non-selected regions to their original playlist & positions, - // and then ripple them back by the length of the regions that were dragged away - // do the same things as RegionMotionDrag::aborted - - RegionView *rv = to_erase->view; - TimeAxisView* tv = &(rv->get_time_axis_view ()); - RouteTimeAxisView* rtv = dynamic_cast (tv); - assert (rtv); - - // plonk them back onto their own track - rv->get_canvas_group()->reparent(rtv->view()->canvas_item()); - rv->get_canvas_group()->set_y_position (0); - rv->drag_end (); - - if (move_regions) { - // move the underlying region to match the view - rv->region()->set_position (rv->region()->position() + amount); - } else { - // restore the view to match the underlying region's original position - rv->move(-amount, 0); // second parameter is y delta - seems 0 is OK - } - - rv->set_height (rtv->view()->child_height ()); - _views.erase (to_erase); - } - } -} - bool RegionRippleDrag::y_movement_allowed (int delta_track, double delta_layer, int skip_invisible) const { @@ -2335,22 +2298,6 @@ RegionRippleDrag::finished (GdkEvent* event, bool movement_occurred) _editor->begin_reversible_command(_("Ripple drag")); - std::set > playlists = _editor->selection->regions.playlists(); - std::set >::const_iterator pi; - - for (pi = playlists.begin(); pi != playlists.end(); ++pi) { - (*pi)->clear_changes(); - (*pi)->clear_owned_changes(); - } - remove_unselected_from_views (prev_amount, true); - - for (pi = playlists.begin(); pi != playlists.end(); ++pi) { - vector cmds; - (*pi)->rdiff (cmds); - _editor->session()->add_commands (cmds); - } - - // other modified playlists are added to undo by RegionMoveDrag::finished() RegionMoveDrag::finished (event, movement_occurred); _editor->commit_reversible_command(); } diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index cdce3765af..ca3b08fb9c 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -516,7 +516,6 @@ private: ARDOUR::samplecnt_t selection_length; ARDOUR::RegionList *exclude; virtual void add_all_after_to_views (TimeAxisView *tav, ARDOUR::samplepos_t where, const RegionSelection &exclude); - void remove_unselected_from_views (ARDOUR::samplecnt_t amount, bool move_regions); }; /** "Drag" to cut a region (action only on button release) */