implemented deleting clips in the timeline

Also fixed bugs in the Node::GetExclusiveDependencies function and in the
NodeInputArray::RemoveAt function to make this functionality work.
This commit is contained in:
itsmattkc
2019-12-14 17:10:06 +11:00
parent 764fbb74c1
commit 2f04a53054
12 changed files with 155 additions and 88 deletions
+1 -1
View File
@@ -293,7 +293,7 @@ void NodeInput::CopyValues(NodeInput *source, NodeInput *dest, bool include_conn
NodeInputArray* src_array = static_cast<NodeInputArray*>(source);
NodeInputArray* dst_array = static_cast<NodeInputArray*>(dest);
dst_array->SetSize(src_array->GetSize());
dst_array->SetSize(src_array->GetSize(), lock_connections);
for (int i=0;i<dst_array->GetSize();i++) {
CopyValues(src_array->At(i), dst_array->At(i), include_connections);
+21 -14
View File
@@ -22,7 +22,7 @@ void NodeInputArray::Prepend()
InsertAt(0);
}
void NodeInputArray::SetSize(int size)
void NodeInputArray::SetSize(int size, bool lock)
{
int old_size = GetSize();
@@ -33,10 +33,14 @@ void NodeInputArray::SetSize(int size)
if (size < old_size) {
// If the new size is less, delete all extraneous parameters
for (int i=size;i<old_size;i++) {
delete sub_params_.at(i);
NodeInput* sub_param = sub_params_.at(i);
delete sub_param;
}
}
if (lock)
parentNode()->LockUserInput();
sub_params_.resize(size);
if (size > old_size) {
@@ -57,6 +61,9 @@ void NodeInputArray::SetSize(int size)
}
}
if (lock)
parentNode()->UnlockUserInput();
emit SizeChanged(size);
}
@@ -126,28 +133,28 @@ void NodeInputArray::RemoveLast()
void NodeInputArray::RemoveAt(int index)
{
int limit = sub_params_.size() - 1;
// Shift all connections from index down
for (int i=index;i<limit;i++) {
for (int i=index;i<sub_params_.size();i++) {
NodeInput* this_param = sub_params_.at(i);
NodeInput* next_param = sub_params_.at(i + 1);
if (this_param->IsConnected()) {
// Disconnect current edge
NodeParam::DisconnectEdge(this_param->edges().first());
}
if (next_param->IsConnected()) {
// Get edge from next param
NodeEdgePtr edge = next_param->edges().first();
if (i < sub_params_.size() - 1) {
NodeInput* next_param = sub_params_.at(i + 1);
if (next_param->IsConnected()) {
// Get edge from next param
NodeEdgePtr edge = next_param->edges().first();
// Disconnect it
NodeParam::DisconnectEdge(edge);
// Disconnect it
NodeParam::DisconnectEdge(edge);
// Reconnect it to this param
NodeParam::ConnectEdge(edge->output(),
this_param);
// Reconnect it to this param
NodeParam::ConnectEdge(edge->output(),
this_param);
}
}
}
+1 -1
View File
@@ -18,7 +18,7 @@ public:
void InsertAt(int index);
void RemoveLast();
void RemoveAt(int index);
void SetSize(int size);
void SetSize(int size, bool lock = true);
int IndexOfSubParameter(NodeInput* input) const;
+21 -18
View File
@@ -324,33 +324,36 @@ QList<Node *> Node::GetDependencies() const
QList<Node *> Node::GetExclusiveDependencies() const
{
QList<Node*> deps = GetDependencies();
QList<Node*> dependency_tree = GetDependencies();
// Filter out any dependencies that are used elsewhere
for (int i=0;i<deps.size();i++) {
QList<NodeParam*> params = deps.at(i)->params_;
QList<Node*> exclusive_deps;
// See if any of this Node's outputs are used outside of this dep list
for (int j=0;j<params.size();j++) {
NodeParam* p = params.at(j);
// See if any nodes in the list output somewhere else
foreach (Node* dep, dependency_tree) {
bool is_exclusive = true;
if (p->type() == NodeParam::kOutput) {
foreach (NodeEdgePtr edge, p->edges()) {
// If any edge goes to from an output here to an input of a Node that isn't in this dep list, it's NOT an
// exclusive dependency
if (deps.contains(edge->input()->parentNode())) {
deps.removeAt(i);
i--; // -1 since we just removed a Node in this list
j = params.size(); // No need to keep looking at this Node's params
break; // Or this param's edges
foreach (NodeParam* param, dep->parameters()) {
if (param->type() == NodeParam::kOutput) {
foreach (NodeEdgePtr edge, param->edges()) {
Node* node_param_outputs_to = edge->input()->parentNode();
if (node_param_outputs_to != this && !dependency_tree.contains(node_param_outputs_to)) {
is_exclusive = false;
break;
}
}
}
if (!is_exclusive) {
break;
}
}
if (is_exclusive) {
exclusive_deps.append(dep);
}
}
return deps;
return exclusive_deps;
}
QList<Node *> Node::GetImmediateDependencies() const
+9 -5
View File
@@ -143,19 +143,23 @@ NodeEdgePtr NodeParam::ConnectEdge(NodeOutput *output, NodeInput *input, bool lo
return edge;
}
void NodeParam::DisconnectEdge(NodeEdgePtr edge)
void NodeParam::DisconnectEdge(NodeEdgePtr edge, bool lock)
{
NodeOutput* output = edge->output();
NodeInput* input = edge->input();
output->parentNode()->LockUserInput();
input->parentNode()->LockUserInput();
if (lock) {
output->parentNode()->LockUserInput();
input->parentNode()->LockUserInput();
}
output->edges_.removeOne(edge);
input->edges_.removeOne(edge);
output->parentNode()->UnlockUserInput();
input->parentNode()->UnlockUserInput();
if (lock) {
output->parentNode()->UnlockUserInput();
input->parentNode()->UnlockUserInput();
}
emit input->EdgeRemoved(edge);
}
+1 -1
View File
@@ -303,7 +303,7 @@ public:
*
* Edge to disconnect.
*/
static void DisconnectEdge(NodeEdgePtr edge);
static void DisconnectEdge(NodeEdgePtr edge, bool lock = true);
/**
* @brief Disconnect an edge