From 643999e30849a371a0b697b3aa508067cf5c22d1 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Tue, 16 Mar 2021 12:13:08 +1100 Subject: [PATCH] auto-position gaps when replacing blocks with gaps --- app/widget/timelinewidget/timelineundo.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/widget/timelinewidget/timelineundo.h b/app/widget/timelinewidget/timelineundo.h index aedeef8d4..1aa557402 100644 --- a/app/widget/timelinewidget/timelineundo.h +++ b/app/widget/timelinewidget/timelineundo.h @@ -1633,10 +1633,16 @@ public: block_(block), existing_gap_(nullptr), existing_merged_gap_(nullptr), - our_gap_(nullptr) + our_gap_(nullptr), + position_command_(nullptr) { } + virtual ~TrackReplaceBlockWithGapCommand() override + { + delete position_command_; + } + virtual Project* GetRelevantProject() const override { return block_->project(); @@ -1691,6 +1697,11 @@ public: our_gap_->setParent(track_->parent()); track_->ReplaceBlock(block_, our_gap_); + + if (!position_command_) { + position_command_ = new NodeSetPositionAsChildCommand(our_gap_, track_, our_gap_->index(), track_->Blocks().size(), true); + } + position_command_->redo(); } } else { @@ -1724,6 +1735,8 @@ public: track_->ReplaceBlock(our_gap_, block_); our_gap_->setParent(&memory_manager_); + position_command_->undo(); + } else if (existing_gap_) { // If we're here, assume that we extended an existing gap @@ -1780,6 +1793,8 @@ private: bool existing_gap_precedes_; GapBlock* our_gap_; + NodeSetPositionAsChildCommand* position_command_; + QObject memory_manager_; };