auto-position gaps when replacing blocks with gaps

This commit is contained in:
itsmattkc
2021-03-16 12:13:08 +11:00
parent 2a3a256f3e
commit 643999e308
+16 -1
View File
@@ -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_;
};