many improvements and reimplementations

This commit is contained in:
itsmattkc
2021-11-29 21:22:49 -08:00
parent 495b07fc55
commit 239a019690
21 changed files with 874 additions and 495 deletions
+80 -3
View File
@@ -43,12 +43,27 @@ public:
void AddNode(Node *node);
void RemoveNode(Node *node, QObject *new_parent = nullptr);
void RemoveNode(Node *node);
bool ContainsNode(Node *node) const
{
return nodes_.contains(node);
}
const QVector<Node*> &GetNodes() const
{
return nodes_;
}
void AddInputPassthrough(const NodeInput &input);
void RemoveInputPassthrough(const NodeInput &input);
Node *GetOutputPassthrough() const
{
return output_passthrough_;
}
void SetOutputPassthrough(Node *node);
const QString &GetCustomName() const
@@ -78,8 +93,21 @@ public:
bool ContainsInputPassthrough(const NodeInput &input) const;
virtual QString GetInputName(const QString& id) const override;
signals:
void NodeAddedToGroup(Node *node);
void NodeRemovedFromGroup(Node *node);
void InputPassthroughAdded(NodeGroup *group, const NodeInput &input);
void InputPassthroughRemoved(NodeGroup *group, const NodeInput &input);
void OutputPassthroughChanged(NodeGroup *group, Node *output);
private:
NodeGraph *graph_;
QVector<Node*> nodes_;
QHash<QString, NodeInput> input_passthroughs_;
@@ -112,7 +140,30 @@ private:
NodeGroup *group_;
QObject *previous_parent_;
};
class NodeRemoveFromGroupCommand : public UndoCommand
{
public:
NodeRemoveFromGroupCommand(Node *node, NodeGroup *group) :
node_(node),
group_(group)
{}
virtual Project * GetRelevantProject() const override
{
return node_->project();
}
protected:
virtual void redo() override;
virtual void undo() override;
private:
Node *node_;
NodeGroup *group_;
};
@@ -171,6 +222,32 @@ private:
};
class NodeGroupSetOutputPassthrough : public UndoCommand
{
public:
NodeGroupSetOutputPassthrough(NodeGroup *group, Node *output) :
group_(group),
new_output_(output)
{}
virtual Project * GetRelevantProject() const override
{
return group_->project();
}
protected:
virtual void redo() override;
virtual void undo() override;
private:
NodeGroup *group_;
Node *new_output_;
Node *old_output_;
};
}
#endif // NODEGROUP_H