Blender V4.5
node_geo_set_grease_pencil_depth_mode.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
6
7#include "UI_interface.hh"
8
9#include "NOD_rna_define.hh"
10
11#include "RNA_enum_types.hh"
12
13#include "node_geometry_util.hh"
14
16
18{
19 b.use_custom_socket_order();
20 b.allow_any_socket_order();
21 b.add_default_layout();
22 b.add_input<decl::Geometry>("Grease Pencil")
23 .supported_type(GeometryComponent::Type::GreasePencil);
24 b.add_output<decl::Geometry>("Grease Pencil").propagate_all().align_with_previous();
25}
26
27static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
28{
29 layout->prop(ptr, "depth_order", UI_ITEM_NONE, "", ICON_NONE);
30}
31
32static void node_init(bNodeTree * /*tree*/, bNode *node)
33{
34 node->custom1 = 0;
35}
36
38{
39 GeometrySet geometry_set = params.extract_input<GeometrySet>("Grease Pencil");
40
41 geometry_set.modify_geometry_sets([&](GeometrySet &geometry) {
42 if (GreasePencil *grease_pencil = geometry.get_grease_pencil_for_write()) {
43 SET_FLAG_FROM_TEST(grease_pencil->flag,
44 params.node().custom1 == GREASE_PENCIL_STROKE_ORDER_3D,
46 }
47 });
48
49 params.set_output("Grease Pencil", std::move(geometry_set));
50}
51
52static void node_rna(StructRNA *srna)
53{
55 "depth_order",
56 "Depth Order",
57 "",
60}
61
62static void node_register()
63{
64 static blender::bke::bNodeType ntype;
65
66 geo_node_type_base(&ntype, "GeometryNodeSetGreasePencilDepth");
67 ntype.ui_name = "Set Grease Pencil Depth";
68 ntype.ui_description = "Set the Grease Pencil depth order to use";
71 ntype.declare = node_declare;
72 ntype.initfunc = node_init;
76
77 node_rna(ntype.rna_ext.srna);
78}
80
81} // namespace blender::nodes::node_geo_grease_pencil_set_depth_mode
Low-level operations for grease pencil.
#define NODE_CLASS_GEOMETRY
Definition BKE_node.hh:447
constexpr int NODE_DEFAULT_MAX_WIDTH
Definition BKE_node.hh:1225
#define SET_FLAG_FROM_TEST(value, test, flag)
@ GREASE_PENCIL_STROKE_ORDER_3D
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_inline_enum_accessors(member)
#define UI_ITEM_NONE
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_type_size(bNodeType &ntype, int width, int minwidth, int maxwidth)
Definition node.cc:5573
void node_register_type(bNodeType &ntype)
Definition node.cc:2748
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
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)
const EnumPropertyItem rna_enum_stroke_depth_order_items[]
StructRNA * srna
Definition RNA_types.hh:909
int16_t custom1
void modify_geometry_sets(ForeachSubGeometryCallback callback)
Defines a node type.
Definition BKE_node.hh:226
std::string ui_description
Definition BKE_node.hh:232
void(* initfunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:277
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:347
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:247
NodeDeclareFunction declare
Definition BKE_node.hh:355
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:4227