Blender V5.0
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);
59 void connect_available_socket_by_identifier(bNode &new_node, StringRef socket_identifier);
60 void connect_socket(bNode &new_node, bNodeSocket &new_socket);
64 void update_and_connect_available_socket(bNode &new_node, StringRef socket_name);
65};
66
68 using LinkSocketFn = std::function<void(LinkSearchOpParams &link_params)>;
69
70 std::string name;
72 int weight = 0;
73};
74
77 const bke::bNodeType &node_type_;
78
79 const SpaceNode &snode_;
80 const bNodeTree &node_tree_;
81
82 const bNodeSocket &other_socket_;
83
84 /* The operations currently being built. Owned by the caller. */
86
87 public:
89 const SpaceNode &snode,
90 const bNodeTree &node_tree,
93 : node_type_(node_type),
94 snode_(snode),
95 node_tree_(node_tree),
96 other_socket_(other_socket),
97 items_(items)
98 {
99 }
100
104 const bNodeSocket &other_socket() const;
105
109 const SpaceNode &space_node() const;
110
114 const bNodeTree &node_tree() const;
115
119 const bke::bNodeType &node_type() const;
120
124 eNodeSocketInOut in_out() const;
125
133 void add_item(std::string socket_name, SocketLinkOperation::LinkSocketFn fn, int weight = 0);
134
139 void add_item_full_name(std::string name, SocketLinkOperation::LinkSocketFn fn, int weight = 0);
140};
141
154void search_link_ops_for_basic_node(GatherLinkSearchOpParams &params);
155
156void search_link_ops_for_declarations(GatherLinkSearchOpParams &params,
157 Span<SocketDeclaration *> declarations);
158
159} // 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 add_item_full_name(std::string name, SocketLinkOperation::LinkSocketFn fn, int weight=0)
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 connect_available_socket_by_identifier(bNode &new_node, StringRef socket_identifier)
void connect_socket(bNode &new_node, bNodeSocket &new_socket)
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)
const char * name
Defines a node type.
Definition BKE_node.hh:238
std::function< void(LinkSearchOpParams &link_params)> LinkSocketFn