Node Editor: Controlled node link swapping

Allow to explicitly swap node links by pressing the alt-key while
reconnecting node links. This replaces the old auto-swapping based on
matching prefixes in socket names.

The new behavior works as follows:

* By default plugging links into already occupied (single input)
  sockets will connect the dragged link and remove the existing one.
* Pressing the alt-key while dragging an existing node link from one
  socket to another socket that is already connected will swap the
  links' destinations.
* Pressing the alt-key while dragging a new node link into an already
  linked socket will try to reconnect the existing links into another
  socket of the same type and remove the links, if no matching socket
  is found on the node. This is similar to the old auto-swapping.

Swapping links from or to multi input sockets is not supported.

This commit also makes the link drag tooltip better visible, when using
light themes by using the text theme color.

Reviewed By: Hans Goudey, Simon Thommes

Differential Revision: https://developer.blender.org/D16244
This commit is contained in:
2023-01-28 10:07:29 +01:00
parent fe5c3a0ab3
commit 89aae4ac82
5 changed files with 203 additions and 137 deletions

View File

@@ -70,9 +70,7 @@ void node_combsep_color_label(const ListBase *sockets, NodeCombSepColorMode mode
/*** Link Handling */
/**
* The idea behind this is: When a user connects an input to a socket that is
* already linked (and if its not an Multi Input Socket), we try to find a replacement socket for
* the link that we try to overwrite and connect that previous link to the new socket.
* By default there are no links we don't want to connect, when inserting.
*/
bool node_insert_link_default(struct bNodeTree *ntree, struct bNode *node, struct bNodeLink *link);