diff --git a/mrv2/docs/HISTORY.md b/mrv2/docs/HISTORY.md index 840facabc..ec71cd376 100644 --- a/mrv2/docs/HISTORY.md +++ b/mrv2/docs/HISTORY.md @@ -54,6 +54,8 @@ v0.8.0 - Made dragging a clip from the Files Panel not loose the selection. - Fixed a network error (harmless) about edit mode. - Fixed Creation of EDL Playlist with image sequences. +- Fixed annotations copying from source clip to EDL Playlist when adding the + clip to the playlist. - Some UI fixes: * The Zoom factor in the Pixel Toolbar keeps its value when selecting it from the pulldown. diff --git a/mrv2/lib/mrvEdit/mrvEditCallbacks.cpp b/mrv2/lib/mrvEdit/mrvEditCallbacks.cpp index 96c024399..ab206a68e 100644 --- a/mrv2/lib/mrvEdit/mrvEditCallbacks.cpp +++ b/mrv2/lib/mrvEdit/mrvEditCallbacks.cpp @@ -243,6 +243,28 @@ namespace mrv copiedFrames.push_back(frame); } + std::vector > deepCopyAnnotations( + const std::vector >& + originalAnnotations) + { + // First, do a deep copy of all annotations. + std::vector> annotations; + std::vector< draw::Annotation > flatAnnotations; + for (const auto& annotation : originalAnnotations) + { + flatAnnotations.push_back(*annotation.get()); + } + Message json = flatAnnotations; + for (const auto& j : json) + { + std::shared_ptr< draw::Annotation > tmp = + draw::messageToAnnotation(j); + annotations.push_back(tmp); + } + + return annotations; + } + static size_t otioIndex = 1; file::Path savedPath, savedAudioPath; @@ -629,23 +651,27 @@ namespace mrv //! Routine used to add annotations to the end of the timeline, //! once a clip is added. std::vector> addAnnotations( - const RationalTime& duration, const double videoRate, - const std::vector>& annotations, + const RationalTime& duration, + const std::vector>& + playerAnnotations, const std::vector>& clipAnnotations) { std::vector> out; - for (auto a : annotations) + + // Shallow copy player annotations + for (auto a : playerAnnotations) { out.push_back(a); } - for (auto a : clipAnnotations) + + // First, do a deep copy of all clip annotations. + auto annotations = deepCopyAnnotations(clipAnnotations); + for (auto& a : annotations) { - out.push_back(a); - auto time = out.back()->time; + auto& time = a->time; time += duration; - time = time::round(time.rescaled_to(videoRate)); - out.back()->time = time; + out.push_back(a); } return out; } @@ -1241,20 +1267,7 @@ namespace mrv return; const auto& originalAnnotations = player->getAllAnnotations(); - - // First, do a deep copy of all annotations. - std::vector> annotations; - std::vector< draw::Annotation > flatAnnotations; - for (const auto& annotation : originalAnnotations) - { - flatAnnotations.push_back(*annotation.get()); - } - Message json = flatAnnotations; - for (const auto& j : json) - { - std::shared_ptr< Annotation > tmp = messageToAnnotation(j); - annotations.push_back(tmp); - } + auto annotations = deepCopyAnnotations(originalAnnotations); // Then, adjust the annotations within the range. std::set> skipAnnotations; @@ -1510,16 +1523,17 @@ namespace mrv try { auto timelineDuration = timeline->duration(); + timelineDuration = + timelineDuration.rescaled_to(player->defaultSpeed()); auto annotations = addAnnotations( - timelineDuration, player->defaultSpeed(), - player->getAllAnnotations(), sourceItem->annotations); + timelineDuration, player->getAllAnnotations(), + sourceItem->annotations); edit_store_undo(player, ui); auto Aindex = model->observeAIndex()->get(); auto stack = timeline->tracks(); - bool reloadOtio = hasEmptyTracks(stack); auto tracks = stack->children(); otio::ErrorStatus errorStatus; int videoTrackIndex = -1; @@ -1744,8 +1758,10 @@ namespace mrv player = ui->uiView->getTimelinePlayer(); if (!player) return; - player->setAllAnnotations(annotations); + updateTimeline(timeline, player->currentTime(), ui); + player->setAllAnnotations(annotations); + player->seek(timelineDuration + sourceItem->currentTime); ui->uiTimeline->frameView(); panel::refreshPanelThumbnails(); diff --git a/mrv2/lib/mrvFl/mrvCallbacks.cpp b/mrv2/lib/mrvFl/mrvCallbacks.cpp index 6471daca8..e491aa681 100644 --- a/mrv2/lib/mrvFl/mrvCallbacks.cpp +++ b/mrv2/lib/mrvFl/mrvCallbacks.cpp @@ -1886,38 +1886,14 @@ namespace mrv if (model->observeFiles()->getSize() < 1) return; - auto item = model->observeA()->get(); auto origIndex = model->observeAIndex()->get(); - int layer = ui->uiColorChannel->value(); - auto player = ui->uiView->getTimelinePlayer(); - timeline::Playback playback = player->playback(); - auto currentTime = player->currentTime(); - auto inOutRange = player->inOutRange(); + clone_file_cb(m, d); - app->open(item->path.get(), item->audioPath.get()); - - auto newItem = model->observeA()->get(); auto newIndex = model->observeAIndex()->get(); - newItem->inOutRange = inOutRange; - newItem->speed = item->speed; - newItem->audioOffset = item->audioOffset; - newItem->loop = item->loop; - newItem->playback = playback; - newItem->currentTime = currentTime; - newItem->annotations = item->annotations; - ui->uiColorChannel->value(layer); - ui->uiColorChannel->do_callback(); - model->setA(origIndex); model->close(); model->setA(newIndex); - - player = ui->uiView->getTimelinePlayer(); - player->setAllAnnotations(newItem->annotations); - player->setPlayback(playback); - player->seek(currentTime); - panel::redrawPanelThumbnails(); } void set_stereo_cb(Fl_Menu_* m, void* d) diff --git a/mrv2/lib/mrvFl/mrvTimelinePlayer.cpp b/mrv2/lib/mrvFl/mrvTimelinePlayer.cpp index 761716cab..7787f38f4 100644 --- a/mrv2/lib/mrvFl/mrvTimelinePlayer.cpp +++ b/mrv2/lib/mrvFl/mrvTimelinePlayer.cpp @@ -632,7 +632,7 @@ namespace mrv { TLRENDER_P(); - auto time = currentTime(); + const auto& time = currentTime(); otime::RationalTime previousTime( static_cast(previous), time.rate()); @@ -650,8 +650,8 @@ namespace mrv { if (a->allFrames) return true; - otime::RationalTime start = a->time - previousTime; - otime::RationalTime end = a->time + nextTime; + const otime::RationalTime start = a->time - previousTime; + const otime::RationalTime end = a->time + nextTime; return (time > start && time < end); }); diff --git a/mrv2/lib/mrvGL/mrvGLViewportDraw.cpp b/mrv2/lib/mrvGL/mrvGLViewportDraw.cpp index 04314b349..e2966cd03 100644 --- a/mrv2/lib/mrvGL/mrvGLViewportDraw.cpp +++ b/mrv2/lib/mrvGL/mrvGLViewportDraw.cpp @@ -388,7 +388,7 @@ namespace mrv if (!player) return; - const otime::RationalTime& time = p.videoData[0].time; + const otime::RationalTime& time = player->currentTime(); const auto& annotations = player->getAnnotations(p.ghostPrevious, p.ghostNext); @@ -528,14 +528,14 @@ namespace mrv if (!player) return; - const otime::RationalTime& time = p.videoData[0].time; + const otime::RationalTime& time = player->currentTime(); if (panel::annotationsPanel) { panel::annotationsPanel->notes->value(""); } - const auto& annotations = + const auto annotations = player->getAnnotations(p.ghostPrevious, p.ghostNext); if (annotations.empty()) return;