Blender V4.3
rna_node_tree_interface.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#include "RNA_define.hh"
12#include "RNA_enum_types.hh"
13#include "RNA_types.hh"
14
15#include "rna_internal.hh"
16
17#include "WM_types.hh"
18
20 {NODE_INTERFACE_SOCKET, "SOCKET", 0, "Socket", ""},
21 {NODE_INTERFACE_PANEL, "PANEL", 0, "Panel", ""},
22 {0, nullptr, 0, nullptr, nullptr}};
23
25 {NODE_INTERFACE_SOCKET_INPUT, "INPUT", 0, "Input", "Generate a input node socket"},
26 {NODE_INTERFACE_SOCKET_OUTPUT, "OUTPUT", 0, "Output", "Generate a output node socket"},
27 {0, nullptr, 0, nullptr, nullptr}};
28
29#ifdef RNA_RUNTIME
30
31# include <fmt/format.h>
32
33# include "BKE_attribute.hh"
34# include "BKE_node.hh"
35# include "BKE_node_enum.hh"
36# include "BKE_node_runtime.hh"
39
40# include "BLI_set.hh"
41
42# include "BLT_translation.hh"
43
44# include "DNA_material_types.h"
45# include "ED_node.hh"
46# include "WM_api.hh"
47
48/* Internal RNA function declarations, used to invoke registered callbacks. */
49extern FunctionRNA rna_NodeTreeInterfaceSocket_draw_func;
50extern FunctionRNA rna_NodeTreeInterfaceSocket_init_socket_func;
51extern FunctionRNA rna_NodeTreeInterfaceSocket_from_socket_func;
52
54
55static void rna_NodeTreeInterfaceItem_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
56{
57 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
58 if (!ntree) {
59 /* This can happen because of the dummy socket in #rna_NodeTreeInterfaceSocket_register. */
60 return;
61 }
62 ntree->tree_interface.tag_items_changed();
63 ED_node_tree_propagate_change(nullptr, bmain, ntree);
64}
65
66static StructRNA *rna_NodeTreeInterfaceItem_refine(PointerRNA *ptr)
67{
69
70 switch (item->item_type) {
73 *item);
75 socket.socket_type);
76 if (socket_typeinfo && socket_typeinfo->ext_interface.srna) {
77 return socket_typeinfo->ext_interface.srna;
78 }
79 return &RNA_NodeTreeInterfaceSocket;
80 }
82 return &RNA_NodeTreeInterfacePanel;
83 default:
84 return &RNA_NodeTreeInterfaceItem;
85 }
86}
87
88static std::optional<std::string> rna_NodeTreeInterfaceItem_path(const PointerRNA *ptr)
89{
90 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
91 const bNodeTreeInterfaceItem *item = static_cast<const bNodeTreeInterfaceItem *>(ptr->data);
92 if (!ntree->runtime) {
93 return std::nullopt;
94 }
95
96 ntree->ensure_interface_cache();
97 for (const int index : ntree->interface_items().index_range()) {
98 if (ntree->interface_items()[index] == item) {
99 return fmt::format("interface.items_tree[{}]", index);
100 }
101 }
102 return std::nullopt;
103}
104
105static PointerRNA rna_NodeTreeInterfaceItem_parent_get(PointerRNA *ptr)
106{
107 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
108 const bNodeTreeInterfaceItem *item = static_cast<const bNodeTreeInterfaceItem *>(ptr->data);
109 bNodeTreeInterfacePanel *parent = ntree->tree_interface.find_item_parent(*item, true);
110 PointerRNA result = RNA_pointer_create(&ntree->id, &RNA_NodeTreeInterfacePanel, parent);
111 return result;
112}
113
114static int rna_NodeTreeInterfaceItem_position_get(PointerRNA *ptr)
115{
116 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
117 const bNodeTreeInterfaceItem *item = static_cast<const bNodeTreeInterfaceItem *>(ptr->data);
118 return ntree->tree_interface.find_item_position(*item);
119}
120
121static int rna_NodeTreeInterfaceItem_index_get(PointerRNA *ptr)
122{
123 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
124 const bNodeTreeInterfaceItem *item = static_cast<const bNodeTreeInterfaceItem *>(ptr->data);
125 return ntree->tree_interface.find_item_index(*item);
126}
127
128static bool rna_NodeTreeInterfaceSocket_unregister(Main * /*bmain*/, StructRNA *type)
129{
132 if (!st) {
133 return false;
134 }
135
137
139
140 /* update while blender is running */
142 return true;
143}
144
145static void rna_NodeTreeInterfaceSocket_draw_builtin(ID *id,
146 bNodeTreeInterfaceSocket *interface_socket,
147 bContext *C,
148 uiLayout *layout)
149{
150 blender::bke::bNodeSocketType *typeinfo = interface_socket->socket_typeinfo();
151 if (typeinfo && typeinfo->interface_draw) {
152 typeinfo->interface_draw(id, interface_socket, C, layout);
153 }
154}
155
156static void rna_NodeTreeInterfaceSocket_draw_custom(ID *id,
157 bNodeTreeInterfaceSocket *interface_socket,
158 bContext *C,
159 uiLayout *layout)
160{
162 interface_socket->socket_type);
163 if (typeinfo == nullptr) {
164 return;
165 }
166
167 PointerRNA ptr = RNA_pointer_create(id, &RNA_NodeTreeInterfaceSocket, interface_socket);
168
169 FunctionRNA *func = &rna_NodeTreeInterfaceSocket_draw_func;
170
171 ParameterList list;
172 RNA_parameter_list_create(&list, &ptr, func);
173 RNA_parameter_set_lookup(&list, "context", &C);
174 RNA_parameter_set_lookup(&list, "layout", &layout);
175 typeinfo->ext_interface.call(C, &ptr, func, &list);
176
178}
179
180static void rna_NodeTreeInterfaceSocket_init_socket_builtin(
181 ID *id,
182 bNodeTreeInterfaceSocket *interface_socket,
183 bNode *node,
184 bNodeSocket *socket,
185 const char *data_path)
186{
187 blender::bke::bNodeSocketType *typeinfo = interface_socket->socket_typeinfo();
188 if (typeinfo && typeinfo->interface_draw) {
189 typeinfo->interface_init_socket(id, interface_socket, node, socket, data_path);
190 }
191}
192
193static void rna_NodeTreeInterfaceSocket_init_socket_custom(
194 ID *id,
195 const bNodeTreeInterfaceSocket *interface_socket,
196 bNode *node,
197 bNodeSocket *socket,
198 const char *data_path)
199{
201 interface_socket->socket_type);
202 if (typeinfo == nullptr) {
203 return;
204 }
205
207 id, &RNA_NodeTreeInterfaceSocket, const_cast<bNodeTreeInterfaceSocket *>(interface_socket));
208
209 FunctionRNA *func = &rna_NodeTreeInterfaceSocket_init_socket_func;
210
211 ParameterList list;
212 RNA_parameter_list_create(&list, &ptr, func);
213 RNA_parameter_set_lookup(&list, "node", node);
214 RNA_parameter_set_lookup(&list, "socket", socket);
215 RNA_parameter_set_lookup(&list, "data_path", &data_path);
216 typeinfo->ext_interface.call(nullptr, &ptr, func, &list);
217
219}
220
221static void rna_NodeTreeInterfaceSocket_from_socket_builtin(
222 ID *id, bNodeTreeInterfaceSocket *interface_socket, bNode *node, bNodeSocket *socket)
223{
224 blender::bke::bNodeSocketType *typeinfo = interface_socket->socket_typeinfo();
225 if (typeinfo && typeinfo->interface_draw) {
226 typeinfo->interface_from_socket(id, interface_socket, node, socket);
227 }
228}
229
230static void rna_NodeTreeInterfaceSocket_from_socket_custom(
231 ID *id,
232 bNodeTreeInterfaceSocket *interface_socket,
233 const bNode *node,
234 const bNodeSocket *socket)
235{
237 interface_socket->socket_type);
238 if (typeinfo == nullptr) {
239 return;
240 }
241
242 PointerRNA ptr = RNA_pointer_create(id, &RNA_NodeTreeInterfaceSocket, interface_socket);
243
244 FunctionRNA *func = &rna_NodeTreeInterfaceSocket_from_socket_func;
245
246 ParameterList list;
247 RNA_parameter_list_create(&list, &ptr, func);
248 RNA_parameter_set_lookup(&list, "node", node);
249 RNA_parameter_set_lookup(&list, "socket", socket);
250 typeinfo->ext_interface.call(nullptr, &ptr, func, &list);
251
253}
254
255static StructRNA *rna_NodeTreeInterfaceSocket_register(Main * /*bmain*/,
256 ReportList * /*reports*/,
257 void *data,
258 const char *identifier,
259 StructValidateFunc validate,
262{
263 bNodeTreeInterfaceSocket dummy_socket;
264 memset(&dummy_socket, 0, sizeof(bNodeTreeInterfaceSocket));
265 /* Set #item_type so that refining the type ends up with RNA_NodeTreeInterfaceSocket. */
266 dummy_socket.item.item_type = NODE_INTERFACE_SOCKET;
267
268 PointerRNA dummy_socket_ptr = RNA_pointer_create(
269 nullptr, &RNA_NodeTreeInterfaceSocket, &dummy_socket);
270
271 /* Validate the python class. */
272 bool have_function[3];
273 if (validate(&dummy_socket_ptr, data, have_function) != 0) {
274 return nullptr;
275 }
276
277 /* Check if we have registered this socket type before. */
279 dummy_socket.socket_type);
280 if (st) {
281 /* Socket type registered before. */
282 }
283 else {
284 /* Create a new node socket type. */
285 st = MEM_cnew<blender::bke::bNodeSocketType>(__func__);
286 BLI_strncpy(st->idname, dummy_socket.socket_type, sizeof(st->idname));
287
289 }
290
291 st->free_self = (void (*)(blender::bke::bNodeSocketType *stype))MEM_freeN;
292
293 /* if RNA type is already registered, unregister first */
294 if (st->ext_interface.srna) {
295 StructRNA *srna = st->ext_interface.srna;
298 }
300 &BLENDER_RNA, identifier, &RNA_NodeTreeInterfaceSocket);
301 st->ext_interface.data = data;
302 st->ext_interface.call = call;
303 st->ext_interface.free = free;
305
306 st->interface_draw = (have_function[0]) ? rna_NodeTreeInterfaceSocket_draw_custom : nullptr;
307 st->interface_init_socket = (have_function[1]) ? rna_NodeTreeInterfaceSocket_init_socket_custom :
308 nullptr;
309 st->interface_from_socket = (have_function[2]) ? rna_NodeTreeInterfaceSocket_from_socket_custom :
310 nullptr;
311
312 /* Cleanup local dummy type. */
313 MEM_SAFE_FREE(dummy_socket.socket_type);
314
315 /* Update while blender is running */
317
318 return st->ext_interface.srna;
319}
320
321static IDProperty **rna_NodeTreeInterfaceSocket_idprops(PointerRNA *ptr)
322{
324 return &socket->properties;
325}
326
327static void rna_NodeTreeInterfaceSocket_identifier_get(PointerRNA *ptr, char *value)
328{
330 strcpy(value, socket->identifier);
331}
332
333static int rna_NodeTreeInterfaceSocket_identifier_length(PointerRNA *ptr)
334{
336 return strlen(socket->identifier);
337}
338
339static int rna_NodeTreeInterfaceSocket_socket_type_get(PointerRNA *ptr)
340{
343}
344
345static void rna_NodeTreeInterfaceSocket_socket_type_set(PointerRNA *ptr, int value)
346{
348
349 if (typeinfo) {
351 socket->set_socket_type(typeinfo->idname);
352 }
353}
354
355static bool is_socket_type_supported(blender::bke::bNodeTreeType *ntreetype,
357{
358 /* Check if the node tree supports the socket type. */
359 if (ntreetype->valid_socket_type && !ntreetype->valid_socket_type(ntreetype, socket_type)) {
360 return false;
361 }
362
363 /* Only use basic socket types for this enum. */
364 if (socket_type->subtype != PROP_NONE) {
365 return false;
366 }
367
368 return true;
369}
370
371static blender::bke::bNodeSocketType *find_supported_socket_type(
372 blender::bke::bNodeTreeType *ntree_type)
373{
374 NODE_SOCKET_TYPES_BEGIN (socket_type) {
375 if (is_socket_type_supported(ntree_type, socket_type)) {
376 return socket_type;
377 }
378 }
380 return nullptr;
381}
382
383static bool rna_NodeTreeInterfaceSocket_socket_type_poll(
384 void *userdata, blender::bke::bNodeSocketType *socket_type)
385{
386 blender::bke::bNodeTreeType *ntreetype = static_cast<blender::bke::bNodeTreeType *>(userdata);
387 return is_socket_type_supported(ntreetype, socket_type);
388}
389
390static const EnumPropertyItem *rna_NodeTreeInterfaceSocket_socket_type_itemf(
391 bContext * /*C*/, PointerRNA *ptr, PropertyRNA * /*prop*/, bool *r_free)
392{
393 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
394
395 if (!ntree) {
397 }
398
400 ntree->typeinfo, rna_NodeTreeInterfaceSocket_socket_type_poll, r_free);
401}
402
403static const EnumPropertyItem *rna_NodeTreeInterfaceSocket_default_input_itemf(
404 bContext * /*C*/, PointerRNA *ptr, PropertyRNA * /*prop*/, bool *r_free)
405{
406 const bNodeTree *ntree = reinterpret_cast<const bNodeTree *>(ptr->owner_id);
407 const bNodeTreeInterfaceSocket *socket = static_cast<const bNodeTreeInterfaceSocket *>(
408 ptr->data);
409 if (!ntree) {
411 }
412
413 *r_free = true;
414 EnumPropertyItem *items = nullptr;
415 int items_count = 0;
416
418 "VALUE",
419 0,
420 N_("Default Value"),
421 N_("The node socket's default value")};
422 RNA_enum_item_add(&items, &items_count, &none);
423
424 if (ntree->type == NTREE_GEOMETRY) {
425 const blender::bke::bNodeSocketType *type = socket->socket_typeinfo();
426 if (type->type == SOCK_INT) {
428 "INDEX",
429 0,
430 N_("Index"),
431 N_("The index from the context")};
432 RNA_enum_item_add(&items, &items_count, &index);
433 const EnumPropertyItem index_or_id{
435 "ID_OR_INDEX",
436 0,
437 N_("ID or Index"),
438 N_("The \"id\" attribute if available, otherwise the index")};
439 RNA_enum_item_add(&items, &items_count, &index_or_id);
440 }
441 else if (type->type == SOCK_VECTOR) {
443 "NORMAL",
444 0,
445 N_("Normal"),
446 N_("The geometry's normal direction")};
447 RNA_enum_item_add(&items, &items_count, &normal);
449 "POSITION",
450 0,
451 N_("Position"),
452 N_("The position from the context")};
453 RNA_enum_item_add(&items, &items_count, &position);
454 }
455 else if (type->type == SOCK_MATRIX) {
458 "INSTANCE_TRANSFORM",
459 0,
460 N_("Instance Transform"),
461 N_("Transformation of each instance from the geometry context")};
462 RNA_enum_item_add(&items, &items_count, &instance_transform);
463 }
464 }
465
466 RNA_enum_item_end(&items, &items_count);
467 return items;
468}
469
470static const EnumPropertyItem *rna_NodeTreeInterfaceSocket_attribute_domain_itemf(
471 bContext * /*C*/, PointerRNA * /*ptr*/, PropertyRNA * /*prop*/, bool *r_free)
472{
473 using namespace blender;
474 EnumPropertyItem *item_array = nullptr;
475 int items_len = 0;
476
477 for (const EnumPropertyItem *item = rna_enum_attribute_domain_items; item->identifier != nullptr;
478 item++)
479 {
480 RNA_enum_item_add(&item_array, &items_len, item);
481 }
482 RNA_enum_item_end(&item_array, &items_len);
483
484 *r_free = true;
485 return item_array;
486}
487
488static PointerRNA rna_NodeTreeInterfaceItems_active_get(PointerRNA *ptr)
489{
490 bNodeTreeInterface *interface = static_cast<bNodeTreeInterface *>(ptr->data);
492 ptr->owner_id, &RNA_NodeTreeInterfaceItem, interface->active_item());
493 return r_ptr;
494}
495
496static void rna_NodeTreeInterfaceItems_active_set(PointerRNA *ptr,
497 PointerRNA value,
498 ReportList * /*reports*/)
499{
500 bNodeTreeInterface *interface = static_cast<bNodeTreeInterface *>(ptr->data);
501 bNodeTreeInterfaceItem *item = static_cast<bNodeTreeInterfaceItem *>(value.data);
502 interface->active_item_set(item);
503}
504
505static bNodeTreeInterfaceSocket *rna_NodeTreeInterfaceItems_new_socket(
506 ID *id,
507 bNodeTreeInterface *interface,
508 Main *bmain,
509 ReportList *reports,
510 const char *name,
511 const char *description,
512 int in_out,
513 int socket_type_enum,
515{
516 if (parent != nullptr && !interface->find_item(parent->item)) {
517 BKE_report(reports, RPT_ERROR_INVALID_INPUT, "Parent is not part of the interface");
518 return nullptr;
519 }
520 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
522 if (typeinfo == nullptr) {
523 BKE_report(reports, RPT_ERROR_INVALID_INPUT, "Unknown socket type");
524 return nullptr;
525 }
526
527 /* If data type is unsupported try to find a valid type. */
528 if (!is_socket_type_supported(ntree->typeinfo, typeinfo)) {
529 typeinfo = find_supported_socket_type(ntree->typeinfo);
530 if (typeinfo == nullptr) {
531 BKE_report(reports, RPT_ERROR, "Could not find supported socket type");
532 return nullptr;
533 }
534 }
535 const char *socket_type = typeinfo->idname;
537 bNodeTreeInterfaceSocket *socket = interface->add_socket(
538 name, description, socket_type, flag, parent);
539
540 if (socket == nullptr) {
541 BKE_report(reports, RPT_ERROR, "Unable to create socket");
542 }
543 else {
544 ED_node_tree_propagate_change(nullptr, bmain, ntree);
546 }
547
548 return socket;
549}
550
551static bNodeTreeInterfacePanel *rna_NodeTreeInterfaceItems_new_panel(ID *id,
552 bNodeTreeInterface *interface,
553 Main *bmain,
554 ReportList *reports,
555 const char *name,
556 const char *description,
557 bool default_closed)
558{
561
562 bNodeTreeInterfacePanel *panel = interface->add_panel(
563 name ? name : "", description ? description : "", flag, nullptr);
564
565 if (panel == nullptr) {
566 BKE_report(reports, RPT_ERROR, "Unable to create panel");
567 }
568 else {
569 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
570 ED_node_tree_propagate_change(nullptr, bmain, ntree);
572 }
573
574 return panel;
575}
576
577static bNodeTreeInterfaceItem *rna_NodeTreeInterfaceItems_copy_to_parent(
578 ID *id,
579 bNodeTreeInterface *interface,
580 Main *bmain,
581 ReportList *reports,
584{
585 if (parent != nullptr) {
586 if (!interface->find_item(parent->item)) {
587 BKE_report(reports, RPT_ERROR_INVALID_INPUT, "Parent is not part of the interface");
588 return nullptr;
589 }
590 if (item->item_type == NODE_INTERFACE_PANEL &&
592 {
593 BKE_report(reports, RPT_WARNING, "Parent panel does not allow child panels");
594 return nullptr;
595 }
596 }
597
598 if (parent == nullptr) {
599 parent = &interface->root_panel;
600 }
601 const int index = parent->items().as_span().first_index_try(item);
602 if (!parent->items().index_range().contains(index)) {
603 return nullptr;
604 }
605
606 bNodeTreeInterfaceItem *item_copy = interface->insert_item_copy(*item, parent, index + 1);
607
608 if (item_copy == nullptr) {
609 BKE_report(reports, RPT_ERROR, "Unable to copy item");
610 }
611 else {
612 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
613 ED_node_tree_propagate_change(nullptr, bmain, ntree);
615 }
616
617 return item_copy;
618}
619
620static bNodeTreeInterfaceItem *rna_NodeTreeInterfaceItems_copy(ID *id,
621 bNodeTreeInterface *interface,
622 Main *bmain,
623 ReportList *reports,
625{
626 /* Copy to same parent as the item. */
627 bNodeTreeInterfacePanel *parent = interface->find_item_parent(*item);
628 return rna_NodeTreeInterfaceItems_copy_to_parent(id, interface, bmain, reports, item, parent);
629}
630
631static void rna_NodeTreeInterfaceItems_remove(ID *id,
632 bNodeTreeInterface *interface,
633 Main *bmain,
635 bool move_content_to_parent)
636{
637 interface->remove_item(*item, move_content_to_parent);
638
639 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
640 ED_node_tree_propagate_change(nullptr, bmain, ntree);
642}
643
644static void rna_NodeTreeInterfaceItems_clear(ID *id, bNodeTreeInterface *interface, Main *bmain)
645{
646 interface->clear_items();
647
648 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
649 ED_node_tree_propagate_change(nullptr, bmain, ntree);
651}
652
653static void rna_NodeTreeInterfaceItems_move(ID *id,
654 bNodeTreeInterface *interface,
655 Main *bmain,
657 int to_position)
658{
659 interface->move_item(*item, to_position);
660
661 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
662 ED_node_tree_propagate_change(nullptr, bmain, ntree);
664}
665
666static void rna_NodeTreeInterfaceItems_move_to_parent(ID *id,
667 bNodeTreeInterface *interface,
668 Main *bmain,
669 ReportList *reports,
672 int to_position)
673{
674 if (item->item_type == NODE_INTERFACE_PANEL && parent &&
676 {
677 BKE_report(reports, RPT_WARNING, "Parent panel does not allow child panels");
678 return;
679 }
680
681 interface->move_item_to_parent(*item, parent, to_position);
682
683 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
684 ED_node_tree_propagate_change(nullptr, bmain, ntree);
686}
687
688/* ******** Node Socket Subtypes ******** */
689
690static const EnumPropertyItem *rna_subtype_filter_itemf(const blender::Set<int> &subtypes,
691 bool *r_free)
692{
693 if (subtypes.is_empty()) {
695 }
696
697 EnumPropertyItem *items = nullptr;
698 int items_count = 0;
699 for (const EnumPropertyItem *item = rna_enum_property_subtype_items; item->name != nullptr;
700 item++)
701 {
702 if (subtypes.contains(item->value)) {
703 RNA_enum_item_add(&items, &items_count, item);
704 }
705 }
706
707 if (items_count == 0) {
709 }
710
711 RNA_enum_item_end(&items, &items_count);
712 *r_free = true;
713 return items;
714}
715
716static const EnumPropertyItem *rna_NodeTreeInterfaceSocketFloat_subtype_itemf(
717 bContext * /*C*/, PointerRNA * /*ptr*/, PropertyRNA * /*prop*/, bool *r_free)
718{
719 return rna_subtype_filter_itemf({PROP_PERCENTAGE,
722 PROP_TIME,
728 PROP_NONE},
729 r_free);
730}
731
732void rna_NodeTreeInterfaceSocketFloat_default_value_range(
733 PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax)
734{
736 bNodeSocketValueFloat *dval = static_cast<bNodeSocketValueFloat *>(socket->socket_data);
738 socket->socket_type);
739 int subtype = socket_typeinfo ? socket_typeinfo->subtype : PROP_NONE;
740
741 if (dval->max < dval->min) {
742 dval->max = dval->min;
743 }
744
745 *min = (subtype == PROP_UNSIGNED ? 0.0f : -FLT_MAX);
746 *max = FLT_MAX;
747 *softmin = dval->min;
748 *softmax = dval->max;
749}
750
751static const EnumPropertyItem *rna_NodeTreeInterfaceSocketInt_subtype_itemf(bContext * /*C*/,
752 PointerRNA * /*ptr*/,
753 PropertyRNA * /*prop*/,
754 bool *r_free)
755{
756 return rna_subtype_filter_itemf({PROP_PERCENTAGE, PROP_FACTOR, PROP_NONE}, r_free);
757}
758
759void rna_NodeTreeInterfaceSocketInt_default_value_range(
760 PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
761{
763 bNodeSocketValueInt *dval = static_cast<bNodeSocketValueInt *>(socket->socket_data);
765 socket->socket_type);
766 int subtype = socket_typeinfo ? socket_typeinfo->subtype : PROP_NONE;
767
768 if (dval->max < dval->min) {
769 dval->max = dval->min;
770 }
771
772 *min = (subtype == PROP_UNSIGNED ? 0 : INT_MIN);
773 *max = INT_MAX;
774 *softmin = dval->min;
775 *softmax = dval->max;
776}
777
778static const EnumPropertyItem *rna_NodeTreeInterfaceSocketVector_subtype_itemf(
779 bContext * /*C*/, PointerRNA * /*ptr*/, PropertyRNA * /*prop*/, bool *r_free)
780{
781 return rna_subtype_filter_itemf({PROP_TRANSLATION,
786 PROP_XYZ,
787 PROP_NONE},
788 r_free);
789}
790
791void rna_NodeTreeInterfaceSocketVector_default_value_range(
792 PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax)
793{
795 bNodeSocketValueVector *dval = static_cast<bNodeSocketValueVector *>(socket->socket_data);
796
797 if (dval->max < dval->min) {
798 dval->max = dval->min;
799 }
800
801 *min = -FLT_MAX;
802 *max = FLT_MAX;
803 *softmin = dval->min;
804 *softmax = dval->max;
805}
806
807static const EnumPropertyItem *rna_NodeTreeInterfaceSocketString_subtype_itemf(
808 bContext * /*C*/, PointerRNA * /*ptr*/, PropertyRNA * /*prop*/, bool *r_free)
809{
810 return rna_subtype_filter_itemf({PROP_FILEPATH, PROP_NONE}, r_free);
811}
812
813/* using a context update function here, to avoid searching the node if possible */
814static void rna_NodeTreeInterfaceSocket_value_update(Main *bmain, Scene *scene, PointerRNA *ptr)
815{
816 /* default update */
817 rna_NodeTreeInterfaceItem_update(bmain, scene, ptr);
818}
819
820static bool rna_NodeTreeInterfaceSocketMaterial_default_value_poll(PointerRNA * /*ptr*/,
821 PointerRNA value)
822{
823 /* Do not show grease pencil materials for now. */
824 Material *ma = static_cast<Material *>(value.data);
825 return ma->gp_style == nullptr;
826}
827
828static void rna_NodeTreeInterface_items_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
829{
830 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
831 if (!ntree->runtime) {
832 return;
833 }
834
835 ntree->ensure_interface_cache();
837 const_cast<bNodeTreeInterfaceItem **>(ntree->interface_items().data()),
838 sizeof(bNodeTreeInterfaceItem *),
839 ntree->interface_items().size(),
840 false,
841 nullptr);
842}
843
844static int rna_NodeTreeInterface_items_length(PointerRNA *ptr)
845{
846 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
847 if (!ntree->runtime) {
848 return 0;
849 }
850
851 ntree->ensure_interface_cache();
852 return ntree->interface_items().size();
853}
854
855static bool rna_NodeTreeInterface_items_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr)
856{
857 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
858 if (!ntree->runtime) {
859 return false;
860 }
861
862 ntree->ensure_interface_cache();
863 if (!ntree->interface_items().index_range().contains(index)) {
864 return false;
865 }
866
867 *r_ptr = RNA_pointer_create(
868 ptr->owner_id, &RNA_NodeTreeInterfaceItem, ntree->interface_items()[index]);
869 return true;
870}
871
872static bool rna_NodeTreeInterface_items_lookup_string(PointerRNA *ptr,
873 const char *key,
874 PointerRNA *r_ptr)
875{
876 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
877 if (!ntree->runtime) {
878 return false;
879 }
880
881 ntree->ensure_interface_cache();
882 for (bNodeTreeInterfaceItem *item : ntree->interface_items()) {
883 switch (item->item_type) {
885 bNodeTreeInterfaceSocket *socket = reinterpret_cast<bNodeTreeInterfaceSocket *>(item);
886 if (STREQ(socket->name, key)) {
887 *r_ptr = RNA_pointer_create(ptr->owner_id, &RNA_NodeTreeInterfaceSocket, socket);
888 return true;
889 }
890 break;
891 }
893 bNodeTreeInterfacePanel *panel = reinterpret_cast<bNodeTreeInterfacePanel *>(item);
894 if (STREQ(panel->name, key)) {
895 *r_ptr = RNA_pointer_create(ptr->owner_id, &RNA_NodeTreeInterfacePanel, panel);
896 return true;
897 }
898 break;
899 }
900 }
901 }
902 return false;
903}
904
905const EnumPropertyItem *RNA_node_tree_interface_socket_menu_itemf(bContext * /*C*/,
907 PropertyRNA * /*prop*/,
908 bool *r_free)
909{
910 const bNodeTreeInterfaceSocket *socket = static_cast<bNodeTreeInterfaceSocket *>(ptr->data);
911 if (!socket) {
912 *r_free = false;
914 }
915 const bNodeSocketValueMenu *data = static_cast<bNodeSocketValueMenu *>(socket->socket_data);
916 if (!data->enum_items) {
917 *r_free = false;
919 }
920 return RNA_node_enum_definition_itemf(*data->enum_items, r_free);
921}
922
923#else
924
926{
927 StructRNA *srna;
928 PropertyRNA *prop;
929
930 srna = RNA_def_struct(brna, "NodeTreeInterfaceItem", nullptr);
931 RNA_def_struct_ui_text(srna, "Node Tree Interface Item", "Item in a node tree interface");
932 RNA_def_struct_sdna(srna, "bNodeTreeInterfaceItem");
933 RNA_def_struct_refine_func(srna, "rna_NodeTreeInterfaceItem_refine");
934 RNA_def_struct_path_func(srna, "rna_NodeTreeInterfaceItem_path");
935
936 prop = RNA_def_property(srna, "item_type", PROP_ENUM, PROP_NONE);
937 RNA_def_property_enum_sdna(prop, nullptr, "item_type");
940 RNA_def_property_ui_text(prop, "Item Type", "Type of interface item");
941
942 prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
943 RNA_def_property_struct_type(prop, "NodeTreeInterfacePanel");
945 prop, "rna_NodeTreeInterfaceItem_parent_get", nullptr, nullptr, nullptr);
948 RNA_def_property_ui_text(prop, "Parent", "Panel that contains the item");
949
950 prop = RNA_def_property(srna, "position", PROP_INT, PROP_NONE);
951 RNA_def_property_int_funcs(prop, "rna_NodeTreeInterfaceItem_position_get", nullptr, nullptr);
952 RNA_def_property_range(prop, -1, INT_MAX);
954 RNA_def_property_ui_text(prop, "Position", "Position of the item in its parent panel");
955
956 prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE);
957 RNA_def_property_int_funcs(prop, "rna_NodeTreeInterfaceItem_index_get", nullptr, nullptr);
958 RNA_def_property_range(prop, -1, INT_MAX);
961 prop, "Index", "Global index of the item among all items in the interface");
962}
963
965{
966 StructRNA *srna;
967 PropertyRNA *prop;
968 FunctionRNA *func;
969 PropertyRNA *parm;
970
971 srna = RNA_def_struct(brna, "NodeTreeInterfaceSocket", "NodeTreeInterfaceItem");
972 RNA_def_struct_ui_text(srna, "Node Tree Interface Socket", "Declaration of a node socket");
973 RNA_def_struct_sdna(srna, "bNodeTreeInterfaceSocket");
975 "rna_NodeTreeInterfaceSocket_register",
976 "rna_NodeTreeInterfaceSocket_unregister",
977 nullptr);
978 RNA_def_struct_idprops_func(srna, "rna_NodeTreeInterfaceSocket_idprops");
979
980 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
981 RNA_def_property_ui_text(prop, "Name", "Socket name");
983 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
984
985 prop = RNA_def_property(srna, "identifier", PROP_STRING, PROP_NONE);
987 "rna_NodeTreeInterfaceSocket_identifier_get",
988 "rna_NodeTreeInterfaceSocket_identifier_length",
989 nullptr);
991 RNA_def_property_ui_text(prop, "Identifier", "Unique identifier for mapping sockets");
992
993 prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
994 RNA_def_property_string_sdna(prop, nullptr, "description");
995 RNA_def_property_ui_text(prop, "Description", "Socket description");
996 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
997
998 prop = RNA_def_property(srna, "socket_type", PROP_ENUM, PROP_NONE);
1001 "rna_NodeTreeInterfaceSocket_socket_type_get",
1002 "rna_NodeTreeInterfaceSocket_socket_type_set",
1003 "rna_NodeTreeInterfaceSocket_socket_type_itemf");
1006 prop, "Socket Type", "Type of the socket generated by this interface item");
1007 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1008
1009 prop = RNA_def_property(srna, "in_out", PROP_ENUM, PROP_NONE);
1010 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "flag");
1013 RNA_def_property_ui_text(prop, "Input/Output Type", "Input or output socket type");
1014
1015 prop = RNA_def_property(srna, "hide_value", PROP_BOOLEAN, PROP_NONE);
1019 prop, "Hide Value", "Hide the socket input value even when the socket is not connected");
1020 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1021
1022 prop = RNA_def_property(srna, "hide_in_modifier", PROP_BOOLEAN, PROP_NONE);
1026 "Hide in Modifier",
1027 "Don't show the input value in the geometry nodes modifier interface");
1028 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1029
1030 prop = RNA_def_property(srna, "force_non_field", PROP_BOOLEAN, PROP_NONE);
1034 prop, "Single Value", "Only allow single value inputs rather than fields");
1035 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1036
1037 prop = RNA_def_property(srna, "is_inspect_output", PROP_BOOLEAN, PROP_NONE);
1041 "Is Inspect Output",
1042 "Take link out of node group to connect to root tree output node");
1043 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1044
1045 prop = RNA_def_property(srna, "layer_selection_field", PROP_BOOLEAN, PROP_NONE);
1049 prop, "Layer Selection", "Take Grease Pencil Layer or Layer Group as selection field");
1050 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1051
1052 prop = RNA_def_property(srna, "attribute_domain", PROP_ENUM, PROP_NONE);
1055 prop, nullptr, nullptr, "rna_NodeTreeInterfaceSocket_attribute_domain_itemf");
1057 prop,
1058 "Attribute Domain",
1059 "Attribute domain used by the geometry nodes modifier to create an attribute output");
1060 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1061
1062 prop = RNA_def_property(srna, "default_attribute_name", PROP_STRING, PROP_NONE);
1063 RNA_def_property_string_sdna(prop, nullptr, "default_attribute_name");
1065 "Default Attribute",
1066 "The attribute name used by default when the node group is used by a "
1067 "geometry nodes modifier");
1068 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1069
1070 prop = RNA_def_property(srna, "default_input", PROP_ENUM, PROP_NONE);
1073 prop,
1074 "Default Input",
1075 "Input to use when the socket is unconnected. Requires \"Hide Value\".");
1077 prop, nullptr, nullptr, "rna_NodeTreeInterfaceSocket_default_input_itemf");
1078 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1079
1080 /* Registered properties and functions for custom socket types. */
1081 prop = RNA_def_property(srna, "bl_socket_idname", PROP_STRING, PROP_NONE);
1082 RNA_def_property_string_sdna(prop, nullptr, "socket_type");
1084 RNA_def_property_ui_text(prop, "Socket Type Name", "Name of the socket type");
1085 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1086
1087 func = RNA_def_function(srna, "draw", nullptr);
1089 RNA_def_function_ui_description(func, "Draw properties of the socket interface");
1090 parm = RNA_def_pointer(func, "context", "Context", "", "");
1092 parm = RNA_def_property(func, "layout", PROP_POINTER, PROP_NONE);
1093 RNA_def_property_struct_type(parm, "UILayout");
1094 RNA_def_property_ui_text(parm, "Layout", "Layout in the UI");
1096
1097 func = RNA_def_function(srna, "init_socket", nullptr);
1098 RNA_def_function_ui_description(func, "Initialize a node socket instance");
1100 parm = RNA_def_pointer(func, "node", "Node", "Node", "Node of the socket to initialize");
1102 parm = RNA_def_pointer(func, "socket", "NodeSocket", "Socket", "Socket to initialize");
1104 parm = RNA_def_string(
1105 func, "data_path", nullptr, 0, "Data Path", "Path to specialized socket data");
1107
1108 func = RNA_def_function(srna, "from_socket", nullptr);
1109 RNA_def_function_ui_description(func, "Setup template parameters from an existing socket");
1111 parm = RNA_def_pointer(func, "node", "Node", "Node", "Node of the original socket");
1113 parm = RNA_def_pointer(func, "socket", "NodeSocket", "Socket", "Original socket");
1115}
1116
1118{
1119 StructRNA *srna;
1120 PropertyRNA *prop;
1121
1122 srna = RNA_def_struct(brna, "NodeTreeInterfacePanel", "NodeTreeInterfaceItem");
1123 RNA_def_struct_ui_text(srna, "Node Tree Interface Item", "Declaration of a node panel");
1124 RNA_def_struct_sdna(srna, "bNodeTreeInterfacePanel");
1125
1126 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1127 RNA_def_property_ui_text(prop, "Name", "Panel name");
1128 RNA_def_struct_name_property(srna, prop);
1129 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1130
1131 prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
1132 RNA_def_property_string_sdna(prop, nullptr, "description");
1133 RNA_def_property_ui_text(prop, "Description", "Panel description");
1134 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1135
1136 prop = RNA_def_property(srna, "default_closed", PROP_BOOLEAN, PROP_NONE);
1139 RNA_def_property_ui_text(prop, "Default Closed", "Panel is closed by default on new nodes");
1140 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1141
1142 prop = RNA_def_property(srna, "interface_items", PROP_COLLECTION, PROP_NONE);
1143 RNA_def_property_collection_sdna(prop, nullptr, "items_array", "items_num");
1144 RNA_def_property_struct_type(prop, "NodeTreeInterfaceItem");
1146 RNA_def_property_ui_text(prop, "Items", "Items in the node panel");
1147
1148 prop = RNA_def_property(srna, "persistent_uid", PROP_INT, PROP_NONE);
1149 RNA_def_property_int_sdna(prop, nullptr, "identifier");
1151 prop, "Persistent Identifier", "Unique identifier for this panel within this node tree");
1153}
1154
1156{
1157 PropertyRNA *prop;
1158 PropertyRNA *parm;
1159 FunctionRNA *func;
1160
1161 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
1162 RNA_def_property_int_sdna(prop, nullptr, "active_index");
1163 RNA_def_property_ui_text(prop, "Active Index", "Index of the active item");
1165 RNA_def_property_update(prop, NC_NODE, nullptr);
1166
1167 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1168 RNA_def_property_struct_type(prop, "NodeTreeInterfaceItem");
1171 "rna_NodeTreeInterfaceItems_active_get",
1172 "rna_NodeTreeInterfaceItems_active_set",
1173 nullptr,
1174 nullptr);
1175 RNA_def_property_ui_text(prop, "Active", "Active item");
1176 RNA_def_property_update(prop, NC_NODE, nullptr);
1177
1178 func = RNA_def_function(srna, "new_socket", "rna_NodeTreeInterfaceItems_new_socket");
1179 RNA_def_function_ui_description(func, "Add a new socket to the interface");
1181 parm = RNA_def_string(func, "name", nullptr, 0, "Name", "Name of the socket");
1183 RNA_def_string(func, "description", nullptr, 0, "Description", "Description of the socket");
1184 RNA_def_enum(func,
1185 "in_out",
1188 "Input/Output Type",
1189 "Create an input or output socket");
1190 parm = RNA_def_enum(func,
1191 "socket_type",
1193 0,
1194 "Socket Type",
1195 "Type of socket generated on nodes");
1196 /* NOTE: itemf callback works for the function parameter, it does not require a data pointer. */
1198 parm, nullptr, nullptr, "rna_NodeTreeInterfaceSocket_socket_type_itemf");
1200 func, "parent", "NodeTreeInterfacePanel", "Parent", "Panel to add the socket in");
1201 /* return value */
1202 parm = RNA_def_pointer(func, "item", "NodeTreeInterfaceSocket", "Socket", "New socket");
1203 RNA_def_function_return(func, parm);
1204
1205 func = RNA_def_function(srna, "new_panel", "rna_NodeTreeInterfaceItems_new_panel");
1206 RNA_def_function_ui_description(func, "Add a new panel to the interface");
1208 parm = RNA_def_string(func, "name", nullptr, 0, "Name", "Name of the new panel");
1209 RNA_def_string(func, "description", nullptr, 0, "Description", "Description of the panel");
1211 func, "default_closed", false, "Default Closed", "Panel is closed by default on new nodes");
1213 /* return value */
1214 parm = RNA_def_pointer(func, "item", "NodeTreeInterfacePanel", "Panel", "New panel");
1215 RNA_def_function_return(func, parm);
1216
1217 func = RNA_def_function(srna, "copy", "rna_NodeTreeInterfaceItems_copy");
1218 RNA_def_function_ui_description(func, "Add a copy of an item to the interface");
1220 parm = RNA_def_pointer(func, "item", "NodeTreeInterfaceItem", "Item", "Item to copy");
1222 /* return value */
1223 parm = RNA_def_pointer(
1224 func, "item_copy", "NodeTreeInterfaceItem", "Item Copy", "Copy of the item");
1225 RNA_def_function_return(func, parm);
1226
1227 func = RNA_def_function(srna, "remove", "rna_NodeTreeInterfaceItems_remove");
1228 RNA_def_function_ui_description(func, "Remove an item from the interface");
1230 parm = RNA_def_pointer(func, "item", "NodeTreeInterfaceItem", "Item", "The item to remove");
1233 func,
1234 "move_content_to_parent",
1235 true,
1236 "Move Content",
1237 "If the item is a panel, move the contents to the parent instead of deleting it");
1238
1239 func = RNA_def_function(srna, "clear", "rna_NodeTreeInterfaceItems_clear");
1240 RNA_def_function_ui_description(func, "Remove all items from the interface");
1242
1243 func = RNA_def_function(srna, "move", "rna_NodeTreeInterfaceItems_move");
1244 RNA_def_function_ui_description(func, "Move an item to another position");
1246 parm = RNA_def_pointer(func, "item", "NodeTreeInterfaceItem", "Item", "The item to move");
1248 parm = RNA_def_int(func,
1249 "to_position",
1250 -1,
1251 0,
1252 INT_MAX,
1253 "To Position",
1254 "Target position for the item in its current panel",
1255 0,
1256 10000);
1258
1259 func = RNA_def_function(srna, "move_to_parent", "rna_NodeTreeInterfaceItems_move_to_parent");
1260 RNA_def_function_ui_description(func, "Move an item to a new panel and/or position.");
1262 parm = RNA_def_pointer(func, "item", "NodeTreeInterfaceItem", "Item", "The item to move");
1264 parm = RNA_def_pointer(
1265 func, "parent", "NodeTreeInterfacePanel", "Parent", "New parent of the item");
1267 parm = RNA_def_int(func,
1268 "to_position",
1269 -1,
1270 0,
1271 INT_MAX,
1272 "To Position",
1273 "Target position for the item in the new parent panel",
1274 0,
1275 10000);
1277}
1278
1280{
1281 StructRNA *srna;
1282 PropertyRNA *prop;
1283
1284 srna = RNA_def_struct(brna, "NodeTreeInterface", nullptr);
1286 srna, "Node Tree Interface", "Declaration of sockets and ui panels of a node group");
1287 RNA_def_struct_sdna(srna, "bNodeTreeInterface");
1288
1289 prop = RNA_def_property(srna, "items_tree", PROP_COLLECTION, PROP_NONE);
1291 "rna_NodeTreeInterface_items_begin",
1292 "rna_iterator_array_next",
1293 "rna_iterator_array_end",
1294 "rna_iterator_array_dereference_get",
1295 "rna_NodeTreeInterface_items_length",
1296 "rna_NodeTreeInterface_items_lookup_int",
1297 "rna_NodeTreeInterface_items_lookup_string",
1298 nullptr);
1299 RNA_def_property_struct_type(prop, "NodeTreeInterfaceItem");
1301 RNA_def_property_ui_text(prop, "Items", "Items in the node interface");
1302
1304}
1305
1315
1316#endif
#define NODE_SOCKET_TYPES_BEGIN(stype)
Definition BKE_node.hh:623
#define NODE_SOCKET_TYPES_END
Definition BKE_node.hh:632
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:125
void BLI_kdtree_nd_ free(KDTree *tree)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define SET_FLAG_FROM_TEST(value, test, flag)
#define STREQ(a, b)
@ NODE_INTERFACE_PANEL_ALLOW_CHILD_PANELS
@ NODE_INTERFACE_PANEL_DEFAULT_CLOSED
@ NODE_INTERFACE_SOCKET_HIDE_IN_MODIFIER
@ NODE_INTERFACE_SOCKET_SINGLE_VALUE_ONLY
@ NODE_INTERFACE_SOCKET_INSPECT
@ NODE_INTERFACE_SOCKET_LAYER_SELECTION
@ NODE_INTERFACE_SOCKET_HIDE_VALUE
@ GEO_NODE_DEFAULT_FIELD_INPUT_POSITION_FIELD
@ GEO_NODE_DEFAULT_FIELD_INPUT_NORMAL_FIELD
@ GEO_NODE_DEFAULT_FIELD_INPUT_ID_INDEX_FIELD
@ GEO_NODE_DEFAULT_FIELD_INPUT_INDEX_FIELD
@ GEO_NODE_DEFAULT_FIELD_INPUT_INSTANCE_TRANSFORM_FIELD
@ NTREE_GEOMETRY
@ SOCK_INT
@ SOCK_VECTOR
@ SOCK_MATRIX
@ RPT_ERROR_INVALID_INPUT
void ED_node_tree_propagate_change(const bContext *C, Main *bmain, bNodeTree *ntree)
Definition node_edit.cc:492
#define MEM_SAFE_FREE(v)
const EnumPropertyItem * RNA_node_enum_definition_itemf(const blender::bke::RuntimeNodeEnumItems &enum_items, bool *r_free)
int rna_node_socket_idname_to_enum(const char *idname)
blender::bke::bNodeSocketType * rna_node_socket_type_from_enum(int value)
const EnumPropertyItem * rna_node_socket_type_itemf(void *data, bool(*poll)(void *data, blender::bke::bNodeSocketType *), bool *r_free)
@ PARM_REQUIRED
Definition RNA_types.hh:397
@ FUNC_USE_REPORTS
Definition RNA_types.hh:680
@ FUNC_USE_MAIN
Definition RNA_types.hh:678
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:667
@ FUNC_REGISTER_OPTIONAL
Definition RNA_types.hh:689
@ FUNC_ALLOW_WRITE
Definition RNA_types.hh:695
int(*)(PointerRNA *ptr, void *data, bool *have_function) StructValidateFunc
Definition RNA_types.hh:746
@ PROP_BOOLEAN
Definition RNA_types.hh:65
@ PROP_ENUM
Definition RNA_types.hh:69
@ PROP_INT
Definition RNA_types.hh:66
@ PROP_STRING
Definition RNA_types.hh:68
@ PROP_POINTER
Definition RNA_types.hh:70
@ PROP_COLLECTION
Definition RNA_types.hh:71
void(*)(void *data) StructFreeFunc
Definition RNA_types.hh:751
int(*)(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *list) StructCallbackFunc
Definition RNA_types.hh:747
@ PROPOVERRIDE_NO_COMPARISON
Definition RNA_types.hh:363
PropertyFlag
Definition RNA_types.hh:201
@ PROP_ANIMATABLE
Definition RNA_types.hh:220
@ PROP_EDITABLE
Definition RNA_types.hh:207
@ PROP_NEVER_NULL
Definition RNA_types.hh:266
@ PROP_REGISTER
Definition RNA_types.hh:300
@ PROP_TIME
Definition RNA_types.hh:156
@ PROP_DIRECTION
Definition RNA_types.hh:165
@ PROP_XYZ
Definition RNA_types.hh:172
@ PROP_DISTANCE
Definition RNA_types.hh:159
@ PROP_ACCELERATION
Definition RNA_types.hh:167
@ PROP_ANGLE
Definition RNA_types.hh:155
@ PROP_TIME_ABSOLUTE
Definition RNA_types.hh:157
@ PROP_EULER
Definition RNA_types.hh:169
@ PROP_COLOR_TEMPERATURE
Definition RNA_types.hh:193
@ PROP_NONE
Definition RNA_types.hh:136
@ PROP_PERCENTAGE
Definition RNA_types.hh:153
@ PROP_FREQUENCY
Definition RNA_types.hh:195
@ PROP_FACTOR
Definition RNA_types.hh:154
@ PROP_TRANSLATION
Definition RNA_types.hh:164
@ PROP_UNSIGNED
Definition RNA_types.hh:152
@ PROP_FILEPATH
Definition RNA_types.hh:139
@ PROP_VELOCITY
Definition RNA_types.hh:166
@ PROP_WAVELENGTH
Definition RNA_types.hh:190
#define NC_NODE
Definition WM_types.hh:361
#define NA_EDITED
Definition WM_types.hh:550
bool contains(const Key &key) const
Definition BLI_set.hh:291
bool is_empty() const
Definition BLI_set.hh:572
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
T & get_item_as(bNodeTreeInterfaceItem &item)
bNodeSocketType * node_socket_type_find(const char *idname)
Definition node.cc:1763
void node_register_socket_type(bNodeSocketType *stype)
Definition node.cc:1787
void instance_transform(const bNode &, void *r_value)
void RNA_struct_blender_type_set(StructRNA *srna, void *blender_type)
void * RNA_struct_blender_type_get(StructRNA *srna)
void RNA_parameter_list_free(ParameterList *parms)
void rna_iterator_array_begin(CollectionPropertyIterator *iter, void *ptr, int itemsize, int length, bool free_ptr, IteratorSkipFunc skip)
void RNA_parameter_set_lookup(ParameterList *parms, const char *identifier, const void *value)
ParameterList * RNA_parameter_list_create(ParameterList *parms, PointerRNA *, FunctionRNA *func)
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
const EnumPropertyItem rna_enum_attribute_domain_items[]
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg, const char *instance)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
StructRNA * RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRNA *srnafrom)
void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop, const char *structname, const char *propname)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
void RNA_def_function_flag(FunctionRNA *func, int flag)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *rna_ext)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
void RNA_def_struct_idprops_func(StructRNA *srna, const char *idproperties)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
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 RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
BlenderRNA BLENDER_RNA
void rna_def_node_socket_interface_subtypes(BlenderRNA *brna)
static void rna_def_node_tree_interface_items_api(StructRNA *srna)
static const EnumPropertyItem node_tree_interface_socket_in_out_items[]
const EnumPropertyItem rna_enum_node_tree_interface_item_type_items[]
static void rna_def_node_interface_item(BlenderRNA *brna)
void RNA_def_node_tree_interface(BlenderRNA *brna)
static void rna_def_node_interface_socket(BlenderRNA *brna)
static void rna_def_node_interface_panel(BlenderRNA *brna)
static void rna_def_node_tree_interface(BlenderRNA *brna)
const EnumPropertyItem rna_enum_dummy_NULL_items[]
Definition rna_rna.cc:29
const EnumPropertyItem rna_enum_property_subtype_items[]
Definition rna_rna.cc:127
const EnumPropertyItem rna_enum_dummy_DEFAULT_items[]
Definition rna_rna.cc:35
#define min(a, b)
Definition sort.c:32
#define FLT_MAX
Definition stdcycles.h:14
StructRNA * srna
Definition RNA_types.hh:780
StructCallbackFunc call
Definition RNA_types.hh:781
StructFreeFunc free
Definition RNA_types.hh:782
Definition DNA_ID.h:413
struct MaterialGPencilStyle * gp_style
ID * owner_id
Definition RNA_types.hh:40
void * data
Definition RNA_types.hh:42
bNodeTreeInterfacePanel root_panel
bNodeTreeRuntimeHandle * runtime
bNodeTreeTypeHandle * typeinfo
bNodeTreeInterface tree_interface
Defines a socket type.
Definition BKE_node.hh:151
void(* interface_init_socket)(ID *id, const bNodeTreeInterfaceSocket *interface_socket, bNode *node, bNodeSocket *socket, const char *data_path)
Definition BKE_node.hh:165
void(* free_self)(bNodeSocketType *stype)
Definition BKE_node.hh:188
void(* interface_draw)(ID *id, bNodeTreeInterfaceSocket *socket, bContext *C, uiLayout *layout)
Definition BKE_node.hh:164
void(* interface_from_socket)(ID *id, bNodeTreeInterfaceSocket *interface_socket, const bNode *node, const bNodeSocket *socket)
Definition BKE_node.hh:170
bool(* valid_socket_type)(bNodeTreeType *ntreetype, bNodeSocketType *socket_type)
Definition BKE_node.hh:480
#define N_(msgid)
void WM_main_add_notifier(uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4126
uint8_t flag
Definition wm_window.cc:138