Blender V5.3
node_fn_input_color.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
9#include "UI_interface.hh"
11#include "UI_resources.hh"
12
14
16{
17 b.add_output<decl::Color>("Color"_ustr).custom_draw([](CustomSocketDrawParams &params) {
19 ui::Layout &col = params.layout.column(false);
20 template_color_picker(&col, &params.node_ptr, "value", true, false, false, false);
21 col.prop(&params.node_ptr, "value", ui::ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
22 });
23}
24
26{
27 const bNode &bnode = builder.node();
28 NodeInputColor *node_storage = static_cast<NodeInputColor *>(bnode.storage);
30 builder.construct_and_set_matching_fn<mf::CustomMF_Constant<ColorGeometry4f>>(color);
31}
32
33static void node_init(bNodeTree * /*tree*/, bNode *node)
34{
35 NodeInputColor *data = MEM_new<NodeInputColor>(__func__);
36 copy_v4_fl4(data->color, 0.5f, 0.5f, 0.5f, 1.0f);
37 node->storage = data;
38}
39
40static void node_register()
41{
42 static bke::bNodeType ntype;
43
44 fn_node_type_base(&ntype, "FunctionNodeInputColor"_ustr, FN_NODE_INPUT_COLOR);
45 ntype.ui_name = "Color";
46 ntype.ui_description = "Output a color value chosen with the color picker widget";
47 ntype.enum_name_legacy = "INPUT_COLOR";
49 ntype.declare = node_declare;
50 ntype.initfunc = node_init;
55}
57
58} // namespace blender::nodes::node_fn_input_color_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:478
#define FN_NODE_INPUT_COLOR
#define NOD_REGISTER_NODE(REGISTER_FUNC)
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
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:6166
static void node_init(bNodeTree *, bNode *node)
static void node_build_multi_function(nodes::NodeMultiFunctionBuilder &builder)
static void node_declare(NodeDeclarationBuilder &b)
MINLINE void copy_v4_fl4(float v[4], float x, float y, float z, float w)
BMesh const char void * data
void fn_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
Definition node_util.cc:57
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
void node_free_standard_storage(bNode *node)
Definition node_util.cc:45
Defines a node type.
Definition BKE_node.hh:265
std::string ui_description
Definition BKE_node.hh:271
NodeMultiFunctionBuildFunction build_multi_function
Definition BKE_node.hh:382
void(*) initfunc(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:320
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeDeclareFunction declare
Definition BKE_node.hh:393
void alignment_set(LayoutAlign alignment)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
Layout & column(bool align)