Fix #115540: nodes with sockets only on one side are hard to resize

This was caused by 74dd1e044b.

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.
This commit is contained in:
Jacques Lucke 2024-01-09 13:19:40 +01:00
parent c4376c58e9
commit d19e7cbb5a
1 changed files with 8 additions and 2 deletions

View File

@ -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;