13#include <fmt/format.h>
36#include "RNA_prototypes.hh"
84 if (
node->is_group()) {
85 return (
node->id == id_cast<ID *>(item->
ngroup));
92 if (
node->is_group()) {
177 if (!sock_to->
link) {
191 if (!sock_to->
link) {
213 bNode *node_prev =
nullptr;
222 for (node_from = ntree->
nodes.first(); node_from; node_from = node_from->
next) {
238 node_from = node_prev;
240 else if (!node_from) {
242 if (node_prev !=
nullptr) {
266 if (node_prev && node_from != node_prev) {
310#define UI_NODE_LINK_DISCONNECT -1
311#define UI_NODE_LINK_REMOVE -2
328 std::optional<NodeDeclaration> &r_node_decl)
339 const char *disabled_hint;
346 ngroup.ensure_interface_cache();
348 ngroup.interface_inputs() :
349 ngroup.interface_outputs());
374 r_node_decl->outputs;
394 for (stemp = socket_templates; stemp && stemp->
type != -1; stemp++, i++) {
438 if (
node->inputs.is_empty() &&
node->outputs.first() !=
node->outputs.last()) {
442 IFACE_(node_name.c_str()),
459 return (typeA == typeB);
471 if (ntype->
is_type(
"ShaderNodeUVAlongStroke"_ustr)) {
496 const char *disabled_hint;
497 if (!(ntype->poll && ntype->poll(ntype, ntree, &disabled_hint))) {
501 if (ntype->nclass != nclass) {
509 sorted_ntypes.
append(ntype);
512 qsort(sorted_ntypes.
data(),
513 sorted_ntypes.
size(),
518 for (
int j = 0; j < sorted_ntypes.
size(); j++) {
521 const char *cur_node_name =
nullptr;
523 int icon = ICON_NONE;
527 std::optional<nodes::NodeDeclaration> node_decl;
542 column = &layout->
column(
false);
550 if (!cur_node_name || !
STREQ(cur_node_name, item.node_name)) {
551 cur_node_name = item.node_name;
584 TIP_(
"Add node to input"));
586 argN = MEM_dupalloc(arg);
624 column = &
split->column(
false);
640 TIP_(
"Remove nodes connected to the input"));
643 but = uiDefBut(block,
653 TIP_(
"Disconnect nodes connected to the input"));
695 but = uiDefIconMenuBut(
699 button_type_set_menu_from_pulldown(but);
700 button_node_link_set(but, input, socket_col);
712 button_disable(but,
"Cannot edit linked node tree");
726 const char *panel_label);
736 const std::string panel_id = fmt::format(
742 if (panel_toggle_decl) {
746 &ntree.
id, RNA_NodeSocket, &
node.socket_by_decl(*panel_toggle_decl));
758 if (!panel_layout.
body) {
762 if (item_decl == panel_toggle_decl) {
767 if (socket_decl->custom_draw_fn) {
776 (*socket_decl->custom_draw_fn)(params);
778 else if (socket_decl->in_out ==
SOCK_IN) {
790 layout_decl->draw(layout, &
C, &nodeptr);
801 if (
node.typeinfo->draw_buttons) {
804 node.typeinfo->draw_buttons(layout, &
C, &nodeptr);
808 if (
node.declaration()) {
817 if (socket_decl->custom_draw_fn) {
826 (*socket_decl->custom_draw_fn)(params);
828 else if (socket_decl->in_out ==
SOCK_IN) {
834 if (!layout_decl->is_default) {
837 layout_decl->draw(column, &
C, &nodeptr);
856 const char *panel_label)
860 bool dependency_loop;
871 if (dependency_loop) {
879 row = &layout.
row(
true);
885 bool add_dummy_decorator =
false;
898 bool can_expand = lnode->
inputs.first();
903 else if (lnode->declaration()) {
909 if (socket_decl->custom_draw_fn) {
916 if (can_expand && !lnode->is_muted()) {
925 sub = &sub->
row(
true);
930 if (dependency_loop) {
931 row->
label(
RPT_(
"Dependency Loop"), ICON_STATUS_WARNING_FILLED);
932 add_dummy_decorator =
true;
934 else if (lnode && !lnode->is_muted()) {
937 add_dummy_decorator =
true;
953 add_dummy_decorator =
true;
957 switch (input.
type) {
993 add_dummy_decorator =
true;
1018 ntree->ensure_topology_cache();
1021 for (
bNode *tnode : ntree->all_nodes()) {
#define NODE_CLASS_LAYOUT
#define NODE_CLASS_TEXTURE
#define STRNCPY_UTF8(dst, src)
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
#define ID_IS_EDITABLE(_id)
Read Blender memory allocation and freeing.
#define POINTER_FROM_INT(i)
#define POINTER_AS_INT(i)
constexpr IndexRange index_range() const
constexpr const char * c_str() const
const char * c_str() const
StringRefNull ref() const
void append(const T &value)
Vector< ItemDeclaration * > root_items
std::optional< std::string > translation_context
Vector< ItemDeclaration * > items
const SocketDeclaration * panel_input_decl() const
eNodeSocketDatatype socket_type
std::string node_label(const bNodeTree &ntree, const bNode &node)
void node_remove_node(Main *bmain, bNodeTree &ntree, bNode &node, bool do_id_user, bool remove_animation=true)
bool node_group_poll(const bNodeTree *nodetree, const bNodeTree *grouptree, const char **r_disabled_hint)
void node_remove_link(bNodeTree *ntree, bNodeLink &link)
Span< bNodeType * > node_types_get()
int node_count_socket_links(const bNodeTree &ntree, const bNodeSocket &sock)
void node_position_relative(bNode &from_node, const bNode &to_node, const bNodeSocket *from_sock, const bNodeSocket &to_sock)
bNode * node_add_static_node(const bContext *C, bNodeTree &ntree, int type)
bNodeLink & node_add_link(bNodeTree &ntree, bNode &fromnode, bNodeSocket &fromsock, bNode &tonode, bNodeSocket &tosock)
void socket_value_copy_content(eNodeSocketDatatype type, void *dst, const void *src, bool do_id_user)
void node_set_active(bNodeTree &ntree, bNode &node)
int node_socket_link_limit(const bNodeSocket &sock)
static void node_clear_recursive(bNode *node)
static void node_socket_disconnect(Main *bmain, bNodeTree *ntree, bNode *node_to, bNodeSocket *sock_to)
void node_geometry_add_attribute_search_button(const bContext &, const bNode &node, PointerRNA &socket_ptr, ui::Layout &layout, const StringRef placeholder)
static void ui_template_node_link_menu(bContext *C, ui::Layout *layout, void *but_p)
static void ui_node_draw_node(ui::Layout &layout, bContext &C, bNodeTree &ntree, bNode &node, int depth)
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 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 ui_node_sock_name(const bNodeTree *ntree, bNodeSocket *sock, char name[UI_MAX_NAME_STR])
void node_socket_color_get(const bContext &C, const bNodeTree &ntree, PointerRNA &node_ptr, const bNodeSocket &sock, float r_color[4])
void node_socket_add_tooltip(const bNodeTree &ntree, const bNodeSocket &sock, ui::Layout &layout)
static void node_socket_add_replace(const bContext *C, bNodeTree *ntree, bNode *node_to, bNodeSocket *sock_to, int type, NodeLinkItem *item)
static void ui_node_draw_input(ui::Layout &layout, bContext &C, bNodeTree &ntree, bNode &node, bNodeSocket &input, int depth, const char *panel_label)
static void node_remove_linked(Main *bmain, bNodeTree *ntree, bNode *rem_node)
static int ui_compatible_sockets(int typeA, int typeB)
const char * node_socket_get_label(const bNodeSocket *socket, const char *panel_label=nullptr)
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 void node_menu_column_foreach_cb(void *calldata, int nclass, const StringRefNull name)
static bool ui_node_item_special_poll(const bNodeTree *, const bke::bNodeType *ntype)
static void ui_node_link(bContext *C, void *arg_p, void *event_p)
static void ui_node_draw_recursive(ui::Layout &layout, bContext &C, bNodeTree &ntree, bNode &node, const nodes::PanelDeclaration &panel_decl, const int depth)
static void node_link_item_init(NodeLinkItem &item)
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
void build_node_declaration(const bke::bNodeType &typeinfo, NodeDeclaration &r_declaration, const bNodeTree *ntree, const bNode *node)
void button_poin_menu_argN_set(Button *but, void *poin, void *argN, ButtonArgNFree func_argN_free_fn, ButtonArgNCopy func_argN_copy_fn)
void button_flag_enable(Button *but, int64_t flag)
void * button_func_argN_get(const Button *but)
void block_layout_set_current(Block *block, Layout *layout)
size_t size_t size_t BLI_snprintf_utf8(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
void uiTemplateNodeLink(ui::Layout *layout, bContext *C, bNodeTree *ntree, bNode *node, bNodeSocket *input)
const char * BKE_id_name(const ID &id)
void MEM_delete_void(void *vmemh)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * MEM_dupalloc_void(const void *vmemh) ATTR_WARN_UNUSED_RESULT
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void ED_undo_push(bContext *C, const char *str, UndoEncodeHints hints=UndoEncodeHints(0))
void BKE_main_ensure_invariants(Main &bmain, std::optional< Span< ID * > > modified_ids=std::nullopt)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
SpaceNode * CTX_wm_space_node(const bContext *C)
ATTR_WARN_UNUSED_RESULT const size_t num
void uiTemplateNodeView(ui::Layout *layout, bContext *C, bNodeTree *ntree, bNode *node, bNodeSocket *input)
void BKE_ntree_update_tag_node_property(bNodeTree *ntree, bNode *node)
Main * CTX_data_main(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
#define UI_NODE_LINK_DISCONNECT
#define UI_NODE_LINK_REMOVE
ListBaseT< bNodeTree > nodetrees
bke::bNodeSocketType * typeinfo
bke::bNodeTreeType * typeinfo
ListBaseT< bNodeSocket > outputs
ListBaseT< bNodeSocket > inputs
bke::bNodeType * typeinfo
Compact definition of a node socket.
void(*) draw(bContext *C, ui::Layout *layout, PointerRNA *ptr, PointerRNA *node_ptr, StringRef text)
void(*) foreach_nodeclass(void *calldata, bNodeClassCallback func)
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
bNodeSocketTemplate * inputs
void(*) draw_buttons_ex(ui::Layout &, bContext *C, PointerRNA *ptr)
bool is_type(UString query_idname) const
bNodeSocketTemplate * outputs
NodeDeclareFunction declare
bke::bNodeType * node_type
void alignment_set(LayoutAlign alignment)
void use_property_decorate_set(bool is_decorate)
void use_property_split_set(bool is_sep)
void label(StringRef name, int icon)
void decorator(PointerRNA *ptr, PropertyRNA *prop, int index)
PanelLayout panel(const bContext *C, StringRef idname, bool default_closed)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
void active_set(bool active)
Layout & split(float percentage, bool align)
Layout & column(bool align)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)