Blender V5.3
node_geo_mouse_position.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
6
8
10{
11 b.add_output<decl::Int>("Mouse X"_ustr)
12 .description("The region-space mouse X location, in pixels, increasing from 0 at the left");
13 b.add_output<decl::Int>("Mouse Y"_ustr)
14 .description(
15 "The region-space mouse Y location, in pixels, increasing from 0 at the bottom");
16 b.add_output<decl::Int>("Region Width"_ustr)
17 .description("The total X size of the region in pixels");
18 b.add_output<decl::Int>("Region Height"_ustr)
19 .description("The total Y size of the region in pixels");
20}
21
23{
24 if (!check_tool_context_and_error(params)) {
25 return;
26 }
27 const int2 mouse = params.user_data()->call_data->operator_data->mouse_position;
28 const int2 size = params.user_data()->call_data->operator_data->region_size;
29 params.set_output("Mouse X"_ustr, mouse.x);
30 params.set_output("Mouse Y"_ustr, mouse.y);
31 params.set_output("Region Width"_ustr, size.x);
32 params.set_output("Region Height"_ustr, size.y);
33}
34
35static void node_register()
36{
37 static bke::bNodeType ntype;
38 geo_node_type_base(&ntype, "GeometryNodeToolMousePosition"_ustr, GEO_NODE_TOOL_MOUSE_POSITION);
39 ntype.ui_name = "Mouse Position";
40 ntype.ui_description = "Retrieve the position of the mouse cursor";
41 ntype.enum_name_legacy = "TOOL_MOUSE_POSITION";
43 ntype.declare = node_declare;
47}
49
50} // namespace blender::nodes::node_geo_mouse_position_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:478
#define GEO_NODE_TOOL_MOUSE_POSITION
#define NOD_REGISTER_NODE(REGISTER_FUNC)
GeoNodesUserData * user_data() const
void set_output(const UString identifier, T &&value)
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static void node_declare(NodeDeclarationBuilder &b)
static void node_geo_exec(GeoNodeExecParams params)
void search_link_ops_for_tool_node(GatherLinkSearchOpParams &params)
bool check_tool_context_and_error(GeoNodeExecParams &params)
VecBase< int32_t, 2 > int2
void geo_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
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:385
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
Definition BKE_node.hh:409
NodeDeclareFunction declare
Definition BKE_node.hh:393