From 50c7f8019b5d62c860c95461e4469bc0efe3dc68 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 15 Mar 2021 18:23:34 +1100 Subject: [PATCH] added auto-positioning to split command --- app/widget/timelinewidget/timelineundo.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/widget/timelinewidget/timelineundo.h b/app/widget/timelinewidget/timelineundo.h index 9264278a8..aedeef8d4 100644 --- a/app/widget/timelinewidget/timelineundo.h +++ b/app/widget/timelinewidget/timelineundo.h @@ -40,7 +40,6 @@ namespace olive { inline bool NodeCanBeRemoved(Node* n) { - //return n->edges().isEmpty() && n->GetExclusiveDependencies().isEmpty(); return n->output_connections().empty(); } @@ -490,13 +489,15 @@ public: block_(block), new_block_(nullptr), point_(point), - reconnect_tree_command_(nullptr) + reconnect_tree_command_(nullptr), + position_command_(nullptr) { } virtual ~BlockSplitCommand() override { delete reconnect_tree_command_; + delete position_command_; } virtual Project* GetRelevantProject() const override @@ -540,6 +541,12 @@ public: // Insert new block track->InsertBlockAfter(new_block(), block_); + // Position the block + if (!position_command_) { + position_command_ = new NodeSetPositionAsChildCommand(new_block(), track, new_block()->index(), track->Blocks().size(), true); + } + position_command_->redo(); + // If the block had an out transition, we move it to the new block moved_transition_ = NodeInput(); @@ -569,6 +576,8 @@ public: Node::ConnectEdge(block_, moved_transition_); } + position_command_->undo(); + block_->set_length_and_media_out(old_length_); track->RippleRemoveBlock(new_block()); @@ -589,6 +598,8 @@ private: NodeInput moved_transition_; + NodeSetPositionAsChildCommand* position_command_; + }; class BlockSplitPreservingLinksCommand : public UndoCommand {