Blender V5.3
scene_compositor_effect_inputs_srna.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <fmt/format.h>
10
11#include "BLI_listbase.hh"
12#include "BLI_string.hh"
13
16#include "NOD_socket.hh"
17
18#include "DNA_node_types.h"
19
20#include "BKE_compositor.hh"
21#include "BKE_node_runtime.hh"
22
23#include "RNA_access.hh"
24#include "RNA_define.hh"
25#include "RNA_prototypes.hh"
26
27namespace blender::nodes {
28
29static std::optional<std::string> rna_SceneCompositorEffectInputProperty_path(
30 const PointerRNA *property_ptr)
31{
32 const char *identifier = RNA_struct_identifier(property_ptr->type);
34 return fmt::format(
35 "compositor_effects[\"{}\"].properties.inputs.{}", BLI_str_escape(effect->name), identifier);
36}
37
39 const bNodeTreeInterfaceSocket &socket,
40 GeneratedTreeSrnaData &r_generated)
41{
42 const bke::bNodeSocketType *stype = socket.socket_typeinfo();
43 if (!stype) {
44 return nullptr;
45 }
46 const StringRefNull srna_identifier = r_generated.scope.allocator().copy_string(
47 socket.identifier);
48
50 r_generated.generated_rna, srna_identifier.c_str(), RNA_PropertyGroup);
53 stype->make_scene_compositor_effect_input_srna(node_group, *srna, socket, r_generated);
54 }
55
56 return srna;
57}
58
59static StructRNA *create_inputs_srna(const bNodeTree &node_group,
60 GeneratedTreeSrnaData &r_generated)
61{
63 r_generated.generated_rna, "SceneCompositorEffectInterfaceInputs", RNA_PropertyGroup);
64
65 node_group.ensure_interface_cache();
66 for (const bNodeTreeInterfaceSocket *socket : node_group.interface_inputs()) {
67 StructRNA *socket_srna = get_input_socket_struct_rna(node_group, *socket, r_generated);
68 if (!socket_srna) {
69 continue;
70 }
71 const StringRefNull identifier = r_generated.scope.allocator().copy_string(socket->identifier);
73 srna, identifier.c_str(), socket_srna, socket->name().c_str(), "");
75 }
76
77 return srna;
78}
79
80static StructRNA *create_panels_srna(const bNodeTree &node_group,
81 GeneratedTreeSrnaData &r_generated)
82{
84 r_generated.generated_rna, "SceneCompositorEffectInterfacePanels", RNA_PropertyGroup);
85
86 LinearAllocator<> &allocator = r_generated.scope.allocator();
87
88 node_group.ensure_interface_cache();
89 for (const bNodeTreeInterfaceItem *item : node_group.interface_items()) {
90 if (item->item_type != NodeTreeInterfaceItemType::Panel) {
91 continue;
92 }
93 const auto &panel = *reinterpret_cast<const bNodeTreeInterfacePanel *>(item);
94 const StringRefNull identifier = allocator.copy_string(
95 fmt::format("open_{}", panel.identifier));
96 PropertyRNA *prop = RNA_def_boolean(srna,
97 identifier.c_str(),
99 "Is Open",
100 "");
102 }
103
104 return srna;
105}
106
107std::shared_ptr<GeneratedTreeSrnaData> create_scene_compositor_effect_inputs_srna(
108 const bNodeTree &node_group)
109{
110 std::unique_ptr<GeneratedTreeSrnaData> generated = std::make_unique<GeneratedTreeSrnaData>();
111
112 StructRNA *srna = RNA_def_struct_ptr(generated->generated_rna,
113 "SceneCompositorEffectInterface",
114 RNA_SceneCompositorEffectProperties);
115 generated->properties_struct = srna;
116
117 StructRNA *inputs_srna = create_inputs_srna(node_group, *generated);
118 StructRNA *panels_srna = create_panels_srna(node_group, *generated);
119
120 PropertyRNA *prop;
122 srna, "inputs", inputs_srna, "Inputs", "Settings for input sockets");
124 prop = RNA_def_pointer_runtime(srna, "panels", panels_srna, "Panels", "Settings for panels");
126
127 return generated;
128}
129
130} // namespace blender::nodes
StringRefNull copy_string(StringRef str)
LinearAllocator & allocator()
constexpr const char * c_str() const
const SceneCompositorEffect * get_effect_from_property(const PointerRNA &property_ptr)
static std::optional< std::string > rna_SceneCompositorEffectInputProperty_path(const PointerRNA *property_ptr)
static StructRNA * create_inputs_srna(const bNodeTree &tree, const CompositorNodesSrnaContext &context, GeneratedTreeSrnaData &r_generated)
static StructRNA * create_panels_srna(const bNodeTree &tree, GeneratedTreeSrnaData &r_generated)
static StructRNA * get_input_socket_struct_rna(const bNodeTree &tree, const bNodeTreeInterfaceSocket &socket, const CompositorNodesSrnaContext &context, GeneratedTreeSrnaData &r_generated)
std::shared_ptr< GeneratedTreeSrnaData > create_scene_compositor_effect_inputs_srna(const bNodeTree &node_group)
PropertyRNA * RNA_def_pointer_runtime(StructOrFunctionRNA *cont, const char *identifier, StructRNA *type, const char *ui_name, const char *ui_description)
StructRNA RNA_PropertyGroup
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:588
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
char char size_t BLI_str_escape(char *__restrict dst, StringRef src, size_t dst_maxncpy) ATTR_NONNULL(1)
const char * RNA_struct_identifier(const StructRNA *type)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_struct_path_func_runtime(StructRNA *srna, StructPathFunc path_fn)
@ PROP_NO_DEG_UPDATE
Definition RNA_types.hh:509
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
StructRNA * RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRNA *srnafrom)
StructRNA * type
Definition RNA_types.hh:63
Defines a socket type.
Definition BKE_node.hh:163
SocketMakeNodesInputSrnaFunction make_scene_compositor_effect_input_srna
Definition BKE_node.hh:220