diff --git a/app/node/node.cpp b/app/node/node.cpp index 43b616130..89d3fe145 100644 --- a/app/node/node.cpp +++ b/app/node/node.cpp @@ -778,87 +778,74 @@ bool Node::InputIsArray(const QString &id) const return GetInputFlags(id) & kInputFlagArray; } -void Node::InputArrayInsert(const QString &id, int index, bool undoable) +void Node::InputArrayInsert(const QString &id, int index) { - if (undoable) { - Core::instance()->undo_stack()->push(new ArrayInsertCommand(this, id, index)); - } else { - // Add new input - ArrayResizeInternal(id, InputArraySize(id) + 1); + // Add new input + ArrayResizeInternal(id, InputArraySize(id) + 1); - // Move connections down - InputConnections copied_edges = input_connections(); - for (auto it=copied_edges.crbegin(); it!=copied_edges.crend(); it++) { - if (it->first.input() == id && it->first.element() >= index) { - // Disconnect this and reconnect it one element down - NodeInput new_edge = it->first; - new_edge.set_element(new_edge.element() + 1); + // Move connections down + InputConnections copied_edges = input_connections(); + for (auto it=copied_edges.crbegin(); it!=copied_edges.crend(); it++) { + if (it->first.input() == id && it->first.element() >= index) { + // Disconnect this and reconnect it one element down + NodeInput new_edge = it->first; + new_edge.set_element(new_edge.element() + 1); - DisconnectEdge(it->second, it->first); - ConnectEdge(it->second, new_edge); - } + DisconnectEdge(it->second, it->first); + ConnectEdge(it->second, new_edge); } - - // Shift values and keyframes up one element - for (int i=InputArraySize(id)-1; i>index; i--) { - CopyValuesOfElement(this, this, id, i-1, i); - } - - // Reset value of element we just "inserted" - ClearElement(id, index); } + + // Shift values and keyframes up one element + for (int i=InputArraySize(id)-1; i>index; i--) { + CopyValuesOfElement(this, this, id, i-1, i); + } + + // Reset value of element we just "inserted" + ClearElement(id, index); } -void Node::InputArrayResize(const QString &id, int size, bool undoable) +void Node::InputArrayResize(const QString &id, int size) { if (InputArraySize(id) == size) { return; } ArrayResizeCommand* c = new ArrayResizeCommand(this, id, size); - - if (undoable) { - Core::instance()->undo_stack()->push(c); - } else { - c->redo_now(); - delete c; - } + c->redo_now(); + delete c; } -void Node::InputArrayRemove(const QString &id, int index, bool undoable) +void Node::InputArrayRemove(const QString &id, int index) { - if (undoable) { - Core::instance()->undo_stack()->push(new ArrayRemoveCommand(this, id, index)); - } else { - // Remove input - ArrayResizeInternal(id, InputArraySize(id) - 1); + // Remove input + ArrayResizeInternal(id, InputArraySize(id) - 1); - // Move connections up - InputConnections copied_edges = input_connections(); - for (auto it=copied_edges.cbegin(); it!=copied_edges.cend(); it++) { - if (it->first.input() == id && it->first.element() >= index) { - // Disconnect this and reconnect it one element up if it's not the element being removed - DisconnectEdge(it->second, it->first); + // Move connections up + InputConnections copied_edges = input_connections(); + for (auto it=copied_edges.cbegin(); it!=copied_edges.cend(); it++) { + if (it->first.input() == id && it->first.element() >= index) { + // Disconnect this and reconnect it one element up if it's not the element being removed + DisconnectEdge(it->second, it->first); - if (it->first.element() > index) { - NodeInput new_edge = it->first; - new_edge.set_element(new_edge.element() - 1); + if (it->first.element() > index) { + NodeInput new_edge = it->first; + new_edge.set_element(new_edge.element() - 1); - ConnectEdge(it->second, new_edge); - } + ConnectEdge(it->second, new_edge); } } - - // Shift values and keyframes down one element - int arr_sz = InputArraySize(id); - for (int i=index; iInputArrayInsert(input_, index_, false); + node_->InputArrayInsert(input_, index_); } virtual void undo() override { - node_->InputArrayRemove(input_, index_, false); + node_->InputArrayRemove(input_, index_); } private: @@ -1072,12 +1072,12 @@ public: keyframes_ = node_->GetKeyframeTracks(input_, index_); node_->GetImmediate(input_, index_)->delete_all_keyframes(&memory_manager_); - node_->InputArrayRemove(input_, index_, false); + node_->InputArrayRemove(input_, index_); } virtual void undo() override { - node_->InputArrayInsert(input_, index_, false); + node_->InputArrayInsert(input_, index_); // Restore keyframes foreach (const NodeKeyframeTrack& track, keyframes_) { diff --git a/app/node/output/track/tracklist.cpp b/app/node/output/track/tracklist.cpp index 3c15dc628..767dfc195 100644 --- a/app/node/output/track/tracklist.cpp +++ b/app/node/output/track/tracklist.cpp @@ -167,14 +167,14 @@ int TrackList::ArraySize() const return parent()->InputArraySize(track_input()); } -void TrackList::ArrayAppend(bool undoable) +void TrackList::ArrayAppend() { - parent()->InputArrayAppend(track_input(), undoable); + parent()->InputArrayAppend(track_input()); } -void TrackList::ArrayRemoveLast(bool undoable) +void TrackList::ArrayRemoveLast() { - parent()->InputArrayRemoveLast(track_input(), undoable); + parent()->InputArrayRemoveLast(track_input()); } void TrackList::UpdateTotalLength() diff --git a/app/node/output/track/tracklist.h b/app/node/output/track/tracklist.h index 5b97f58be..b9d6173fd 100644 --- a/app/node/output/track/tracklist.h +++ b/app/node/output/track/tracklist.h @@ -67,8 +67,8 @@ public: int ArraySize() const; - void ArrayAppend(bool undoable = false); - void ArrayRemoveLast(bool undoable = false); + void ArrayAppend(); + void ArrayRemoveLast(); int GetArrayIndexFromCacheIndex(int index) const { diff --git a/app/node/project/folder/folder.cpp b/app/node/project/folder/folder.cpp index d39c2e9e5..9df90a03f 100644 --- a/app/node/project/folder/folder.cpp +++ b/app/node/project/folder/folder.cpp @@ -140,7 +140,7 @@ Project *FolderAddChild::GetRelevantProject() const void FolderAddChild::redo() { int array_index = folder_->InputArraySize(Folder::kChildInput); - folder_->InputArrayAppend(Folder::kChildInput, false); + folder_->InputArrayAppend(Folder::kChildInput); Node::ConnectEdge(child_, NodeInput(folder_, Folder::kChildInput, array_index)); } diff --git a/app/widget/nodeparamview/nodeparamviewitem.cpp b/app/widget/nodeparamview/nodeparamviewitem.cpp index 340e4e370..5d3f6331e 100644 --- a/app/widget/nodeparamview/nodeparamviewitem.cpp +++ b/app/widget/nodeparamview/nodeparamviewitem.cpp @@ -444,7 +444,7 @@ void NodeParamViewItemBody::ArrayAppendClicked() for (auto it=array_ui_.cbegin(); it!=array_ui_.cend(); it++) { if (it.value().append_btn == sender()) { NodeInput real_input = NodeGroup::ResolveInput(NodeInput(it.key().node, it.key().input)); - real_input.node()->InputArrayAppend(real_input.input(), true); + Core::instance()->undo_stack()->push(new Node::ArrayInsertCommand(real_input.node(), real_input.input(), real_input.GetArraySize()+1)); break; } } @@ -456,7 +456,7 @@ void NodeParamViewItemBody::ArrayInsertClicked() if (it.value().array_insert_btn == sender()) { // Found our input and element NodeInput ic = NodeGroup::ResolveInput(it.key()); - ic.node()->InputArrayInsert(ic.input(), ic.element(), true); + Core::instance()->undo_stack()->push(new Node::ArrayInsertCommand(ic.node(), ic.input(), ic.element())); break; } } @@ -468,7 +468,7 @@ void NodeParamViewItemBody::ArrayRemoveClicked() if (it.value().array_remove_btn == sender()) { // Found our input and element NodeInput ic = NodeGroup::ResolveInput(it.key()); - ic.node()->InputArrayRemove(ic.input(), ic.element(), true); + Core::instance()->undo_stack()->push(new Node::ArrayRemoveCommand(ic.node(), ic.input(), ic.element())); break; } } diff --git a/app/widget/nodeparamview/nodeparamviewundo.cpp b/app/widget/nodeparamview/nodeparamviewundo.cpp index a3e448fda..81a7d0d8d 100644 --- a/app/widget/nodeparamview/nodeparamviewundo.cpp +++ b/app/widget/nodeparamview/nodeparamviewundo.cpp @@ -193,12 +193,12 @@ Project *NodeParamArrayAppendCommand::GetRelevantProject() const void NodeParamArrayAppendCommand::redo() { - node_->InputArrayAppend(input_, false); + node_->InputArrayAppend(input_); } void NodeParamArrayAppendCommand::undo() { - node_->InputArrayRemoveLast(input_, false); + node_->InputArrayRemoveLast(input_); } void NodeSetValueHintCommand::redo()