added new node auto-positioning for items

This commit is contained in:
itsmattkc
2021-03-14 21:09:00 +11:00
parent 500fb58d49
commit 2a9513e56a
6 changed files with 224 additions and 4 deletions
+19 -1
View File
@@ -115,10 +115,16 @@ void Folder::InputDisconnectedEvent(const QString &input, int element, const Nod
FolderAddChild::FolderAddChild(Folder *folder, Node *child, bool autoposition) :
folder_(folder),
child_(child),
autoposition_(autoposition)
autoposition_(autoposition),
position_command_(nullptr)
{
}
FolderAddChild::~FolderAddChild()
{
delete position_command_;
}
Project *FolderAddChild::GetRelevantProject() const
{
return folder_->project();
@@ -129,10 +135,22 @@ void FolderAddChild::redo()
int array_index = folder_->InputArraySize(Folder::kChildInput);
folder_->InputArrayAppend(Folder::kChildInput, false);
Node::ConnectEdge(child_, NodeInput(folder_, Folder::kChildInput, array_index));
if (autoposition_) {
old_position_ = child_->GetPosition();
if (!position_command_) {
position_command_ = new NodeSetPositionAsChildCommand(child_, folder_, array_index, array_index+1, true);
}
position_command_->redo();
}
}
void FolderAddChild::undo()
{
if (position_command_) {
position_command_->undo();
}
Node::DisconnectEdge(child_, NodeInput(folder_, Folder::kChildInput, folder_->InputArraySize(Folder::kChildInput)-1));
folder_->InputArrayRemoveLast(Folder::kChildInput);
}
+4
View File
@@ -160,6 +160,8 @@ class FolderAddChild : public UndoCommand
public:
FolderAddChild(Folder* folder, Node* child, bool autoposition = true);
virtual ~FolderAddChild() override;
virtual Project * GetRelevantProject() const override;
virtual void redo() override;
@@ -175,6 +177,8 @@ private:
QPointF old_position_;
NodeSetPositionAsChildCommand* position_command_;
};
}
+4
View File
@@ -39,16 +39,20 @@ Project::Project() :
// Adds a color manager "node" to this project so that it synchronizes
color_manager_ = new ColorManager();
color_manager_->setParent(this);
color_manager_->SetPosition(QPointF(1, 0));
AddDefaultNode(color_manager_);
// Same with project settings
settings_ = new ProjectSettingsNode();
settings_->setParent(this);
settings_->SetPosition(QPointF(2, 0));
AddDefaultNode(settings_);
// Viewer node for connecting with the footage viewer
footage_viewer_ = new ViewerOutput();
footage_viewer_->setParent(this);
footage_viewer_->SetLabel(tr("Footage Viewer"));
footage_viewer_->SetPosition(QPointF(3, 0));
AddDefaultNode(footage_viewer_);
// Folder root for project