Blender V5.0
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
8#include "UI_resources.hh"
9
10#include "NOD_rna_define.hh"
11
12#include "RNA_enum_types.hh"
13
15
16#include "node_geometry_util.hh"
17
19
21{
22 b.use_custom_socket_order();
23 b.allow_any_socket_order();
24 b.add_default_layout();
25 b.add_input<decl::Geometry>("Grease Pencil")
26 .supported_type(GeometryComponent::Type::GreasePencil)
27 .description("Grease Pencil to set the depth order of");
28 b.add_output<decl::Geometry>("Grease Pencil").propagate_all().align_with_previous();
29}
30
31static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
32{
33 layout->prop(ptr, "depth_order", UI_ITEM_NONE, "", ICON_NONE);
34}
35
36static void node_init(bNodeTree * /*tree*/, bNode *node)
37{
38 node->custom1 = 0;
39}
40
42{
43 GeometrySet geometry_set = params.extract_input<GeometrySet>("Grease Pencil");
44
46 if (GreasePencil *grease_pencil = geometry.get_grease_pencil_for_write()) {
47 SET_FLAG_FROM_TEST(grease_pencil->flag,
48 params.node().custom1 == GREASE_PENCIL_STROKE_ORDER_3D,
50 }
51 });
52
53 params.set_output("Grease Pencil", std::move(geometry_set));
54}
55
56static void node_rna(StructRNA *srna)
57{
59 "depth_order",
60 "Depth Order",
61 "",
64}
65
66static void node_register()
67{
68 static blender::bke::bNodeType ntype;
69
70 geo_node_type_base(&ntype, "GeometryNodeSetGreasePencilDepth");
71 ntype.ui_name = "Set Grease Pencil Depth";
72 ntype.ui_description = "Set the Grease Pencil depth order to use";
75 ntype.declare = node_declare;
76 ntype.initfunc = node_init;
80
81 node_rna(ntype.rna_ext.srna);
82}
84
85} // namespace blender::nodes::node_geo_grease_pencil_set_depth_mode
Low-level operations for grease pencil.
#define NODE_CLASS_GEOMETRY
Definition BKE_node.hh:461
constexpr int NODE_DEFAULT_MAX_WIDTH
Definition BKE_node.hh:1250
#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:5384
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
void foreach_real_geometry(bke::GeometrySet &geometry, FunctionRef< void(bke::GeometrySet &geometry_set)> fn)
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
int16_t custom1
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
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:354
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