38#include "RNA_prototypes.hh"
48struct DrawGroupInputsContext {
51 PointerRNA *properties_ptr;
52 PointerRNA *bmain_ptr;
54 Array<nodes::socket_usage_inference::SocketUsage> input_usages;
55 Array<nodes::socket_usage_inference::SocketUsage> output_usages;
57 bool input_is_visible(
const bNodeTreeInterfaceSocket &socket)
const
59 return this->input_usages[this->tree->interface_input_index(socket)].is_visible;
62 bool input_is_active(
const bNodeTreeInterfaceSocket &socket)
const
64 return this->input_usages[this->tree->interface_input_index(socket)].is_used;
76 const std::optional<StringRef> parent_name = std::nullopt)
78 if (!ctx.input_is_visible(socket)) {
113 std::string name =
IFACE_(socket.name());
117 if (parent_name.has_value()) {
118 const StringRef prefix_to_remove = *parent_name;
119 const int prefix_size = prefix_to_remove.
size();
120 const int pos = name.find(prefix_to_remove);
121 if (pos == 0 && name.size() > prefix_size && name[prefix_size] ==
' ') {
122 name = name.substr(prefix_size + 1);
128 row.
prop_search(socket_props_ptr,
"value", ctx.bmain_ptr,
"objects", name, ICON_OBJECT_DATA);
135 row.
prop(socket_props_ptr,
172 return skipped_inputs[ctx.tree->interface_input_index(socket)];
175 switch (item->item_type) {
184 return !input_is_skipped(socket) && ctx.input_is_visible(socket);
187 return !input_is_skipped(socket) && ctx.input_is_active(socket);
192 const std::optional<StringRef> parent_name) {
193 if (!input_is_skipped(socket)) {
194 draw_property_for_socket(ctx, layout, socket, socket_props_ptr, parent_name);
202 if (!input_is_skipped(interface_socket) &&
207 interface_socket.identifier);
209 ctx, layout, interface_socket, &socket_props_ptr, std::nullopt);
219 const int num_float_inputs,
220 const int num_color_inputs)
224 int floats_left = num_float_inputs;
225 int colors_left = num_color_inputs;
229 if (floats_left > 0 && socket_type ==
SOCK_FLOAT) {
230 supplied_inputs[i] =
true;
233 else if (colors_left > 0 && socket_type ==
SOCK_RGBA) {
234 supplied_inputs[i] =
true;
238 return supplied_inputs;
246 const int input_mask_type =
RNA_enum_get(ptr,
"input_mask_type");
256 &sequencer_scene->
id, RNA_SequenceEditor,
ed);
258 ptr,
"input_mask_strip", &sequences_object,
"strips_all",
IFACE_(
"Mask"), ICON_NONE);
262 row = &col.
row(
true);
272 if (interface_inputs.
size() > 0) {
277 row.
label(
RPT_(
"The first node group input must have the Color type"), ICON_STATUS_ERROR);
282 if (interface_inputs.
size() < 2) {
284 row.
label(
RPT_(
"Node group must have at least two inputs to use the mask input"),
292 row.
label(
RPT_(
"The second node group input must have the Color type"), ICON_STATUS_ERROR);
299 row.
label(
RPT_(
"Node group must have an output"), ICON_STATUS_ERROR);
306 row.
label(
RPT_(
"The first node group output must have the Color type"), ICON_STATUS_ERROR);
319 DrawGroupInputsContext ctx{
C, cmd.
node_group, &properties_ptr, &bmain_ptr};
324 const char *newop = (cmd.
node_group ==
nullptr) ?
325 "node.new_compositor_sequencer_node_group" :
326 "node.duplicate_compositing_modifier_node_group";
327 template_id(&layout, &
C, modifier_ptr,
"node_group", newop,
nullptr,
nullptr);
337 tree.ensure_interface_cache();
340 ctx.input_usages.reinitialize(tree.interface_inputs().size());
341 ctx.output_usages.reinitialize(tree.interface_outputs().size());
343 tree, *ctx.properties_ptr, ctx.input_usages, ctx.output_usages);
350 &
C, modifier_ptr,
"open_mask_input_panel",
IFACE_(
"Mask Input")))
363 if (comp->node_group ==
nullptr ||
ID_MISSING(comp->node_group)) {
371 if (!properties_ptr) {
376 tree.ensure_interface_cache();
378 DrawGroupInputsContext ctx{
C, &tree, &properties_ptr, &bmain_ptr};
382 const int inputs_num = tree.interface_inputs().size();
383 ctx.input_usages.reinitialize(inputs_num);
388 ctx.input_usages[i].is_used = i < used.
size() ? used[i] :
true;
389 ctx.input_usages[i].is_visible = i < visible.
size() ? visible[i] :
true;
393 tree, 1, strip.effect_num_inputs_get());
constexpr int64_t size() const
constexpr IndexRange index_range() const
constexpr bool is_empty() const
constexpr int64_t size() const
void infer_group_interface_inputs_usage(const bNodeTree &group, Span< const bNodeSocket * > input_sockets, MutableSpan< SocketUsage > r_input_usages)
void draw_interface_panel_as_panel(const bContext &C, ui::Layout &layout, PointerRNA *properties_ptr, const bNodeTreeInterfacePanel &interface_panel, FunctionRef< bool(const bNodeTreeInterfaceSocket &)> fn_input_is_visible, FunctionRef< bool(const bNodeTreeInterfaceSocket &)> fn_input_is_active, FunctionRef< void(ui::Layout &, const bNodeTreeInterfaceSocket &, PointerRNA *, const std::optional< StringRef >)> fn_draw_property_for_socket)
static Array< bool > find_automatic_inputs(const bNodeTree &tree, const int num_float_inputs, const int num_color_inputs)
void draw_compositor_nodes_effect_ui(const bContext &C, PointerRNA *strip_ptr, ui::Layout &layout)
void draw_compositor_nodes_modifier_ui(const bContext &C, PointerRNA *modifier_ptr, ui::Layout &layout)
static void draw_mask_input_type_settings(const bContext &C, ui::Layout &layout, PointerRNA *ptr)
static void draw_error_message(const bNodeTree &tree, ui::Layout &layout, const bool is_mask_used)
static void draw_property_for_socket(DrawGroupInputsContext &ctx, ui::Layout &layout, const bNodeTreeInterfaceSocket &socket, PointerRNA *socket_props_ptr, const std::optional< StringRef > parent_name=std::nullopt)
static void draw_interface_root_panel_content(DrawGroupInputsContext &ctx, ui::Layout &layout, const bNodeTreeInterfacePanel &interface_panel, const Span< bool > skipped_inputs)
Editing * editing_get(const Scene *scene)
void compositor_effect_nodes_input_usages(const Scene &sequencer_scene, Strip &strip, Vector< bool > &r_used, Vector< bool > &r_visible)
int RNA_enum_get(PointerRNA *ptr, const char *name)
Scene * CTX_data_sequencer_scene(const bContext *C)
PointerRNA RNA_main_pointer_create(Main *main)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
@ SEQ_COMP_MOD_HIDE_DATABLOCK_SELECTOR
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
Main * CTX_data_main(const bContext *C)
@ NODE_INTERFACE_SOCKET_HIDE_IN_MODIFIER
@ NODE_INTERFACE_SOCKET_MENU_EXPANDED
@ NODE_INTERFACE_SOCKET_INPUT
SequencerCompositorModifierFlag flag
StripModifierData modifier
struct bNodeTree * node_group
struct Strip * mask_strip
eModMaskInput mask_input_type
NodeTreeInterfaceSocketFlag flag
bNodeTreeInterfacePanel root_panel
bNodeTreeInterface tree_interface
void prop_search(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop, PropertyRNA *item_searchpropname, std::optional< StringRefNull > name, int icon, bool results_are_suggestions)
void use_property_decorate_set(bool is_decorate)
void use_property_split_set(bool is_sep)
void label(StringRef name, int icon)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
void active_set(bool active)
Layout & column(bool align)
PanelLayout panel_prop(const bContext *C, PointerRNA *open_prop_owner, StringRefNull open_prop_name)