Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_node/link_drag_search.cc')
-rw-r--r--source/blender/editors/space_node/link_drag_search.cc46
1 files changed, 41 insertions, 5 deletions
diff --git a/source/blender/editors/space_node/link_drag_search.cc b/source/blender/editors/space_node/link_drag_search.cc
index e1ba36e81c0..45126e9cee0 100644
--- a/source/blender/editors/space_node/link_drag_search.cc
+++ b/source/blender/editors/space_node/link_drag_search.cc
@@ -29,6 +29,8 @@
#include "WM_api.h"
+#include "ED_node.h"
+
#include "node_intern.hh"
using blender::nodes::SocketLinkOperation;
@@ -77,7 +79,7 @@ static void add_group_input_node_fn(nodes::LinkSearchOpParams &params)
bNode &group_input = params.add_node("NodeGroupInput");
/* This is necessary to create the new sockets in the other input nodes. */
- ntreeUpdateTree(CTX_data_main(&params.C), &params.node_tree);
+ ED_node_tree_propagate_change(&params.C, CTX_data_main(&params.C), &params.node_tree);
/* Hide the new input in all other group input nodes, to avoid making them taller. */
LISTBASE_FOREACH (bNode *, node, &params.node_tree.nodes) {
@@ -103,6 +105,26 @@ static void add_group_input_node_fn(nodes::LinkSearchOpParams &params)
nodeAddLink(&params.node_tree, &group_input, socket, &params.node, &params.socket);
}
+static void add_existing_group_input_fn(nodes::LinkSearchOpParams &params,
+ const bNodeSocket &interface_socket)
+{
+ const int group_input_index = BLI_findindex(&params.node_tree.inputs, &interface_socket);
+ bNode &group_input = params.add_node("NodeGroupInput");
+
+ LISTBASE_FOREACH (bNodeSocket *, socket, &group_input.outputs) {
+ socket->flag |= SOCK_HIDDEN;
+ }
+
+ bNodeSocket *socket = (bNodeSocket *)BLI_findlink(&group_input.outputs, group_input_index);
+ if (socket == nullptr) {
+ /* Adding sockets can fail in some cases. There's no good reason not to be safe here. */
+ return;
+ }
+
+ socket->flag &= ~SOCK_HIDDEN;
+ nodeAddLink(&params.node_tree, &group_input, socket, &params.node, &params.socket);
+}
+
/**
* Call the callback to gather compatible socket connections for all node types, and the operations
* that will actually make the connections. Also add some custom operations like connecting a group
@@ -134,6 +156,22 @@ static void gather_socket_link_operations(bNodeTree &node_tree,
if (is_node_group && socket.in_out == SOCK_IN) {
search_link_ops.append({IFACE_("Group Input"), add_group_input_node_fn});
+
+ int weight = -1;
+ LISTBASE_FOREACH (const bNodeSocket *, interface_socket, &node_tree.inputs) {
+ eNodeSocketDatatype from = (eNodeSocketDatatype)interface_socket->type;
+ eNodeSocketDatatype to = (eNodeSocketDatatype)socket.type;
+ if (node_tree.typeinfo->validate_link && !node_tree.typeinfo->validate_link(from, to)) {
+ continue;
+ }
+ search_link_ops.append(
+ {std::string(IFACE_("Group Input ")) + UI_MENU_ARROW_SEP + interface_socket->name,
+ [interface_socket](nodes::LinkSearchOpParams &params) {
+ add_existing_group_input_fn(params, *interface_socket);
+ },
+ weight});
+ weight--;
+ }
}
}
@@ -203,9 +241,7 @@ static void link_drag_search_exec_fn(bContext *C, void *arg1, void *arg2)
/* Ideally it would be possible to tag the node tree in some way so it updates only after the
* translate operation is finished, but normally moving nodes around doesn't cause updates. */
- ntreeUpdateTree(&bmain, snode.edittree);
- snode_notify(*C, snode);
- snode_dag_update(*C, snode);
+ ED_node_tree_propagate_change(C, &bmain, snode.edittree);
/* Start translation operator with the new node. */
wmOperatorType *ot = WM_operatortype_find("TRANSFORM_OT_translate", true);
@@ -288,4 +324,4 @@ void invoke_node_link_drag_add_menu(bContext &C,
UI_popup_block_invoke_ex(&C, create_search_popup_block, storage, nullptr, false);
}
-} // namespace blender::ed::space_node \ No newline at end of file
+} // namespace blender::ed::space_node