Blender V5.3
node_composite_switch.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2006 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
6
8
10
12{
13 b.add_input<decl::Bool>("Switch"_ustr).default_value(false);
14 b.add_input<decl::Color>("Off"_ustr)
15 .default_value({0.8f, 0.8f, 0.8f, 1.0f})
16 .compositor_realization_mode(CompositorInputRealizationMode::None)
17 .structure_type(StructureType::Dynamic);
18 b.add_input<decl::Color>("On"_ustr)
19 .default_value({0.8f, 0.8f, 0.8f, 1.0f})
20 .compositor_realization_mode(CompositorInputRealizationMode::None)
21 .structure_type(StructureType::Dynamic);
22
23 b.add_output<decl::Color>("Image"_ustr);
24}
25
26using namespace blender::compositor;
27
29 public:
31
32 void execute() override
33 {
34 const Result &input = this->get_input(this->get_condition() ? "On" : "Off");
35 Result &output = this->get_result("Image");
36 output.share_data(input);
37 }
38
40 {
41 return this->get_input("Switch").get_single_value_default<bool>();
42 }
43};
44
46{
47 return new SwitchOperation(context, node);
48}
49
50static void node_register()
51{
52 static bke::bNodeType ntype;
53
54 cmp_node_type_base(&ntype, "CompositorNodeSwitch"_ustr, CMP_NODE_SWITCH);
55 ntype.ui_name = "Switch";
56 ntype.ui_description = "Switch between two images using a checkbox";
57 ntype.enum_name_legacy = "SWITCH";
59 ntype.declare = node_declare;
61 ntype.deprecation_notice = N_("Use Utilities \u25B8 Switch node instead");
62
64}
66
67} // namespace blender::nodes::node_composite_switch_cc
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:484
#define CMP_NODE_SWITCH
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define output
NodeOperation(Context &context, const bNode &node)
Result & get_result(StringRef identifier)
Definition operation.cc:40
Result & get_input(StringRef identifier) const
Definition operation.cc:35
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static void node_declare(NodeDeclarationBuilder &b)
static NodeOperation * get_compositor_operation(Context &context, const bNode &node)
void cmp_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
Defines a node type.
Definition BKE_node.hh:265
std::string ui_description
Definition BKE_node.hh:271
NodeGetCompositorOperationFunction get_compositor_operation
Definition BKE_node.hh:379
const char * deprecation_notice
Definition BKE_node.hh:455
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeDeclareFunction declare
Definition BKE_node.hh:393
#define N_(msgid)