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/nodes/NOD_socket_declarations.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/nodes/NOD_socket_declarations.hh')
-rw-r--r-- | source/blender/nodes/NOD_socket_declarations.hh | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/source/blender/nodes/NOD_socket_declarations.hh b/source/blender/nodes/NOD_socket_declarations.hh index 1b78a09d6a8..3fb21a4263d 100644 --- a/source/blender/nodes/NOD_socket_declarations.hh +++ b/source/blender/nodes/NOD_socket_declarations.hh @@ -39,9 +39,10 @@ class Float : public SocketDeclaration { public: using Builder = FloatBuilder; - bNodeSocket &build(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out) const override; + bNodeSocket &build(bNodeTree &ntree, bNode &node) const override; bool matches(const bNodeSocket &socket) const override; bNodeSocket &update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const override; + bool can_connect(const bNodeSocket &socket) const override; }; class FloatBuilder : public SocketDeclarationBuilder<Float> { @@ -66,9 +67,10 @@ class Int : public SocketDeclaration { public: using Builder = IntBuilder; - bNodeSocket &build(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out) const override; + bNodeSocket &build(bNodeTree &ntree, bNode &node) const override; bool matches(const bNodeSocket &socket) const override; bNodeSocket &update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const override; + bool can_connect(const bNodeSocket &socket) const override; }; class IntBuilder : public SocketDeclarationBuilder<Int> { @@ -93,9 +95,10 @@ class Vector : public SocketDeclaration { public: using Builder = VectorBuilder; - bNodeSocket &build(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out) const override; + bNodeSocket &build(bNodeTree &ntree, bNode &node) const override; bool matches(const bNodeSocket &socket) const override; bNodeSocket &update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const override; + bool can_connect(const bNodeSocket &socket) const override; }; class VectorBuilder : public SocketDeclarationBuilder<Vector> { @@ -117,8 +120,9 @@ class Bool : public SocketDeclaration { public: using Builder = BoolBuilder; - bNodeSocket &build(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out) const override; + bNodeSocket &build(bNodeTree &ntree, bNode &node) const override; bool matches(const bNodeSocket &socket) const override; + bool can_connect(const bNodeSocket &socket) const override; }; class BoolBuilder : public SocketDeclarationBuilder<Bool> { @@ -137,8 +141,9 @@ class Color : public SocketDeclaration { public: using Builder = ColorBuilder; - bNodeSocket &build(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out) const override; + bNodeSocket &build(bNodeTree &ntree, bNode &node) const override; bool matches(const bNodeSocket &socket) const override; + bool can_connect(const bNodeSocket &socket) const override; }; class ColorBuilder : public SocketDeclarationBuilder<Color> { @@ -157,8 +162,9 @@ class String : public SocketDeclaration { public: using Builder = StringBuilder; - bNodeSocket &build(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out) const override; + bNodeSocket &build(bNodeTree &ntree, bNode &node) const override; bool matches(const bNodeSocket &socket) const override; + bool can_connect(const bNodeSocket &socket) const override; }; class StringBuilder : public SocketDeclarationBuilder<String> { @@ -173,9 +179,10 @@ class IDSocketDeclaration : public SocketDeclaration { public: IDSocketDeclaration(const char *idname); - bNodeSocket &build(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out) const override; + bNodeSocket &build(bNodeTree &ntree, bNode &node) const override; bool matches(const bNodeSocket &socket) const override; bNodeSocket &update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const override; + bool can_connect(const bNodeSocket &socket) const override; }; class Object : public IDSocketDeclaration { @@ -222,8 +229,9 @@ class Shader : public SocketDeclaration { public: using Builder = ShaderBuilder; - bNodeSocket &build(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out) const override; + bNodeSocket &build(bNodeTree &ntree, bNode &node) const override; bool matches(const bNodeSocket &socket) const override; + bool can_connect(const bNodeSocket &socket) const; }; class ShaderBuilder : public SocketDeclarationBuilder<Shader> { |