Blender V5.0
node_fn_input_int.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
8#include "UI_resources.hh"
9
11
13
15{
16 b.add_output<decl::Int>("Integer").custom_draw([](CustomSocketDrawParams &params) {
17 params.layout.alignment_set(ui::LayoutAlign::Expand);
18 uiLayout &row = params.layout.row(true);
19 row.prop(&params.node_ptr, "integer", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
21 row.prop(&params.socket_ptr, "pin_gizmo", UI_ITEM_NONE, "", ICON_GIZMO);
22 }
23 });
24 ;
25}
26
28{
29 const bNode &bnode = builder.node();
30 NodeInputInt *node_storage = static_cast<NodeInputInt *>(bnode.storage);
31 builder.construct_and_set_matching_fn<mf::CustomMF_Constant<int>>(node_storage->integer);
32}
33
34static void node_init(bNodeTree * /*tree*/, bNode *node)
35{
37 node->storage = data;
38}
39
40static void node_register()
41{
42 static blender::bke::bNodeType ntype;
43
44 fn_node_type_base(&ntype, "FunctionNodeInputInt", FN_NODE_INPUT_INT);
45 ntype.ui_name = "Integer";
46 ntype.ui_description =
47 "Provide an integer value that can be connected to other nodes in the tree";
48 ntype.enum_name_legacy = "INPUT_INT";
50 ntype.declare = node_declare;
51 ntype.initfunc = node_init;
56}
58
59} // namespace blender::nodes::node_fn_input_int_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:447
#define FN_NODE_INPUT_INT
#define NOD_REGISTER_NODE(REGISTER_FUNC)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
#define UI_ITEM_NONE
BMesh const char void * data
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
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
bool value_node_has_gizmo(const bNodeTree &tree, const bNode &node)
static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
static void node_declare(NodeDeclarationBuilder &b)
static void node_init(bNodeTree *, bNode *node)
void fn_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 * 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
NodeMultiFunctionBuildFunction build_multi_function
Definition BKE_node.hh:351
const char * enum_name_legacy
Definition BKE_node.hh:247
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)