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()
This commit is contained in:
Paul Davis 2021-06-21 12:23:52 -06:00
parent 140c5e818f
commit 23aa663f9d
5 changed files with 41 additions and 5 deletions

View File

@ -589,6 +589,8 @@ public:
void do_ripple (boost::shared_ptr<ARDOUR::Playlist>, samplepos_t, samplecnt_t, ARDOUR::RegionList* exclude, bool add_to_command);
void do_ripple (boost::shared_ptr<ARDOUR::Playlist>, samplepos_t, samplecnt_t, boost::shared_ptr<ARDOUR::Region> exclude, bool add_to_command);
void ripple_marks (boost::shared_ptr<ARDOUR::Playlist> target_playlist, samplepos_t at, samplecnt_t distance);
void get_markers_to_ripple (boost::shared_ptr<ARDOUR::Playlist> target_playlist, samplepos_t pos, std::vector<ArdourMarker*>& markers);
samplepos_t effective_ripple_mark_start (boost::shared_ptr<ARDOUR::Playlist> target_playlist, samplepos_t pos);
void add_region_marker ();
void clear_region_markers ();

View File

@ -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<ArdourMarker*>::iterator m = ripple_markers.begin(); m != ripple_markers.end(); ++m) {
(*m)->the_item().move (Duple (x_delta, 0.));
}
}
for (list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
RegionView* rv = i->view;

View File

@ -435,6 +435,7 @@ protected:
double _total_x_delta;
int _last_pointer_time_axis_view;
double _last_pointer_layer;
std::vector<ArdourMarker*> ripple_markers;
private:
uint32_t _ndropzone;

View File

@ -467,6 +467,23 @@ Editor::LocationMarkers::~LocationMarkers ()
delete end;
}
void
Editor::get_markers_to_ripple (boost::shared_ptr<Playlist> target_playlist, samplepos_t pos, std::vector<ArdourMarker*>& 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
{

View File

@ -9280,8 +9280,8 @@ Editor::do_ripple (boost::shared_ptr<Playlist> target_playlist, samplepos_t at,
ripple_marks (target_playlist, at, distance);
}
void
Editor::ripple_marks (boost::shared_ptr<Playlist> target_playlist, samplepos_t at, samplecnt_t distance)
samplepos_t
Editor::effective_ripple_mark_start (boost::shared_ptr<Playlist> 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<Playlist> 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<Playlist> 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);