Blender V5.0
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
8
9#include "UI_resources.hh"
10
11#include "COM_node_operation.hh"
12
14
15/* **************** Switch ******************** */
16
18
20{
21 b.add_input<decl::Bool>("Switch").default_value(false);
22 b.add_input<decl::Color>("Off")
23 .default_value({0.8f, 0.8f, 0.8f, 1.0f})
24 .compositor_realization_mode(CompositorInputRealizationMode::None)
25 .structure_type(StructureType::Dynamic);
26 b.add_input<decl::Color>("On")
27 .default_value({0.8f, 0.8f, 0.8f, 1.0f})
28 .compositor_realization_mode(CompositorInputRealizationMode::None)
29 .structure_type(StructureType::Dynamic);
30
31 b.add_output<decl::Color>("Image");
32}
33
34using namespace blender::compositor;
35
37 public:
39
40 void execute() override
41 {
42 const Result &input = this->get_input(this->get_condition() ? "On" : "Off");
43 Result &output = this->get_result("Image");
44 output.share_data(input);
45 }
46
48 {
49 return this->get_input("Switch").get_single_value_default(false);
50 }
51};
52
54{
55 return new SwitchOperation(context, node);
56}
57
58} // namespace blender::nodes::node_composite_switch_cc
59
61{
63
64 static blender::bke::bNodeType ntype;
65
66 cmp_node_type_base(&ntype, "CompositorNodeSwitch", CMP_NODE_SWITCH);
67 ntype.ui_name = "Switch";
68 ntype.ui_description = "Switch between two images using a checkbox";
69 ntype.enum_name_legacy = "SWITCH";
71 ntype.declare = file_ns::cmp_node_switch_declare;
73 ntype.get_compositor_operation = file_ns::get_compositor_operation;
74
76}
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:453
#define CMP_NODE_SWITCH
#define NOD_REGISTER_NODE(REGISTER_FUNC)
NodeOperation(Context &context, DNode node)
Result & get_result(StringRef identifier)
Definition operation.cc:39
Result & get_input(StringRef identifier) const
Definition operation.cc:138
void share_data(const Result &source)
Definition result.cc:523
T get_single_value_default(const T &default_value) const
#define input
#define output
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
void node_type_size_preset(bNodeType &ntype, eNodeSizePreset size)
Definition node.cc:5396
static NodeOperation * get_compositor_operation(Context &context, DNode node)
static void cmp_node_switch_declare(NodeDeclarationBuilder &b)
static void register_node_type_cmp_switch()
void cmp_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
Defines a node type.
Definition BKE_node.hh:238
std::string ui_description
Definition BKE_node.hh:244
NodeGetCompositorOperationFunction get_compositor_operation
Definition BKE_node.hh:348
const char * enum_name_legacy
Definition BKE_node.hh:247
NodeDeclareFunction declare
Definition BKE_node.hh:362