nodeview: updates to complete new context paradigm

This commit is contained in:
itsmattkc
2021-07-09 18:00:01 -07:00
parent d83087a4ef
commit f14a301ffa
8 changed files with 666 additions and 149 deletions
+36
View File
@@ -91,6 +91,8 @@ protected:
virtual void ZoomIntoCursorPosition(QWheelEvent *event, double multiplier, const QPointF &cursor_pos) override;
virtual bool event(QEvent *event) override;
private:
void AttachNodesToCursor(const QVector<Node *> &nodes);
@@ -107,6 +109,14 @@ private:
void ZoomFromKeyboard(double multiplier);
bool DetermineIfNodeIsFloatingInContext(Node *node, Node *context, Node *source, const Node::OutputConnections &removed_edges, const Node::OutputConnection &added_edge);
void UpdateContextsFromEdgeRemove(MultiUndoCommand *command, const Node::OutputConnections &remove_edges);
void UpdateContextsFromEdgeAdd(MultiUndoCommand *command, const Node::OutputConnection &added_edge, const Node::OutputConnections &removed_edges = Node::OutputConnections());
void RecursivelyAddNodeToContext(MultiUndoCommand *command, Node *node, Node *context);
void RecursivelyRemoveFloatingNodeFromContext(MultiUndoCommand *command, Node *node, Node *context, Node *source, const Node::OutputConnections &removed_edges, const Node::OutputConnection &added_edge, bool prevent_removing);
QPointF GetEstimatedPositionForContext(NodeViewItem *item, Node *context) const;
class NodeViewAttachNodesToCursor : public UndoCommand
{
public:
@@ -132,6 +142,32 @@ private:
QPointF original_pos;
};
class NodeViewItemPreventRemovingCommand : public UndoCommand
{
public:
NodeViewItemPreventRemovingCommand(NodeView *view, Node *node, bool prevent_removing) :
view_(view),
node_(node),
new_prevent_removing_(prevent_removing)
{}
virtual void redo() override;
virtual void undo() override;
virtual Project * GetRelevantProject() const override
{
return node_->project();
}
private:
NodeView *view_;
Node *node_;
bool new_prevent_removing_;
bool old_prevent_removing_;
};
QList<AttachedItem> attached_items_;
NodeViewEdge* drop_edge_;