Skip to content

Commit

Permalink
Merge branch 'fix_test'
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed Oct 24, 2023
2 parents bab21d0 + 1474da7 commit c71be60
Show file tree
Hide file tree
Showing 14 changed files with 173 additions and 140 deletions.
7 changes: 6 additions & 1 deletion mrv2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ if(FLTK_BUILD_SHARED_LIBS)
endif()
endif()
else()
set(FLTK_LIBRARIES ${CMAKE_INSTALL_PREFIX}/lib/libfltk.lib glu32 comctl32 ws2_32 opengl32 gdiplus)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(FLTK_LIBRARIES ${CMAKE_INSTALL_PREFIX}/lib/libfltkd.lib)
else()
set(FLTK_LIBRARIES ${CMAKE_INSTALL_PREFIX}/lib/libfltk.lib)
endif()
list(APPEND FLTK_LIBRARIES glu32 comctl32 ws2_32 opengl32 gdiplus)
set(FLTK_gl_LIBRARY ${FLTK_LIBRARIES} )
endif()
else()
Expand Down
1 change: 1 addition & 0 deletions mrv2/docs/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ v0.8.2
- Fixed a random OpenGL error when creating the color texture in the main
viewport.
- Fixed EDL creation for movies that did not have audio.
- Fixed selecting the wrong clip when loading a session from the command-line.


v0.8.1
Expand Down
14 changes: 11 additions & 3 deletions mrv2/lib/mrvApp/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,8 @@ namespace mrv
p.devicesModel->setHDRData(data);
}

DBG;

p.logObserver = observer::ListObserver<log::Item>::create(
ui->app->getContext()->getLogSystem()->observeLog(),
[this](const std::vector<log::Item>& value)
Expand Down Expand Up @@ -693,9 +695,11 @@ namespace mrv
});
#endif

DBG;
cacheUpdate();
_audioUpdate();

DBG;
// Open the input files.
if (!p.options.fileNames.empty())
{
Expand All @@ -715,8 +719,6 @@ namespace mrv
}
}

p.filesModel->setA(0);

if (!p.timelinePlayers.empty() && p.timelinePlayers[0])
{
if (p.options.speed > 0.0)
Expand Down Expand Up @@ -751,13 +753,14 @@ namespace mrv
p.filesModel->setB(numFiles - 1, true);
}

if (!p.options.fileNames.empty())
if (!p.options.fileNames.empty() && !p.session)
{
auto model = filesModel();
if (model->observeFiles()->getSize() > 0)
model->setA(0);
}

DBG;
#ifdef MRV2_NETWORK
if (p.options.server)
{
Expand All @@ -784,18 +787,23 @@ namespace mrv
}
#endif

DBG;
ui->uiMain->show();
ui->uiView->take_focus();

DBG;

if (!p.session)
Preferences::open_windows();
ui->uiMain->fill_menu(ui->uiMenuBar);

DBG;
if (ui->uiSecondary)
{
// We raise the secondary window last, so it shows at front
ui->uiSecondary->window()->show();
}
DBG;
}

void App::cleanResources()
Expand Down
111 changes: 53 additions & 58 deletions mrv2/lib/mrvEdit/mrvEditCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace fs = std::filesystem;
#include "mrvDraw/Annotation.h"

#include "mrvNetwork/mrvTCP.h"
#include "mrvNetwork/mrvMoveData.h"
#include "mrvNetwork/mrvInsertData.h"

#include "mrvPanels/mrvPanelsCallbacks.h"

Expand Down Expand Up @@ -593,6 +593,7 @@ namespace mrv
auto duration = time::round(
range.duration().rescaled_to(sampleRate));
range = TimeRange(start, duration);
duration = duration.rescaled_to(videoRate);
clip->set_source_range(range);
}
}
Expand Down Expand Up @@ -1257,7 +1258,7 @@ namespace mrv
refresh_file_cache_cb(nullptr, ui);
}

