33#include "RNA_prototypes.hh"
82 return (node->id == (
ID *)item->
ngroup);
119 if (!node || !(node->flag &
NODE_TEST)) {
123 node->flag &= ~NODE_TEST;
142 node->
flag &= ~NODE_TEST;
151 if (sock->link && sock->link->fromnode != rem_node) {
174 if (!sock_to->
link) {
188 if (!sock_to->
link) {
210 bNode *node_prev =
nullptr;
220 if (node_from->
type == type) {
227 node_from->
typeinfo->draw_buttons_ex)
235 node_from = node_prev;
237 else if (!node_from) {
239 if (node_prev !=
nullptr) {
260 sock_to->
flag &= ~SOCK_COLLAPSED;
263 if (node_prev && node_from != node_prev) {
272 if (
STREQ(sock_prev->identifier, sock_from->identifier) &&
273 sock_prev->type == sock_from->type)
308#define UI_NODE_LINK_DISCONNECT -1
309#define UI_NODE_LINK_REMOVE -2
326 std::optional<NodeDeclaration> &r_node_decl)
337 const char *disabled_hint;
348 const char *disabled_hint;
355 ngroup->ensure_interface_cache();
357 ngroup->interface_inputs() :
358 ngroup->interface_outputs());
384 r_node_decl->outputs;
404 for (stemp = socket_templates; stemp && stemp->
type != -1; stemp++, i++) {
468 return (typeA == typeB);
480 if (
STREQ(ntype->
idname,
"ShaderNodeUVAlongStroke")) {
506 const char *disabled_hint;
507 if (!(ntype->poll && ntype->poll(ntype, ntree, &disabled_hint))) {
511 if (ntype->nclass != nclass) {
519 sorted_ntypes.
append(ntype);
523 qsort(sorted_ntypes.
data(),
524 sorted_ntypes.
size(),
529 for (
int j = 0; j < sorted_ntypes.
size(); j++) {
532 const char *cur_node_name =
nullptr;
534 int icon = ICON_NONE;
538 std::optional<blender::nodes::NodeDeclaration> node_decl;
563 if (!cur_node_name || !
STREQ(cur_node_name, item.node_name)) {
564 cur_node_name = item.node_name;
601 TIP_(
"Add node to input"));
660 TIP_(
"Remove nodes connected to the input"));
674 TIP_(
"Disconnect nodes connected to the input"));
694 arg = MEM_cnew<NodeLinkArg>(
"NodeLinkArg");
698 node_link_item_init(arg->
item);
701 node_socket_color_get(*C, *ntree, node_ptr, *input, socket_col);
707 ui_node_sock_name(ntree, input, name);
709 block, ui_template_node_link_menu,
nullptr, name, 0, 0,
UI_UNIT_X * 4,
UI_UNIT_Y,
"");
713 block, ui_template_node_link_menu,
nullptr, ICON_NONE, 0, 0,
UI_UNIT_X,
UI_UNIT_Y,
"");
720 but->
poin = (
char *)but;
725 if (input->link && input->link->fromnode) {
742 const char *panel_label);
774 panel_state.is_collapsed() ? ICON_RIGHTARROW : ICON_DOWNARROW_HLT,
789 if (!panel_state.is_collapsed() && panel_decl.
draw_buttons) {
800 if (node.typeinfo->draw_buttons) {
803 node.typeinfo->draw_buttons(&layout, &C, &nodeptr);
807 if (node.declaration() && node.declaration()->use_custom_socket_order) {
814 ItemDeclIterator item_decl = node.declaration()->items.begin();
815 SocketIterator input = node.input_sockets().begin();
816 PanelStateIterator panel_state = node.panel_states().begin();
817 const ItemDeclIterator item_decl_end = node.declaration()->items.end();
819 bool panel_collapsed =
false;
820 const char *panel_label =
nullptr;
822 for (; item_decl != item_decl_end; ++item_decl) {
826 if (socket_decl->in_out ==
SOCK_IN) {
827 if (!panel_collapsed) {
836 panel_collapsed = panel_state->is_collapsed();
837 panel_label = panel_decl->name.c_str();
857 const char *panel_label)
861 bool dependency_loop;
869 bNode *lnode = (input.link) ? input.link->fromnode :
nullptr;
872 if (dependency_loop) {
886 bool add_dummy_decorator =
false;
897 int icon = (input.flag &
SOCK_COLLAPSED) ? ICON_RIGHTARROW : ICON_DOWNARROW_HLT;
909 if (dependency_loop) {
911 add_dummy_decorator =
true;
916 add_dummy_decorator =
true;
932 add_dummy_decorator =
true;
936 switch (input.type) {
970 uiItemL(sub,
RPT_(
"Unsupported Menu Socket"), ICON_NONE);
973 input.typeinfo->draw(&C, sub, &inputptr, &nodeptr, input.name);
976 add_dummy_decorator =
true;
988 node.flag &= ~NODE_TEST;
1001 ntree->ensure_topology_cache();
1005 tnode->
flag &= ~NODE_TEST;
1009 ui_node_draw_input(*layout, *C, *ntree, *node, *input, 0,
nullptr);
1012 ui_node_draw_node(*layout, *C, *ntree, *node, 0);
SpaceNode * CTX_wm_space_node(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
#define NODE_TYPES_BEGIN(ntype)
#define NODE_CUSTOM_GROUP
#define NODE_CLASS_LAYOUT
#define NODE_CLASS_TEXTURE
void BKE_ntree_update_tag_node_property(bNodeTree *ntree, bNode *node)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
#define LISTBASE_FOREACH(type, var, list)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define SNPRINTF(dst, format,...)
size_t BLI_snprintf(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
int char char int int int BLI_strcasecmp_natural(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define STRNCPY_UTF8(dst, src)
#define POINTER_FROM_INT(i)
#define POINTER_AS_INT(i)
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
void ED_node_tree_propagate_change(const bContext *C, Main *bmain, bNodeTree *ntree)
void ED_undo_push(bContext *C, const char *str)
static void split(const char *text, const char *seps, char ***str, int *count)
Read Guarded memory(de)allocation.
void UI_but_func_set(uiBut *but, std::function< void(bContext &)> func)
uiPropertySplitWrapper uiItemPropertySplitWrapperCreate(uiLayout *parent_layout)
uiBut * uiDefBut(uiBlock *block, int type, int retval, blender::StringRef str, int x, int y, short width, short height, void *poin, float min, float max, const char *tip)
void uiItemL(uiLayout *layout, const char *name, int icon)
void uiTemplateNodeLink(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, bNodeSocket *input)
uiBlock * uiLayoutGetBlock(uiLayout *layout)
uiLayout * uiLayoutRow(uiLayout *layout, bool align)
void UI_but_drawflag_enable(uiBut *but, int flag)
void uiLayoutSetAlignment(uiLayout *layout, char alignment)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
void uiItemS(uiLayout *layout)
uiBut * uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, blender::StringRef str, int x, int y, short width, short height, void *poin, float min, float max, const char *tip)
void UI_but_type_set_menu_from_pulldown(uiBut *but)
void UI_block_emboss_set(uiBlock *block, eUIEmbossType emboss)
uiBut * uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, blender::StringRef str, int x, int y, short width, short height, const char *tip)
void uiItemDecoratorR(uiLayout *layout, PointerRNA *ptr, const char *propname, int index)
void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep)
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
uiLayout * uiLayoutSplit(uiLayout *layout, float percentage, bool align)
void UI_block_layout_set_current(uiBlock *block, uiLayout *layout)
uiBut * uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, int x, int y, short width, short height, const char *tip)
void UI_but_funcN_set(uiBut *but, uiButHandleNFunc funcN, void *argN, void *arg2, uiButArgNFree func_argN_free_fn=MEM_freeN, uiButArgNCopy func_argN_copy_fn=MEM_dupallocN)
void UI_but_node_link_set(uiBut *but, bNodeSocket *socket, const float draw_color[4])
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
#define ND_SPACE_NODE_VIEW
constexpr IndexRange index_range() const
void append(const T &value)
PanelDrawButtonsFunction draw_buttons
eNodeSocketDatatype socket_type
local_group_size(16, 16) .push_constant(Type b
void MEM_freeN(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
void node_set_active(bNodeTree *ntree, bNode *node)
bNode * node_add_static_node(const bContext *C, bNodeTree *ntree, int type)
void node_remove_node(Main *bmain, bNodeTree *ntree, bNode *node, bool do_id_user)
bool node_group_poll(const bNodeTree *nodetree, const bNodeTree *grouptree, const char **r_disabled_hint)
void node_position_relative(bNode *from_node, const bNode *to_node, const bNodeSocket *from_sock, const bNodeSocket *to_sock)
bNodeLink * node_add_link(bNodeTree *ntree, bNode *fromnode, bNodeSocket *fromsock, bNode *tonode, bNodeSocket *tosock)
void nodeLabel(const bNodeTree *ntree, const bNode *node, char *label, int maxlen)
void node_remove_link(bNodeTree *ntree, bNodeLink *link)
int node_socket_link_limit(const bNodeSocket *sock)
int node_count_socket_links(const bNodeTree *ntree, const bNodeSocket *sock)
static void node_clear_recursive(bNode *node)
static void ui_node_draw_panel(uiLayout &layout, bContext &C, bNodeTree &ntree, const nodes::PanelDeclaration &panel_decl, bNodePanelState &panel_state, PointerRNA nodeptr)
static void node_socket_disconnect(Main *bmain, bNodeTree *ntree, bNode *node_to, bNodeSocket *sock_to)
static void node_link_item_apply(bNodeTree *ntree, bNode *node, NodeLinkItem *item)
static int ui_node_item_name_compare(const void *a, const void *b)
static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_p)
static void node_tag_recursive(bNode *node)
static Vector< NodeLinkItem > ui_node_link_items(NodeLinkArg *arg, int in_out, std::optional< NodeDeclaration > &r_node_decl)
static void node_menu_column_foreach_cb(void *calldata, int nclass, const char *name)
static void ui_node_draw_input(uiLayout &layout, bContext &C, bNodeTree &ntree, bNode &node, bNodeSocket &input, int depth, const char *panel_label)
static void ui_node_sock_name(const bNodeTree *ntree, bNodeSocket *sock, char name[UI_MAX_NAME_STR])
static void node_socket_add_replace(const bContext *C, bNodeTree *ntree, bNode *node_to, bNodeSocket *sock_to, int type, NodeLinkItem *item)
static void node_remove_linked(Main *bmain, bNodeTree *ntree, bNode *rem_node)
static void ui_node_draw_node(uiLayout &layout, bContext &C, bNodeTree &ntree, bNode &node, int depth)
const char * node_socket_get_label(const bNodeSocket *socket, const char *panel_label)
static int ui_compatible_sockets(int typeA, int typeB)
static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
static void node_socket_remove(Main *bmain, bNodeTree *ntree, bNode *node_to, bNodeSocket *sock_to)
static bool node_link_item_compare(bNode *node, NodeLinkItem *item)
static bool ui_node_item_special_poll(const bNodeTree *, const bke::bNodeType *ntype)
static void node_panel_toggle_button_cb(bContext *C, void *panel_state_argv, void *ntree_argv)
void node_geometry_add_attribute_search_button(const bContext &, const bNode &node, PointerRNA &socket_ptr, uiLayout &layout, const StringRefNull placeholder)
static void ui_node_link(bContext *C, void *arg_p, void *event_p)
void node_socket_add_tooltip(const bNodeTree &ntree, const bNodeSocket &sock, uiLayout &layout)
static void node_link_item_init(NodeLinkItem &item)
void build_node_declaration(const bke::bNodeType &typeinfo, NodeDeclaration &r_declaration, const bNodeTree *ntree, const bNode *node)
void node_socket_copy_default_value(bNodeSocket *to, const bNodeSocket *from)
#define UI_NODE_LINK_DISCONNECT
void uiTemplateNodeView(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, bNodeSocket *input)
void uiTemplateNodeLink(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, bNodeSocket *input)
#define UI_NODE_LINK_REMOVE
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
bNodeTreeTypeHandle * typeinfo
bNodeTypeHandle * typeinfo
Compact definition of a node socket.
void(* foreach_nodeclass)(void *calldata, bNodeClassCallback func)
bNodeSocketTemplate * inputs
bNodeSocketTemplate * outputs
NodeDeclareFunction declare
bke::bNodeType * node_type
uiButArgNFree func_argN_free_fn
uiButArgNCopy func_argN_copy_fn
uiLayout * decorate_column
void WM_event_add_notifier(const bContext *C, uint type, void *reference)