43#include "RNA_prototypes.hh"
75 storage.update_items_tag =
true;
101 item.set_selected(
false);
114 if (
node->is_group_input()) {
117 if (new_group_input_socket) {
156 if (socket !=
nullptr) {
175 if (tree_type ==
nullptr ||
IDP_int_get(tree_type) != node_tree.
type) {
187 properties, in_out ==
SOCK_IN ?
"inputs" :
"output_sockets");
213 if (!socket_names.
add(name)) {
228 bNode &
node = params.add_node(params.node_tree.typeinfo->group_idname);
243 if (new_node_socket !=
nullptr) {
246 params.node_tree, params.node, params.socket,
node, *new_node_socket);
286 const char *disabled_hint;
287 if (node_type->poll && !node_type->poll(node_type, &node_tree, &disabled_hint)) {
290 if (node_type->add_ui_poll && !node_type->add_ui_poll(&
C)) {
293 if (
StringRefNull(node_type->ui_name).endswith(
"(Legacy)")) {
296 if (node_type->gather_link_search_ops) {
298 *node_type, snode, node_tree, socket, search_link_ops};
299 node_type->gather_link_search_ops(params);
347 if (
storage.update_items_tag) {
349 storage.search_link_ops.clear();
351 storage.update_items_tag =
false;
363 const char *
string = is_first ?
"" :
str;
367 if (!search_item_add(items, item->name, item, ICON_NONE, 0, 0)) {
375 for (
const bNodeLink *link : socket.directly_linked_links()) {
376 if (new_nodes.
contains(link->fromnode)) {
377 return link->fromnode;
379 if (new_nodes.
contains(link->tonode)) {
393 if (item ==
nullptr) {
412 node_tree.ensure_topology_cache();
414 link_offset -= new_directly_linked_node->location;
416 link_offset.x -= new_directly_linked_node->width;
420 const float2 offset_in_tree = cursor_offset + link_offset;
421 for (
bNode *new_node : new_nodes) {
423 new_node->location[0] += offset_in_tree.x;
424 new_node->location[1] += offset_in_tree.y;
466 button_func_search_set(but,
490 block_bounds_set_popup(block, 0.3f *
U.widget_unit, offset);
536 for (
const int i : search_link_ops.index_range()) {
541 MEM_delete(idp_link_op_name);
547 const int link_op_index =
RNA_int_get(op->
ptr,
"link_operation_index");
548 if (!search_link_ops.index_range().contains(link_op_index)) {
574 ot->
name =
"Link Drag Operation Test";
575 ot->
idname =
"NODE_OT_link_drag_operation_test";
576 ot->
description =
"Run a node link-drag operation for testing";
584 "find_link_operations",
586 "Find Link Operations",
587 "Write link operation names for the context socket the \"link_operation_names\" "
588 "property of the node tree");
590 "link_operation_index",
594 "Link Operation Index",
595 "Link operation to execute on the context socket",
Main runtime representation of an asset.
#define IDP_int_get(prop)
#define STRNCPY_UTF8(dst, src)
#define ND_ASSET_LIST_READING
#define SET_FLAG_FROM_TEST(value, test, flag)
constexpr bool contains(const T &value) const
constexpr StringRefNull()
void append(const T &value)
bNode & add_node(UString idname)
void add(const StringRef str, T *user_data, const int weight=0)
Vector< T * > query(const StringRef query) const
#define storage(slot, qualifiers)
AssetLibraryReference all_library_reference()
bNodeTreeInterfaceSocket * add_interface_socket_from_node(bNodeTree &ntree, const bNode &from_node, const bNodeSocket &from_sock, std::optional< StringRef > name=std::nullopt, std::optional< eNodeSocketInOut > in_out=std::nullopt)
Span< bNodeType * > node_types_get()
bool node_set_selected(bNode &node, bool select)
bNodeSocketType * node_socket_type_find(StringRef idname)
bNodeLink & node_add_link(bNodeTree &ntree, bNode &fromnode, bNodeSocket &fromsock, bNode &tonode, bNodeSocket &tosock)
bNodeSocket * node_find_enabled_socket(bNode &node, eNodeSocketInOut in_out, StringRef name)
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, UString identifier)
void node_set_active(bNodeTree &ntree, bNode &node)
void node_socket_move_default_value(Main &bmain, bNodeTree &tree, bNodeSocket &src, bNodeSocket &dst)
void node_unique_name(bNodeTree &ntree, bNode &node)
void storage_fetch(const AssetLibraryReference *library_reference, const bContext *C)
void iterate(const AssetLibraryReference &library_reference, AssetListIterFn fn)
bool filter_matches_asset(const AssetFilterSettings *filter, const asset_system::AssetRepresentation &asset)
ID * asset_local_id_ensure_imported(Main &bmain, const asset_system::AssetRepresentation &asset, int flags=0, const std::optional< eAssetImportMethod > import_method=std::nullopt, const std::optional< ImportInstantiateContext > instantiate_context=std::nullopt, ReportList *reports=nullptr)
void invoke_node_link_drag_add_menu(bContext &C, bNode &node, bNodeSocket &socket, const float2 &cursor)
bool node_deselect_all(bNodeTree &node_tree)
static bNode * get_new_linked_node(bNodeSocket &socket, const Span< bNode * > new_nodes)
static void add_reroute_node_fn(nodes::LinkSearchOpParams ¶ms)
static ui::Block * create_search_popup_block(bContext *C, ARegion *region, void *arg_op)
static void link_drag_search_free_fn(void *arg)
static void gather_search_link_ops_for_all_assets(const bContext &C, const bNodeTree &node_tree, const bNodeSocket &socket, Vector< SocketLinkOperation > &search_link_ops)
static void add_existing_group_input_fn(nodes::LinkSearchOpParams ¶ms, const bNodeTreeInterfaceSocket &interface_socket)
static void add_group_input_node_fn(nodes::LinkSearchOpParams ¶ms)
static void link_drag_search_listen_fn(const wmRegionListenerParams *params, void *arg)
static void link_drag_search_exec_fn(bContext *C, void *arg1, void *arg2)
void NODE_OT_link_drag_operation_test(wmOperatorType *ot)
static wmOperatorStatus link_drag_operation_test_exec(bContext *C, wmOperator *op)
static void gather_socket_link_operations(const bContext &C, bNodeTree &node_tree, const bNodeSocket &socket, Vector< SocketLinkOperation > &search_link_ops)
static void search_link_ops_for_asset_metadata(const bNodeTree &node_tree, const bNodeSocket &socket, const asset_system::AssetRepresentation &asset, Vector< SocketLinkOperation > &search_link_ops)
static bool link_drag_operation_test_poll(bContext *C)
static void link_drag_search_update_fn(const bContext *C, void *arg, const char *str, ui::SearchItems *items, const bool is_first)
void update_node_declaration_and_sockets(bNodeTree &ntree, bNode &node, Main *bmain)
@ BLOCK_THEME_STYLE_POPUP
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop) ATTR_NONNULL()
@ RPT_ERROR_INVALID_INPUT
void WM_operator_properties_free(PointerRNA *ptr)
IDProperty * IDP_GetPropertyFromGroup(const IDProperty *prop, StringRef name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
PointerRNA WM_operator_properties_create_ptr(wmOperatorType *ot)
bool ED_operator_node_editable(bContext *C)
int RNA_int_get(PointerRNA *ptr, const char *name)
std::optional< int > IDP_group_lookup_int(const IDProperty &group, StringRef name)
const char * BKE_id_name(const ID &id)
IDProperty * IDP_NewString(const char *st, StringRef name, eIDPropertyFlag flags={}) ATTR_WARN_UNUSED_RESULT
std::optional< StringRefNull > IDP_group_lookup_string(const IDProperty &group, StringRef name)
void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
void BKE_report(ReportList *reports, eReportType type, const char *message)
void BKE_main_ensure_invariants(Main &bmain, std::optional< Span< ID * > > modified_ids=std::nullopt)
void IDP_SetIndexArray(IDProperty *prop, int index, IDProperty *item) ATTR_NONNULL()
IDProperty * BKE_asset_metadata_idprop_find(const AssetMetaData *asset_data, const char *name) ATTR_WARN_UNUSED_RESULT
SpaceNode * CTX_wm_space_node(const bContext *C)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void BKE_ntree_update_tag_node_property(bNodeTree *ntree, bNode *node)
Main * CTX_data_main(const bContext *C)
wmOperatorStatus WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wm::OpCallContext context, PointerRNA *properties, const wmEvent *event)
IDProperty * IDP_EnsureProperties(ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void DEG_relations_tag_update(Main *bmain)
NodeTreeInterfaceSocketFlag
@ NODE_INTERFACE_SOCKET_OUTPUT
@ NODE_INTERFACE_SOCKET_INPUT
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
IDProperty * IDP_NewIDPArray(StringRef name) ATTR_WARN_UNUSED_RESULT
#define UI_MENU_ARROW_SEP
ListBaseT< struct IDProperty > group
struct bNodeTree * edittree
bke::bNodeSocketType * typeinfo
NodeTreeInterfaceItemType item_type
NodeTreeInterfaceSocketFlag flag
bNodeTreeInterfaceItem item
int default_group_node_width
bke::bNodeTreeType * typeinfo
bNodeTreeInterface tree_interface
ListBaseT< bNodeSocket > outputs
ListBaseT< bNodeSocket > inputs
bool(*) validate_link(eNodeSocketDatatype from, eNodeSocketDatatype to)
Vector< SocketLinkOperation > search_link_ops
eNodeSocketInOut in_out() const
bNodeSocket & from_socket
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
const wmNotifier * notifier