Blender V5.3
node_add.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2005 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <numeric>
10
12
13#include "MEM_guardedalloc.h"
14
16#include "DNA_node_types.h"
17#include "DNA_sequence_types.h"
18#include "DNA_texture_types.h"
19
20#include "BLI_easing.hh"
21#include "BLI_listbase.hh"
22#include "BLI_math_geom_c.hh"
23#include "BLI_string.hh"
24#include "BLI_string_utf8.hh"
25
26#include "BLT_translation.hh"
27
28#include "BKE_compositor.hh"
29#include "BKE_context.hh"
30#include "BKE_image.hh"
31#include "BKE_lib_id.hh"
32#include "BKE_main.hh"
34#include "BKE_node.hh"
36#include "BKE_node_runtime.hh"
38#include "BKE_report.hh"
39#include "BKE_scene.hh"
40#include "BKE_texture.h"
41
43
44#include "DEG_depsgraph.hh"
46
47#include "ED_asset.hh"
49#include "ED_node.hh" /* own include */
50#include "ED_render.hh"
51#include "ED_screen.hh"
52
53#include "RNA_access.hh"
54#include "RNA_define.hh"
55#include "RNA_enum_types.hh"
56#include "RNA_prototypes.hh"
57
58#include "SEQ_modifier.hh"
59#include "SEQ_relations.hh"
60#include "SEQ_select.hh"
61#include "SEQ_sequencer.hh"
62
63#include "NOD_defaults.hh"
64
65#include "WM_api.hh"
66#include "WM_types.hh"
67
68#include "UI_view2d.hh"
69
70#include "io_utils.hh"
71#include <fmt/format.h>
72
73#include "node_intern.hh" /* own include */
74
76
77/* -------------------------------------------------------------------- */
80
81static void position_node_based_on_mouse(bNode &node, const float2 &location)
82{
83 node.location[0] = location.x - NODE_DY * 1.5f / UI_SCALE_FAC;
84 node.location[1] = location.y + NODE_DY * 0.5f / UI_SCALE_FAC;
85}
86
87bNode *add_node(const bContext &C, const UString idname, const float2 &location)
88{
89 SpaceNode &snode = *CTX_wm_space_node(&C);
90 Main &bmain = *CTX_data_main(&C);
91 bNodeTree &node_tree = *snode.edittree;
92
93 node_deselect_all(node_tree);
94
95 bNode *node = bke::node_add_node(&C, node_tree, idname);
96 BLI_assert(node && node->typeinfo);
97
99
101 ED_node_set_active(&bmain, &snode, &node_tree, node, nullptr);
102
103 BKE_main_ensure_invariants(bmain, node_tree.id);
104 return node;
105}
106
107bNode *add_static_node(const bContext &C, int type, const float2 &location)
108{
109 SpaceNode &snode = *CTX_wm_space_node(&C);
110 Main &bmain = *CTX_data_main(&C);
111 bNodeTree &node_tree = *snode.edittree;
112
113 node_deselect_all(node_tree);
114
115 bNode *node = bke::node_add_static_node(&C, node_tree, type);
116 BLI_assert(node && node->typeinfo);
117
119
121 ED_node_set_active(&bmain, &snode, &node_tree, node, nullptr);
122
123 BKE_main_ensure_invariants(bmain, node_tree.id);
124 return node;
125}
126
131{
132 Main *bmain = CTX_data_main(C);
133 SpaceNode *snode = CTX_wm_space_node(C);
134
135 PointerRNA ptr;
136 PropertyRNA *prop;
137
139
140 if (prop) {
141 /* #RNA_property_pointer_set increases the user count, fixed here as the editor is the initial
142 * user. */
143 id_us_min(&node_tree->id);
144
145 if (ptr.owner_id) {
146 BKE_id_move_to_same_lib(*bmain, node_tree->id, *ptr.owner_id);
147 }
148
149 PointerRNA idptr = RNA_id_pointer_create(&node_tree->id);
150 RNA_property_pointer_set(&ptr, prop, idptr, nullptr);
151 RNA_property_update(C, &ptr, prop);
152 }
153 else if (snode) {
154 snode->nodetree = node_tree;
155
156 tree_update(C);
157 }
158}
159
161
162/* -------------------------------------------------------------------- */
165
166std::optional<float2> link_path_intersection(const bNodeLink &link, const Span<float2> path)
167{
168 std::array<float2, NODE_LINK_RESOL + 1> coords;
170
171 for (const int i : path.index_range().drop_back(1)) {
172 for (const int j : IndexRange(NODE_LINK_RESOL)) {
174 if (isect_seg_seg_v2_point(path[i], path[i + 1], coords[j], coords[j + 1], result) > 0) {
175 return result;
176 }
177 }
178 }
179
180 return std::nullopt;
181}
182
184 /* The output socket's owner node. */
186 /* Intersected links connected to the socket and their path intersection locations. */
188};
189
191{
192 const ARegion &region = *CTX_wm_region(C);
193 SpaceNode &snode = *CTX_wm_space_node(C);
194 bNodeTree &ntree = *snode.edittree;
195
196 Vector<float2> path;
197 RNA_BEGIN (op->ptr, itemptr, "path") {
198 float2 loc_region;
199 RNA_float_get_array(&itemptr, "loc", loc_region);
200 float2 loc_view;
201 ui::view2d_region_to_view(&region.v2d, loc_region.x, loc_region.y, &loc_view.x, &loc_view.y);
202 path.append(loc_view);
203 if (path.size() >= 256) {
204 break;
205 }
206 }
207 RNA_END;
208
209 if (path.is_empty()) {
211 }
212
213 node_deselect_all(ntree);
214
215 ntree.ensure_topology_cache();
216 const Vector<bNode *> frame_nodes = ntree.nodes_by_type("NodeFrame"_ustr);
217
219
220 /* All link "cuts" that start at a particular output socket. Deduplicating new reroutes per
221 * output socket is useful because it allows reusing reroutes for connected intersections.
222 * Further deduplication using the second map means we only have one cut per link. */
224
225 int intersection_count = 0;
226
227 for (bNodeLink &link : ntree.links) {
228
229 if (node_link_is_hidden_or_dimmed(region.v2d, link)) {
230 continue;
231 }
232 const std::optional<float2> cut = link_path_intersection(link, path);
233 if (!cut) {
234 continue;
235 }
236 RerouteCutsForSocket &from_cuts = cuts_per_socket.lookup_or_add_default(link.fromsock);
237 from_cuts.from_node = link.fromnode;
238 from_cuts.links.add(&link, *cut);
239 intersection_count++;
240 }
241
242 for (const auto item : cuts_per_socket.items()) {
243 const Map<bNodeLink *, float2> &cuts = item.value.links;
244
245 bNode *reroute = bke::node_add_static_node(C, ntree, NODE_REROUTE);
246
247 if (intersection_count == 1) {
248 bke::node_set_active(ntree, *reroute);
249 }
250
251 bNodeLink &link_from = bke::node_add_link(
252 ntree, *item.value.from_node, *item.key, *reroute, *reroute->inputs.first());
253
254 /* Mute resulting link if all cut links were muted as well. */
256 link_from,
257 std::all_of(cuts.keys().begin(),
258 cuts.keys().end(),
259 [](const bNodeLink *link) { return link->is_muted(); }));
260
261 /* Reconnect links from the original output socket to the new reroute. */
262 for (bNodeLink *link : cuts.keys()) {
263 link->fromnode = reroute;
264 link->fromsock = reroute->outputs.first();
266 }
267
268 /* Place the new reroute at the average location of all connected cuts. */
269 const float2 insert_point = std::accumulate(
270 cuts.values().begin(), cuts.values().end(), float2(0)) /
271 cuts.size();
272 reroute->location[0] = insert_point.x / UI_SCALE_FAC;
273 reroute->location[1] = insert_point.y / UI_SCALE_FAC;
274
275 /* Attach the reroute node to frame nodes behind it. */
276 for (const int i : frame_nodes.index_range()) {
277 bNode *frame_node = frame_nodes.last(i);
278 if (BLI_rctf_isect_pt_v(&frame_node->runtime->draw_bounds, insert_point)) {
279 bke::node_attach_node(ntree, *reroute, *frame_node);
280 break;
281 }
282 }
283 }
284
286 return OPERATOR_FINISHED;
287}
288
290{
291 ot->name = "Add Reroute";
292 ot->idname = "NODE_OT_add_reroute";
293 ot->description = "Add a reroute node";
294
299
301
302 /* flags */
304
305 /* properties */
306 PropertyRNA *prop;
307 prop = RNA_def_collection_runtime(ot->srna, "path", RNA_OperatorMousePath, "Path", "");
309 /* internal */
310 RNA_def_int(ot->srna, "cursor", WM_CURSOR_CROSS, 0, INT_MAX, "Cursor", "", 0, INT_MAX);
311}
312
314
315/* -------------------------------------------------------------------- */
318
319static bool node_group_add_poll(const bNodeTree &node_tree,
320 const bNodeTree &node_group,
321 ReportList &reports)
322{
323 if (node_group.type != node_tree.type) {
324 return false;
325 }
326
327 const char *disabled_hint = nullptr;
328 if (!bke::node_group_poll(&node_tree, &node_group, &disabled_hint)) {
329 if (disabled_hint) {
330 BKE_reportf(&reports,
331 RPT_ERROR,
332 "Cannot add node group '%s' to '%s':\n %s",
333 node_group.id.name + 2,
334 node_tree.id.name + 2,
335 disabled_hint);
336 }
337 else {
338 BKE_reportf(&reports,
339 RPT_ERROR,
340 "Cannot add node group '%s' to '%s'",
341 node_group.id.name + 2,
342 node_tree.id.name + 2);
343 }
344
345 return false;
346 }
347
348 return true;
349}
350
352{
353 Main *bmain = CTX_data_main(C);
354 SpaceNode *snode = CTX_wm_space_node(C);
355 bNodeTree *ntree = snode->edittree;
356
357 bNodeTree *node_group = reinterpret_cast<bNodeTree *>(
359 if (!node_group) {
360 return OPERATOR_CANCELLED;
361 }
362 if (!node_group_add_poll(*ntree, *node_group, *op->reports)) {
363 return OPERATOR_CANCELLED;
364 }
365
367
368 const UString node_idname = node_group_idname(C);
369 if (node_idname[0] == '\0') {
370 BKE_report(op->reports, RPT_WARNING, "Could not determine type of group node");
371 return OPERATOR_CANCELLED;
372 }
373
374 bNode *group_node = add_node(*C, node_idname, snode->runtime->cursor);
375 if (!group_node) {
376 BKE_report(op->reports, RPT_WARNING, "Could not add node group");
377 return OPERATOR_CANCELLED;
378 }
379 if (!RNA_boolean_get(op->ptr, "show_datablock_in_node")) {
380 /* By default, don't show the data-block selector since it's not usually necessary for assets.
381 */
382 group_node->flag &= ~NODE_OPTIONS;
383 }
384 group_node->width = node_group->default_group_node_width;
385
386 group_node->id = &node_group->id;
387 id_us_plus(group_node->id);
389
390 bke::node_set_active(*ntree, *group_node);
394 return OPERATOR_FINISHED;
395}
396
398{
400 return false;
401 }
402 const SpaceNode *snode = CTX_wm_space_node(C);
403 if (snode->edittree->type == NTREE_CUSTOM) {
405 C, "Adding node groups isn't supported for custom (Python defined) node trees");
406 return false;
407 }
408 return true;
409}
410
412{
414 return false;
415 }
416 const SpaceNode *snode = CTX_wm_space_node(C);
417 if (snode->edittree->type == NTREE_CUSTOM) {
419 C, "Adding node groups isn't supported for custom (Python defined) node trees");
420 return false;
421 }
422 Vector<PointerRNA> selected_nodes;
423 selected_nodes = CTX_data_collection_get(C, "selected_nodes");
424
425 if (selected_nodes.size() <= 0) {
426 CTX_wm_operator_poll_msg_set(C, "No nodes selected.");
427 return false;
428 }
429 return true;
430}
431
433{
434 ARegion *region = CTX_wm_region(C);
435 SpaceNode *snode = CTX_wm_space_node(C);
436
437 /* Convert mouse coordinates to v2d space. */
439 event->mval[0],
440 event->mval[1],
441 &snode->runtime->cursor[0],
442 &snode->runtime->cursor[1]);
443
444 snode->runtime->cursor[0] /= UI_SCALE_FAC;
445 snode->runtime->cursor[1] /= UI_SCALE_FAC;
446
447 return node_add_group_exec(C, op);
448}
449
451{
452 /* identifiers */
453 ot->name = "Add Node Group";
454 ot->description = "Add an existing node group to the current node editor";
455 ot->idname = "NODE_OT_add_group";
456
457 /* callbacks */
461
462 /* flags */
464
466
468 ot->srna, "show_datablock_in_node", true, "Show the data-block selector in the node", "");
470}
471
473
474/* -------------------------------------------------------------------- */
477
478static bool add_node_group_asset(const bContext &C,
480 ReportList &reports)
481{
482 Main &bmain = *CTX_data_main(&C);
483 SpaceNode &snode = *CTX_wm_space_node(&C);
484 bNodeTree &edit_tree = *snode.edittree;
485
486 bNodeTree *node_group = reinterpret_cast<bNodeTree *>(
488 if (!node_group) {
489 return false;
490 }
491 if (!node_group_add_poll(edit_tree, *node_group, reports)) {
492 /* Remove the node group if it was newly appended but can't be added to the tree. */
493 id_us_plus(&node_group->id);
494 BKE_id_free_us(&bmain, node_group);
495 return false;
496 }
497
499
500 bNode *group_node = add_node(
501 C, bke::node_tree_type_find(node_group->idname)->group_idname, snode.runtime->cursor);
502 if (!group_node) {
503 BKE_report(&reports, RPT_WARNING, "Could not add node group");
504 return false;
505 }
506 STRNCPY_UTF8(group_node->name, BKE_id_name(node_group->id));
507 bke::node_unique_name(*snode.edittree, *group_node);
508
509 /* By default, don't show the data-block selector since it's not usually necessary for assets. */
510 group_node->flag &= ~NODE_OPTIONS;
511 group_node->width = node_group->default_group_node_width;
512
513 group_node->id = &node_group->id;
514 id_us_plus(group_node->id);
515 BKE_ntree_update_tag_node_property(&edit_tree, group_node);
516
517 bke::node_set_active(edit_tree, *group_node);
521
522 return true;
523}
524
526 wmOperator *op,
527 const wmEvent *event)
528{
529 ARegion &region = *CTX_wm_region(C);
530 SpaceNode &snode = *CTX_wm_space_node(C);
531
534 if (!asset) {
535 return OPERATOR_CANCELLED;
536 }
537
538 /* Convert mouse coordinates to v2d space. */
540 event->mval[0],
541 event->mval[1],
542 &snode.runtime->cursor[0],
543 &snode.runtime->cursor[1]);
544
545 snode.runtime->cursor /= UI_SCALE_FAC;
546
547 if (!add_node_group_asset(*C, *asset, *op->reports)) {
548 return OPERATOR_CANCELLED;
549 }
550
551 wmOperatorType *ot = WM_operatortype_find("NODE_OT_translate_attach_remove_on_cancel", true);
552 BLI_assert(ot);
556
557 return OPERATOR_FINISHED;
558}
559
561 wmOperator *op,
562 const wmEvent *event)
563{
564 ARegion &region = *CTX_wm_region(C);
565 Main &bmain = *CTX_data_main(C);
566 SpaceNode &snode = *CTX_wm_space_node(C);
567 bNodeTree &ntree = *snode.edittree;
568
571 if (!asset) {
572 return OPERATOR_CANCELLED;
573 }
574 bNodeTree *node_group = reinterpret_cast<bNodeTree *>(
576 if (!node_group) {
577 return OPERATOR_CANCELLED;
578 }
579
580 /* Convert mouse coordinates to v2d space. */
582 event->mval[0],
583 event->mval[1],
584 &snode.runtime->cursor[0],
585 &snode.runtime->cursor[1]);
586
587 snode.runtime->cursor /= UI_SCALE_FAC;
588
589 const UString node_idname = node_group_idname(C);
590 if (node_idname[0] == '\0') {
591 BKE_report(op->reports, RPT_WARNING, "Could not determine type of group node");
592 return OPERATOR_CANCELLED;
593 }
594 wmOperatorType *ot = WM_operatortype_find("NODE_OT_swap_node", true);
595 BLI_assert(ot);
596 PointerRNA itemptr;
598 RNA_string_set(&ptr, "type", node_idname.c_str());
599
600 /* Assign node group via operator.settings. This needs to be done here so that NODE_OT_swap_node
601 * can preserve matching links */
602 /* Assigning it in the for-loop along with the other node group properties causes the links to
603 * not be preserved*/
604 RNA_collection_add(&ptr, "settings", &itemptr);
605 RNA_string_set(&itemptr, "name", "node_tree");
606
607 /* Reference the node group by index.
608 *
609 * NOTE: #RNA_path_full_ID_py would be preferable, however its `(name, library-filepath)` key
610 * fails to resolve packed IDs (essentials assets for e.g.) since archive libraries share their
611 * file-path with the library they were packed from. As the expression is evaluated immediately,
612 * an index is reliable, so use it for now. */
613 const int node_group_index = BLI_findindex(&bmain.nodetrees, node_group);
614 BLI_assert(node_group_index != -1);
615 const std::string setting_value = fmt::format("bpy.data.node_groups[{}]", node_group_index);
616 RNA_string_set(&itemptr, "value", setting_value.c_str());
617
620
621 for (bNode *group_node : get_selected_nodes(ntree)) {
622 STRNCPY_UTF8(group_node->name, BKE_id_name(node_group->id));
623 bke::node_unique_name(*snode.edittree, *group_node);
624
625 /* By default, don't show the data-block selector since it's not usually necessary for assets.
626 */
627 group_node->flag &= ~NODE_OPTIONS;
628 group_node->width = node_group->default_group_node_width;
629
630 id_us_plus(group_node->id);
631 BKE_ntree_update_tag_node_property(&ntree, group_node);
632 }
633
637
638 return OPERATOR_FINISHED;
639}
640
642 wmOperatorType * /*ot*/,
643 PointerRNA *ptr)
644{
647 if (!asset) {
648 return "";
649 }
650 const AssetMetaData &asset_data = asset->get_metadata();
651 if (!asset_data.description) {
652 return "";
653 }
654 return TIP_(asset_data.description);
655}
656
658{
659 ot->name = "Add Node Group Asset";
660 ot->description = "Add a node group asset to the active node tree";
661 ot->idname = "NODE_OT_add_group_asset";
662
666
668
670}
671
673{
674 ot->name = "Swap Node Group Asset";
675 ot->description = "Swap selected nodes with the specified node group asset";
676 ot->idname = "NODE_OT_swap_group_asset";
677
681
683
685}
686
688
689/* -------------------------------------------------------------------- */
692
694{
695 Main *bmain = CTX_data_main(C);
696 SpaceNode *snode = CTX_wm_space_node(C);
697 bNodeTree *ntree = snode->edittree;
698
699 Object *object = reinterpret_cast<Object *>(
701
702 if (!object) {
703 return OPERATOR_CANCELLED;
704 }
705
707
708 bNode *object_node = add_static_node(*C, GEO_NODE_OBJECT_INFO, snode->runtime->cursor);
709 if (!object_node) {
710 BKE_report(op->reports, RPT_WARNING, "Could not add node object");
711 return OPERATOR_CANCELLED;
712 }
713
714 bNodeSocket *sock = bke::node_find_socket(*object_node, SOCK_IN, "Object"_ustr);
715 if (!sock) {
717 return OPERATOR_CANCELLED;
718 }
719
720 bNodeSocketValueObject *socket_data = static_cast<bNodeSocketValueObject *>(sock->default_value);
721 socket_data->value = object;
722 id_us_plus(&object->id);
724
725 bke::node_set_active(*ntree, *object_node);
726 BKE_main_ensure_invariants(*bmain, ntree->id);
728
729 return OPERATOR_FINISHED;
730}
731
733{
734 ARegion *region = CTX_wm_region(C);
735 SpaceNode *snode = CTX_wm_space_node(C);
736
737 /* Convert mouse coordinates to v2d space. */
739 event->mval[0],
740 event->mval[1],
741 &snode->runtime->cursor[0],
742 &snode->runtime->cursor[1]);
743
744 snode->runtime->cursor[0] /= UI_SCALE_FAC;
745 snode->runtime->cursor[1] /= UI_SCALE_FAC;
746
747 return node_add_object_exec(C, op);
748}
749
751{
752 const SpaceNode *snode = CTX_wm_space_node(C);
755}
756
758{
759 /* identifiers */
760 ot->name = "Add Node Object";
761 ot->description = "Add an object info node to the current node editor";
762 ot->idname = "NODE_OT_add_object";
763
764 /* callbacks */
768
769 /* flags */
771
773}
774
776
777/* -------------------------------------------------------------------- */
780
782{
783 Main *bmain = CTX_data_main(C);
784 SpaceNode &snode = *CTX_wm_space_node(C);
785 bNodeTree &ntree = *snode.edittree;
786
787 Collection *collection = reinterpret_cast<Collection *>(
789
790 if (!collection) {
791 return OPERATOR_CANCELLED;
792 }
793
795
796 bNode *collection_node = add_static_node(*C, GEO_NODE_COLLECTION_INFO, snode.runtime->cursor);
797 if (!collection_node) {
798 BKE_report(op->reports, RPT_WARNING, "Could not add node collection");
799 return OPERATOR_CANCELLED;
800 }
801
802 bNodeSocket *sock = bke::node_find_socket(*collection_node, SOCK_IN, "Collection"_ustr);
803 if (!sock) {
804 BKE_report(op->reports, RPT_WARNING, "Could not find node collection socket");
805 return OPERATOR_CANCELLED;
806 }
807
808 bNodeSocketValueCollection *socket_data = static_cast<bNodeSocketValueCollection *>(
809 sock->default_value);
810 socket_data->value = collection;
811 id_us_plus(&collection->id);
813
814 bke::node_set_active(ntree, *collection_node);
815 BKE_main_ensure_invariants(*bmain, ntree.id);
817
818 return OPERATOR_FINISHED;
819}
820
822 wmOperator *op,
823 const wmEvent *event)
824{
825 ARegion *region = CTX_wm_region(C);
826 SpaceNode *snode = CTX_wm_space_node(C);
827
828 /* Convert mouse coordinates to v2d space. */
830 event->mval[0],
831 event->mval[1],
832 &snode->runtime->cursor[0],
833 &snode->runtime->cursor[1]);
834
835 snode->runtime->cursor[0] /= UI_SCALE_FAC;
836 snode->runtime->cursor[1] /= UI_SCALE_FAC;
837
838 return node_add_collection_exec(C, op);
839}
840
842{
843 const SpaceNode *snode = CTX_wm_space_node(C);
845}
846
848{
849 /* identifiers */
850 ot->name = "Add Node Collection";
851 ot->description = "Add a collection info node to the current node editor";
852 ot->idname = "NODE_OT_add_collection";
853
854 /* callbacks */
858
859 /* flags */
861
863}
864
866
867/* -------------------------------------------------------------------- */
870
872{
873 const SpaceNode *snode = CTX_wm_space_node(C);
874 if (!snode || !snode->nodetree) {
875 return false;
876 }
877
878 /* Note: Validity of snode->nodetree is checked later for better error reporting. */
879 return STR_ELEM(snode->tree_idname,
880 "ShaderNodeTree",
881 "CompositorNodeTree",
882 "TextureNodeTree",
883 "GeometryNodeTree");
884}
885
891
893{
895
896 if (event->type != TIMER || data == nullptr || data->anim_timer != event->customdata) {
898 }
899
900 const float node_stack_anim_duration = 0.25f;
901 const float duration = float(data->anim_timer->time_duration);
902 const float prev_duration = duration - float(data->anim_timer->time_delta);
903 const float clamped_duration = math::min(duration, node_stack_anim_duration);
904 const float delta_factor =
905 BLI_easing_cubic_ease_in_out(clamped_duration, 0.0f, 1.0f, node_stack_anim_duration) -
906 BLI_easing_cubic_ease_in_out(prev_duration, 0.0f, 1.0f, node_stack_anim_duration);
907
908 bool redraw = false;
909 /* Each node is pushed by all previous nodes in the stack. */
910 float stack_offset = 0.0f;
911
912 for (bNode *node : data->nodes) {
913 node->location[1] -= stack_offset;
914 stack_offset += (node->runtime->draw_bounds.ymax - node->runtime->draw_bounds.ymin) *
915 delta_factor / UI_SCALE_FAC;
916 redraw = true;
917 }
918
919 if (redraw) {
921 }
922
923 /* End stack animation. */
924 if (duration > node_stack_anim_duration) {
925 WM_event_timer_remove(CTX_wm_manager(C), nullptr, data->anim_timer);
926 MEM_delete(data);
927 op->customdata = nullptr;
929 }
930
932}
933
935{
936 Main *bmain = CTX_data_main(C);
937 SpaceNode &snode = *CTX_wm_space_node(C);
938 int type = 0;
939 switch (snode.nodetree->type) {
940 case NTREE_SHADER:
941 if (snode.shaderfrom == SNODE_SHADER_WORLD) {
943 }
944 else {
945 type = SH_NODE_TEX_IMAGE;
946 }
947 break;
948 case NTREE_TEXTURE:
949 type = TEX_NODE_IMAGE;
950 break;
951 case NTREE_COMPOSIT:
952 type = CMP_NODE_IMAGE;
953 break;
954 case NTREE_GEOMETRY:
956 break;
957 default:
958 return OPERATOR_CANCELLED;
959 }
960 Vector<Image *> images;
961 /* Load all paths as ID Images. */
963 for (const std::string &path : paths) {
964 RNA_string_set(op->ptr, "filepath", path.c_str());
965 Image *image = id_cast<Image *>(WM_operator_drop_load_path(C, op, ID_IM));
966 if (!image) {
967 BKE_report(op->reports, RPT_WARNING, fmt::format("Could not load {}", path).c_str());
968 continue;
969 }
970 images.append(image);
971 /* When adding new image file via drag-drop we need to load #ImBuf in order
972 * to get proper image source. */
973 BKE_image_signal(bmain, image, nullptr, IMA_SIGNAL_RELOAD);
975 }
976
977 /* If not path is provided, try to get a ID Image from operator. */
978 if (paths.is_empty()) {
979 Image *image = id_cast<Image *>(WM_operator_drop_load_path(C, op, ID_IM));
980 if (image) {
981 images.append(image);
982 }
983 }
984
985 bNodeTree &node_tree = *snode.edittree;
986 float2 position = snode.runtime->cursor;
988 /* Add a node for each image. */
989 for (Image *image : images) {
990 bNode *node = add_static_node(*C, type, position);
991 if (!node) {
992 BKE_report(op->reports, RPT_WARNING, "Could not add an image node");
993 continue;
994 }
995 if (type == GEO_NODE_IMAGE_TEXTURE) {
996 bNodeSocket *image_socket = node->inputs.first();
997 bNodeSocketValueImage *socket_value = static_cast<bNodeSocketValueImage *>(
998 image_socket->default_value);
999 socket_value->value = image;
1000 BKE_ntree_update_tag_socket_property(&node_tree, image_socket);
1001 }
1002 else {
1003 node->id = id_cast<ID *>(image);
1005 }
1007 nodes.append(node);
1008 /* Initial offset between nodes. */
1009 position[1] -= 20.0f;
1010 }
1011
1012 if (nodes.is_empty()) {
1013 return OPERATOR_CANCELLED;
1014 }
1015
1016 /* Set new nodes as selected. */
1017 node_deselect_all(node_tree);
1018 for (bNode *node : nodes) {
1020 }
1021 ED_node_set_active(bmain, &snode, &node_tree, nodes[0], nullptr);
1022
1024
1025 BKE_main_ensure_invariants(*bmain, snode.edittree->id);
1027
1028 if (nodes.size() == 1) {
1029 return OPERATOR_FINISHED;
1030 }
1031
1032 /* Start the stack animation, so each node is placed on top of each other. */
1033 NodeStackAnimationData *data = MEM_new<NodeStackAnimationData>(__func__);
1034 data->nodes = std::move(nodes);
1035 data->anim_timer = WM_event_timer_add(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.02);
1036 op->customdata = data;
1038
1040}
1041
1043{
1044 ARegion *region = CTX_wm_region(C);
1045 SpaceNode *snode = CTX_wm_space_node(C);
1046
1048 BKE_report(op->reports,
1049 RPT_ERROR,
1050 "Could not add image. A node tree has not been created or assigned");
1051 return OPERATOR_CANCELLED;
1052 }
1053
1054 /* Convert mouse coordinates to `v2d` space. */
1056 event->mval[0],
1057 event->mval[1],
1058 &snode->runtime->cursor[0],
1059 &snode->runtime->cursor[1]);
1060
1061 snode->runtime->cursor[0] /= UI_SCALE_FAC;
1062 snode->runtime->cursor[1] /= UI_SCALE_FAC;
1063
1065 RNA_struct_property_is_set(op->ptr, "filepath"))
1066 {
1067 return node_add_image_exec(C, op);
1068 }
1069 return WM_operator_filesel(C, op, event);
1070}
1071
1073{
1074 /* identifiers */
1075 ot->name = "Add Image as Node";
1076 ot->description = "Add a image/movie file as node to the current node editor";
1077 ot->idname = "NODE_OT_add_image";
1078
1079 /* callbacks */
1084
1085 /* flags */
1087
1097}
1098
1100
1101/* -------------------------------------------------------------------- */
1104
1106{
1107 SpaceNode *snode = CTX_wm_space_node(C);
1108
1110}
1111
1113{
1114 Main *bmain = CTX_data_main(C);
1115 SpaceNode &snode = *CTX_wm_space_node(C);
1116
1118 if (!mask) {
1119 return OPERATOR_CANCELLED;
1120 }
1121
1123
1125
1126 if (!node) {
1127 BKE_report(op->reports, RPT_WARNING, "Could not add a mask node");
1128 return OPERATOR_CANCELLED;
1129 }
1130
1131 node->id = mask;
1133
1134 BKE_main_ensure_invariants(*bmain, snode.edittree->id);
1136
1137 return OPERATOR_FINISHED;
1138}
1139
1141{
1142 /* identifiers */
1143 ot->name = "Add Mask Node";
1144 ot->description = "Add a mask node to the current node editor";
1145 ot->idname = "NODE_OT_add_mask";
1146
1147 /* callbacks */
1150
1151 /* flags */
1153
1155}
1156
1158
1159/* -------------------------------------------------------------------- */
1162
1164{
1165 Main *bmain = CTX_data_main(C);
1166 SpaceNode *snode = CTX_wm_space_node(C);
1167 bNodeTree *ntree = snode->edittree;
1168
1169 Material *material = reinterpret_cast<Material *>(
1171
1172 if (!material) {
1173 return OPERATOR_CANCELLED;
1174 }
1175
1177
1178 bNode *material_node = add_static_node(*C, GEO_NODE_INPUT_MATERIAL, snode->runtime->cursor);
1179 if (!material_node) {
1180 BKE_report(op->reports, RPT_WARNING, "Could not add material");
1181 return OPERATOR_CANCELLED;
1182 }
1183
1184 material_node->id = &material->id;
1185 id_us_plus(&material->id);
1186
1187 BKE_main_ensure_invariants(*bmain, ntree->id);
1189
1190 return OPERATOR_FINISHED;
1191}
1192
1194{
1195 ARegion *region = CTX_wm_region(C);
1196 SpaceNode *snode = CTX_wm_space_node(C);
1197
1198 /* Convert mouse coordinates to v2d space. */
1200 event->mval[0],
1201 event->mval[1],
1202 &snode->runtime->cursor[0],
1203 &snode->runtime->cursor[1]);
1204
1205 snode->runtime->cursor[0] /= UI_SCALE_FAC;
1206 snode->runtime->cursor[1] /= UI_SCALE_FAC;
1207
1208 return node_add_material_exec(C, op);
1209}
1210
1212{
1213 const SpaceNode *snode = CTX_wm_space_node(C);
1215}
1216
1218{
1219 /* identifiers */
1220 ot->name = "Add Material";
1221 ot->description = "Add a material node to the current node editor";
1222 ot->idname = "NODE_OT_add_material";
1223
1224 /* callbacks */
1228
1229 /* flags */
1231
1233}
1234
1236
1237/* -------------------------------------------------------------------- */
1240
1242{
1243 Main *bmain = CTX_data_main(C);
1244 SpaceNode *snode = CTX_wm_space_node(C);
1245 bNodeTree *ntree = snode->edittree;
1246 const bool is_geometry_tree = ntree->type == NTREE_GEOMETRY;
1247
1249
1250 Vector<bNode *> new_nodes;
1251 for (const StringRefNull path : paths) {
1252 bNode *node = nullptr;
1253 if (is_geometry_tree && path.endswith(".csv")) {
1254 node = add_node(*C, "GeometryNodeImportCSV"_ustr, snode->runtime->cursor);
1255 }
1256 else if (is_geometry_tree && path.endswith(".obj")) {
1257 node = add_node(*C, "GeometryNodeImportOBJ"_ustr, snode->runtime->cursor);
1258 }
1259 else if (is_geometry_tree && path.endswith(".ply")) {
1260 node = add_node(*C, "GeometryNodeImportPLY"_ustr, snode->runtime->cursor);
1261 }
1262 else if (is_geometry_tree && path.endswith(".spz")) {
1263 node = add_node(*C, "GeometryNodeImportSPZ"_ustr, snode->runtime->cursor);
1264 }
1265 else if (is_geometry_tree && path.endswith(".stl")) {
1266 node = add_node(*C, "GeometryNodeImportSTL"_ustr, snode->runtime->cursor);
1267 }
1268 else if (path.endswith(".txt")) {
1269 node = add_node(*C, "GeometryNodeImportText"_ustr, snode->runtime->cursor);
1270 }
1271 else if (is_geometry_tree && path.endswith(".vdb")) {
1272 node = add_node(*C, "GeometryNodeImportVDB"_ustr, snode->runtime->cursor);
1273 }
1274
1275 if (node) {
1276 bNodeSocket &path_socket = *node->input_by_identifier("Path"_ustr);
1277 BLI_assert(path_socket.type == SOCK_STRING);
1278 auto *socket_data = static_cast<bNodeSocketValueString *>(path_socket.default_value);
1279 STRNCPY(socket_data->value, path.c_str());
1280 new_nodes.append(node);
1281 }
1282 }
1283
1284 if (new_nodes.is_empty()) {
1285 return OPERATOR_CANCELLED;
1286 }
1287
1288 node_deselect_all(*ntree);
1289
1290 for (const int i : new_nodes.index_range()) {
1291 bNode *node = new_nodes[i];
1292 node->flag |= NODE_SELECT;
1293 }
1294 bke::node_set_active(*ntree, *new_nodes[0]);
1295
1296 NodeStackAnimationData *data = MEM_new<NodeStackAnimationData>(__func__);
1297 data->nodes = std::move(new_nodes);
1298 data->anim_timer = WM_event_timer_add(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.02);
1299 op->customdata = data;
1301
1302 BKE_main_ensure_invariants(*bmain, ntree->id);
1303
1305}
1306
1308 wmOperator *op,
1309 const wmEvent *event)
1310{
1311 ARegion *region = CTX_wm_region(C);
1312 SpaceNode *snode = CTX_wm_space_node(C);
1313
1314 /* Convert mouse coordinates to v2d space. */
1316 event->mval[0],
1317 event->mval[1],
1318 &snode->runtime->cursor[0],
1319 &snode->runtime->cursor[1]);
1320
1321 snode->runtime->cursor[0] /= UI_SCALE_FAC;
1322 snode->runtime->cursor[1] /= UI_SCALE_FAC;
1323
1324 return node_add_import_node_exec(C, op);
1325}
1326
1328{
1329 const SpaceNode *snode = CTX_wm_space_node(C);
1330 return ED_operator_node_editable(C) &&
1332}
1333
1335{
1336 ot->name = "Add Import Node";
1337 ot->description = "Add an import node to the node tree";
1338 ot->idname = "NODE_OT_add_import_node";
1339
1344
1346
1347 PropertyRNA *prop;
1348
1350 ot->srna, "directory", nullptr, FILE_MAX, "Directory", "Directory of the file");
1352
1353 prop = RNA_def_collection_runtime(ot->srna, "files", RNA_OperatorFileListElement, "Files", "");
1355}
1356
1358
1359/* -------------------------------------------------------------------- */
1362
1365 bool panels_with_header_unselected)
1366{
1367 switch (item->item_type) {
1369 auto *socket = reinterpret_cast<bNodeTreeInterfaceSocket *>(item);
1370 if (socket->flag & NODE_INTERFACE_SOCKET_INPUT &&
1371 !(socket->flag & NODE_INTERFACE_SOCKET_SELECT))
1372 {
1373 auto *node_socket = node->output_by_identifier(UString(socket->identifier));
1374 node_socket->flag |= SOCK_HIDDEN;
1375 }
1376 break;
1377 }
1379 /* Only visit unselected panels. */
1380 auto *interface_panel = reinterpret_cast<bNodeTreeInterfacePanel *>(item);
1381 bool panel_selection_ignored = panels_with_header_unselected &&
1382 interface_panel->header_toggle_socket();
1383 if (!(interface_panel->flag & NODE_INTERFACE_PANEL_SELECT) || panel_selection_ignored) {
1384 for (auto *sub_item : interface_panel->items()) {
1385 hide_unselected_sockets(node, sub_item, panels_with_header_unselected);
1386 }
1387 }
1388 break;
1389 }
1390 }
1391}
1392
1394{
1395 SpaceNode *snode = CTX_wm_space_node(C);
1396 bNodeTree *ntree = snode->edittree;
1397 bNodeTreeInterface &interface = ntree->tree_interface;
1398
1399 const bool only_selected = RNA_boolean_get(op->ptr, "only_selected_sockets");
1400 const bool all_panel_contents = RNA_boolean_get(op->ptr, "all_panel_contents");
1401
1403
1404 bNode *group_input_node = add_node(*C, "NodeGroupInput"_ustr, snode->runtime->cursor);
1405
1406 if (only_selected) {
1407 hide_unselected_sockets(group_input_node,
1408 reinterpret_cast<bNodeTreeInterfaceItem *>(&interface.root_panel),
1409 !all_panel_contents);
1410
1411 /* Hide __extend__ socket. */
1412 group_input_node->output_by_identifier("__extend__"_ustr)->flag |= SOCK_HIDDEN;
1413 }
1414
1415 return OPERATOR_FINISHED;
1416}
1417
1419 wmOperator *op,
1420 const wmEvent *event)
1421{
1422 ARegion *region = CTX_wm_region(C);
1423 SpaceNode *snode = CTX_wm_space_node(C);
1424
1425 /* Convert mouse coordinates to v2d space. */
1427 event->mval[0],
1428 event->mval[1],
1429 &snode->runtime->cursor[0],
1430 &snode->runtime->cursor[1]);
1431
1432 snode->runtime->cursor[0] /= UI_SCALE_FAC;
1433 snode->runtime->cursor[1] /= UI_SCALE_FAC;
1434
1436}
1437
1438static bool contains_any_selected_input(const bNodeTreeInterfaceItem &item, bool parent_selected)
1439{
1440 switch (item.item_type) {
1442 const auto &socket = reinterpret_cast<const bNodeTreeInterfaceSocket &>(item);
1443 return socket.flag & NODE_INTERFACE_SOCKET_INPUT &&
1444 (parent_selected || socket.flag & NODE_INTERFACE_SOCKET_SELECT);
1445 }
1447 const auto &panel = reinterpret_cast<const bNodeTreeInterfacePanel &>(item);
1448 for (const auto *sub_item : panel.items()) {
1449 /* There's no need to handle the header toggle differently. */
1451 *sub_item, parent_selected || panel.flag & NODE_INTERFACE_PANEL_SELECT))
1452 {
1453 return true;
1454 }
1455 }
1456 }
1457 }
1458 return false;
1459}
1460
1462{
1464 return false;
1465 }
1466
1467 const SpaceNode *snode = CTX_wm_space_node(C);
1468 bNodeTree *ntree = snode->edittree;
1469 bNodeTreeInterface &interface = ntree->tree_interface;
1470
1472 reinterpret_cast<bNodeTreeInterfaceItem &>(interface.root_panel), false))
1473 {
1474 CTX_wm_operator_poll_msg_set(C, "No selected input sockets or panels");
1475 return false;
1476 }
1477
1478 return true;
1479}
1480
1482{
1483 ot->name = "Add Group Input Node";
1484 ot->description = "Add a Group Input node with selected sockets to the current node editor";
1485 ot->idname = "NODE_OT_add_group_input_node";
1486
1490
1492
1494 ot->srna,
1495 "only_selected_sockets",
1496 true,
1497 "Only Selected Sockets",
1498 "Include only selected sockets/panels in the added group input node");
1500 prop = RNA_def_boolean(
1501 ot->srna,
1502 "all_panel_contents",
1503 false,
1504 "All Panel Contents",
1505 "Include sockets in all selected panels, even if they have a panel toggle");
1507}
1508
1510
1511/* -------------------------------------------------------------------- */
1514
1516{
1517 Main *bmain = CTX_data_main(C);
1518 SpaceNode *snode = CTX_wm_space_node(C);
1519 bNodeTree *ntree = snode->edittree;
1520
1521 float color[4];
1522 RNA_float_get_array(op->ptr, "color", color);
1523 const bool gamma = RNA_boolean_get(op->ptr, "gamma");
1524 const bool has_alpha = RNA_boolean_get(op->ptr, "has_alpha");
1525
1526 if (!has_alpha) {
1527 color[3] = 1.0f;
1528 }
1529
1530 if (gamma) {
1532 }
1533
1534 bNode *color_node;
1535
1536 switch (snode->nodetree->type) {
1537 case NTREE_SHADER:
1538 color_node = add_node(*C, "ShaderNodeRGB"_ustr, snode->runtime->cursor);
1539 break;
1540 case NTREE_COMPOSIT:
1541 color_node = add_node(*C, "CompositorNodeRGB"_ustr, snode->runtime->cursor);
1542 break;
1543 case NTREE_GEOMETRY:
1544 color_node = add_node(*C, "FunctionNodeInputColor"_ustr, snode->runtime->cursor);
1545 break;
1546 default:
1547 return OPERATOR_CANCELLED;
1548 }
1549
1550 if (!color_node) {
1551 BKE_report(op->reports, RPT_WARNING, "Could not add a color node");
1552 return OPERATOR_CANCELLED;
1553 }
1554
1555 /* The Geometry Node color node stores the color value inside the node storage, while
1556 * the Compositing and Shading color nodes store it in the output socket. */
1557 if (snode->nodetree->type == NTREE_GEOMETRY) {
1558 NodeInputColor *input_color_storage = static_cast<NodeInputColor *>(color_node->storage);
1559 copy_v4_v4(input_color_storage->color, color);
1560 }
1561 else {
1562 bNodeSocket *sock = color_node->outputs.first();
1563 if (!sock) {
1564 BKE_report(op->reports, RPT_WARNING, "Could not find node color socket");
1565 return OPERATOR_CANCELLED;
1566 }
1567
1568 bNodeSocketValueRGBA *socket_data = static_cast<bNodeSocketValueRGBA *>(sock->default_value);
1569 copy_v4_v4(socket_data->value, color);
1570 }
1571
1572 bke::node_set_active(*ntree, *color_node);
1573 BKE_main_ensure_invariants(*bmain, ntree->id);
1574
1575 return OPERATOR_FINISHED;
1576}
1577
1579{
1580 ARegion *region = CTX_wm_region(C);
1581 SpaceNode *snode = CTX_wm_space_node(C);
1582
1583 /* Convert mouse coordinates to v2d space. */
1585 event->mval[0],
1586 event->mval[1],
1587 &snode->runtime->cursor[0],
1588 &snode->runtime->cursor[1]);
1589
1590 snode->runtime->cursor[0] /= UI_SCALE_FAC;
1591 snode->runtime->cursor[1] /= UI_SCALE_FAC;
1592
1593 return node_add_color_exec(C, op);
1594}
1595
1597{
1598 const SpaceNode *snode = CTX_wm_space_node(C);
1599 return ED_operator_node_editable(C) &&
1601}
1602
1604{
1605 /* identifiers */
1606 ot->name = "Add Color";
1607 ot->description = "Add a color node to the current node editor";
1608 ot->idname = "NODE_OT_add_color";
1609
1610 /* callbacks */
1614
1615 /* flags */
1617
1619 ot->srna, "color", 4, nullptr, 0.0, FLT_MAX, "Color", "Source color", 0.0, 1.0);
1621 ot->srna, "gamma", false, "Gamma Corrected", "The source color is gamma corrected");
1623 ot->srna, "has_alpha", false, "Has Alpha", "The source color contains an Alpha component");
1624}
1625
1627
1628/* -------------------------------------------------------------------- */
1631
1633{
1634 Main *bmain = CTX_data_main(C);
1635
1636 bNodeTree *node_tree = bke::node_tree_add_tree(bmain, treename, idname);
1637 node_templateID_assign(C, node_tree);
1638
1639 return node_tree;
1640}
1641
1643{
1644 SpaceNode *snode = CTX_wm_space_node(C);
1645 PointerRNA ptr;
1646 PropertyRNA *prop;
1647 const char *idname;
1648 char treename_buf[MAX_ID_NAME - 2];
1649 const char *treename;
1650
1651 if (RNA_struct_property_is_set(op->ptr, "type")) {
1652 prop = RNA_struct_find_property(op->ptr, "type");
1653 RNA_property_enum_identifier(C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &idname);
1654 }
1655 else if (snode) {
1656 idname = snode->tree_idname;
1657 }
1658 else {
1659 return OPERATOR_CANCELLED;
1660 }
1661
1662 if (!bke::node_tree_type_find(idname)) {
1663 BKE_reportf(op->reports, RPT_ERROR, "Node tree type %s undefined", idname);
1664 return OPERATOR_CANCELLED;
1665 }
1666
1667 if (RNA_struct_property_is_set(op->ptr, "name")) {
1668 RNA_string_get(op->ptr, "name", treename_buf);
1669 treename = treename_buf;
1670 }
1671 else {
1672 const bke::bNodeTreeType *type = bke::node_tree_type_find(idname);
1673 treename = type->ui_name.c_str();
1674 }
1675
1676 new_node_tree_impl(C, treename, idname);
1677
1679 return OPERATOR_FINISHED;
1680}
1681
1683 PointerRNA * /*ptr*/,
1684 PropertyRNA * /*prop*/,
1685 bool *r_free)
1686{
1687 return rna_node_tree_type_itemf(nullptr, nullptr, r_free);
1688}
1689
1691{
1692 PropertyRNA *prop;
1693
1694 /* identifiers */
1695 ot->name = "New Node Tree";
1696 ot->idname = "NODE_OT_new_node_tree";
1697 ot->description = "Create a new node tree";
1698
1699 /* API callbacks. */
1701
1702 /* flags */
1704
1705 prop = RNA_def_enum(ot->srna, "type", rna_enum_dummy_NULL_items, 0, "Tree Type", "");
1707 RNA_def_string(ot->srna, "name", "NodeTree", MAX_ID_NAME - 2, "Name", "");
1708}
1709
1711
1712/* -------------------------------------------------------------------- */
1715
1717{
1718 Main *bmain = CTX_data_main(C);
1719
1720 char tree_name[MAX_ID_NAME - 2];
1721 RNA_string_get(op->ptr, "name", tree_name);
1722
1723 bNodeTree *ntree = new_node_tree_impl(C, tree_name, "CompositorNodeTree");
1725
1728
1729 return OPERATOR_FINISHED;
1730}
1731
1733 wmOperator *op,
1734 const wmEvent * /* event */)
1735{
1736 PropertyRNA *prop;
1737 prop = RNA_struct_find_property(op->ptr, "name");
1738 if (!RNA_property_is_set(op->ptr, prop)) {
1739 RNA_property_string_set(op->ptr, prop, DATA_("Compositor Nodes"));
1740 }
1742}
1743
1744/* Todo(#140111): Unused, remove in 6.0. */
1746{
1747 /* identifiers */
1748 ot->name = "New Compositing Node Group";
1749 ot->idname = "NODE_OT_new_compositing_node_group";
1750 ot->description =
1751 "Create a new compositing node group and initialize it with default nodes. Deprecated and "
1752 "will be removed in 6.0";
1753
1754 /* api callbacks */
1757
1758 /* flags */
1760
1761 /* The default name of the new node tree can be translated if new data
1762 * translation is enabled, but since the user can choose it at invoke time,
1763 * the translation happens in the invoke callback instead of here. */
1764 RNA_def_string(ot->srna, "name", nullptr, MAX_ID_NAME - 2, "Name", "");
1765}
1766
1768
1769/* -------------------------------------------------------------------- */
1773{
1774 Main *bmain = CTX_data_main(C);
1775 if (source_node_tree == nullptr) {
1776 return OPERATOR_CANCELLED;
1777 }
1778
1779 bNodeTree *node_tree = reinterpret_cast<bNodeTree *>(
1780 BKE_id_copy_ex(bmain, &source_node_tree->id, nullptr, LIB_ID_COPY_ACTIONS));
1781 node_templateID_assign(C, node_tree);
1782
1785
1786 return OPERATOR_FINISHED;
1787}
1788
1790 wmOperator * /*op*/)
1791{
1793 Strip *strip = seq::select_active_get(scene);
1794
1795 if (strip == nullptr) {
1796 return OPERATOR_CANCELLED;
1797 }
1798
1800
1801 if (!(smd && smd->type == eSeqModifierType_Compositor)) {
1802 return OPERATOR_CANCELLED;
1803 }
1804
1807}
1808
1810{
1811 ot->name = "New Compositing Node Group";
1812 ot->idname = "NODE_OT_duplicate_compositing_modifier_node_group";
1813 ot->description = "Duplicate the currently assigned compositing node group.";
1814
1816
1818}
1819
1821
1822/* -------------------------------------------------------------------- */
1825
1827 bNodeTree &ntree,
1828 bool for_effect,
1829 int effect_input_count)
1830{
1831 BLI_assert(ntree.type == NTREE_COMPOSIT);
1832 BLI_assert(ntree.nodes.count() == 0);
1833
1834 if (for_effect) {
1835 /* Effect: Input 1, Input 2, Fader depending on input count. */
1836 if (effect_input_count == 2) {
1837 ntree.tree_interface.add_socket(
1838 "Input 1", "", "NodeSocketColor", NODE_INTERFACE_SOCKET_INPUT, nullptr);
1839 ntree.tree_interface.add_socket(
1840 "Input 2", "", "NodeSocketColor", NODE_INTERFACE_SOCKET_INPUT, nullptr);
1841 }
1842 else if (effect_input_count == 1) {
1843 ntree.tree_interface.add_socket(
1844 "Input", "", "NodeSocketColor", NODE_INTERFACE_SOCKET_INPUT, nullptr);
1845 }
1846 ntree.tree_interface.add_socket(
1847 "Effect Fader", "", "NodeSocketFloat", NODE_INTERFACE_SOCKET_INPUT, nullptr);
1848 }
1849 else {
1850 /* Modifier: Image, Mask. */
1851 ntree.tree_interface.add_socket(
1852 "Image", "", "NodeSocketColor", NODE_INTERFACE_SOCKET_INPUT, nullptr);
1853 ntree.tree_interface.add_socket(
1854 "Mask", "", "NodeSocketColor", NODE_INTERFACE_SOCKET_INPUT, nullptr);
1855 }
1856 ntree.tree_interface.add_socket(
1857 "Image", "", "NodeSocketColor", NODE_INTERFACE_SOCKET_OUTPUT, nullptr);
1858
1859 bNode *output_node = bke::node_add_node(C, ntree, "NodeGroupOutput"_ustr);
1860 output_node->location[0] = 200.0f;
1861 output_node->location[1] = 0.0f;
1862
1863 bNode *input_node = bke::node_add_node(C, ntree, "NodeGroupInput"_ustr);
1864 input_node->location[0] = -150.0f - input_node->width;
1865 input_node->location[1] = 0.0f;
1866 bke::node_set_active(ntree, *input_node);
1867
1868 bke::node_add_link(ntree,
1869 *input_node,
1870 *input_node->outputs.first(),
1871 *output_node,
1872 *output_node->inputs.first());
1873
1875}
1876
1878{
1879 Main *bmain = CTX_data_main(C);
1881
1882 char tree_name[MAX_ID_NAME - 2];
1883 RNA_string_get(op->ptr, "name", tree_name);
1884
1885 Strip *strip = seq::select_active_get(scene);
1886 const bool is_effect_active = strip != nullptr && strip->type == STRIP_TYPE_COMPOSITOR;
1887 int effect_input_count = 0;
1888 if (is_effect_active) {
1889 effect_input_count = (strip->input1 && strip->input2) ? 2 : (strip->input1 ? 1 : 0);
1890 }
1891
1892 /* We cannot use `new_node_tree_impl` here because that will call `node_templateID_assign` before
1893 * we're able to trigger an update on the new node tree
1894 * (`BKE_ntree_update_after_single_tree_change`). This is an issue because assigning the tree to
1895 * the ID template field will cause a property update that expects the tree update function
1896 * already have been called. */
1897 bNodeTree *ntree = bke::node_tree_add_tree(bmain, tree_name, "CompositorNodeTree");
1898 initialize_compositor_sequencer_node_group(C, *ntree, is_effect_active, effect_input_count);
1899 if (!is_effect_active) {
1900 /* Set the compositor asset trait `is_strip_modifier` to true. */
1901 if (!ntree->compositor_node_asset_traits) {
1902 ntree->compositor_node_asset_traits = MEM_new<CompositorNodeAssetTraits>(__func__);
1903 }
1906 }
1907 node_templateID_assign(C, ntree);
1908
1909 if (strip != nullptr && strip->type != STRIP_TYPE_SOUND) {
1910 bool assigned_node_tree = false;
1911
1912 /* If strip is a compositor effect: assign the node tree. */
1913 if (strip->type == STRIP_TYPE_COMPOSITOR && strip->effectdata) {
1914 CompositorEffectVars *comp_data = static_cast<CompositorEffectVars *>(strip->effectdata);
1915 comp_data->node_group = ntree;
1916 assigned_node_tree = true;
1917 }
1918
1919 /* Otherwise, if there's no active compositor modifier: create one and assign the node tree. */
1920 StripModifierData *active_smd = seq::modifier_get_active(strip);
1921 if (!assigned_node_tree && (!active_smd || active_smd->type != eSeqModifierType_Compositor)) {
1924
1925 SequencerCompositorModifierData *modifier_data =
1926 reinterpret_cast<SequencerCompositorModifierData *>(smd);
1928 modifier_data->node_group = ntree;
1929 assigned_node_tree = true;
1930 }
1931
1932 if (assigned_node_tree) {
1933 /* Which strips are used by which node trees has changed. */
1935 seq::relations_invalidate_cache(scene, strip);
1936 /* Tag depsgraph relations for an update since the modifier should now be referencing a
1937 * different node tree. */
1940 }
1941 }
1942
1945
1946 return OPERATOR_FINISHED;
1947}
1948
1950{
1951 operator_type->name = "New Compositor Sequencer Node Group";
1952 operator_type->idname = "NODE_OT_new_compositor_sequencer_node_group";
1953 operator_type->description = "Create a new compositor node group for sequencer";
1954
1956
1957 operator_type->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
1958
1959 RNA_def_string(operator_type->srna,
1960 "name",
1961 DATA_("Sequencer Compositor Nodes"),
1962 MAX_ID_NAME - 2,
1963 "Name",
1964 "");
1965}
1966
1968
1969} // namespace blender::ed::space_node
Main runtime representation of an asset.
#define IMA_SIGNAL_RELOAD
Definition BKE_image.hh:178
#define NODE_REROUTE
Definition BKE_node.hh:867
#define CMP_NODE_MASK
#define GEO_NODE_OBJECT_INFO
#define SH_NODE_TEX_IMAGE
#define SH_NODE_TEX_ENVIRONMENT
#define GEO_NODE_IMAGE_TEXTURE
#define TEX_NODE_IMAGE
#define GEO_NODE_INPUT_MATERIAL
#define CMP_NODE_IMAGE
#define GEO_NODE_COLLECTION_INFO
#define FILE_MAX
#define STR_ELEM(...)
#define STRNCPY_UTF8(dst, src)
#define TIP_(msgid)
#define DATA_(msgid)
#define MAX_ID_NAME
Definition DNA_ID.h:367
Object groups, one object can be in many groups at once.
#define UI_SCALE_FAC
Read Blender memory allocation and freeing.
#define RNA_BEGIN(sptr, itemptr, propname)
#define RNA_END
#define C
Definition RandGen.cpp:29
#define ND_SEQUENCER
Definition WM_types.hh:456
#define NC_NODE
Definition WM_types.hh:407
#define NC_SCENE
Definition WM_types.hh:391
#define NA_ADDED
Definition WM_types.hh:636
#define NA_EDITED
Definition WM_types.hh:634
#define NC_IMAGE
Definition WM_types.hh:397
#define BLI_assert_unreachable()
#define ELEM(...)
constexpr IndexRange drop_back(int64_t n) const
constexpr IndexRange()=default
SubIterator begin() const
Definition BLI_map.hh:768
SubIterator end() const
Definition BLI_map.hh:778
Value & lookup_or_add_default(const Key &key)
Definition BLI_map.hh:639
ValueIterator values() const &
Definition BLI_map.hh:884
int64_t size() const
Definition BLI_map.hh:976
KeyIterator keys() const &
Definition BLI_map.hh:875
ItemIterator items() const &
Definition BLI_map.hh:902
constexpr IndexRange index_range() const
Definition BLI_span.hh:405
const char * c_str() const
UString()=default
int64_t size() const
void append(const T &value)
const T & last(const int64_t n=0) const
bool is_empty() const
IndexRange index_range() const
#define FLT_MAX
#define INT_MAX
#define position
void node_attach_node(bNodeTree &ntree, bNode &node, bNode &parent)
Definition node.cc:4883
bNodeTreeType * node_tree_type_find(StringRef idname)
Definition node.cc:2797
void node_tag_update_id(bNode &node)
Definition node.cc:5593
void node_update_asset_metadata(bNodeTree &node_tree)
Definition node.cc:2462
bool node_group_poll(const bNodeTree *nodetree, const bNodeTree *grouptree, const char **r_disabled_hint)
bNode * node_add_node(const bContext *C, bNodeTree &ntree, UString idname, std::optional< int > unique_identifier=std::nullopt)
Definition node.cc:4260
bool node_set_selected(bNode &node, bool select)
Definition node.cc:5455
bNode * node_add_static_node(const bContext *C, bNodeTree &ntree, int type)
Definition node.cc:4283
bNodeLink & node_add_link(bNodeTree &ntree, bNode &fromnode, bNodeSocket &fromsock, bNode &tonode, bNodeSocket &tosock)
Definition node.cc:4638
bNodeTree * node_tree_add_tree(Main *bmain, StringRef name, StringRef idname)
Definition node.cc:4992
void node_link_set_mute(bNodeTree &ntree, bNodeLink &link, const bool muted)
Definition node.cc:4693
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, UString identifier)
Definition node.cc:3036
void node_set_active(bNodeTree &ntree, bNode &node)
Definition node.cc:5484
void node_unique_name(bNodeTree &ntree, bNode &node)
Definition node.cc:4238
ID * asset_local_id_ensure_imported(Main &bmain, const asset_system::AssetRepresentation &asset, int flags=0, const std::optional< eAssetImportMethod > import_method=std::nullopt, const std::optional< ImportInstantiateContext > instantiate_context=std::nullopt, ReportList *reports=nullptr)
void operator_asset_reference_props_register(StructRNA &srna)
const asset_system::AssetRepresentation * operator_asset_reference_props_get_asset_from_all_library(const bContext &C, PointerRNA &ptr, ReportList *reports)
Vector< std::string > paths_from_operator_properties(PointerRNA *ptr)
Definition io_utils.cc:79
void NODE_OT_add_group_input_node(wmOperatorType *ot)
Definition node_add.cc:1481
void NODE_OT_add_object(wmOperatorType *ot)
Definition node_add.cc:757
static bool node_add_material_poll(bContext *C)
Definition node_add.cc:1211
static wmOperatorStatus node_add_group_exec(bContext *C, wmOperator *op)
Definition node_add.cc:351
void NODE_OT_add_mask(wmOperatorType *ot)
Definition node_add.cc:1140
static bool node_add_object_poll(bContext *C)
Definition node_add.cc:750
static wmOperatorStatus add_reroute_exec(bContext *C, wmOperator *op)
Definition node_add.cc:190
bNode * add_static_node(const bContext &C, int type, const float2 &location)
Definition node_add.cc:107
static wmOperatorStatus node_add_color_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition node_add.cc:1578
static wmOperatorStatus node_add_mask_exec(bContext *C, wmOperator *op)
Definition node_add.cc:1112
static bool node_add_image_poll(bContext *C)
Definition node_add.cc:871
static bool node_add_group_poll(bContext *C)
Definition node_add.cc:397
void NODE_OT_add_reroute(wmOperatorType *ot)
Definition node_add.cc:289
static wmOperatorStatus node_add_collection_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition node_add.cc:821
bool node_deselect_all(bNodeTree &node_tree)
void NODE_OT_new_compositing_node_group(wmOperatorType *ot)
Definition node_add.cc:1745
static wmOperatorStatus node_add_import_node_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition node_add.cc:1307
void NODE_OT_add_collection(wmOperatorType *ot)
Definition node_add.cc:847
static void node_templateID_assign(bContext *C, bNodeTree *node_tree)
Definition node_add.cc:130
static wmOperatorStatus new_compositing_node_group_exec(bContext *C, wmOperator *op)
Definition node_add.cc:1716
static wmOperatorStatus node_add_group_input_node_exec(bContext *C, wmOperator *op)
Definition node_add.cc:1393
void NODE_OT_add_group_asset(wmOperatorType *ot)
Definition node_add.cc:657
static wmOperatorStatus node_add_material_exec(bContext *C, wmOperator *op)
Definition node_add.cc:1163
static void position_node_based_on_mouse(bNode &node, const float2 &location)
Definition node_add.cc:81
static bool node_add_color_poll(bContext *C)
Definition node_add.cc:1596
static wmOperatorStatus node_add_collection_exec(bContext *C, wmOperator *op)
Definition node_add.cc:781
static wmOperatorStatus node_swap_group_asset_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition node_add.cc:560
void NODE_OT_swap_group_asset(wmOperatorType *ot)
Definition node_add.cc:672
static const EnumPropertyItem * new_node_tree_type_itemf(bContext *, PointerRNA *, PropertyRNA *, bool *r_free)
Definition node_add.cc:1682
static bool contains_any_selected_input(const bNodeTreeInterfaceItem &item, bool parent_selected)
Definition node_add.cc:1438
static bool node_add_import_node_poll(bContext *C)
Definition node_add.cc:1327
static wmOperatorStatus new_compositing_node_group_invoke(bContext *C, wmOperator *op, const wmEvent *)
Definition node_add.cc:1732
static bNodeTree * new_node_tree_impl(bContext *C, StringRef treename, StringRef idname)
Definition node_add.cc:1632
void NODE_OT_add_color(wmOperatorType *ot)
Definition node_add.cc:1603
static wmOperatorStatus node_add_group_asset_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition node_add.cc:525
bNode * add_node(const bContext &C, const UString idname, const float2 &location)
Definition node_add.cc:87
static wmOperatorStatus node_add_material_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition node_add.cc:1193
UString node_group_idname(const bContext *C)
bool node_link_is_hidden_or_dimmed(const View2D &v2d, const bNodeLink &link)
Definition node_edit.cc:914
static void initialize_compositor_sequencer_node_group(const bContext *C, bNodeTree &ntree, bool for_effect, int effect_input_count)
Definition node_add.cc:1826
void tree_update(const bContext *C)
Definition node_draw.cc:189
static wmOperatorStatus new_compositor_sequencer_node_group_exec(bContext *C, wmOperator *op)
Definition node_add.cc:1877
std::optional< float2 > link_path_intersection(const bNodeLink &link, const Span< float2 > path)
Definition node_add.cc:166
VectorSet< bNode * > get_selected_nodes(bNodeTree &node_tree)
static bool node_swap_group_poll(bContext *C)
Definition node_add.cc:411
void NODE_OT_new_compositor_sequencer_node_group(wmOperatorType *operator_type)
Definition node_add.cc:1949
static bool node_group_add_poll(const bNodeTree &node_tree, const bNodeTree &node_group, ReportList &reports)
Definition node_add.cc:319
static wmOperatorStatus duplicate_compositing_modifier_node_group_exec(bContext *C, wmOperator *)
Definition node_add.cc:1789
static wmOperatorStatus node_add_object_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition node_add.cc:732
void node_link_bezier_points_evaluated(const bNodeLink &link, std::array< float2, NODE_LINK_RESOL+1 > &coords)
Definition drawnode.cc:1864
static bool node_add_mask_poll(bContext *C)
Definition node_add.cc:1105
void NODE_OT_duplicate_compositing_modifier_node_group(wmOperatorType *ot)
Definition node_add.cc:1809
static wmOperatorStatus node_add_object_exec(bContext *C, wmOperator *op)
Definition node_add.cc:693
static bool node_add_group_input_node_poll(bContext *C)
Definition node_add.cc:1461
void NODE_OT_add_import_node(wmOperatorType *ot)
Definition node_add.cc:1334
static std::string node_add_group_asset_get_description(bContext *C, wmOperatorType *, PointerRNA *ptr)
Definition node_add.cc:641
void NODE_OT_add_image(wmOperatorType *ot)
Definition node_add.cc:1072
static wmOperatorStatus new_node_tree_exec(bContext *C, wmOperator *op)
Definition node_add.cc:1642
void NODE_OT_add_group(wmOperatorType *ot)
Definition node_add.cc:450
static wmOperatorStatus node_add_nodes_modal(bContext *C, wmOperator *op, const wmEvent *event)
Definition node_add.cc:892
static wmOperatorStatus node_add_color_exec(bContext *C, wmOperator *op)
Definition node_add.cc:1515
static bool node_add_collection_poll(bContext *C)
Definition node_add.cc:841
static wmOperatorStatus node_add_import_node_exec(bContext *C, wmOperator *op)
Definition node_add.cc:1241
static wmOperatorStatus duplicate_and_assign_node_tree(bContext *C, bNodeTree *source_node_tree)
Definition node_add.cc:1772
static wmOperatorStatus node_add_group_input_node_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition node_add.cc:1418
static wmOperatorStatus node_add_group_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition node_add.cc:432
void NODE_OT_add_material(wmOperatorType *ot)
Definition node_add.cc:1217
static wmOperatorStatus node_add_image_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition node_add.cc:1042
static wmOperatorStatus node_add_image_exec(bContext *C, wmOperator *op)
Definition node_add.cc:934
void NODE_OT_new_node_tree(wmOperatorType *ot)
Definition node_add.cc:1690
static void hide_unselected_sockets(bNode *node, bNodeTreeInterfaceItem *item, bool panels_with_header_unselected)
Definition node_add.cc:1363
static bool add_node_group_asset(const bContext &C, const asset_system::AssetRepresentation &asset, ReportList &reports)
Definition node_add.cc:478
T min(const T &a, const T &b)
void node_tree_composit_default_init(const bContext *C, bNodeTree *ntree)
void relations_invalidate_cache(Scene *scene, Strip *strip)
void modifier_persistent_uid_init(const Strip &strip, StripModifierData &smd)
Strip * select_active_get(const Scene *scene)
StripModifierData * modifier_new(Strip *strip, const char *name, eStripModifierType type)
void strip_lookup_invalidate(const Editing *ed)
StripModifierData * modifier_get_active(const Strip *strip)
void view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
Definition view2d.cc:1651
void context_active_but_prop_get_templateID(const bContext *C, PointerRNA *r_ptr, PropertyRNA **r_prop)
ID * WM_operator_drop_load_path(bContext *C, wmOperator *op, const short idcode)
@ COMPOSIT_NODE_ASSET_STRIP_MODIFIER
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
Vector< PointerRNA > CTX_data_collection_get(const bContext *C, const char *member)
char * STRNCPY(char(&dst)[N], const char *src)
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_WARNING
Definition BKE_report.hh:40
Scene * CTX_data_sequencer_scene(const bContext *C)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
bool BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2])
void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value, ReportList *reports)
void WM_operator_properties_id_lookup(wmOperatorType *ot, const bool add_name_prop)
void BKE_ntree_update_tag_link_changed(bNodeTree *ntree)
void BKE_id_free_us(Main *bmain, void *idv) ATTR_NONNULL()
wmOperatorStatus WM_operator_filesel(bContext *C, wmOperator *op, const wmEvent *)
void BKE_ntree_update_tag_socket_property(bNodeTree *ntree, bNodeSocket *socket)
bool RNA_property_enum_identifier(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **r_identifier)
void id_us_plus(ID *id)
Definition lib_id.cc:433
void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
PointerRNA RNA_id_pointer_create(ID *id)
PropertyRNA * RNA_def_float_color(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void WM_operator_properties_free(PointerRNA *ptr)
ID * WM_operator_properties_id_lookup_from_name_or_session_uid(Main *bmain, PointerRNA *ptr, const ID_Type type)
void ED_node_set_active(Main *bmain, SpaceNode *snode, bNodeTree *ntree, bNode *node, bool *r_active_texture_changed)
Definition node_edit.cc:237
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PointerRNA WM_operator_properties_create_ptr(wmOperatorType *ot)
bool ED_operator_node_editable(bContext *C)
int isect_seg_seg_v2_point(const float v0[2], const float v1[2], const float v2[2], const float v3[2], float r_vi[2])
float BLI_easing_cubic_ease_in_out(float time, float begin, float change, float duration)
Definition easing.cc:110
PropertyRNA * RNA_def_string_dir_path(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
wmWindow * CTX_wm_window(const bContext *C)
PropertyRNA * RNA_def_collection_runtime(StructOrFunctionRNA *cont, const char *identifier, StructRNA *type, const char *ui_name, const char *ui_description)
const char * BKE_id_name(const ID &id)
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:681
void WM_operator_properties_filesel(wmOperatorType *ot, const int filter, const short type, const eFileSel_Action action, const eFileSel_Flag flag, const short display, const short sort)
@ LIB_ID_COPY_ACTIONS
void WM_gesture_lines_cancel(bContext *C, wmOperator *op)
wmOperatorStatus WM_gesture_lines_modal(bContext *C, wmOperator *op, const wmEvent *event)
void ED_preview_kill_jobs(wmWindowManager *wm, Main *bmain)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:593
wmOperatorStatus WM_gesture_lines_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
VecBase< float, 2 > float2
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
BMesh const char void * data
@ WM_FILESEL_DIRECTORY
Definition WM_api.hh:1330
@ WM_FILESEL_RELPATH
Definition WM_api.hh:1329
@ WM_FILESEL_FILES
Definition WM_api.hh:1333
@ WM_FILESEL_FILEPATH
Definition WM_api.hh:1332
wmWindowManager * CTX_wm_manager(const bContext *C)
BLI_INLINE void IMB_colormanagement_srgb_to_scene_linear_v3(float scene_linear[3], const float srgb[3])
void BKE_main_ensure_invariants(Main &bmain, std::optional< Span< ID * > > modified_ids=std::nullopt)
bool WM_operator_properties_id_lookup_is_set(PointerRNA *ptr)
void BKE_ntree_update_after_single_tree_change(Main &bmain, bNodeTree &modified_tree, const NodeTreeUpdateExtraParams &params={})
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
SpaceNode * CTX_wm_space_node(const bContext *C)
@ SEQ_COMP_MOD_HIDE_DATABLOCK_SELECTOR
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
const EnumPropertyItem rna_enum_dummy_NULL_items[]
Definition rna_rna.cc:28
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
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)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
@ FILE_OPENFILE
Definition WM_api.hh:1341
@ WM_CURSOR_CROSS
Definition wm_cursors.hh:28
void BKE_ntree_update_tag_node_property(bNodeTree *ntree, bNode *node)
Main * CTX_data_main(const bContext *C)
wmOperatorStatus WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wm::OpCallContext context, PointerRNA *properties, const wmEvent *event)
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
@ PROP_HIDDEN
Definition RNA_types.hh:408
const EnumPropertyItem * rna_node_tree_type_itemf(void *data, bool(*poll)(void *data, bke::bNodeTreeType *), bool *r_free)
void BKE_id_move_to_same_lib(Main &bmain, ID &id, const ID &owner_id)
Definition lib_id.cc:953
void DEG_relations_tag_update(Main *bmain)
void WM_event_timer_remove(wmWindowManager *wm, wmWindow *, wmTimer *timer)
MINLINE void copy_v4_v4(float r[4], const float a[4])
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
@ OPTYPE_DEPENDS_ON_CURSOR
Definition WM_types.hh:228
@ OPTYPE_INTERNAL
Definition WM_types.hh:210
std::string RNA_string_get(PointerRNA *ptr, const char *name)
ID * BKE_id_copy_ex(Main *bmain, const ID *id, ID **new_id_p, int flag)
Definition lib_id.cc:851
wmTimer * WM_event_timer_add(wmWindowManager *wm, wmWindow *win, const wmEventType event_type, const double time_step)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
@ eSeqModifierType_Compositor
void RNA_collection_add(PointerRNA *ptr, const char *name, PointerRNA *r_value)
void id_us_min(ID *id)
Definition lib_id.cc:441
ARegion * CTX_wm_region(const bContext *C)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
#define NODE_LINK_RESOL
#define NODE_DY
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
The meta-data of an asset. By creating and giving this for a data-block (ID.asset_data),...
char name[258]
Definition DNA_ID.h:433
ListBaseT< bNodeTree > nodetrees
Definition BKE_main.hh:409
struct Editing * ed
eSpaceNode_ShaderFrom shaderfrom
struct bNodeTree * edittree
struct bNodeTree * nodetree
ed::space_node::SpaceNode_Runtime * runtime
eNodeSocketDatatype type
struct CompositorNodeAssetTraits * compositor_node_asset_traits
ListBaseT< bNodeLink > links
bNodeTreeInterface tree_interface
eNodeTree_Type type
ListBaseT< bNode > nodes
ListBaseT< bNodeSocket > outputs
bke::bNodeRuntime * runtime
ListBaseT< bNodeSocket > inputs
wmEventType type
Definition WM_types.hh:817
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
void(*) cancel(bContext *C, wmOperator *op)
Definition WM_types.hh:1149
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1157
std::string(*) get_description(bContext *C, wmOperatorType *ot, PointerRNA *ptr)
Definition WM_types.hh:1197
struct ReportList * reports