From 23aa663f9d35185346986aa606550162c2a165ba Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 21 Jun 2021 12:23:52 -0600 Subject: [PATCH] when doing a ripple-all drag, move relevant markers during the drag too Note that this is purely GUI-level: the ARDOUR::Locations are changed at the end of the drag in Editor::ripple_marks() --- gtk2_ardour/editor.h | 2 ++ gtk2_ardour/editor_drag.cc | 8 ++++++++ gtk2_ardour/editor_drag.h | 1 + gtk2_ardour/editor_markers.cc | 17 +++++++++++++++++ gtk2_ardour/editor_ops.cc | 18 +++++++++++++----- 5 files changed, 41 insertions(+), 5 deletions(-) diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index e4ad54eca6..6bfe1c6a6d 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -589,6 +589,8 @@ public: void do_ripple (boost::shared_ptr, samplepos_t, samplecnt_t, ARDOUR::RegionList* exclude, bool add_to_command); void do_ripple (boost::shared_ptr, samplepos_t, samplecnt_t, boost::shared_ptr exclude, bool add_to_command); void ripple_marks (boost::shared_ptr target_playlist, samplepos_t at, samplecnt_t distance); + void get_markers_to_ripple (boost::shared_ptr target_playlist, samplepos_t pos, std::vector& markers); + samplepos_t effective_ripple_mark_start (boost::shared_ptr target_playlist, samplepos_t pos); void add_region_marker (); void clear_region_markers (); diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 797d93bfe7..3d360c167b 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -1029,6 +1029,8 @@ RegionMotionDrag::collect_ripple_views () _views.push_back (DraggingView (*i, this, &(*i)->get_time_axis_view())); } } + + _editor->get_markers_to_ripple (_primary->region()->playlist(), _primary->region()->position(), ripple_markers); } void @@ -1255,6 +1257,12 @@ RegionMotionDrag::motion (GdkEvent* event, bool first_move) #endif } + if (x_delta) { + for (vector::iterator m = ripple_markers.begin(); m != ripple_markers.end(); ++m) { + (*m)->the_item().move (Duple (x_delta, 0.)); + } + } + for (list::iterator i = _views.begin(); i != _views.end(); ++i) { RegionView* rv = i->view; diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index 64ce55ca57..de4714fb1b 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -435,6 +435,7 @@ protected: double _total_x_delta; int _last_pointer_time_axis_view; double _last_pointer_layer; + std::vector ripple_markers; private: uint32_t _ndropzone; diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index 60090ee81a..7f17f183f7 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -467,6 +467,23 @@ Editor::LocationMarkers::~LocationMarkers () delete end; } +void +Editor::get_markers_to_ripple (boost::shared_ptr target_playlist, samplepos_t pos, std::vector& markers) +{ + + pos = effective_ripple_mark_start (target_playlist, pos); + + for (LocationMarkerMap::const_iterator i = location_markers.begin(); i != location_markers.end(); ++i) { + if (i->first->start() >= pos) { + cerr << "Add markers for " << i->first->name() << endl; + markers.push_back (i->second->start); + } + if (i->first->end() >= pos && i->second->end) { + markers.push_back (i->second->end); + } + } +} + Editor::LocationMarkers * Editor::find_location_markers (Location *location) const { diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index f22cbf0ce4..c9eb193d87 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -9280,8 +9280,8 @@ Editor::do_ripple (boost::shared_ptr target_playlist, samplepos_t at, ripple_marks (target_playlist, at, distance); } -void -Editor::ripple_marks (boost::shared_ptr target_playlist, samplepos_t at, samplecnt_t distance) +samplepos_t +Editor::effective_ripple_mark_start (boost::shared_ptr target_playlist, samplepos_t pos) { /* in the target playlist, find the region before the target * (implicitly given by @param at. Allow all markers that occur between @@ -9294,15 +9294,23 @@ Editor::ripple_marks (boost::shared_ptr target_playlist, samplepos_t a for (RegionList::const_iterator r = rl->begin(); r != rl->end(); ++r) { samplepos_t region_end = (*r)->position() + (*r)->length(); - if (region_end > last_region_end_before_at && region_end < at) { + if (region_end > last_region_end_before_at && region_end < pos) { last_region_end_before_at = region_end; } } - if (last_region_end_before_at < at) { - at = last_region_end_before_at + 1; + if (last_region_end_before_at < pos) { + pos = last_region_end_before_at + 1; } + return pos; +} + +void +Editor::ripple_marks (boost::shared_ptr target_playlist, samplepos_t at, samplecnt_t distance) +{ + at = effective_ripple_mark_start (target_playlist, at); + XMLNode& before (_session->locations()->get_state()); /* do not move locked markers, do notify */ _session->locations()->ripple (at, distance, false, true);