From 8a8cd53d8a0bf5daca4261d45999273c37ab9f7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Garramu=C3=B1o?= Date: Sat, 21 Oct 2023 17:22:30 -0300 Subject: [PATCH 1/3] Update tlRender. --- tlRender | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tlRender b/tlRender index a865496bf..417b1acdf 160000 --- a/tlRender +++ b/tlRender @@ -1 +1 @@ -Subproject commit a865496bfdde40e9520ee68cfa2ffd8e4d651a80 +Subproject commit 417b1acdfa06ecae5c8f0d2011d04a954fc01f3a From 8e82e923b40890dd8490b9a6e644da2bec8769bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Garramu=C3=B1o?= Date: Sun, 22 Oct 2023 13:18:14 -0300 Subject: [PATCH 2/3] Updated tlRender. --- mrv2/lib/mrvEdit/mrvEditCallbacks.cpp | 127 +++++++++--------- mrv2/lib/mrvEdit/mrvEditCallbacks.h | 8 +- mrv2/lib/mrvGL/mrvTimelineWidget.cpp | 10 +- mrv2/lib/mrvGL/mrvTimelineWidget.h | 2 +- mrv2/lib/mrvNetwork/CMakeLists.txt | 4 +- mrv2/lib/mrvNetwork/mrvCommandInterpreter.cpp | 2 +- mrv2/lib/mrvNetwork/mrvInsertData.cpp | 26 ---- mrv2/lib/mrvNetwork/mrvInsertData.h | 23 ---- mrv2/lib/mrvNetwork/mrvMoveData.cpp | 26 ++++ mrv2/lib/mrvNetwork/mrvMoveData.h | 23 ++++ tlRender | 2 +- 11 files changed, 126 insertions(+), 127 deletions(-) delete mode 100644 mrv2/lib/mrvNetwork/mrvInsertData.cpp delete mode 100644 mrv2/lib/mrvNetwork/mrvInsertData.h create mode 100644 mrv2/lib/mrvNetwork/mrvMoveData.cpp create mode 100644 mrv2/lib/mrvNetwork/mrvMoveData.h diff --git a/mrv2/lib/mrvEdit/mrvEditCallbacks.cpp b/mrv2/lib/mrvEdit/mrvEditCallbacks.cpp index 67a8b3736..c192e1ace 100644 --- a/mrv2/lib/mrvEdit/mrvEditCallbacks.cpp +++ b/mrv2/lib/mrvEdit/mrvEditCallbacks.cpp @@ -34,7 +34,7 @@ namespace fs = std::filesystem; #include "mrvDraw/Annotation.h" #include "mrvNetwork/mrvTCP.h" -#include "mrvNetwork/mrvInsertData.h" +#include "mrvNetwork/mrvMoveData.h" #include "mrvPanels/mrvPanelsCallbacks.h" @@ -1257,7 +1257,7 @@ namespace mrv refresh_file_cache_cb(nullptr, ui); } - void shiftAnnotations( + void moveAnnotations( const otime::TimeRange& range, const otime::RationalTime& insertTime, const bool previous, ViewerUI* ui) { @@ -1268,12 +1268,13 @@ namespace mrv if (!player) return; + // First, deep copy the annotations. const auto& originalAnnotations = player->getAllAnnotations(); auto annotations = deepCopyAnnotations(originalAnnotations); // Then, adjust the annotations within the range. std::set> skipAnnotations; - for (auto& annotation : annotations) + for (auto annotation : annotations) { if (annotation->allFrames) continue; @@ -1281,20 +1282,12 @@ namespace mrv if (range.contains(annotation->time)) { auto offset = annotation->time - range.start_time(); - if (previous) - { - annotation->time = - insertTime + offset - range.end_time_exclusive(); - } - else - { - annotation->time = insertTime + offset; - } + annotation->time = insertTime + offset; skipAnnotations.insert(annotation); } } - // Finally, shift the annotations. + // Finally, move the annotations. if (previous) { for (auto annotation : annotations) @@ -1314,7 +1307,7 @@ namespace mrv else { auto endTime = range.end_time_exclusive(); - for (auto& annotation : annotations) + for (auto annotation : annotations) { if (annotation->allFrames) continue; @@ -1833,8 +1826,8 @@ namespace mrv tcp->unlock(); } - void edit_insert_clip_annotations( - const std::vector& inserts, ViewerUI* ui) + void edit_move_clip_annotations( + const std::vector& moves, ViewerUI* ui) { auto player = ui->uiView->getTimelinePlayer(); if (!player) @@ -1852,62 +1845,73 @@ namespace mrv const auto& stack = timeline->tracks(); const auto& tracks = stack->children(); - for (const auto& insert : inserts) + for (const auto& move : moves) { - const int oldIndex = insert.oldIndex; - const int oldTrackIndex = insert.oldTrackIndex; - if (oldIndex < 0 || oldTrackIndex < 0 || insert.trackIndex < 0 || - insert.trackIndex >= tracks.size()) + if (move.fromTrack < 0 || move.fromTrack >= tracks.size() || + move.toTrack < 0 || move.toTrack >= tracks.size()) continue; if (auto track = otio::dynamic_retainer_cast( - stack->children()[oldTrackIndex])) + stack->children()[move.fromTrack])) { if (track->kind() != otio::Track::Kind::video) continue; } - int insertIndex = insert.insertIndex; - if (oldTrackIndex == insert.trackIndex && oldIndex < insertIndex) + int toIndex = move.toIndex; + if (move.fromTrack == move.toTrack && move.fromIndex < toIndex) { - --insertIndex; + --toIndex; } if (auto track = otio::dynamic_retainer_cast( - tracks[oldTrackIndex])) + tracks[move.fromTrack])) { - auto child = track->children()[oldIndex]; + auto child = track->children()[move.fromIndex]; auto item = otio::dynamic_retainer_cast(child); if (!item) continue; - auto oldRange = item->trimmed_range_in_parent().value(); + auto fromRange = item->trimmed_range_in_parent().value(); if (auto track = otio::dynamic_retainer_cast( - tracks[insert.trackIndex])) + tracks[move.toTrack])) { - auto child = track->children()[insertIndex]; + auto child = track->children()[toIndex]; auto item = otio::dynamic_retainer_cast(child); if (!item) continue; - auto insertRange = item->trimmed_range_in_parent().value(); + auto toRange = item->trimmed_range_in_parent().value(); otime::RationalTime insertTime; - bool previous = insertIndex > oldIndex; + bool previous = toIndex > move.fromIndex; if (previous) { - insertTime = insertRange.end_time_exclusive(); + insertTime = + toRange.end_time_exclusive() - fromRange.duration(); } else { - insertTime = insertRange.start_time(); + insertTime = toRange.start_time(); } // // Shift annotations // - shiftAnnotations(oldRange, insertTime, previous, ui); + // std::cerr << "---------------------------------------" + // << std::endl; + // std::cerr << "IS PREV: " << previous << std::endl; + // std::cerr << " FROM: " << move.fromIndex << " " + // << fromRange << std::endl; + // std::cerr << " TO: " << move.toIndex + // << " RANGE: " << toRange << std::endl; + // std::cerr << "CORR.TO: " << toIndex << " RANGE: " << + // toRange + // << std::endl; + // std::cerr << " PREV: " << previousRange << std::endl; + // std::cerr << " TO: " << insertTime << std::endl; + moveAnnotations(fromRange, insertTime, previous, ui); } } } @@ -1915,68 +1919,63 @@ namespace mrv ui->uiTimeline->redraw(); } - void - edit_insert_clip(const std::vector& inserts, ViewerUI* ui) + void edit_move_clip(const std::vector& moves, ViewerUI* ui) { auto player = ui->uiView->getTimelinePlayer(); if (!player) return; - std::vector insertData; + std::vector moveData; const auto& timeline = player->getTimeline(); const auto& stack = timeline->tracks(); const auto& tracks = stack->children(); - for (const auto& insert : inserts) + for (const auto& move : moves) { - const int oldIndex = insert.oldIndex; - const int oldTrackIndex = insert.oldTrackIndex; - if (auto track = otio::dynamic_retainer_cast( - tracks[oldTrackIndex])) + tracks[move.fromTrack])) { - if (auto child = track->children()[oldIndex]) + if (auto child = track->children()[move.fromIndex]) { auto item = otio::dynamic_retainer_cast(child); if (!item) continue; - timeline::InsertData data; - data.composable = child; - data.trackIndex = insert.trackIndex; - data.insertIndex = insert.insertIndex; - insertData.push_back(data); + timeline::MoveData data; + data.fromTrack = move.fromTrack; + data.fromIndex = move.fromIndex; + data.toTrack = move.toTrack; + data.toIndex = move.toIndex; + moveData.push_back(data); } } } - auto otioTimeline = tl::timeline::insert(timeline, insertData); + auto otioTimeline = tl::timeline::move(timeline, moveData); player->player()->getTimeline()->setTimeline(otioTimeline); - edit_insert_clip_annotations(inserts, ui); + edit_move_clip_annotations(moves, ui); } - void edit_insert_clip_annotations( - const std::vector& inserts, ViewerUI* ui) + void edit_move_clip_annotations( + const std::vector& moves, ViewerUI* ui) { auto player = ui->uiView->getTimelinePlayer(); if (!player) return; // Convert tlRender data to mrv2's one. - std::vector networkInsertData; - for (const auto& insert : inserts) + std::vector networkMoveData; + for (const auto& move : moves) { - const int oldIndex = getIndex(insert.composable); - const int oldTrackIndex = getIndex(insert.composable->parent()); - InsertData networkInsert; - networkInsert.oldIndex = oldIndex; - networkInsert.oldTrackIndex = oldTrackIndex; - networkInsert.trackIndex = insert.trackIndex; - networkInsert.insertIndex = insert.insertIndex; - networkInsertData.push_back(networkInsert); + MoveData networkMove; + networkMove.fromIndex = move.fromIndex; + networkMove.fromTrack = move.fromTrack; + networkMove.toTrack = move.toTrack; + networkMove.toIndex = move.toIndex; + networkMoveData.push_back(networkMove); } - edit_insert_clip_annotations(networkInsertData, ui); + edit_move_clip_annotations(networkMoveData, ui); } EditMode editMode = EditMode::kTimeline; diff --git a/mrv2/lib/mrvEdit/mrvEditCallbacks.h b/mrv2/lib/mrvEdit/mrvEditCallbacks.h index a6032baeb..22195778b 100644 --- a/mrv2/lib/mrvEdit/mrvEditCallbacks.h +++ b/mrv2/lib/mrvEdit/mrvEditCallbacks.h @@ -22,7 +22,7 @@ namespace mrv class TimelinePlayer; using otio::Timeline; - struct InsertData; + struct MoveData; //@{ //! Store timeline in undo queue. @@ -38,12 +38,12 @@ namespace mrv bool edit_has_redo(); //! Handle insert of clip (used in shifting clips around in tlRender). - void edit_insert_clip_annotations( - const std::vector& inserts, ViewerUI* ui); + void edit_move_clip_annotations( + const std::vector& inserts, ViewerUI* ui); //! Handle insert of clip annotations from network. void - edit_insert_clip(const std::vector& inserts, ViewerUI* ui); + edit_move_clip(const std::vector& inserts, ViewerUI* ui); //! Set the temporary EDL for a drag item callback. void toOtioFile(TimelinePlayer*, ViewerUI* ui); diff --git a/mrv2/lib/mrvGL/mrvTimelineWidget.cpp b/mrv2/lib/mrvGL/mrvTimelineWidget.cpp index 1f5150565..421eba3a9 100644 --- a/mrv2/lib/mrvGL/mrvTimelineWidget.cpp +++ b/mrv2/lib/mrvGL/mrvTimelineWidget.cpp @@ -178,8 +178,8 @@ namespace mrv p.timelineWidget->setFrameView(true); p.timelineWidget->setScrollBarsVisible(false); p.timelineWidget->setStopOnScrub(false); - p.timelineWidget->setInsertCallback(std::bind( - &mrv::TimelineWidget::insertCallback, this, std::placeholders::_1)); + p.timelineWidget->setMoveCallback(std::bind( + &mrv::TimelineWidget::moveCallback, this, std::placeholders::_1)); p.eventLoop->addWidget(p.timelineWidget); const float devicePixelRatio = pixels_per_unit(); @@ -1422,13 +1422,13 @@ namespace mrv redraw(); } - void TimelineWidget::insertCallback( - const std::vector& inserts) + void TimelineWidget::moveCallback( + const std::vector& inserts) { TLRENDER_P(); edit_store_undo(p.player, p.ui); edit_clear_redo(p.ui); - edit_insert_clip_annotations(inserts, p.ui); + edit_move_clip_annotations(inserts, p.ui); } void TimelineWidget::single_thumbnail( diff --git a/mrv2/lib/mrvGL/mrvTimelineWidget.h b/mrv2/lib/mrvGL/mrvTimelineWidget.h index f13831338..7b824a8cd 100644 --- a/mrv2/lib/mrvGL/mrvTimelineWidget.h +++ b/mrv2/lib/mrvGL/mrvTimelineWidget.h @@ -131,7 +131,7 @@ namespace mrv int keyPressEvent(unsigned key, const int modifiers); int keyReleaseEvent(unsigned key, const int modifiers); - void insertCallback(const std::vector&); + void moveCallback(const std::vector&); protected: void _initializeGL(); diff --git a/mrv2/lib/mrvNetwork/CMakeLists.txt b/mrv2/lib/mrvNetwork/CMakeLists.txt index e0a24c3d8..b386b3ad8 100644 --- a/mrv2/lib/mrvNetwork/CMakeLists.txt +++ b/mrv2/lib/mrvNetwork/CMakeLists.txt @@ -10,7 +10,7 @@ set(HEADERS mrvFilesModelItem.h mrvFilePath.h mrvImageOptions.h - mrvInsertData.h + mrvMoveData.h mrvLUTOptions.h mrvTCP.h mrvTimelineItemOptions.h @@ -24,7 +24,7 @@ set(SOURCES mrvFilesModelItem.cpp mrvFilePath.cpp mrvImageOptions.cpp - mrvInsertData.cpp + mrvMoveData.cpp mrvLUTOptions.cpp mrvTCP.cpp mrvTimelineItemOptions.cpp diff --git a/mrv2/lib/mrvNetwork/mrvCommandInterpreter.cpp b/mrv2/lib/mrvNetwork/mrvCommandInterpreter.cpp index 795bfa719..a7f9edde7 100644 --- a/mrv2/lib/mrvNetwork/mrvCommandInterpreter.cpp +++ b/mrv2/lib/mrvNetwork/mrvCommandInterpreter.cpp @@ -22,7 +22,7 @@ #include "mrvNetwork/mrvCommandInterpreter.h" #include "mrvNetwork/mrvCompareOptions.h" #include "mrvNetwork/mrvDisplayOptions.h" -#include "mrvNetwork/mrvInsertData.h" +#include "mrvNetwork/mrvMoveData.h" #include "mrvNetwork/mrvImageOptions.h" #include "mrvNetwork/mrvLUTOptions.h" #include "mrvNetwork/mrvTimelineItemOptions.h" diff --git a/mrv2/lib/mrvNetwork/mrvInsertData.cpp b/mrv2/lib/mrvNetwork/mrvInsertData.cpp deleted file mode 100644 index 59b54e572..000000000 --- a/mrv2/lib/mrvNetwork/mrvInsertData.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// mrv2 -// Copyright Contributors to the mrv2 Project. All rights reserved. - -#include - -#include "mrvNetwork/mrvInsertData.h" - -namespace mrv -{ - void to_json(nlohmann::json& j, const InsertData& value) - { - j["oldIndex"] = value.oldIndex; - j["oldTrackIndex"] = value.oldTrackIndex; - j["trackIndex"] = value.trackIndex; - j["insertIndex"] = value.insertIndex; - } - - void from_json(const nlohmann::json& j, InsertData& value) - { - j["oldIndex"].get_to(value.oldIndex); - j["oldTrackIndex"].get_to(value.oldTrackIndex); - j["trackIndex"].get_to(value.trackIndex); - j["insertIndex"].get_to(value.insertIndex); - } -} // namespace mrv diff --git a/mrv2/lib/mrvNetwork/mrvInsertData.h b/mrv2/lib/mrvNetwork/mrvInsertData.h deleted file mode 100644 index 014930dff..000000000 --- a/mrv2/lib/mrvNetwork/mrvInsertData.h +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// mrv2 -// Copyright Contributors to the mrv2 Project. All rights reserved. - -#pragma once - -#include - -namespace mrv -{ - //! Insert data for mrv2 Network connections. - struct InsertData - { - int oldIndex = 0; - int oldTrackIndex = 0; - int trackIndex = 0; - int insertIndex = 0; - }; - - void to_json(nlohmann::json& j, const InsertData& value); - - void from_json(const nlohmann::json& j, InsertData& value); -} // namespace mrv diff --git a/mrv2/lib/mrvNetwork/mrvMoveData.cpp b/mrv2/lib/mrvNetwork/mrvMoveData.cpp new file mode 100644 index 000000000..ef7d0837c --- /dev/null +++ b/mrv2/lib/mrvNetwork/mrvMoveData.cpp @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: BSD-3-Clause +// mrv2 +// Copyright Contributors to the mrv2 Project. All rights reserved. + +#include + +#include "mrvNetwork/mrvMoveData.h" + +namespace mrv +{ + void to_json(nlohmann::json& j, const MoveData& value) + { + j["fromTrack"] = value.fromTrack; + j["fromIndex"] = value.fromIndex; + j["trackIndex"] = value.toTrack; + j["toIndex"] = value.toIndex; + } + + void from_json(const nlohmann::json& j, MoveData& value) + { + j["fromTrack"].get_to(value.fromTrack); + j["fromIndex"].get_to(value.fromIndex); + j["toTrace"].get_to(value.toTrack); + j["toIndex"].get_to(value.toIndex); + } +} // namespace mrv diff --git a/mrv2/lib/mrvNetwork/mrvMoveData.h b/mrv2/lib/mrvNetwork/mrvMoveData.h new file mode 100644 index 000000000..a29d14366 --- /dev/null +++ b/mrv2/lib/mrvNetwork/mrvMoveData.h @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: BSD-3-Clause +// mrv2 +// Copyright Contributors to the mrv2 Project. All rights reserved. + +#pragma once + +#include + +namespace mrv +{ + //! Move data for mrv2 Network connections. + struct MoveData + { + int fromTrack = 0; + int fromIndex = 0; + int toTrack = 0; + int toIndex = 0; + }; + + void to_json(nlohmann::json& j, const MoveData& value); + + void from_json(const nlohmann::json& j, MoveData& value); +} // namespace mrv diff --git a/tlRender b/tlRender index 50ecd20e3..8d4c93b7d 160000 --- a/tlRender +++ b/tlRender @@ -1 +1 @@ -Subproject commit 50ecd20e3e453bd79137e8e78788d08533651bc4 +Subproject commit 8d4c93b7d16ef4dd14356f3971cfa49b21ace05c From f97703ff3265bfabbf3496974e69e964b11634ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Garramu=C3=B1o?= Date: Mon, 23 Oct 2023 08:31:15 -0300 Subject: [PATCH 3/3] Fixed sequence detection in tlRender. --- mrv2/lib/mrvEdit/mrvEditCallbacks.cpp | 6 +++--- tlRender | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mrv2/lib/mrvEdit/mrvEditCallbacks.cpp b/mrv2/lib/mrvEdit/mrvEditCallbacks.cpp index c192e1ace..8042d997d 100644 --- a/mrv2/lib/mrvEdit/mrvEditCallbacks.cpp +++ b/mrv2/lib/mrvEdit/mrvEditCallbacks.cpp @@ -1274,7 +1274,7 @@ namespace mrv // Then, adjust the annotations within the range. std::set> skipAnnotations; - for (auto annotation : annotations) + for (auto& annotation : annotations) { if (annotation->allFrames) continue; @@ -1290,7 +1290,7 @@ namespace mrv // Finally, move the annotations. if (previous) { - for (auto annotation : annotations) + for (auto& annotation : annotations) { if (annotation->allFrames) continue; @@ -1307,7 +1307,7 @@ namespace mrv else { auto endTime = range.end_time_exclusive(); - for (auto annotation : annotations) + for (auto& annotation : annotations) { if (annotation->allFrames) continue; diff --git a/tlRender b/tlRender index 8d4c93b7d..324295e4a 160000 --- a/tlRender +++ b/tlRender @@ -1 +1 @@ -Subproject commit 8d4c93b7d16ef4dd14356f3971cfa49b21ace05c +Subproject commit 324295e4a3752d52f39c4c7541e3d446212d8846