From d19e7cbb5ae7323650d11aa1174952b71b8b1ddc Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 9 Jan 2024 13:19:40 +0100 Subject: [PATCH] Fix #115540: nodes with sockets only on one side are hard to resize This was caused by 74dd1e044b55d10f6567697be2a30eda8995f697. The fix implemented here disables socket picking in the header region of non-collapsed nodes. This way, resizing always works when on the left and right side of the header. --- source/blender/editors/space_node/node_edit.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index 443acb57189..caae7d8d45e 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -1225,6 +1225,12 @@ bNodeSocket *node_find_indicated_socket(SpaceNode &snode, }; for (bNode *node : sorted_nodes) { + const bool node_hidden = node->flag & NODE_HIDDEN; + if (!node_hidden && node->runtime->totr.ymax - cursor.y < NODE_DY) { + /* Don't pick socket when cursor is over node header. This allows the user to always resize + * by dragging on the left and right side of the header. */ + continue; + } if (in_out & SOCK_IN) { for (bNodeSocket *sock : node->input_sockets()) { if (!node->is_socket_icon_drawn(*sock)) { @@ -1232,7 +1238,7 @@ bNodeSocket *node_find_indicated_socket(SpaceNode &snode, } const float2 location = sock->runtime->location; const float distance = math::distance(location, cursor); - if (sock->flag & SOCK_MULTI_INPUT && !(node->flag & NODE_HIDDEN)) { + if (sock->flag & SOCK_MULTI_INPUT && !node_hidden) { if (cursor_isect_multi_input_socket(cursor, *sock)) { update_best_socket(sock, distance); continue; @@ -1251,7 +1257,7 @@ bNodeSocket *node_find_indicated_socket(SpaceNode &snode, const float2 location = sock->runtime->location; const float distance = math::distance(location, cursor); if (distance < max_distance) { - if (node->flag & NODE_HIDDEN) { + if (node_hidden) { if (location.x - cursor.x > padded_socket_size) { /* Needed to be able to resize collapsed nodes. */ continue;