From 896ef17272d0b151fbea2893626614489a247a69 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Fri, 3 Mar 2023 00:28:10 -0800 Subject: [PATCH] timeline: jump playhead to end when inserting or overwriting --- app/widget/timelinewidget/timelinewidget.cpp | 4 ++-- app/widget/timelinewidget/tool/import.cpp | 18 +++++++++++++++--- app/widget/timelinewidget/tool/import.h | 4 ++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/widget/timelinewidget/timelinewidget.cpp b/app/widget/timelinewidget/timelinewidget.cpp index 955281e27..3765b0c0b 100644 --- a/app/widget/timelinewidget/timelinewidget.cpp +++ b/app/widget/timelinewidget/timelinewidget.cpp @@ -582,14 +582,14 @@ void TimelineWidget::DecreaseTrackHeight() void TimelineWidget::InsertFootageAtPlayhead(const QVector& footage) { auto command = new MultiUndoCommand(); - import_tool_->PlaceAt(footage, GetConnectedNode()->GetPlayhead(), true, command); + import_tool_->PlaceAt(footage, GetConnectedNode()->GetPlayhead(), true, command, 0, true); Core::instance()->undo_stack()->push(command); } void TimelineWidget::OverwriteFootageAtPlayhead(const QVector &footage) { auto command = new MultiUndoCommand(); - import_tool_->PlaceAt(footage, GetConnectedNode()->GetPlayhead(), false, command); + import_tool_->PlaceAt(footage, GetConnectedNode()->GetPlayhead(), false, command, 0, true); Core::instance()->undo_stack()->push(command); } diff --git a/app/widget/timelinewidget/tool/import.cpp b/app/widget/timelinewidget/tool/import.cpp index bc6ff74e3..2cc1248d5 100644 --- a/app/widget/timelinewidget/tool/import.cpp +++ b/app/widget/timelinewidget/tool/import.cpp @@ -192,7 +192,7 @@ void ImportTool::DragDrop(TimelineViewMouseEvent *event) } } -void ImportTool::PlaceAt(const QVector &footage, const rational &start, bool insert, MultiUndoCommand *command, int track_offset) +void ImportTool::PlaceAt(const QVector &footage, const rational &start, bool insert, MultiUndoCommand *command, int track_offset, bool jump_to_end) { DraggedFootageData refs; @@ -200,10 +200,10 @@ void ImportTool::PlaceAt(const QVector &footage, const rational refs.append({f, f->GetEnabledStreamsAsReferences()}); } - PlaceAt(refs, start, insert, command, track_offset); + PlaceAt(refs, start, insert, command, track_offset, jump_to_end); } -void ImportTool::PlaceAt(const DraggedFootageData &footage, const rational &start, bool insert, MultiUndoCommand *command, int track_offset) +void ImportTool::PlaceAt(const DraggedFootageData &footage, const rational &start, bool insert, MultiUndoCommand *command, int track_offset, bool jump_to_end) { dragged_footage_ = footage; @@ -212,7 +212,19 @@ void ImportTool::PlaceAt(const DraggedFootageData &footage, const rational &star } PrepGhosts(start, track_offset); + + rational max(0); + if (jump_to_end) { + for (TimelineViewGhostItem* ghost : parent()->GetGhostItems()) { + max = std::max(max, ghost->GetAdjustedOut()); + } + } + DropGhosts(insert, command); + + if (jump_to_end) { + this->sequence()->SetPlayhead(max); + } } void ImportTool::FootageToGhosts(rational ghost_start, const DraggedFootageData &sorted, const rational& dest_tb, const int& track_start) diff --git a/app/widget/timelinewidget/tool/import.h b/app/widget/timelinewidget/tool/import.h index 765fd9d04..58f5b8856 100644 --- a/app/widget/timelinewidget/tool/import.h +++ b/app/widget/timelinewidget/tool/import.h @@ -37,8 +37,8 @@ public: using DraggedFootageData = QVector > >; - void PlaceAt(const QVector &footage, const rational& start, bool insert, MultiUndoCommand *command, int track_offset = 0); - void PlaceAt(const DraggedFootageData &footage, const rational& start, bool insert, MultiUndoCommand *command, int track_offset = 0); + void PlaceAt(const QVector &footage, const rational& start, bool insert, MultiUndoCommand *command, int track_offset = 0, bool jump_to_end = false); + void PlaceAt(const DraggedFootageData &footage, const rational& start, bool insert, MultiUndoCommand *command, int track_offset = 0, bool jump_to_end = false); enum DropWithoutSequenceBehavior { kDWSAsk,