Blender V5.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
8
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 "UI_interface_c.hh"
18
19#include "WM_types.hh"
20
21namespace blender {
22
24 {int(NodeTreeInterfaceItemType::Socket), "SOCKET", 0, "Socket", ""},
25 {int(NodeTreeInterfaceItemType::Panel), "PANEL", 0, "Panel", ""},
26 {0, nullptr, 0, nullptr, nullptr}};
27
29 {NODE_INTERFACE_SOCKET_INPUT, "INPUT", 0, "Input", "Generate a input node socket"},
30 {NODE_INTERFACE_SOCKET_OUTPUT, "OUTPUT", 0, "Output", "Generate a output node socket"},
31 {0, nullptr, 0, nullptr, nullptr}};
32
35 "AUTO",
36 0,
37 "Auto",
38 "Automatically detect a good structure type based on how the socket is used"},
40 "DYNAMIC",
41 0,
42 "Dynamic",
43 "Socket can work with different kinds of structures"},
44 {int(NodeSocketInterfaceStructureType::Field), "FIELD", 0, "Field", "Socket expects a field"},
45 {int(NodeSocketInterfaceStructureType::Grid), "GRID", 0, "Grid", "Socket expects a grid"},
46 {int(NodeSocketInterfaceStructureType::List), "LIST", 0, "List", "Socket expects a list"},
48 "SINGLE",
49 0,
50 "Single",
51 "Socket expects a single value"},
52 {0, nullptr, 0, nullptr, nullptr}};
53
55 {NODE_DEFAULT_INPUT_VALUE, "VALUE", 0, "Default Value", "The node socket's default value"},
56 {NODE_DEFAULT_INPUT_INDEX_FIELD, "INDEX", 0, "Index", "The index from the context"},
58 "ID_OR_INDEX",
59 0,
60 "ID or Index",
61 "The \"id\" attribute if available, otherwise the index"},
62 {NODE_DEFAULT_INPUT_NORMAL_FIELD, "NORMAL", 0, "Normal", "The geometry's normal direction"},
64 "POSITION",
65 0,
66 "Position",
67 "The position from the context"},
69 "INSTANCE_TRANSFORM",
70 0,
71 "Instance Transform",
72 "Transformation of each instance from the geometry context"},
74 "HANDLE_LEFT",
75 0,
76 "Left Handle",
77 "The left Bézier control point handle from the context"},
79 "HANDLE_RIGHT",
80 0,
81 "Right Handle",
82 "The right Bézier control point handle from the context"},
84 "SCENE_FRAME",
85 0,
86 "Scene Frame",
87 "The current frame in the scene"},
89 "UNIFORM_IMAGE_COORDINATES",
90 0,
91 "Uniform Image Coordinates",
92 "The uniform image coordinates of the compositing space"},
94 "SELF_OBJECT",
95 0,
96 "Self Object",
97 "The object that contains the geometry nodes modifier currently being executed"},
98 {0, nullptr, 0, nullptr, nullptr}};
99
100} // namespace blender
101
102#ifdef RNA_RUNTIME
103
104# include <fmt/format.h>
105
106# include "BLI_string_ref.hh"
107
108# include "BKE_attribute.hh"
109# include "BKE_main_invariants.hh"
110# include "BKE_node.hh"
111# include "BKE_node_enum.hh"
112# include "BKE_node_runtime.hh"
114# include "BKE_node_tree_update.hh"
115
116# include "BLI_set.hh"
117
118# include "BLT_translation.hh"
119
120# include "NOD_node_declaration.hh"
121# include "NOD_rna_define.hh"
122# include "NOD_socket.hh"
123
124# include "DNA_material_types.h"
125
126# include "WM_api.hh"
127
128# include "ED_node.hh"
129
130namespace blender {
131
132/* Internal RNA function declarations, used to invoke registered callbacks. */
133extern FunctionRNA *rna_NodeTreeInterfaceSocket_draw_func;
134extern FunctionRNA *rna_NodeTreeInterfaceSocket_init_socket_func;
135extern FunctionRNA *rna_NodeTreeInterfaceSocket_from_socket_func;
136
138
139static void rna_NodeTreeInterfaceItem_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
140{
141 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
142 if (!ntree) {
143 /* This can happen because of the dummy socket in #rna_NodeTreeInterfaceSocket_register. */
144 return;
145 }
146 ntree->tree_interface.tag_item_property_changed();
147 BKE_main_ensure_invariants(*bmain, ntree->id);
148}
149
150static void rna_NodeTreeInterfaceItem_subtype_update(Main *bmain, Scene *scene, PointerRNA *ptr)
151{
152 bNodeTreeInterfaceSocket *socket = static_cast<bNodeTreeInterfaceSocket *>(ptr->data);
153 socket->update_socket_type();
154
155 rna_NodeTreeInterfaceItem_update(bmain, scene, ptr);
156}
157
158static StructRNA *rna_NodeTreeInterfaceItem_refine(PointerRNA *ptr)
159{
160 bNodeTreeInterfaceItem *item = static_cast<bNodeTreeInterfaceItem *>(ptr->data);
161
162 switch (item->item_type) {
165 *item);
166 if (socket.socket_type) {
167 bke::bNodeSocketType *socket_typeinfo = bke::node_socket_type_find(socket.socket_type);
168 if (socket_typeinfo && socket_typeinfo->ext_interface.srna) {
169 return socket_typeinfo->ext_interface.srna;
170 }
171 }
172 return RNA_NodeTreeInterfaceSocket;
173 }
175 return RNA_NodeTreeInterfacePanel;
176 default:
177 return RNA_NodeTreeInterfaceItem;
178 }
179}
180
181static std::optional<std::string> rna_NodeTreeInterfaceItem_path(const PointerRNA *ptr)
182{
183 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
184 const bNodeTreeInterfaceItem *item = static_cast<const bNodeTreeInterfaceItem *>(ptr->data);
185 if (!ntree->runtime) {
186 return std::nullopt;
187 }
188
189 ntree->ensure_interface_cache();
190 for (const int index : ntree->interface_items().index_range()) {
191 if (ntree->interface_items()[index] == item) {
192 return fmt::format("interface.items_tree[{}]", index);
193 }
194 }
195 return std::nullopt;
196}
197
198static PointerRNA rna_NodeTreeInterfaceItem_parent_get(PointerRNA *ptr)
199{
200 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
201 const bNodeTreeInterfaceItem *item = static_cast<const bNodeTreeInterfaceItem *>(ptr->data);
202 bNodeTreeInterfacePanel *parent = ntree->tree_interface.find_item_parent(*item, true);
203 PointerRNA result = RNA_pointer_create_discrete(&ntree->id, RNA_NodeTreeInterfacePanel, parent);
204 return result;
205}
206
207static int rna_NodeTreeInterfaceItem_position_get(PointerRNA *ptr)
208{
209 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
210 const bNodeTreeInterfaceItem *item = static_cast<const bNodeTreeInterfaceItem *>(ptr->data);
211 return ntree->tree_interface.find_item_position(*item);
212}
213
214static int rna_NodeTreeInterfaceItem_index_get(PointerRNA *ptr)
215{
216 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
217 const bNodeTreeInterfaceItem *item = static_cast<const bNodeTreeInterfaceItem *>(ptr->data);
218 return ntree->tree_interface.find_item_index(*item);
219}
220
221static bool rna_NodeTreeInterfaceSocket_unregister(Main *bmain, StructRNA *type)
222{
223 bke::bNodeSocketType *st = static_cast<bke::bNodeSocketType *>(
225 if (!st) {
226 return false;
227 }
229 ui::refresh_for_srna_unregister(bmain, st->ext_interface.srna);
230 ui::refresh_for_srna_unregister(bmain, st->ext_socket.srna);
231
232 RNA_struct_free_extension(type, &st->ext_interface);
233
235
236 /* update while blender is running */
238 return true;
239}
240
241static void rna_NodeTreeInterfaceSocket_draw_builtin(ID *id,
242 bNodeTreeInterfaceSocket *interface_socket,
243 bContext *C,
244 ui::Layout *layout)
245{
246 bke::bNodeSocketType *typeinfo = interface_socket->socket_typeinfo();
247 if (typeinfo && typeinfo->interface_draw) {
248 typeinfo->interface_draw(id, interface_socket, C, layout);
249 }
250}
251
252static void rna_NodeTreeInterfaceSocket_draw_custom(ID *id,
253 bNodeTreeInterfaceSocket *interface_socket,
254 bContext *C,
255 ui::Layout *layout)
256{
257 bke::bNodeSocketType *typeinfo = bke::node_socket_type_find(interface_socket->socket_type);
258 if (typeinfo == nullptr) {
259 return;
260 }
261
262 PointerRNA ptr = RNA_pointer_create_discrete(id, RNA_NodeTreeInterfaceSocket, interface_socket);
263
264 FunctionRNA *func = rna_NodeTreeInterfaceSocket_draw_func;
265
267 RNA_parameter_list_create(&list, &ptr, func);
268 RNA_parameter_set_lookup(&list, "context", &C);
269 RNA_parameter_set_lookup(&list, "layout", &layout);
270 typeinfo->ext_interface.call(C, &ptr, func, &list);
271
273}
274
275static void rna_NodeTreeInterfaceSocket_init_socket_builtin(
276 ID *id,
277 bNodeTreeInterfaceSocket *interface_socket,
278 bNode *node,
279 bNodeSocket *socket,
280 const char *data_path)
281{
282 bke::bNodeSocketType *typeinfo = interface_socket->socket_typeinfo();
283 if (typeinfo && typeinfo->interface_draw) {
284 typeinfo->interface_init_socket(id, interface_socket, node, socket, data_path);
285 }
286}
287
288static void rna_NodeTreeInterfaceSocket_init_socket_custom(
289 ID *id,
290 const bNodeTreeInterfaceSocket *interface_socket,
291 bNode *node,
292 bNodeSocket *socket,
293 const StringRefNull data_path)
294{
295 bke::bNodeSocketType *typeinfo = bke::node_socket_type_find(interface_socket->socket_type);
296 if (typeinfo == nullptr) {
297 return;
298 }
299
301 id, RNA_NodeTreeInterfaceSocket, const_cast<bNodeTreeInterfaceSocket *>(interface_socket));
302
303 FunctionRNA *func = rna_NodeTreeInterfaceSocket_init_socket_func;
304
306 RNA_parameter_list_create(&list, &ptr, func);
308 RNA_parameter_set_lookup(&list, "socket", &socket);
309 RNA_parameter_set_lookup(&list, "data_path", &data_path);
310 typeinfo->ext_interface.call(nullptr, &ptr, func, &list);
311
313}
314
315static void rna_NodeTreeInterfaceSocket_from_socket_builtin(
316 ID *id, bNodeTreeInterfaceSocket *interface_socket, bNode *node, bNodeSocket *socket)
317{
318 bke::bNodeSocketType *typeinfo = interface_socket->socket_typeinfo();
319 if (typeinfo && typeinfo->interface_draw) {
320 typeinfo->interface_from_socket(id, interface_socket, node, socket);
321 }
322}
323
324static void rna_NodeTreeInterfaceSocket_from_socket_custom(
325 ID *id,
326 bNodeTreeInterfaceSocket *interface_socket,
327 const bNode *node,
328 const bNodeSocket *socket)
329{
330 bke::bNodeSocketType *typeinfo = bke::node_socket_type_find(interface_socket->socket_type);
331 if (typeinfo == nullptr) {
332 return;
333 }
334
335 PointerRNA ptr = RNA_pointer_create_discrete(id, RNA_NodeTreeInterfaceSocket, interface_socket);
336
337 FunctionRNA *func = rna_NodeTreeInterfaceSocket_from_socket_func;
338
340 RNA_parameter_list_create(&list, &ptr, func);
342 RNA_parameter_set_lookup(&list, "socket", &socket);
343 typeinfo->ext_interface.call(nullptr, &ptr, func, &list);
344
346}
347
348static StructRNA *rna_NodeTreeInterfaceSocket_register(Main *bmain,
349 ReportList * /*reports*/,
350 void *data,
351 const char *identifier,
352 StructValidateFunc validate,
355{
356 bNodeTreeInterfaceSocket dummy_socket = {};
357 /* Set #item_type so that refining the type ends up with RNA_NodeTreeInterfaceSocket. */
359
360 PointerRNA dummy_socket_ptr = RNA_pointer_create_discrete(
361 nullptr, RNA_NodeTreeInterfaceSocket, &dummy_socket);
362
363 /* Validate the python class. */
364 bool have_function[3];
365 if (validate(&dummy_socket_ptr, data, have_function) != 0) {
366 return nullptr;
367 }
368
369 /* Check if we have registered this socket type before. */
370 bke::bNodeSocketType *st = bke::node_socket_type_find(dummy_socket.socket_type);
371 if (st) {
372 /* Socket type registered before. */
373 }
374 else {
375 /* Create a new node socket type. */
376 st = MEM_new<bke::bNodeSocketType>(__func__);
377 st->idname = UString(dummy_socket.socket_type);
378
380 }
381
382 st->free_self = [](bke::bNodeSocketType *type) { MEM_delete(type); };
383
384 /* if RNA type is already registered, unregister first */
385 if (st->ext_interface.srna) {
386 ui::refresh_for_srna_unregister(bmain, st->ext_interface.srna);
387 StructRNA *srna = st->ext_interface.srna;
388 RNA_struct_free_extension(srna, &st->ext_interface);
390 }
391 st->ext_interface.srna = RNA_def_struct_ptr(
392 &RNA_blender_rna_get(), identifier, RNA_NodeTreeInterfaceSocket);
393 st->ext_interface.data = data;
394 st->ext_interface.call = call;
395 st->ext_interface.free = free;
396 RNA_struct_blender_type_set(st->ext_interface.srna, st);
397
398 st->interface_draw = (have_function[0]) ? rna_NodeTreeInterfaceSocket_draw_custom : nullptr;
399 st->interface_init_socket = (have_function[1]) ? rna_NodeTreeInterfaceSocket_init_socket_custom :
400 nullptr;
401 st->interface_from_socket = (have_function[2]) ? rna_NodeTreeInterfaceSocket_from_socket_custom :
402 nullptr;
403
404 /* Cleanup local dummy type. */
405 MEM_SAFE_DELETE(dummy_socket.socket_type);
406
407 /* Update while blender is running */
409
410 return st->ext_interface.srna;
411}
412
413static IDProperty **rna_NodeTreeInterfaceSocket_idprops(PointerRNA *ptr)
414{
415 bNodeTreeInterfaceSocket *socket = static_cast<bNodeTreeInterfaceSocket *>(ptr->data);
416 return &socket->properties;
417}
418
419static void rna_NodeTreeInterfaceSocket_identifier_get(PointerRNA *ptr, char *value)
420{
421 bNodeTreeInterfaceSocket *socket = static_cast<bNodeTreeInterfaceSocket *>(ptr->data);
422 strcpy(value, socket->identifier);
423}
424
425static int rna_NodeTreeInterfaceSocket_identifier_length(PointerRNA *ptr)
426{
427 bNodeTreeInterfaceSocket *socket = static_cast<bNodeTreeInterfaceSocket *>(ptr->data);
428 return strlen(socket->identifier);
429}
430
431static int rna_NodeTreeInterfaceSocket_socket_type_get(PointerRNA *ptr)
432{
433 bNodeTreeInterfaceSocket *socket = static_cast<bNodeTreeInterfaceSocket *>(ptr->data);
434 return rna_node_socket_idname_to_enum(socket->socket_type);
435}
436
437static void rna_NodeTreeInterfaceSocket_socket_type_set(PointerRNA *ptr, int value)
438{
440
441 if (typeinfo) {
442 bNodeTreeInterfaceSocket *socket = static_cast<bNodeTreeInterfaceSocket *>(ptr->data);
443 socket->set_socket_type(typeinfo->idname.ref());
444 }
445}
446
447static bool is_socket_type_supported(bke::bNodeTreeType *ntreetype,
448 bke::bNodeSocketType *socket_type)
449{
450 /* Check if the node tree supports the socket type. */
451 if (ntreetype->valid_socket_type && !ntreetype->valid_socket_type(ntreetype, socket_type)) {
452 return false;
453 }
454
455 /* Only basic socket types are supported. Custom sockets don't have a base type. */
456 if (socket_type->type != SOCK_CUSTOM) {
457 bke::bNodeSocketType *base_socket_type = bke::node_socket_type_find_static(socket_type->type,
458 PROP_NONE);
459 BLI_assert(base_socket_type != nullptr);
460 if (socket_type != base_socket_type) {
461 return false;
462 }
463 }
464
465 return true;
466}
467
468static bke::bNodeSocketType *find_supported_socket_type(bke::bNodeTreeType *ntree_type)
469{
470 for (bke::bNodeSocketType *socket_type : bke::node_socket_types_get()) {
471 if (is_socket_type_supported(ntree_type, socket_type)) {
472 return socket_type;
473 }
474 }
475 return nullptr;
476}
477
478static bool rna_NodeTreeInterfaceSocket_socket_type_poll(void *userdata,
479 bke::bNodeSocketType *socket_type)
480{
481 bke::bNodeTreeType *ntreetype = static_cast<bke::bNodeTreeType *>(userdata);
482 return is_socket_type_supported(ntreetype, socket_type);
483}
484
485static const EnumPropertyItem *rna_NodeTreeInterfaceSocket_socket_type_itemf(
486 bContext * /*C*/, PointerRNA *ptr, PropertyRNA * /*prop*/, bool *r_free)
487{
488 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
489
490 if (!ntree) {
492 }
493
495 ntree->typeinfo, rna_NodeTreeInterfaceSocket_socket_type_poll, r_free);
496}
497
498static void rna_NodeTreeInterfaceSocket_is_panel_toggle_set(PointerRNA *ptr, bool value)
499{
500 bNodeTree &ntree = *blender::id_cast<bNodeTree *>(ptr->owner_id);
501 bNodeTreeInterfaceSocket &io_socket = *static_cast<bNodeTreeInterfaceSocket *>(ptr->data);
502 const bke::bNodeSocketType *base_typeinfo = bke::node_socket_type_find(io_socket.socket_type);
503 BLI_assert(base_typeinfo);
504 bNodeTreeInterfacePanel *parent = ntree.tree_interface.find_item_parent(io_socket.item);
505
506 /* Skip if called for a root socket. */
507 if (!parent) {
508 return;
509 }
510
511 if (value) {
512 if (base_typeinfo->type != SOCK_BOOLEAN) {
513 return;
514 }
515 if (io_socket.flag & NODE_INTERFACE_SOCKET_PANEL_TOGGLE) {
516 return;
517 }
518
519 io_socket.flag |= NODE_INTERFACE_SOCKET_PANEL_TOGGLE;
520 /* Panel toggle item must always be at the first position. */
521 parent->move_item(io_socket.item, 0);
522 ntree.tree_interface.tag_items_changed();
523 }
524 else {
525 BLI_assert(base_typeinfo->type == SOCK_BOOLEAN);
526 if (!(io_socket.flag & NODE_INTERFACE_SOCKET_PANEL_TOGGLE)) {
527 return;
528 }
529
530 io_socket.flag &= ~NODE_INTERFACE_SOCKET_PANEL_TOGGLE;
531 /* Panel toggles are always the first socket. Unsetting the flag may require reordering of
532 * sockets (inputs after outputs). Reinserting the item makes sure the position is valid. */
533 parent->move_item(io_socket.item, parent->item_position(io_socket.item));
534 ntree.tree_interface.tag_items_changed();
535 }
536}
537
542static void rna_NodeTreeInterfaceSocket_force_non_field_set(PointerRNA *ptr, const bool value)
543{
544 bNodeTreeInterfaceSocket *socket = static_cast<bNodeTreeInterfaceSocket *>(ptr->data);
546 socket->structure_type = value ? NodeSocketInterfaceStructureType::Single :
548}
549
550static void rna_NodeTreeInterfaceSocket_structure_type_set(PointerRNA *ptr, int value)
551{
552 bNodeTreeInterfaceSocket *socket = static_cast<bNodeTreeInterfaceSocket *>(ptr->data);
553 const eNodeSocketDatatype socket_type = socket->socket_typeinfo()->type;
554 const bool supports_fields = nodes::socket_type_supports_fields(socket_type);
555 const bool supports_grids = nodes::socket_type_supports_grids(socket_type);
556
557 bool is_supported = false;
558 switch (NodeSocketInterfaceStructureType(value)) {
562 is_supported = true;
563 break;
565 is_supported = supports_fields;
566 break;
568 is_supported = supports_grids;
569 break;
571 is_supported = supports_fields || supports_grids;
572 break;
573 }
574
575 if (is_supported) {
576 socket->structure_type = NodeSocketInterfaceStructureType(value);
577 }
578}
579
581 const bNodeTree *ntree, const eNodeSocketDatatype socket_type, bool *r_free)
582{
583 if (!ntree) {
585 }
586 const bool is_geometry_nodes = ntree->type == NTREE_GEOMETRY;
587
588 const bool supports_fields = is_geometry_nodes &&
590 const bool supports_grids = is_geometry_nodes && nodes::socket_type_supports_grids(socket_type);
591 const bool supports_lists = is_geometry_nodes;
592
593 *r_free = true;
594 EnumPropertyItem *items = nullptr;
595 int items_count = 0;
596
598 item++)
599 {
600 switch (NodeSocketInterfaceStructureType(item->value)) {
603 RNA_enum_item_add(&items, &items_count, item);
604 break;
605 }
607 if (supports_fields || supports_grids) {
608 RNA_enum_item_add(&items, &items_count, item);
609 }
610 break;
611 }
613 if (supports_fields) {
614 RNA_enum_item_add(&items, &items_count, item);
615 }
616 break;
617 }
619 if (supports_grids) {
620 RNA_enum_item_add(&items, &items_count, item);
621 }
622 break;
623 }
625 if (supports_lists) {
626 RNA_enum_item_add(&items, &items_count, item);
627 }
628 break;
629 }
630 }
631 }
632 RNA_enum_item_end(&items, &items_count);
633 return items;
634}
635
636static const EnumPropertyItem *rna_NodeTreeInterfaceSocket_structure_type_itemf(
637 bContext * /*C*/, PointerRNA *ptr, PropertyRNA * /*prop*/, bool *r_free)
638{
639 const bNodeTree *ntree = reinterpret_cast<const bNodeTree *>(ptr->owner_id);
640 const bNodeTreeInterfaceSocket *socket = static_cast<const bNodeTreeInterfaceSocket *>(
641 ptr->data);
642 const eNodeSocketDatatype socket_type = socket->socket_typeinfo()->type;
643 return rna_NodeSocket_structure_type_item_filter(ntree, socket_type, r_free);
644}
645
646static const EnumPropertyItem *rna_NodeTreeInterfaceSocket_default_input_itemf(
647 bContext * /*C*/, PointerRNA *ptr, PropertyRNA * /*prop*/, bool *r_free)
648{
649 const bNodeTree *ntree = reinterpret_cast<const bNodeTree *>(ptr->owner_id);
650 const bNodeTreeInterfaceSocket *socket = static_cast<const bNodeTreeInterfaceSocket *>(
651 ptr->data);
652 if (!ntree) {
654 }
655 const bke::bNodeSocketType *stype = socket->socket_typeinfo();
656 if (!stype) {
658 }
659
660 *r_free = true;
661 EnumPropertyItem *items = nullptr;
662 int items_count = 0;
663
664 for (const EnumPropertyItem *item = node_default_input_items; item->identifier; item++) {
665 const NodeDefaultInputType type = NodeDefaultInputType(item->value);
667 continue;
668 }
669
671 continue;
672 }
673
674 RNA_enum_item_add(&items, &items_count, item);
675 }
676
677 RNA_enum_item_end(&items, &items_count);
678 return items;
679}
680
681static const EnumPropertyItem *rna_NodeTreeInterfaceSocket_attribute_domain_itemf(
682 bContext * /*C*/, PointerRNA * /*ptr*/, PropertyRNA * /*prop*/, bool *r_free)
683{
684 EnumPropertyItem *item_array = nullptr;
685 int items_len = 0;
686
687 for (const EnumPropertyItem *item = rna_enum_attribute_domain_items; item->identifier != nullptr;
688 item++)
689 {
690 RNA_enum_item_add(&item_array, &items_len, item);
691 }
692 RNA_enum_item_end(&item_array, &items_len);
693
694 *r_free = true;
695 return item_array;
696}
697
698static void rna_NodeTreeInterfaceItems_active_index_set(PointerRNA *ptr, int value)
699{
700 bNodeTreeInterface *interface = static_cast<bNodeTreeInterface *>(ptr->data);
701
702 if (bNodeTreeInterfaceItem *original_active = interface->active_item()) {
703 original_active->set_selected(false);
704 }
705
706 interface->active_index = value;
707 if (bNodeTreeInterfaceItem *new_active = interface->active_item()) {
708 new_active->set_selected(true);
709 }
710}
711
712static PointerRNA rna_NodeTreeInterfaceItems_active_get(PointerRNA *ptr)
713{
714 bNodeTreeInterface *interface = static_cast<bNodeTreeInterface *>(ptr->data);
716 ptr->owner_id, RNA_NodeTreeInterfaceItem, interface->active_item());
717 return ptr_result;
718}
719
720static void rna_NodeTreeInterfaceItems_active_set(PointerRNA *ptr,
721 PointerRNA value,
722 ReportList * /*reports*/)
723{
724 bNodeTreeInterface *interface = static_cast<bNodeTreeInterface *>(ptr->data);
725 bNodeTreeInterfaceItem *item = static_cast<bNodeTreeInterfaceItem *>(value.data);
726 interface->active_item_set(item);
727}
728
729static bNodeTreeInterfaceSocket *rna_NodeTreeInterfaceItems_new_socket(
730 ID *id,
731 bNodeTreeInterface *interface,
732 Main *bmain,
733 ReportList *reports,
734 const char *name,
735 const char *description,
736 int in_out,
737 int socket_type_enum,
739{
740 if (parent != nullptr && !interface->find_item(parent->item)) {
741 BKE_report(reports, RPT_ERROR_INVALID_INPUT, "Parent is not part of the interface");
742 return nullptr;
743 }
744 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
745 bke::bNodeSocketType *typeinfo = rna_node_socket_type_from_enum(socket_type_enum);
746 if (typeinfo == nullptr) {
747 BKE_report(reports, RPT_ERROR_INVALID_INPUT, "Unknown socket type");
748 return nullptr;
749 }
750
751 /* If data type is unsupported try to find a valid type. */
752 if (!is_socket_type_supported(ntree->typeinfo, typeinfo)) {
753 typeinfo = find_supported_socket_type(ntree->typeinfo);
754 if (typeinfo == nullptr) {
755 BKE_report(reports, RPT_ERROR, "Could not find supported socket type");
756 return nullptr;
757 }
758 }
759 const StringRef socket_type = typeinfo->idname.ref();
761 bNodeTreeInterfaceSocket *socket = interface->add_socket(
762 name, description, socket_type, flag, parent);
763
764 if (socket == nullptr) {
765 BKE_report(reports, RPT_ERROR, "Unable to create socket");
766 }
767 else {
768 BKE_main_ensure_invariants(*bmain, ntree->id);
770 }
771
772 return socket;
773}
774
775static bNodeTreeInterfacePanel *rna_NodeTreeInterfaceItems_new_panel(ID *id,
776 bNodeTreeInterface *interface,
777 Main *bmain,
778 ReportList *reports,
779 const char *name,
780 const char *description,
781 bool default_closed)
782{
785
786 bNodeTreeInterfacePanel *panel = interface->add_panel(
787 name ? name : "", description ? description : "", flag, nullptr);
788
789 if (panel == nullptr) {
790 BKE_report(reports, RPT_ERROR, "Unable to create panel");
791 }
792 else {
793 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
794 BKE_main_ensure_invariants(*bmain, ntree->id);
796 }
797
798 return panel;
799}
800
801static bNodeTreeInterfaceItem *rna_NodeTreeInterfaceItems_copy_to_parent(
802 ID *id,
803 bNodeTreeInterface *interface,
804 Main *bmain,
805 ReportList *reports,
808{
809 if (parent != nullptr) {
810 if (!interface->find_item(parent->item)) {
811 BKE_report(reports, RPT_ERROR_INVALID_INPUT, "Parent is not part of the interface");
812 return nullptr;
813 }
814 }
815
816 const bNodeTree &interface_node_tree = *blender::id_cast<bNodeTree *>(id);
818 item))
819 {
820 blender::bke::bNodeTreeType *ntreetype = interface_node_tree.typeinfo;
821 /* Check if the node tree supports the socket type. */
822 if (ntreetype->valid_socket_type &&
823 !ntreetype->valid_socket_type(ntreetype, socket->socket_typeinfo()))
824 {
825 BKE_report(reports,
827 "Item to be copied to this interface is of an unsupported socket type");
828 return nullptr;
829 }
830 }
831
832 if (parent == nullptr) {
833 parent = &interface->root_panel;
834 }
835 const int index = parent->items().as_span().first_index_try(item);
836 bNodeTreeInterfaceItem *item_copy = nullptr;
837 if (index == -1) {
838 item_copy = interface->insert_item_copy(*item, parent, parent->items_num);
839 }
840 else if (parent->items().index_range().contains(index)) {
841 item_copy = interface->insert_item_copy(*item, parent, index + 1);
842 }
843
844 if (item_copy == nullptr) {
845 BKE_report(reports, RPT_ERROR, "Unable to copy item");
846 }
847 else {
848 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
849 BKE_main_ensure_invariants(*bmain, ntree->id);
851 }
852
853 return item_copy;
854}
855
856static bNodeTreeInterfaceItem *rna_NodeTreeInterfaceItems_copy(ID *id,
857 bNodeTreeInterface *interface,
858 Main *bmain,
859 ReportList *reports,
861{
862 if (item == &interface->root_panel.item) {
863 BKE_report(reports, RPT_ERROR_INVALID_INPUT, "Root panel can not be copied.");
864 return nullptr;
865 }
866
867 /* Copy to same parent as the item. */
868 bNodeTreeInterfacePanel *parent = interface->find_item_parent(*item);
869 return rna_NodeTreeInterfaceItems_copy_to_parent(id, interface, bmain, reports, item, parent);
870}
871
872static void rna_NodeTreeInterfaceItems_remove(ID *id,
873 bNodeTreeInterface *interface,
874 Main *bmain,
875 ReportList *reports,
877 bool move_content_to_parent)
878{
879 if (item == &interface->root_panel.item) {
880 BKE_report(reports, RPT_ERROR_INVALID_INPUT, "Root panel can not be removed.");
881 return;
882 }
883
884 interface->remove_item(*item, move_content_to_parent);
885
886 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
887 BKE_main_ensure_invariants(*bmain, ntree->id);
889}
890
891static void rna_NodeTreeInterfaceItems_clear(ID *id, bNodeTreeInterface *interface, Main *bmain)
892{
893 interface->clear_items();
894
895 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
896 BKE_main_ensure_invariants(*bmain, ntree->id);
898}
899
900static void rna_NodeTreeInterfaceItems_move(ID *id,
901 bNodeTreeInterface *interface,
902 Main *bmain,
903 ReportList *reports,
905 int to_position)
906{
907 if (item == &interface->root_panel.item) {
908 BKE_report(reports, RPT_ERROR_INVALID_INPUT, "Root panel can not be moved.");
909 return;
910 }
911
912 interface->move_item(*item, to_position);
913
914 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
915 BKE_main_ensure_invariants(*bmain, ntree->id);
917}
918
919static void rna_NodeTreeInterfaceItems_move_to_parent(ID *id,
920 bNodeTreeInterface *interface,
921 Main *bmain,
922 ReportList *reports,
925 int to_position)
926{
927 if (item == &interface->root_panel.item) {
928 BKE_report(reports, RPT_ERROR_INVALID_INPUT, "Root panel can not be moved.");
929 return;
930 }
931
932 interface->move_item_to_parent(*item, parent, to_position);
933
934 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
935 BKE_main_ensure_invariants(*bmain, ntree->id);
937}
938
939/* ******** Node Socket Subtypes ******** */
940
941static const EnumPropertyItem *rna_subtype_filter_itemf(const Set<int> &subtypes, bool *r_free)
942{
943 if (subtypes.is_empty()) {
945 }
946
947 EnumPropertyItem *items = nullptr;
948 int items_count = 0;
949 for (const EnumPropertyItem *item = rna_enum_property_subtype_items; item->name != nullptr;
950 item++)
951 {
952 if (subtypes.contains(item->value)) {
953 RNA_enum_item_add(&items, &items_count, item);
954 }
955 }
956
957 if (items_count == 0) {
959 }
960
961 RNA_enum_item_end(&items, &items_count);
962 *r_free = true;
963 return items;
964}
965
966static const EnumPropertyItem *rna_NodeTreeInterfaceSocketFloat_subtype_itemf(
967 bContext * /*C*/, PointerRNA * /*ptr*/, PropertyRNA * /*prop*/, bool *r_free)
968{
969 return rna_subtype_filter_itemf({PROP_PERCENTAGE,
971 PROP_MASS,
973 PROP_TIME,
980 PROP_NONE},
981 r_free);
982}
983
984void rna_NodeTreeInterfaceSocketFloat_default_value_range(
985 PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax)
986{
987 bNodeTreeInterfaceSocket *socket = static_cast<bNodeTreeInterfaceSocket *>(ptr->data);
988 bNodeSocketValueFloat *dval = static_cast<bNodeSocketValueFloat *>(socket->socket_data);
989 bke::bNodeSocketType *socket_typeinfo = bke::node_socket_type_find(socket->socket_type);
990 int subtype = socket_typeinfo ? socket_typeinfo->subtype : PROP_NONE;
991
992 if (dval->max < dval->min) {
993 dval->max = dval->min;
994 }
995
996 *min = (subtype == PROP_UNSIGNED ? 0.0f : -FLT_MAX);
997 *max = FLT_MAX;
998 *softmin = dval->min;
999 *softmax = dval->max;
1000}
1001
1002static const EnumPropertyItem *rna_NodeTreeInterfaceSocketInt_subtype_itemf(bContext * /*C*/,
1003 PointerRNA * /*ptr*/,
1004 PropertyRNA * /*prop*/,
1005 bool *r_free)
1006{
1007 return rna_subtype_filter_itemf({PROP_PERCENTAGE, PROP_FACTOR, PROP_PIXEL, PROP_NONE}, r_free);
1008}
1009
1010void rna_NodeTreeInterfaceSocketInt_default_value_range(
1011 PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
1012{
1013 bNodeTreeInterfaceSocket *socket = static_cast<bNodeTreeInterfaceSocket *>(ptr->data);
1014 bNodeSocketValueInt *dval = static_cast<bNodeSocketValueInt *>(socket->socket_data);
1015 bke::bNodeSocketType *socket_typeinfo = bke::node_socket_type_find(socket->socket_type);
1016 int subtype = socket_typeinfo ? socket_typeinfo->subtype : PROP_NONE;
1017
1018 if (dval->max < dval->min) {
1019 dval->max = dval->min;
1020 }
1021
1022 *min = (subtype == PROP_UNSIGNED ? 0 : INT_MIN);
1023 *max = INT_MAX;
1024 *softmin = dval->min;
1025 *softmax = dval->max;
1026}
1027
1028static const EnumPropertyItem *rna_NodeTreeInterfaceSocketVector_subtype_itemf(
1029 bContext * /*C*/, PointerRNA * /*ptr*/, PropertyRNA * /*prop*/, bool *r_free)
1030{
1031 return rna_subtype_filter_itemf({PROP_FACTOR,
1037 PROP_EULER,
1038 PROP_XYZ,
1039 PROP_PIXEL,
1040 PROP_NONE},
1041 r_free);
1042}
1043
1044static const EnumPropertyItem *rna_NodeTreeInterfaceSocketIntVector_subtype_itemf(
1045 bContext * /*C*/, PointerRNA * /*ptr*/, PropertyRNA * /*prop*/, bool *r_free)
1046{
1047 return rna_subtype_filter_itemf(
1049}
1050
1051void rna_NodeTreeInterfaceSocketVector_default_value_range(
1052 PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax)
1053{
1054 bNodeTreeInterfaceSocket *socket = static_cast<bNodeTreeInterfaceSocket *>(ptr->data);
1055 bNodeSocketValueVector *dval = static_cast<bNodeSocketValueVector *>(socket->socket_data);
1056
1057 if (dval->max < dval->min) {
1058 dval->max = dval->min;
1059 }
1060
1061 *min = -FLT_MAX;
1062 *max = FLT_MAX;
1063 *softmin = dval->min;
1064 *softmax = dval->max;
1065}
1066
1067void rna_NodeTreeInterfaceSocketIntVector_default_value_range(
1068 PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
1069{
1070 bNodeTreeInterfaceSocket *socket = static_cast<bNodeTreeInterfaceSocket *>(ptr->data);
1071 bNodeSocketValueIntVector *dval = static_cast<bNodeSocketValueIntVector *>(socket->socket_data);
1072 bke::bNodeSocketType *socket_typeinfo = bke::node_socket_type_find(socket->socket_type);
1073 int subtype = socket_typeinfo ? socket_typeinfo->subtype : PROP_NONE;
1074
1075 if (dval->max < dval->min) {
1076 dval->max = dval->min;
1077 }
1078
1079 *min = (subtype == PROP_UNSIGNED ? 0 : INT_MIN);
1080 *max = INT_MAX;
1081 *softmin = dval->min;
1082 *softmax = dval->max;
1083}
1084
1085static const EnumPropertyItem *rna_NodeTreeInterfaceSocketString_subtype_itemf(
1086 bContext * /*C*/, PointerRNA * /*ptr*/, PropertyRNA * /*prop*/, bool *r_free)
1087{
1088 return rna_subtype_filter_itemf({PROP_FILEPATH, PROP_NONE}, r_free);
1089}
1090
1091static bool rna_NodeTreeInterfaceSocketMaterial_default_value_poll(PointerRNA * /*ptr*/,
1092 PointerRNA value)
1093{
1094 /* Do not show grease pencil materials for now. */
1095 Material *ma = static_cast<Material *>(value.data);
1096 return ma->gp_style == nullptr;
1097}
1098
1099static void rna_NodeTreeInterface_items_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
1100{
1101 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
1102 if (!ntree->runtime) {
1103 return;
1104 }
1105
1106 ntree->ensure_interface_cache();
1108 ptr,
1109 const_cast<bNodeTreeInterfaceItem **>(ntree->interface_items().data()),
1110 sizeof(bNodeTreeInterfaceItem *),
1111 ntree->interface_items().size(),
1112 false,
1113 nullptr);
1114}
1115
1116static int rna_NodeTreeInterface_items_length(PointerRNA *ptr)
1117{
1118 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
1119 if (!ntree->runtime) {
1120 return 0;
1121 }
1122
1123 ntree->ensure_interface_cache();
1124 return ntree->interface_items().size();
1125}
1126
1127static bool rna_NodeTreeInterface_items_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr)
1128{
1129 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
1130 if (!ntree->runtime) {
1131 return false;
1132 }
1133
1134 ntree->ensure_interface_cache();
1135 if (!ntree->interface_items().index_range().contains(index)) {
1136 return false;
1137 }
1138
1140 *ptr, RNA_NodeTreeInterfaceItem, ntree->interface_items()[index], *r_ptr);
1141 return true;
1142}
1143
1144static bool rna_NodeTreeInterface_items_lookup_string(PointerRNA *ptr,
1145 const char *key,
1146 PointerRNA *r_ptr)
1147{
1148 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
1149 if (!ntree->runtime) {
1150 return false;
1151 }
1152
1153 ntree->ensure_interface_cache();
1154 for (bNodeTreeInterfaceItem *item : ntree->interface_items()) {
1155 switch (item->item_type) {
1157 bNodeTreeInterfaceSocket *socket = reinterpret_cast<bNodeTreeInterfaceSocket *>(item);
1158 if (STREQ(socket->identifier, key)) {
1159 rna_pointer_create_with_ancestors(*ptr, RNA_NodeTreeInterfaceSocket, socket, *r_ptr);
1160 return true;
1161 }
1162 break;
1163 }
1164 default:
1165 break;
1166 }
1167 }
1168 for (bNodeTreeInterfaceItem *item : ntree->interface_items()) {
1169 switch (item->item_type) {
1171 bNodeTreeInterfaceSocket *socket = reinterpret_cast<bNodeTreeInterfaceSocket *>(item);
1172 if (STREQ(socket->name_, key)) {
1173 rna_pointer_create_with_ancestors(*ptr, RNA_NodeTreeInterfaceSocket, socket, *r_ptr);
1174 return true;
1175 }
1176 break;
1177 }
1179 bNodeTreeInterfacePanel *panel = reinterpret_cast<bNodeTreeInterfacePanel *>(item);
1180 if (STREQ(panel->name_, key)) {
1181 rna_pointer_create_with_ancestors(*ptr, RNA_NodeTreeInterfacePanel, panel, *r_ptr);
1182 return true;
1183 }
1184 break;
1185 }
1186 }
1187 }
1188 return false;
1189}
1190
1191static PointerRNA rna_NodeTreeInterface_root_panel_get(PointerRNA *ptr)
1192{
1193 bNodeTree *ntree = id_cast<bNodeTree *>(ptr->owner_id);
1194 bNodeTreeInterface *interface = static_cast<bNodeTreeInterface *>(ptr->data);
1196 &ntree->id, RNA_NodeTreeInterfacePanel, &interface->root_panel);
1197 return result;
1198}
1199
1200const EnumPropertyItem *RNA_node_tree_interface_socket_menu_itemf(bContext * /*C*/,
1201 PointerRNA *ptr,
1202 PropertyRNA * /*prop*/,
1203 bool *r_free)
1204{
1205 const bNodeTreeInterfaceSocket *socket = static_cast<bNodeTreeInterfaceSocket *>(ptr->data);
1206 if (!socket) {
1207 *r_free = false;
1209 }
1210 const bNodeSocketValueMenu *data = static_cast<bNodeSocketValueMenu *>(socket->socket_data);
1211 if (!data->enum_items) {
1212 *r_free = false;
1214 }
1215 return RNA_node_enum_definition_itemf(*data->enum_items, r_free);
1216}
1217
1218int RNA_node_tree_interface_socket_menu_default(PointerRNA *ptr, PropertyRNA * /*prop*/)
1219{
1220 const bNodeTreeInterfaceSocket *socket = static_cast<bNodeTreeInterfaceSocket *>(ptr->data);
1221 if (!socket) {
1222 return 0;
1223 }
1224 const bNodeSocketValueMenu *data = static_cast<bNodeSocketValueMenu *>(socket->socket_data);
1225 if (!data->enum_items || data->enum_items->items.is_empty()) {
1226 return 0;
1227 }
1228 return data->enum_items->items.first().identifier;
1229}
1230
1231} // namespace blender
1232
1233#else
1234
1235namespace blender {
1236
1238{
1239 StructRNA *srna;
1240 PropertyRNA *prop;
1241
1242 srna = RNA_def_struct(brna, "NodeTreeInterfaceItem", nullptr);
1243 RNA_def_struct_ui_text(srna, "Node Tree Interface Item", "Item in a node tree interface");
1244 RNA_def_struct_sdna(srna, "bNodeTreeInterfaceItem");
1245 RNA_def_struct_refine_func(srna, "rna_NodeTreeInterfaceItem_refine");
1246 RNA_def_struct_path_func(srna, "rna_NodeTreeInterfaceItem_path");
1247
1248 prop = RNA_def_property(srna, "item_type", PROP_ENUM, PROP_NONE);
1249 RNA_def_property_enum_sdna(prop, nullptr, "item_type");
1252 RNA_def_property_ui_text(prop, "Item Type", "Type of interface item");
1253
1254 prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
1255 RNA_def_property_struct_type(prop, "NodeTreeInterfacePanel");
1257 prop, "rna_NodeTreeInterfaceItem_parent_get", nullptr, nullptr, nullptr);
1260 RNA_def_property_ui_text(prop, "Parent", "Panel that contains the item");
1261
1262 prop = RNA_def_property(srna, "position", PROP_INT, PROP_NONE);
1263 RNA_def_property_int_funcs(prop, "rna_NodeTreeInterfaceItem_position_get", nullptr, nullptr);
1266 RNA_def_property_ui_text(prop, "Position", "Position of the item in its parent panel");
1267
1268 prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE);
1269 RNA_def_property_int_funcs(prop, "rna_NodeTreeInterfaceItem_index_get", nullptr, nullptr);
1273 prop, "Index", "Global index of the item among all items in the interface");
1274}
1275
1277{
1278 StructRNA *srna;
1279 PropertyRNA *prop;
1280 FunctionRNA *func;
1281 PropertyRNA *parm;
1282
1283 srna = RNA_def_struct(brna, "NodeTreeInterfaceSocket", "NodeTreeInterfaceItem");
1284 RNA_def_struct_ui_text(srna, "Node Tree Interface Socket", "Declaration of a node socket");
1285 RNA_def_struct_sdna(srna, "bNodeTreeInterfaceSocket");
1287 "rna_NodeTreeInterfaceSocket_register",
1288 "rna_NodeTreeInterfaceSocket_unregister",
1289 nullptr);
1290 RNA_def_struct_system_idprops_func(srna, "rna_NodeTreeInterfaceSocket_idprops");
1291
1292 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1293 RNA_def_property_string_sdna(prop, nullptr, "name_");
1294 RNA_def_property_ui_text(prop, "Name", "Socket name");
1295 RNA_def_struct_name_property(srna, prop);
1296 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1297
1298 prop = RNA_def_property(srna, "identifier", PROP_STRING, PROP_NONE);
1300 "rna_NodeTreeInterfaceSocket_identifier_get",
1301 "rna_NodeTreeInterfaceSocket_identifier_length",
1302 nullptr);
1304 RNA_def_property_ui_text(prop, "Identifier", "Unique identifier for mapping sockets");
1305
1306 prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
1307 RNA_def_property_string_sdna(prop, nullptr, "description_");
1308 RNA_def_property_ui_text(prop, "Description", "Socket description");
1309 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1310
1311 prop = RNA_def_property(srna, "socket_type", PROP_ENUM, PROP_NONE);
1314 "rna_NodeTreeInterfaceSocket_socket_type_get",
1315 "rna_NodeTreeInterfaceSocket_socket_type_set",
1316 "rna_NodeTreeInterfaceSocket_socket_type_itemf");
1319 prop, "Socket Type", "Type of the socket generated by this interface item");
1320 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1321
1322 prop = RNA_def_property(srna, "in_out", PROP_ENUM, PROP_NONE);
1323 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "flag");
1326 RNA_def_property_ui_text(prop, "Input/Output Type", "Input or output socket type");
1327
1328 prop = RNA_def_property(srna, "hide_value", PROP_BOOLEAN, PROP_NONE);
1332 prop, "Hide Value", "Hide the socket input value even when the socket is not connected");
1333 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1334
1335 prop = RNA_def_property(srna, "hide_in_modifier", PROP_BOOLEAN, PROP_NONE);
1339 "Hide in Modifier",
1340 "Don't show the input value in the geometry nodes modifier interface");
1341 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1342
1343 prop = RNA_def_property(srna, "force_non_field", PROP_BOOLEAN, PROP_NONE);
1345 prop, nullptr, "flag", NODE_INTERFACE_SOCKET_SINGLE_VALUE_ONLY_LEGACY);
1346 RNA_def_property_boolean_funcs(prop, nullptr, "rna_NodeTreeInterfaceSocket_force_non_field_set");
1349 prop,
1350 "Single Value",
1351 "Only allow single value inputs rather than field.\nDeprecated. Will be remove in 5.0.");
1352 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1353
1354 prop = RNA_def_property(srna, "is_inspect_output", PROP_BOOLEAN, PROP_NONE);
1358 "Is Inspect Output",
1359 "Take link out of node group to connect to root tree output node");
1360 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1361
1362 prop = RNA_def_property(srna, "is_panel_toggle", PROP_BOOLEAN, PROP_NONE);
1364 RNA_def_property_boolean_funcs(prop, nullptr, "rna_NodeTreeInterfaceSocket_is_panel_toggle_set");
1367 "Is Panel Toggle",
1368 "This socket is meant to be used as the toggle in its panel header");
1369 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1370
1371 prop = RNA_def_property(srna, "layer_selection_field", PROP_BOOLEAN, PROP_NONE);
1375 prop, "Layer Selection", "Take Grease Pencil Layer or Layer Group as selection field");
1376 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1377
1378 prop = RNA_def_property(srna, "menu_expanded", PROP_BOOLEAN, PROP_NONE);
1382 prop, "Menu Expanded", "Draw the menu socket as an expanded drop-down menu");
1383 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1384
1385 prop = RNA_def_property(srna, "optional_label", PROP_BOOLEAN, PROP_NONE);
1389 prop,
1390 "Optional Label",
1391 "Indicate that the label of this socket is not necessary to understand its meaning. This "
1392 "may result in the label being skipped in some cases");
1393 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1394
1395 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1398 RNA_def_property_ui_text(prop, "Select", "Socket is selected in the interface");
1399 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1400
1401 prop = RNA_def_property(srna, "attribute_domain", PROP_ENUM, PROP_NONE);
1404 prop, nullptr, nullptr, "rna_NodeTreeInterfaceSocket_attribute_domain_itemf");
1406 prop,
1407 "Attribute Domain",
1408 "Attribute domain used by the geometry nodes modifier to create an attribute output");
1409 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1410
1411 prop = RNA_def_property(srna, "default_attribute_name", PROP_STRING, PROP_NONE);
1412 RNA_def_property_string_sdna(prop, nullptr, "default_attribute_name");
1414 "Default Attribute",
1415 "The attribute name used by default when the node group is used by a "
1416 "geometry nodes modifier");
1417 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1418
1419 prop = RNA_def_property(srna, "structure_type", PROP_ENUM, PROP_NONE);
1422 prop,
1423 "Structure Type",
1424 "What kind of higher order types are expected to flow through this socket");
1426 nullptr,
1427 "rna_NodeTreeInterfaceSocket_structure_type_set",
1428 "rna_NodeTreeInterfaceSocket_structure_type_itemf");
1429 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1430
1431 prop = RNA_def_property(srna, "default_input", PROP_ENUM, PROP_NONE);
1434 prop,
1435 "Default Input",
1436 "Input to use when the socket is unconnected. Requires \"Hide Value\".");
1438 prop, nullptr, nullptr, "rna_NodeTreeInterfaceSocket_default_input_itemf");
1439 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1440
1441 /* Registered properties and functions for custom socket types. */
1442 prop = RNA_def_property(srna, "bl_socket_idname", PROP_STRING, PROP_NONE);
1443 RNA_def_property_string_sdna(prop, nullptr, "socket_type");
1445 RNA_def_property_ui_text(prop, "Socket Type Name", "Name of the socket type");
1446 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1447
1448 func = RNA_def_function(srna, "draw", nullptr);
1450 RNA_def_function_ui_description(func, "Draw properties of the socket interface");
1451 parm = RNA_def_pointer(func, "context", "Context", "", "");
1453 parm = RNA_def_property(func, "layout", PROP_POINTER, PROP_NONE);
1454 RNA_def_property_struct_type(parm, "UILayout");
1455 RNA_def_property_ui_text(parm, "Layout", "Layout in the UI");
1457
1458 func = RNA_def_function(srna, "init_socket", nullptr);
1459 RNA_def_function_ui_description(func, "Initialize a node socket instance");
1461 parm = RNA_def_pointer(func, "node", "Node", "Node", "Node of the socket to initialize");
1463 parm = RNA_def_pointer(func, "socket", "NodeSocket", "Socket", "Socket to initialize");
1465 parm = RNA_def_string(
1466 func, "data_path", nullptr, 0, "Data Path", "Path to specialized socket data");
1468
1469 func = RNA_def_function(srna, "from_socket", nullptr);
1470 RNA_def_function_ui_description(func, "Setup template parameters from an existing socket");
1472 parm = RNA_def_pointer(func, "node", "Node", "Node", "Node of the original socket");
1474 parm = RNA_def_pointer(func, "socket", "NodeSocket", "Socket", "Original socket");
1476}
1477
1479{
1480 StructRNA *srna;
1481 PropertyRNA *prop;
1482
1483 srna = RNA_def_struct(brna, "NodeTreeInterfacePanel", "NodeTreeInterfaceItem");
1484 RNA_def_struct_ui_text(srna, "Node Tree Interface Item", "Declaration of a node panel");
1485 RNA_def_struct_sdna(srna, "bNodeTreeInterfacePanel");
1486
1487 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1488 RNA_def_property_string_sdna(prop, nullptr, "name_");
1489 RNA_def_property_ui_text(prop, "Name", "Panel name");
1490 RNA_def_struct_name_property(srna, prop);
1491 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1492
1493 prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
1494 RNA_def_property_string_sdna(prop, nullptr, "description_");
1495 RNA_def_property_ui_text(prop, "Description", "Panel description");
1496 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1497
1498 prop = RNA_def_property(srna, "default_closed", PROP_BOOLEAN, PROP_NONE);
1501 RNA_def_property_ui_text(prop, "Default Closed", "Panel is closed by default on new nodes");
1502 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1503
1504 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1507 RNA_def_property_ui_text(prop, "Select", "Panel is selected in the interface");
1508 RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
1509
1510 prop = RNA_def_property(srna, "interface_items", PROP_COLLECTION, PROP_NONE);
1511 RNA_def_property_collection_sdna(prop, nullptr, "items_array", "items_num");
1512 RNA_def_property_struct_type(prop, "NodeTreeInterfaceItem");
1514 RNA_def_property_ui_text(prop, "Items", "Items in the node panel");
1515
1516 prop = RNA_def_property(srna, "persistent_uid", PROP_INT, PROP_NONE);
1517 RNA_def_property_int_sdna(prop, nullptr, "identifier");
1519 prop, "Persistent Identifier", "Unique identifier for this panel within this node tree");
1521
1522 prop = RNA_def_property(srna, "identifier", PROP_INT, PROP_NONE);
1523 RNA_def_property_int_sdna(prop, nullptr, "identifier");
1525 prop, "Identifier", "Unique identifier for this panel within this node tree");
1527}
1528
1530{
1531 PropertyRNA *prop;
1532 PropertyRNA *parm;
1533 FunctionRNA *func;
1534
1535 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
1536 RNA_def_property_int_sdna(prop, nullptr, "active_index");
1538 prop, nullptr, "rna_NodeTreeInterfaceItems_active_index_set", nullptr);
1539 RNA_def_property_ui_text(prop, "Active Index", "Index of the active item");
1541 RNA_def_property_update(prop, NC_NODE, nullptr);
1542
1543 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1544 RNA_def_property_struct_type(prop, "NodeTreeInterfaceItem");
1547 "rna_NodeTreeInterfaceItems_active_get",
1548 "rna_NodeTreeInterfaceItems_active_set",
1549 nullptr,
1550 nullptr);
1551 RNA_def_property_ui_text(prop, "Active", "Active item");
1552 RNA_def_property_update(prop, NC_NODE, nullptr);
1553
1554 func = RNA_def_function(srna, "new_socket", "rna_NodeTreeInterfaceItems_new_socket");
1555 RNA_def_function_ui_description(func, "Add a new socket to the interface");
1557 parm = RNA_def_string(func, "name", nullptr, 0, "Name", "Name of the socket");
1559 RNA_def_string(func, "description", nullptr, 0, "Description", "Description of the socket");
1560 RNA_def_enum(func,
1561 "in_out",
1564 "Input/Output Type",
1565 "Create an input or output socket");
1566 parm = RNA_def_enum(func,
1567 "socket_type",
1569 0,
1570 "Socket Type",
1571 "Type of socket generated on nodes");
1572 /* NOTE: itemf callback works for the function parameter, it does not require a data pointer. */
1574 parm, nullptr, nullptr, "rna_NodeTreeInterfaceSocket_socket_type_itemf");
1576 func, "parent", "NodeTreeInterfacePanel", "Parent", "Panel to add the socket in");
1577 /* return value */
1578 parm = RNA_def_pointer(func, "item", "NodeTreeInterfaceSocket", "Socket", "New socket");
1580 RNA_def_function_return(func, parm);
1581
1582 func = RNA_def_function(srna, "new_panel", "rna_NodeTreeInterfaceItems_new_panel");
1583 RNA_def_function_ui_description(func, "Add a new panel to the interface");
1585 parm = RNA_def_string(func, "name", nullptr, 0, "Name", "Name of the new panel");
1586 RNA_def_string(func, "description", nullptr, 0, "Description", "Description of the panel");
1588 func, "default_closed", false, "Default Closed", "Panel is closed by default on new nodes");
1590 /* return value */
1591 parm = RNA_def_pointer(func, "item", "NodeTreeInterfacePanel", "Panel", "New panel");
1593 RNA_def_function_return(func, parm);
1594
1595 func = RNA_def_function(srna, "copy", "rna_NodeTreeInterfaceItems_copy");
1596 RNA_def_function_ui_description(func, "Add a copy of an item to the interface");
1598 parm = RNA_def_pointer(func, "item", "NodeTreeInterfaceItem", "Item", "Item to copy");
1600 /* return value */
1601 parm = RNA_def_pointer(
1602 func, "item_copy", "NodeTreeInterfaceItem", "Item Copy", "Copy of the item");
1604 RNA_def_function_return(func, parm);
1605
1606 func = RNA_def_function(srna, "remove", "rna_NodeTreeInterfaceItems_remove");
1607 RNA_def_function_ui_description(func, "Remove an item from the interface");
1609 parm = RNA_def_pointer(func, "item", "NodeTreeInterfaceItem", "Item", "The item to remove");
1612 func,
1613 "move_content_to_parent",
1614 true,
1615 "Move Content",
1616 "If the item is a panel, move the contents to the parent instead of deleting it");
1617
1618 func = RNA_def_function(srna, "clear", "rna_NodeTreeInterfaceItems_clear");
1619 RNA_def_function_ui_description(func, "Remove all items from the interface");
1621
1622 func = RNA_def_function(srna, "move", "rna_NodeTreeInterfaceItems_move");
1623 RNA_def_function_ui_description(func, "Move an item to another position");
1625 parm = RNA_def_pointer(func, "item", "NodeTreeInterfaceItem", "Item", "The item to move");
1627 parm = RNA_def_int(func,
1628 "to_position",
1629 -1,
1630 0,
1631 INT_MAX,
1632 "To Position",
1633 "Target position for the item in its current panel",
1634 0,
1635 10000);
1637
1638 func = RNA_def_function(srna, "move_to_parent", "rna_NodeTreeInterfaceItems_move_to_parent");
1639 RNA_def_function_ui_description(func, "Move an item to a new panel and/or position.");
1641 parm = RNA_def_pointer(func, "item", "NodeTreeInterfaceItem", "Item", "The item to move");
1643 parm = RNA_def_pointer(
1644 func, "parent", "NodeTreeInterfacePanel", "Parent", "New parent of the item");
1646 parm = RNA_def_int(func,
1647 "to_position",
1648 -1,
1649 0,
1650 INT_MAX,
1651 "To Position",
1652 "Target position for the item in the new parent panel",
1653 0,
1654 10000);
1656}
1657
1659{
1660 StructRNA *srna;
1661 PropertyRNA *prop;
1662
1663 srna = RNA_def_struct(brna, "NodeTreeInterface", nullptr);
1665 srna, "Node Tree Interface", "Declaration of sockets and ui panels of a node group");
1666 RNA_def_struct_sdna(srna, "bNodeTreeInterface");
1667
1668 prop = RNA_def_property(srna, "items_tree", PROP_COLLECTION, PROP_NONE);
1670 "rna_NodeTreeInterface_items_begin",
1671 "rna_iterator_array_next",
1672 "rna_iterator_array_end",
1673 "rna_iterator_array_dereference_get",
1674 "rna_NodeTreeInterface_items_length",
1675 "rna_NodeTreeInterface_items_lookup_int",
1676 "rna_NodeTreeInterface_items_lookup_string",
1677 nullptr);
1678 RNA_def_property_struct_type(prop, "NodeTreeInterfaceItem");
1680 RNA_def_property_ui_text(prop, "Items", "Items in the node interface");
1681
1682 prop = RNA_def_property(srna, "root_panel", PROP_POINTER, PROP_NONE);
1683 RNA_def_property_struct_type(prop, "NodeTreeInterfacePanel");
1685 prop, "rna_NodeTreeInterface_root_panel_get", nullptr, nullptr, nullptr);
1688 prop,
1689 "Root Panel",
1690 "Root panel containing all items not directly parented to another panel");
1691
1693}
1694
1704
1705} // namespace blender
1706
1707#endif
#define C
Definition RandGen.cpp:29
#define NC_NODE
Definition WM_types.hh:407
#define NA_EDITED
Definition WM_types.hh:634
#define SET_FLAG_FROM_TEST(value, test, flag)
#define STREQ(a, b)
btScalar max
UString()=default
#define FLT_MAX
#define INT_MAX
T & get_item_as(bNodeTreeInterfaceItem &item)
void free(Subdiv *subdiv)
Definition subdiv.cc:192
Span< bNodeSocketType * > node_socket_types_get()
Definition node.cc:2961
void node_register_socket_type(bNodeSocketType &stype)
Definition node.cc:2998
bNodeSocketType * node_socket_type_find(StringRef idname)
Definition node.cc:2966
bNodeSocketType * node_socket_type_find_static(int type, int subtype=0)
Definition node.cc:2975
bool socket_type_supports_default_input_type(const bke::bNodeSocketType &socket_type, const NodeDefaultInputType input_type)
bool socket_type_supports_fields(const eNodeSocketDatatype socket_type)
bool node_tree_type_supports_default_input_type(eNodeTree_Type node_tree_type, NodeDefaultInputType input_type)
bool socket_type_supports_grids(const eNodeSocketDatatype socket_type)
void refresh_for_srna_unregister(Main *bmain, StructRNA *srna_to_unreg)
BMesh Iterators.
void WM_main_add_notifier(uint type, void *reference)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
const EnumPropertyItem * rna_node_socket_type_itemf(void *data, bool(*poll)(void *data, bke::bNodeSocketType *), bool *r_free)
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
static void rna_def_node_tree_interface_items_api(StructRNA *srna)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
int(*)(PointerRNA *ptr, void *data, bool *have_function) StructValidateFunc
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
@ RPT_ERROR_INVALID_INPUT
Definition BKE_report.hh:42
static const EnumPropertyItem node_default_input_items[]
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_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_struct_system_idprops_func(StructRNA *srna, const char *system_idproperties)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
const EnumPropertyItem rna_enum_property_subtype_items[]
Definition rna_rna.cc:129
@ FUNC_ALLOW_WRITE
@ FUNC_USE_REPORTS
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:980
@ FUNC_USE_MAIN
@ FUNC_REGISTER_OPTIONAL
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_struct_blender_type_get(StructRNA *srna)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void rna_pointer_create_with_ancestors(const PointerRNA &parent, StructRNA *type, void *data, PointerRNA &r_ptr)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
const EnumPropertyItem * rna_NodeSocket_structure_type_item_filter(const bNodeTree *ntree, const eNodeSocketDatatype socket_type, bool *r_free)
void rna_def_node_socket_interface_subtypes(BlenderRNA *brna)
void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop, const char *structname, const char *propname)
@ PROPOVERRIDE_NO_COMPARISON
Definition RNA_types.hh:596
ParameterList * RNA_parameter_list_create(ParameterList *parms, PointerRNA *, FunctionRNA *func)
static void rna_def_node_interface_panel(BlenderRNA *brna)
const EnumPropertyItem * RNA_node_enum_definition_itemf(const bke::RuntimeNodeEnumItems &enum_items, bool *r_free)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
@ PROP_BOOLEAN
Definition RNA_types.hh:210
@ PROP_POINTER
Definition RNA_types.hh:215
@ PROP_STRING
Definition RNA_types.hh:213
@ PROP_COLLECTION
Definition RNA_types.hh:216
static void rna_def_node_interface_socket(BlenderRNA *brna)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
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_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
BMesh const char void * data
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
void BKE_main_ensure_invariants(Main &bmain, std::optional< Span< ID * > > modified_ids=std::nullopt)
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
int rna_node_socket_idname_to_enum(const char *idname)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
const EnumPropertyItem rna_enum_dummy_DEFAULT_items[]
Definition rna_rna.cc:34
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
const EnumPropertyItem rna_enum_node_socket_structure_type_items[]
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier_c_str, const char *call)
const EnumPropertyItem rna_enum_dummy_NULL_items[]
Definition rna_rna.cc:28
void(*)(void *data) StructFreeFunc
void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg, const char *instance)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
static const EnumPropertyItem node_tree_interface_socket_in_out_items[]
void RNA_def_function_flag(FunctionRNA *func, FunctionFlag flag)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
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)
static void rna_def_node_tree_interface(BlenderRNA *brna)
void RNA_struct_blender_type_set(StructRNA *srna, void *blender_type)
void RNA_def_node_tree_interface(BlenderRNA *brna)
bke::bNodeSocketType * rna_node_socket_type_from_enum(int value)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
@ PROP_EDITABLE
Definition RNA_types.hh:376
@ PROP_REGISTER
Definition RNA_types.hh:481
@ PROP_NEVER_NULL
Definition RNA_types.hh:447
@ PROP_ANIMATABLE
Definition RNA_types.hh:389
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_parameter_set_lookup(ParameterList *parms, const char *identifier, const void *value)
static void rna_def_node_interface_item(BlenderRNA *brna)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
const EnumPropertyItem rna_enum_node_tree_interface_item_type_items[]
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
@ PROP_ACCELERATION
Definition RNA_types.hh:321
@ PROP_PERCENTAGE
Definition RNA_types.hh:307
@ PROP_TIME_ABSOLUTE
Definition RNA_types.hh:311
@ PROP_FACTOR
Definition RNA_types.hh:308
@ PROP_TRANSLATION
Definition RNA_types.hh:318
@ PROP_DISTANCE
Definition RNA_types.hh:313
@ PROP_VELOCITY
Definition RNA_types.hh:320
@ PROP_FILEPATH
Definition RNA_types.hh:284
@ PROP_FREQUENCY
Definition RNA_types.hh:349
@ PROP_COLOR_TEMPERATURE
Definition RNA_types.hh:347
@ PROP_WAVELENGTH
Definition RNA_types.hh:344
@ PROP_DIRECTION
Definition RNA_types.hh:319
@ PROP_UNSIGNED
Definition RNA_types.hh:306
@ PARM_REQUIRED
Definition RNA_types.hh:631
void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *rna_ext)
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop, const bool allow_replace)
void rna_iterator_array_begin(CollectionPropertyIterator *iter, PointerRNA *ptr, void *data, size_t itemsize, int64_t length, bool free_ptr, IteratorSkipFunc skip)
int(*)(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *list) StructCallbackFunc
const EnumPropertyItem rna_enum_attribute_domain_items[]
void RNA_parameter_list_free(ParameterList *parms)
BlenderRNA RNA_blender_rna_get()
StructRNA * RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRNA *srnafrom)
#define min(a, b)
Definition sort.cc:38
bNodeTreeInterface tree_interface
Defines a socket type.
Definition BKE_node.hh:163
bool(*) valid_socket_type(bNodeTreeType *ntreetype, bNodeSocketType *socket_type)
Definition BKE_node.hh:569