implement entire project in nodes
Project items are now represented directly in nodes opening up more versatility and possibilities. This is the first iteration of this and will be buggy. Need to test thoroughly.
This commit is contained in:
@@ -367,6 +367,10 @@ void NodeView::mousePressEvent(QMouseEvent *event)
|
||||
if (item) {
|
||||
create_edge_ = new NodeViewEdge();
|
||||
create_edge_src_ = item;
|
||||
|
||||
create_edge_->SetCurved(scene_.GetEdgesAreCurved());
|
||||
create_edge_->SetFlowDirection(scene_.GetFlowDirection());
|
||||
|
||||
scene_.addItem(create_edge_);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,9 @@ void NodeViewEdge::SetFlowDirection(NodeViewCommon::FlowDirection dir)
|
||||
{
|
||||
flow_dir_ = dir;
|
||||
|
||||
Adjust();
|
||||
if (from_item_ && to_item_) {
|
||||
Adjust();
|
||||
}
|
||||
}
|
||||
|
||||
void NodeViewEdge::SetCurved(bool e)
|
||||
|
||||
@@ -61,7 +61,7 @@ void NodeEdgeAddCommand::undo()
|
||||
|
||||
Project *NodeEdgeAddCommand::GetRelevantProject() const
|
||||
{
|
||||
return output_.node()->parent()->project();
|
||||
return output_.node()->project();
|
||||
}
|
||||
|
||||
NodeEdgeRemoveCommand::NodeEdgeRemoveCommand(const NodeOutput &output, const NodeInput &input) :
|
||||
@@ -82,13 +82,17 @@ void NodeEdgeRemoveCommand::undo()
|
||||
|
||||
Project *NodeEdgeRemoveCommand::GetRelevantProject() const
|
||||
{
|
||||
return output_.node()->parent()->project();
|
||||
return output_.node()->project();
|
||||
}
|
||||
|
||||
NodeAddCommand::NodeAddCommand(NodeGraph *graph, Node *node) :
|
||||
graph_(graph),
|
||||
node_(node)
|
||||
{
|
||||
if (memory_manager_.thread() != node->thread()) {
|
||||
memory_manager_.moveToThread(node_->thread());
|
||||
}
|
||||
|
||||
// Ensures that when this command is destroyed, if redo() is never called again, the node will be destroyed too
|
||||
node_->setParent(&memory_manager_);
|
||||
}
|
||||
@@ -105,7 +109,7 @@ void NodeAddCommand::undo()
|
||||
|
||||
Project *NodeAddCommand::GetRelevantProject() const
|
||||
{
|
||||
return graph_->project();
|
||||
return dynamic_cast<Project*>(graph_);
|
||||
}
|
||||
|
||||
NodeCopyInputsCommand::NodeCopyInputsCommand(Node *src, Node *dest, bool include_connections) :
|
||||
@@ -139,4 +143,30 @@ void NodeRemoveAndDisconnectCommand::prep()
|
||||
}
|
||||
}
|
||||
|
||||
void NodeRenameCommand::AddNode(Node *node, const QString &new_name)
|
||||
{
|
||||
nodes_.append(node);
|
||||
new_labels_.append(new_name);
|
||||
old_labels_.append(node->GetLabel());
|
||||
}
|
||||
|
||||
void NodeRenameCommand::redo()
|
||||
{
|
||||
for (int i=0; i<nodes_.size(); i++) {
|
||||
nodes_.at(i)->SetLabel(new_labels_.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
void NodeRenameCommand::undo()
|
||||
{
|
||||
for (int i=0; i<nodes_.size(); i++) {
|
||||
nodes_.at(i)->SetLabel(old_labels_.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
Project *NodeRenameCommand::GetRelevantProject() const
|
||||
{
|
||||
return nodes_.isEmpty() ? nullptr : nodes_.first()->project();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "node/graph.h"
|
||||
#include "node/node.h"
|
||||
#include "project/project.h"
|
||||
#include "undo/undocommand.h"
|
||||
|
||||
namespace olive {
|
||||
@@ -104,11 +105,7 @@ public:
|
||||
|
||||
virtual Project* GetRelevantProject() const override
|
||||
{
|
||||
if (graph_) {
|
||||
return graph_->project();
|
||||
} else {
|
||||
return node_->parent()->project();
|
||||
}
|
||||
return dynamic_cast<Project*>(graph_);
|
||||
}
|
||||
|
||||
virtual void redo() override
|
||||
@@ -165,7 +162,7 @@ public:
|
||||
if (command_) {
|
||||
return static_cast<const NodeRemoveAndDisconnectCommand*>(command_->child(0))->GetRelevantProject();
|
||||
} else {
|
||||
return node_->parent()->project();
|
||||
return node_->project();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,7 +233,7 @@ public:
|
||||
|
||||
virtual Project* GetRelevantProject() const override
|
||||
{
|
||||
return a_->parent()->project();
|
||||
return a_->project();
|
||||
}
|
||||
|
||||
virtual void redo() override
|
||||
@@ -276,7 +273,7 @@ public:
|
||||
|
||||
virtual Project* GetRelevantProject() const override
|
||||
{
|
||||
return node_->parent()->project();
|
||||
return node_->project();
|
||||
}
|
||||
|
||||
virtual void redo() override
|
||||
@@ -320,7 +317,7 @@ public:
|
||||
|
||||
virtual Project* GetRelevantProject() const override
|
||||
{
|
||||
return nodes_.first()->parent()->project();
|
||||
return nodes_.first()->project();
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -328,6 +325,27 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class NodeRenameCommand : public UndoCommand
|
||||
{
|
||||
public:
|
||||
NodeRenameCommand() = default;
|
||||
|
||||
void AddNode(Node* node, const QString& new_name);
|
||||
|
||||
virtual void redo() override;
|
||||
|
||||
virtual void undo() override;
|
||||
|
||||
virtual Project * GetRelevantProject() const override;
|
||||
|
||||
private:
|
||||
QVector<Node*> nodes_;
|
||||
|
||||
QStringList new_labels_;
|
||||
QStringList old_labels_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEVIEWUNDO_H
|
||||
|
||||
Reference in New Issue
Block a user