Skip to content

Commit

Permalink
node: set ignore node when positioning and shifting recursively
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmattkc committed Apr 14, 2021
1 parent 51064f4 commit 6481304
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2294,7 +2294,7 @@ void NodeSetPositionAndShiftSurroundingsCommand::redo()

// Start moving other nodes
foreach (Node* surrounding, node_->parent()->nodes()) {
if (bounding_rect.contains(surrounding->GetPosition()) && surrounding != node_) {
if (bounding_rect.contains(surrounding->GetPosition()) && surrounding != node_ && surrounding != ignore_node_) {
QPointF new_pos = surrounding->GetPosition();

qreal move_rate = 0.50;
Expand All @@ -2306,6 +2306,7 @@ void NodeSetPositionAndShiftSurroundingsCommand::redo()
new_pos.setY(new_pos.y() + move_rate);

auto sur_command = new NodeSetPositionAndShiftSurroundingsCommand(surrounding, new_pos, true);
sur_command->SetIgnoreNode(node_);
sur_command->redo();
commands_.append(sur_command);
}
Expand Down
10 changes: 9 additions & 1 deletion app/node/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,8 @@ class NodeSetPositionAndShiftSurroundingsCommand : public UndoCommand
NodeSetPositionAndShiftSurroundingsCommand(Node* node, const QPointF& pos, bool move_dependencies_relatively) :
node_(node),
position_(pos),
move_dependencies_(move_dependencies_relatively)
move_dependencies_(move_dependencies_relatively),
ignore_node_(nullptr)
{}

virtual ~NodeSetPositionAndShiftSurroundingsCommand() override
Expand All @@ -1373,6 +1374,11 @@ class NodeSetPositionAndShiftSurroundingsCommand : public UndoCommand
}
}

void SetIgnoreNode(Node* n)
{
ignore_node_ = n;
}

private:
Node* node_;

Expand All @@ -1382,6 +1388,8 @@ class NodeSetPositionAndShiftSurroundingsCommand : public UndoCommand

QVector<UndoCommand*> commands_;

Node* ignore_node_;

};

class NodeSetPositionAsChildCommand : public UndoCommand
Expand Down

0 comments on commit 6481304

Please sign in to comment.