Fix ripple undo/redo

Ripple edit undo/redo needs a "recursive diff" of all regions
in the playlist. To work properly owned changes have to be
cleared first, previously unrelated edits were be collected too.

This includes a more consistent version of
7a89d56009 using rdiff() instead of explicitly
saving region diffs.
This commit is contained in:
Robin Gareus 2021-05-23 17:42:33 +02:00
parent 31bbf03a67
commit 445f9a51bf
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 23 additions and 14 deletions

View File

@ -1047,10 +1047,17 @@ Editor::finish_bringing_in_material (boost::shared_ptr<Region> region,
boost::shared_ptr<Playlist> playlist = existing_track->playlist();
boost::shared_ptr<Region> copy (RegionFactory::create (region, region->properties()));
playlist->clear_changes ();
playlist->clear_owned_changes ();
playlist->add_region (copy, pos);
if (Config->get_edit_mode() == Ripple)
if (Config->get_edit_mode() == Ripple) {
playlist->ripple (pos, copy->length(), copy);
/* recusive diff of rippled regions */
vector<Command*> cmds;
playlist->rdiff (cmds);
_session->add_commands (cmds);
}
_session->add_command (new StatefulDiffCommand (playlist));
break;
}

View File

@ -2089,26 +2089,20 @@ RegionInsertDrag::finished (GdkEvent * event, bool)
_editor->begin_reversible_command (Operations::insert_region);
playlist->clear_changes ();
playlist->clear_owned_changes ();
_editor->snap_to_with_modifier (_last_position, event);
playlist->add_region (_primary->region (), _last_position.sample, 1.0, false, _last_position.division);
// Mixbus doesn't seem to ripple when inserting regions from the list: should we? yes, probably
if (Config->get_edit_mode() == Ripple) {
boost::shared_ptr<RegionList> rl = playlist->regions_with_start_within (Evoral::Range<samplepos_t>(_last_position.sample, max_samplepos));
for (RegionList::iterator i = rl->begin(); i != rl->end(); ++i) {
(*i)->clear_changes ();
}
playlist->ripple (_last_position.sample, _primary->region()->length(), _primary->region());
samplepos_t where = _last_position.sample + _primary->region()->length();
for (RegionList::iterator i = rl->begin(); i != rl->end(); ++i) {
if ((*i)->position() >= where) {
_editor->session()->add_command (new StatefulDiffCommand (*i));
}
}
/* recusive diff of rippled regions */
vector<Command*> cmds;
playlist->rdiff (cmds);
_session->add_commands (cmds);
}
_editor->session()->add_command (new StatefulDiffCommand (playlist));
_editor->commit_reversible_command ();

View File

@ -2620,9 +2620,15 @@ Editor::insert_source_list_selection (float times)
begin_reversible_command (_("insert region"));
playlist->clear_changes ();
playlist->clear_owned_changes ();
playlist->add_region ((RegionFactory::create (region, true)), get_preferred_edit_position(), times);
if (Config->get_edit_mode() == Ripple)
if (Config->get_edit_mode() == Ripple) {
playlist->ripple (get_preferred_edit_position(), region->length() * times, boost::shared_ptr<Region>());
/* recusive diff of rippled regions */
vector<Command*> cmds;
playlist->rdiff (cmds);
_session->add_commands (cmds);
}
_session->add_command(new StatefulDiffCommand (playlist));
commit_reversible_command ();
@ -5067,6 +5073,7 @@ Editor::duplicate_some_regions (RegionSelection& regions, float times)
if (playlists.insert (playlist).second) {
/* successfully inserted into set, so it's the first time we've seen this playlist */
playlist->clear_changes ();
playlist->clear_owned_changes ();
}
}
@ -5090,6 +5097,7 @@ Editor::duplicate_some_regions (RegionSelection& regions, float times)
if (Config->get_edit_mode() != Ripple) {
if (playlists.insert (playlist).second) {
playlist->clear_changes ();
playlist->clear_owned_changes ();
}
}