diff options
author | Hans Goudey <h.goudey@me.com> | 2021-12-15 18:51:57 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-12-15 18:51:57 +0300 |
commit | 11be151d58ec0ca955f019b0eed738e3245110b8 (patch) | |
tree | 5f9673d5a91060fb3bb2156dddb32c2e95409b48 /source/blender/editors/space_node/node_intern.hh | |
parent | 474adc6f883c2d5a854d7324364f7996044d83cb (diff) |
Node Editor: Link Drag Search Menu
This commit adds a search menu when links are dragged above empty
space. When releasing the drag, a menu displays all compatible
sockets with the source link. The "main" sockets (usually the first)
are weighted above other sockets in the search, so they appear first
when you type the name of the node.
A few special operators for creating a reroute or a group input node
are also added to the search.
Translation is started after choosing a node so it can be placed
quickly, since users would likely adjust the position after anyway.
A small "+" is displayed next to the cursor to give a hint about this.
Further improvements are possible after this first iteration:
- Support custom node trees.
- Better drawing of items in the search menu.
- Potential tweaks to filtering of items, depending on user feedback.
Thanks to Juanfran Matheu for developing an initial patch.
Differential Revision: https://developer.blender.org/D8286
Diffstat (limited to 'source/blender/editors/space_node/node_intern.hh')
-rw-r--r-- | source/blender/editors/space_node/node_intern.hh | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/source/blender/editors/space_node/node_intern.hh b/source/blender/editors/space_node/node_intern.hh index f3ba405c6d0..2e55bb0cb28 100644 --- a/source/blender/editors/space_node/node_intern.hh +++ b/source/blender/editors/space_node/node_intern.hh @@ -43,6 +43,9 @@ struct bNodeLink; struct bNodeSocket; struct wmGizmoGroupType; struct wmKeyConfig; +namespace blender { +struct float2; +} struct wmWindow; /** Temporary data used in node link drag modal operator. */ @@ -50,14 +53,29 @@ struct bNodeLinkDrag { /** Links dragged by the operator. */ blender::Vector<bNodeLink *> links; bool from_multi_input_socket; - int in_out; + eNodeSocketInOut in_out; + + /** Draw handler for the "+" icon when dragging a link in empty space. */ + void *draw_handle; /** Temporarily stores the last picked link from multi-input socket operator. */ - struct bNodeLink *last_picked_multi_input_socket_link; + bNodeLink *last_picked_multi_input_socket_link; + + /** + * Temporarily stores the last hovered socket for multi-input socket operator. + * Store it to recalculate sorting after it is no longer hovered. + */ + bNode *last_node_hovered_while_dragging_a_link; - /** Temporarily stores the last hovered socket for multi-input socket operator. - * Store it to recalculate sorting after it is no longer hovered. */ - struct bNode *last_node_hovered_while_dragging_a_link; + /* The cursor position, used for drawing a + icon when dragging a node link. */ + std::array<int, 2> cursor; + + /** The node the drag started at. */ + bNode *start_node; + /** The socket the drag started at. */ + bNodeSocket *start_socket; + /** The number of links connected to the #start_socket when the drag started. */ + int start_link_count; /* Data for edge panning */ View2DEdgePanData pan_data; @@ -327,4 +345,9 @@ namespace blender::ed::space_node { Vector<ui::ContextPathItem> context_path_for_space_node(const bContext &C); -} +void invoke_node_link_drag_add_menu(bContext &C, + bNode &node, + bNodeSocket &socket, + const float2 &cursor); + +} // namespace blender::ed::space_node |