Blender V4.5
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_interface.hh"
10#include "UI_resources.hh"
11
12#include "COM_node_operation.hh"
13
15
16/* **************** Switch ******************** */
17
19
21{
22 b.add_input<decl::Bool>("Switch").default_value(false).compositor_expects_single_value();
23 b.add_input<decl::Color>("Off")
24 .default_value({0.8f, 0.8f, 0.8f, 1.0f})
25 .compositor_realization_mode(CompositorInputRealizationMode::None);
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
30 b.add_output<decl::Color>("Image");
31}
32
33using namespace blender::compositor;
34
36 public:
38
39 void execute() override
40 {
41 const Result &input = this->get_input(this->get_condition() ? "On" : "Off");
42 Result &output = this->get_result("Image");
43 output.share_data(input);
44 }
45
47 {
48 return this->get_input("Switch").get_single_value_default(false);
49 }
50};
51
53{
54 return new SwitchOperation(context, node);
55}
56
57} // namespace blender::nodes::node_composite_switch_cc
58
60{
62
63 static blender::bke::bNodeType ntype;
64
65 cmp_node_type_base(&ntype, "CompositorNodeSwitch", CMP_NODE_SWITCH);
66 ntype.ui_name = "Switch";
67 ntype.ui_description = "Switch between two images using a checkbox";
68 ntype.enum_name_legacy = "SWITCH";
70 ntype.declare = file_ns::cmp_node_switch_declare;
72 ntype.get_compositor_operation = file_ns::get_compositor_operation;
73
75}
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:439
#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:401
T get_single_value_default(const T &default_value) const
#define input
#define output
void node_register_type(bNodeType &ntype)
Definition node.cc:2748
void node_type_size_preset(bNodeType &ntype, eNodeSizePreset size)
Definition node.cc:5585
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:226
std::string ui_description
Definition BKE_node.hh:232
NodeGetCompositorOperationFunction get_compositor_operation
Definition BKE_node.hh:336
const char * enum_name_legacy
Definition BKE_node.hh:235
NodeDeclareFunction declare
Definition BKE_node.hh:355