refined some nodeview behavior

This commit is contained in:
itsmattkc
2021-12-18 14:03:44 -08:00
parent 8ba5107e73
commit 671fafb496
2 changed files with 19 additions and 3 deletions
+14 -3
View File
@@ -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<NodeViewItem*>(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