Blender V5.0
node_geo_gizmo_linear.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
6
7#include "NOD_rna_define.hh"
8
9#include "RNA_enum_types.hh"
10
12#include "UI_resources.hh"
13
15
17
19{
20 b.add_input<decl::Float>("Value").hide_value().multi_input();
21 b.add_input<decl::Vector>("Position").subtype(PROP_TRANSLATION);
22 b.add_input<decl::Vector>("Direction").default_value({0, 0, 1}).subtype(PROP_XYZ);
23 b.add_output<decl::Geometry>("Transform");
24}
25
26static void node_init(bNodeTree * /*tree*/, bNode *node)
27{
29 node->storage = storage;
30}
31
32static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
33{
34 layout->prop(ptr, "color_id", UI_ITEM_NONE, "", ICON_NONE);
35 layout->prop(ptr, "draw_style", UI_ITEM_NONE, "", ICON_NONE);
36}
37
38static void node_rna(StructRNA *srna)
39{
40 PropertyRNA *prop;
41
43 "color_id",
44 "Color",
45 "",
48 prop = RNA_def_node_enum(srna,
49 "draw_style",
50 "Draw Style",
51 "",
53 NOD_storage_enum_accessors(draw_style));
55}
56
57static void node_register()
58{
59 static bke::bNodeType ntype;
60 geo_node_type_base(&ntype, "GeometryNodeGizmoLinear", GEO_NODE_GIZMO_LINEAR);
61 ntype.ui_name = "Linear Gizmo";
62 ntype.ui_description = "Show a linear gizmo in the viewport for a value";
63 ntype.enum_name_legacy = "GIZMO_LINEAR";
66 ntype, "NodeGeometryLinearGizmo", node_free_standard_storage, node_copy_standard_storage);
67 ntype.declare = node_declare;
69 ntype.initfunc = node_init;
71
72 node_rna(ntype.rna_ext.srna);
73}
75
76} // namespace blender::nodes::node_geo_gizmo_linear_cc
#define NODE_CLASS_INTERFACE
Definition BKE_node.hh:459
#define NODE_STORAGE_FUNCS(StorageT)
Definition BKE_node.hh:1240
#define GEO_NODE_GIZMO_LINEAR
#define BLT_I18NCONTEXT_ID_NODETREE
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_storage_enum_accessors(member)
@ PROP_XYZ
Definition RNA_types.hh:269
@ PROP_TRANSLATION
Definition RNA_types.hh:261
#define UI_ITEM_NONE
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
Definition node.cc:5414
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_init(bNodeTree *, bNode *node)
static void node_declare(NodeDeclarationBuilder &b)
PropertyRNA * RNA_def_node_enum(StructRNA *srna, const char *identifier, const char *ui_name, const char *ui_description, const EnumPropertyItem *static_items, const EnumRNAAccessors accessors, std::optional< int > default_value, const EnumPropertyItemFunc item_func, const bool allow_animation)
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
void node_free_standard_storage(bNode *node)
Definition node_util.cc:42
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
Definition node_util.cc:54
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
const EnumPropertyItem rna_enum_geometry_nodes_linear_gizmo_draw_style_items[]
const EnumPropertyItem rna_enum_geometry_nodes_gizmo_color_items[]
StructRNA * srna
void * storage
Defines a node type.
Definition BKE_node.hh:238
std::string ui_description
Definition BKE_node.hh:244
void(* initfunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:289
const char * enum_name_legacy
Definition BKE_node.hh:247
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:259
NodeDeclareFunction declare
Definition BKE_node.hh:362
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)
PointerRNA * ptr
Definition wm_files.cc:4238