diff --git a/app/widget/nodeview/nodeview.cpp b/app/widget/nodeview/nodeview.cpp index 3c9a855ff..c6a3c9746 100644 --- a/app/widget/nodeview/nodeview.cpp +++ b/app/widget/nodeview/nodeview.cpp @@ -312,6 +312,7 @@ void NodeView::mousePressEvent(QMouseEvent *event) // Sane defaults create_edge_already_exists_ = false; create_edge_from_output_ = true; + create_edge_input_.Reset(); if (event->modifiers() & Qt::ControlModifier) { NodeViewItem *mouse_item = dynamic_cast(item); @@ -324,6 +325,9 @@ void NodeView::mousePressEvent(QMouseEvent *event) create_edge_input_ = mouse_item->GetInput(); create_edge_from_output_ = false; } + + // Highlight start item for better user experience + mouse_item->SetHighlighted(true); } } @@ -1082,7 +1086,7 @@ void NodeView::PositionNewEdge(const QPoint &pos) NodeViewItem *&opposing_item = create_edge_from_output_ ? create_edge_input_item_ : create_edge_output_item_; // Filter out connecting to self - if (item_at_cursor == source_item) { + if (item_at_cursor && item_at_cursor->GetNode() == source_item->GetNode()) { item_at_cursor = nullptr; } @@ -1112,8 +1116,10 @@ void NodeView::PositionNewEdge(const QPoint &pos) create_edge_expanded_items_.resize(i + 1); // Expand item if possible - if (item_at_cursor && item_at_cursor->CanBeExpanded() && !item_at_cursor->IsExpanded() - && (create_edge_from_output_ || !item_at_cursor->IsOutputItem())) { + if (item_at_cursor + && item_at_cursor->CanBeExpanded() + && !item_at_cursor->IsExpanded() + && create_edge_from_output_) { ExpandItem(item_at_cursor); create_edge_expanded_items_.append(item_at_cursor); } @@ -1126,6 +1132,11 @@ void NodeView::PositionNewEdge(const QPoint &pos) item_at_cursor = nullptr; } + // Filter out "output node" of the context, we assume users won't want to fetch the output of this + if (item_at_cursor && !create_edge_from_output_ && item_at_cursor->IsLabelledAsOutputOfContext()) { + item_at_cursor = nullptr; + } + // If the item has changed if (item_at_cursor != opposing_item) { // If we had a destination active, disconnect from it since the item has changed diff --git a/app/widget/nodeview/nodeviewitem.h b/app/widget/nodeview/nodeviewitem.h index 898c49a41..e236de3ea 100644 --- a/app/widget/nodeview/nodeviewitem.h +++ b/app/widget/nodeview/nodeviewitem.h @@ -128,6 +128,11 @@ public: void AddEdge(NodeViewEdge* edge); void RemoveEdge(NodeViewEdge* edge); + bool IsLabelledAsOutputOfContext() const + { + return label_as_output_; + } + void SetLabelAsOutput(bool e); void SetHighlighted(bool e);