From 7825d0e16d38c04188b021e160fea609da3cf7d0 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Thu, 28 Apr 2022 09:54:49 -0700 Subject: [PATCH] nodeview: improved drop functionality --- app/widget/nodeview/nodeview.cpp | 36 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/app/widget/nodeview/nodeview.cpp b/app/widget/nodeview/nodeview.cpp index 2f4041123..f11703822 100644 --- a/app/widget/nodeview/nodeview.cpp +++ b/app/widget/nodeview/nodeview.cpp @@ -500,26 +500,26 @@ void NodeView::mouseMoveEvent(QMouseEvent *event) if (new_drop_edge) { drop_input_.Reset(); - NodeValue::Type drop_edge_data_type = NodeValue::kNone; + NodeValue::Type drop_edge_data_type = new_drop_edge->input().GetDataType(); - // Run the Node and determine what type is being used - NodeTraverser traverser; - NodeValue drop_edge_value = traverser.GenerateRow(new_drop_edge->output(), TimeRange(0, 0))[new_drop_edge->input().input()]; - drop_edge_data_type = drop_edge_value.type(); + // Determine best input to connect to our new node + if (attached_node->GetEffectInput().IsValid()) { + // If node specifies an effect input, use that immediately + drop_input_ = attached_node->GetEffectInput(); + } else { + // Otherwise, we may have to iterate to find a valid one + for (const QString& input : attached_node->inputs()) { + NodeInput i(attached_node, input); - // Iterate through the inputs of our dragging node and see if our node has any acceptable - // inputs to connect to for this type - for (const QString& input : attached_node->inputs()) { - NodeInput i(attached_node, input); - - if (attached_node->IsInputConnectable(input)) { - if (attached_node->GetInputDataType(input) == drop_edge_data_type) { - // Found exactly the type we're looking for, set and break this loop - drop_input_ = i; - break; - } else if (!drop_input_.IsValid()) { - // Default to first connectable input - drop_input_ = i; + if (attached_node->IsInputConnectable(input)) { + if (attached_node->GetInputDataType(input) == drop_edge_data_type) { + // Found exactly the type we're looking for, set and break this loop + drop_input_ = i; + break; + } else if (!drop_input_.IsValid()) { + // Default to first connectable input + drop_input_ = i; + } } } }