Blender V4.3
NOD_socket_search_link.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include <functional>
8
9#include "BLI_string_ref.hh"
10#include "BLI_vector.hh"
11
12#include "DNA_node_types.h" /* Necessary for eNodeSocketInOut. */
13
15
16struct bContext;
17struct SpaceNode;
18
19namespace blender::nodes {
20
25 private:
29 Vector<bNode *> &added_nodes_;
30
31 public:
32 const bContext &C;
42
45 bNode &node,
47 Vector<bNode *> &added_nodes)
48 : added_nodes_(added_nodes), C(C), node_tree(node_tree), node(node), socket(socket)
49 {
50 }
51
52 bNode &add_node(StringRef idname);
53 bNode &add_node(const bke::bNodeType &node_type);
58 void connect_available_socket(bNode &new_node, StringRef socket_name);
62 void update_and_connect_available_socket(bNode &new_node, StringRef socket_name);
63};
64
66 using LinkSocketFn = std::function<void(LinkSearchOpParams &link_params)>;
67
68 std::string name;
70 int weight = 0;
71};
72
75 const bke::bNodeType &node_type_;
76
77 const SpaceNode &snode_;
78 const bNodeTree &node_tree_;
79
80 const bNodeSocket &other_socket_;
81
82 /* The operations currently being built. Owned by the caller. */
84
85 public:
87 const SpaceNode &snode,
88 const bNodeTree &node_tree,
91 : node_type_(node_type),
92 snode_(snode),
93 node_tree_(node_tree),
94 other_socket_(other_socket),
95 items_(items)
96 {
97 }
98
102 const bNodeSocket &other_socket() const;
103
107 const SpaceNode &space_node() const;
108
112 const bNodeTree &node_tree() const;
113
117 const bke::bNodeType &node_type() const;
118
122 eNodeSocketInOut in_out() const;
123
131 void add_item(std::string socket_name, SocketLinkOperation::LinkSocketFn fn, int weight = 0);
132};
133
146void search_link_ops_for_basic_node(GatherLinkSearchOpParams &params);
147
148void search_link_ops_for_declarations(GatherLinkSearchOpParams &params,
149 Span<SocketDeclaration *> declarations);
150
151} // namespace blender::nodes
eNodeSocketInOut
const bke::bNodeType & node_type() const
void add_item(std::string socket_name, SocketLinkOperation::LinkSocketFn fn, int weight=0)
GatherLinkSearchOpParams(const bke::bNodeType &node_type, const SpaceNode &snode, const bNodeTree &node_tree, const bNodeSocket &other_socket, Vector< SocketLinkOperation > &items)
void connect_available_socket(bNode &new_node, StringRef socket_name)
LinkSearchOpParams(const bContext &C, bNodeTree &node_tree, bNode &node, bNodeSocket &socket, Vector< bNode * > &added_nodes)
void update_and_connect_available_socket(bNode &new_node, StringRef socket_name)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void search_link_ops_for_basic_node(GatherLinkSearchOpParams &params)
void search_link_ops_for_declarations(GatherLinkSearchOpParams &params, Span< SocketDeclaration * > declarations)
Defines a node type.
Definition BKE_node.hh:218
std::function< void(LinkSearchOpParams &link_params)> LinkSocketFn