void moveAnnotations(
void shiftAnnotations(
const otime::TimeRange& range, const otime::RationalTime& insertTime,
const bool previous, ViewerUI* ui)
{
Expand Down Expand Up @@ -1794,8 +1795,8 @@ namespace mrv
tcp->unlock();
}

void edit_move_clip_annotations(
const std::vector<mrv::MoveData>& moves, ViewerUI* ui)
void edit_insert_clip_annotations(
const std::vector<mrv::InsertData>& inserts, ViewerUI* ui)
{
auto player = ui->uiView->getTimelinePlayer();
if (!player)
Expand All @@ -1813,137 +1814,131 @@ namespace mrv

const auto& stack = timeline->tracks();
const auto& tracks = stack->children();
for (const auto& move : moves)
for (const auto& insert : inserts)
{
if (move.fromTrack < 0 || move.fromTrack >= tracks.size() ||
move.toTrack < 0 || move.toTrack >= tracks.size())
const int oldIndex = insert.oldIndex;
const int oldTrackIndex = insert.oldTrackIndex;
if (oldIndex < 0 || oldTrackIndex < 0 || insert.trackIndex < 0 ||
insert.trackIndex >= tracks.size())
continue;

if (auto track = otio::dynamic_retainer_cast<otio::Track>(
stack->children()[move.fromTrack]))
stack->children()[oldTrackIndex]))
{
if (track->kind() != otio::Track::Kind::video)
continue;
}

int toIndex = move.toIndex;
if (move.fromTrack == move.toTrack && move.fromIndex < toIndex)
int insertIndex = insert.insertIndex;
if (oldTrackIndex == insert.trackIndex && oldIndex < insertIndex)
{
--toIndex;
--insertIndex;
}

if (auto track = otio::dynamic_retainer_cast<otio::Track>(
tracks[move.fromTrack]))
tracks[oldTrackIndex]))
{
auto child = track->children()[move.fromIndex];
auto child = track->children()[oldIndex];
auto item = otio::dynamic_retainer_cast<otio::Item>(child);
if (!item)
continue;

auto fromRange = item->trimmed_range_in_parent().value();
auto oldRange = item->trimmed_range_in_parent().value();

if (auto track = otio::dynamic_retainer_cast<otio::Track>(
tracks[move.toTrack]))
tracks[insert.trackIndex]))
{
auto child = track->children()[toIndex];
auto child = track->children()[insertIndex];
auto item = otio::dynamic_retainer_cast<otio::Item>(child);
if (!item)
continue;

auto toRange = item->trimmed_range_in_parent().value();
auto insertRange = item->trimmed_range_in_parent().value();

otime::RationalTime insertTime;
bool previous = toIndex > move.fromIndex;
bool previous = insertIndex > oldIndex;
if (previous)
{
insertTime =
toRange.end_time_exclusive() - fromRange.duration();
insertTime = insertRange.end_time_exclusive();
}
else
{
insertTime = toRange.start_time();
insertTime = insertRange.start_time();
}

//
// Shift annotations
//
// 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);
shiftAnnotations(oldRange, insertTime, previous, ui);
}
}
}

ui->uiTimeline->redraw();
}

void edit_move_clip(const std::vector<mrv::MoveData>& moves, ViewerUI* ui)
void
edit_insert_clip(const std::vector<mrv::InsertData>& inserts, ViewerUI* ui)
{
auto player = ui->uiView->getTimelinePlayer();
if (!player)
return;

std::vector<tl::timeline::MoveData> moveData;
std::vector<tl::timeline::InsertData> insertData;
const auto& timeline = player->getTimeline();
const auto& stack = timeline->tracks();
const auto& tracks = stack->children();
for (const auto& move : moves)
for (const auto& insert : inserts)
{
const int oldIndex = insert.oldIndex;
const int oldTrackIndex = insert.oldTrackIndex;

if (auto track = otio::dynamic_retainer_cast<otio::Track>(
tracks[move.fromTrack]))
tracks[oldTrackIndex]))
{
if (auto child = track->children()[move.fromIndex])
if (auto child = track->children()[oldIndex])
{
auto item = otio::dynamic_retainer_cast<otio::Item>(child);
if (!item)
continue;

timeline::MoveData data;
data.fromTrack = move.fromTrack;
data.fromIndex = move.fromIndex;
data.toTrack = move.toTrack;
data.toIndex = move.toIndex;
moveData.push_back(data);
timeline::InsertData data;
data.composable = child;
data.trackIndex = insert.trackIndex;
data.insertIndex = insert.insertIndex;
insertData.push_back(data);
}
}
}

auto otioTimeline = tl::timeline::move(timeline, moveData);
auto otioTimeline = tl::timeline::insert(timeline, insertData);
player->player()->getTimeline()->setTimeline(otioTimeline);

edit_move_clip_annotations(moves, ui);
edit_insert_clip_annotations(inserts, ui);
}

void edit_move_clip_annotations(
const std::vector<tl::timeline::MoveData>& moves, ViewerUI* ui)
void edit_insert_clip_annotations(
const std::vector<tl::timeline::InsertData>& inserts, ViewerUI* ui)
{
auto player = ui->uiView->getTimelinePlayer();
if (!player)
return;

// Convert tlRender data to mrv2's one.
std::vector<mrv::MoveData> networkMoveData;
for (const auto& move : moves)
std::vector<mrv::InsertData> networkInsertData;
for (const auto& insert : inserts)
{
MoveData networkMove;
networkMove.fromIndex = move.fromIndex;
networkMove.fromTrack = move.fromTrack;
networkMove.toTrack = move.toTrack;
networkMove.toIndex = move.toIndex;
networkMoveData.push_back(networkMove);
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);
}

edit_move_clip_annotations(networkMoveData, ui);
edit_insert_clip_annotations(networkInsertData, ui);
}

EditMode editMode = EditMode::kTimeline;
Expand Down
8 changes: 4 additions & 4 deletions mrv2/lib/mrvEdit/mrvEditCallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace mrv
class TimelinePlayer;
using otio::Timeline;

struct MoveData;
struct InsertData;

//@{
//! Store timeline in undo queue.
Expand All @@ -38,12 +38,12 @@ namespace mrv
bool edit_has_redo();

//! Handle insert of clip (used in shifting clips around in tlRender).
void edit_move_clip_annotations(
const std::vector<tl::timeline::MoveData>& inserts, ViewerUI* ui);
void edit_insert_clip_annotations(
const std::vector<tl::timeline::InsertData>& inserts, ViewerUI* ui);

//! Handle insert of clip annotations from network.
void
edit_move_clip(const std::vector<mrv::MoveData>& inserts, ViewerUI* ui);
edit_insert_clip(const std::vector<mrv::InsertData>& inserts, ViewerUI* ui);

//! Set the temporary EDL for a drag item callback.
void toOtioFile(TimelinePlayer*, ViewerUI* ui);
Expand Down
Loading

0 comments on commit c71be60

Please sign in to comment.