Blender V5.3
node_composite_strip_info.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BKE_context.hh"
6
8
9#include "DNA_node_types.h"
10#include "DNA_space_types.h"
11
12#include "COM_node_operation.hh"
13
15
16#include "UI_resources.hh"
17
19
21
23{
24 b.add_output<decl::Int>("Start Frame"_ustr);
25 b.add_output<decl::Int>("End Frame"_ustr);
26 b.add_output<decl::Vector>("Location"_ustr).dimensions(2);
27 b.add_output<decl::Float>("Rotation"_ustr);
28 b.add_output<decl::Vector>("Scale"_ustr).dimensions(2);
29}
30
31using namespace blender::compositor;
32
34 public:
36
37 void execute() override
38 {
39 const Strip *strip = this->context().get_strip();
40 if (strip == nullptr) {
42 return;
43 }
44
45 Result &start_frame_result = this->get_result("Start Frame");
46 if (start_frame_result.should_compute()) {
47 start_frame_result.allocate_single_value();
48 start_frame_result.set_single_value(strip->left_handle());
49 }
50
51 Result &end_frame_result = this->get_result("End Frame");
52 if (end_frame_result.should_compute()) {
53 end_frame_result.allocate_single_value();
54 end_frame_result.set_single_value(strip->right_handle(&context().get_scene()));
55 }
56
57 Result &location_result = this->get_result("Location");
58 if (location_result.should_compute()) {
59 location_result.allocate_single_value();
60 location_result.set_single_value(
61 float2(strip->data->transform->xofs, strip->data->transform->yofs));
62 }
63
64 Result &rotation_result = this->get_result("Rotation");
65 if (rotation_result.should_compute()) {
66 rotation_result.allocate_single_value();
67 rotation_result.set_single_value(strip->data->transform->rotation);
68 }
69
70 Result &scale_result = this->get_result("Scale");
71 if (scale_result.should_compute()) {
72 scale_result.allocate_single_value();
73 scale_result.set_single_value(
74 float2(strip->data->transform->scale_x, strip->data->transform->scale_y));
75 }
76 }
77};
78
79static void node_extra_info(NodeExtraInfoParams &parameters)
80{
81 SpaceNode *space_node = CTX_wm_space_node(&parameters.C);
84 row.text = RPT_("Node Unsupported");
85 row.tooltip = TIP_("The Strip Info node is only supported for sequencer compositing");
86 row.icon = ICON_STATUS_ERROR;
87 parameters.rows.append(std::move(row));
88 }
89}
90
92{
93 return new StripInfoOperation(context, node);
94}
95
96static void node_register()
97{
98 static bke::bNodeType ntype;
99
100 cmp_node_type_base(&ntype, "CompositorNodeSequencerStripInfo"_ustr);
101 ntype.ui_name = "Sequencer Strip Info";
102 ntype.ui_description = "Returns information about the active strip of the modifier";
103 ntype.nclass = NODE_CLASS_INPUT;
104 ntype.declare = node_declare;
107
109}
111
112} // namespace blender::nodes::node_composite_strip_info_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:478
#define RPT_(msgid)
#define TIP_(msgid)
#define NOD_REGISTER_NODE(REGISTER_FUNC)
const T & data(const Action &owning_action) const
virtual const Strip * get_strip() const
NodeOperation(Context &context, const bNode &node)
Result & get_result(StringRef identifier)
Definition operation.cc:40
Context & context() const
Definition operation.cc:57
bool should_compute() const
Definition result.cc:1124
void set_single_value(const T &value)
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static NodeOperation * get_compositor_operation(Context &context, const bNode &node)
static void node_declare(NodeDeclarationBuilder &b)
static void node_extra_info(NodeExtraInfoParams &parameters)
@ SNODE_COMPOSITOR_SEQUENCER
SpaceNode * CTX_wm_space_node(const bContext *C)
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
NodeExtraInfoFunction get_extra_info
Definition BKE_node.hh:412
NodeDeclareFunction declare
Definition BKE_node.hh:393
Vector< NodeExtraInfoRow > & rows