From 1b6e4b0b84cdde91b015081b9864316ec1b0a1d5 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 4 May 2023 06:02:00 +0200 Subject: [PATCH] Implement marker copy/paste section --- libs/ardour/location.cc | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc index 27d7810347..5692270ca1 100644 --- a/libs/ardour/location.cc +++ b/libs/ardour/location.cc @@ -1684,6 +1684,7 @@ void Locations::cut_copy_section (timepos_t const& start, timepos_t const& end, timepos_t const& to, bool const copy) { LocationList ll; + LocationList pastebuf; { Glib::Threads::RWLock::WriterLock lm (_lock); @@ -1756,7 +1757,40 @@ Locations::cut_copy_section (timepos_t const& start, timepos_t const& end, timep i->set (i->start () + distance, i->end () + dist_end); } else { - // TODO Copy/Paste: add new markers, disambiugate names + if (i->start() >= start && i->start() < end) { + Location* copy = new Location (*i); + pastebuf.push_back (copy); + } + } + } + + if (copy) { + /* ripple */ + timecnt_t distance = start.distance(end); + for (auto const& i : ll) { + if (i->start() >= to) { + if (i->is_mark ()) { + i->set_start (i->start () + distance); + } else { + i->set (i->start () + distance, i->end () + distance); + } + } else if (!i->is_mark () && i->end() >= to) { + i->set_end (i->end () + distance); + } + } + /* paste */ + distance = start.distance (to); + for (auto const& i : pastebuf) { + if (i->is_mark ()) { + i->set_start (i->start () + distance); + } else { + i->set (i->start () + distance, i->end () + distance); + } + locations.push_back (i); + added (i); /* EMIT SIGNAL */ + if (i->is_cue_marker()) { + Location::cue_change (i); /* EMIT SIGNAL */ + } } } }