diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2018-03-28 14:24:15 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2018-03-28 14:24:21 -0400 |
commit | 5132a6c2ebfe2559535919d87e73c4e5a58228c7 (patch) | |
tree | 817e28910f1fb2a049d83573890f46425a338f5b | |
parent | dd83d25bafd1b8620eaae8f4ff812e2b536160fe (diff) |
fix undo/redo for duplicate-regions in ripple mode
Also fix duplicate of multiple regions in the same track, and change "gap" variable
name to "span" for greater clarity
-rw-r--r-- | gtk2_ardour/editor_ops.cc | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index d92cbf4b65..7ac2e08390 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -4869,17 +4869,40 @@ Editor::duplicate_some_regions (RegionSelection& regions, float times) } boost::shared_ptr<Playlist> playlist; + std::set<boost::shared_ptr<Playlist> > playlists; // list of unique playlists affected by duplication RegionSelection sel = regions; // clear (below) may clear the argument list if its the current region selection RegionSelection foo; samplepos_t const start_sample = regions.start (); samplepos_t const end_sample = regions.end_sample (); - samplecnt_t const gap = end_sample - start_sample + 1; + samplecnt_t const span = end_sample - start_sample + 1; begin_reversible_command (Operations::duplicate_region); selection->clear_regions (); + /* ripple first so that we don't move the duplicates that will be added */ + + if (Config->get_edit_mode() == Ripple) { + + /* convert RegionSelection into RegionList so that we can pass it to ripple and exclude the regions we will duplicate */ + + RegionList exclude; + + for (RegionSelection::iterator i = sel.begin(); i != sel.end(); ++i) { + exclude.push_back ((*i)->region()); + playlist = (*i)->region()->playlist(); + if (playlists.insert (playlist).second) { + /* successfully inserted into set, so it's the first time we've seen this playlist */ + playlist->clear_changes (); + } + } + + for (set<boost::shared_ptr<Playlist> >::iterator p = playlists.begin(); p != playlists.end(); ++p) { + (*p)->ripple (start_sample, span * times, &exclude); + } + } + for (RegionSelection::iterator i = sel.begin(); i != sel.end(); ++i) { boost::shared_ptr<Region> r ((*i)->region()); @@ -4891,25 +4914,27 @@ Editor::duplicate_some_regions (RegionSelection& regions, float times) samplepos_t const position = end_sample + (r->first_sample() - start_sample + 1); playlist = (*i)->region()->playlist(); - playlist->clear_changes (); - - /* ripple first */ - if (Config->get_edit_mode() == Ripple) { - playlist->ripple (position, (*i)->region()->length() * times, (*i)->region()); + if (Config->get_edit_mode() != Ripple) { + if (playlists.insert (playlist).second) { + playlist->clear_changes (); + } } - /* now duplicate */ - - playlist->duplicate (r, position, gap, times); - - _session->add_command(new StatefulDiffCommand (playlist)); + playlist->duplicate (r, position, span, times); c.disconnect (); foo.insert (foo.end(), latest_regionviews.begin(), latest_regionviews.end()); } + for (set<boost::shared_ptr<Playlist> >::iterator p = playlists.begin(); p != playlists.end(); ++p) { + _session->add_command (new StatefulDiffCommand (*p)); + vector<Command*> cmds; + (*p)->rdiff (cmds); + _session->add_commands (cmds); + } + if (!foo.empty()) { selection->set (foo); } |