Blender V4.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
7#include "BLI_math_vector.h"
8
9#include "UI_interface.hh"
10#include "UI_resources.hh"
11
13
15{
16 b.add_output<decl::Color>("Color");
17}
18
19static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
20{
21 uiTemplateColorPicker(layout, ptr, "value", true, false, false, true);
22 uiItemR(layout, ptr, "value", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
23}
24
26{
27 const bNode &bnode = builder.node();
28 NodeInputColor *node_storage = static_cast<NodeInputColor *>(bnode.storage);
29 blender::ColorGeometry4f color = (ColorGeometry4f)node_storage->color;
30 builder.construct_and_set_matching_fn<blender::mf::CustomMF_Constant<ColorGeometry4f>>(color);
31}
32
33static void node_init(bNodeTree * /*tree*/, bNode *node)
34{
35 NodeInputColor *data = MEM_cnew<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 blender::bke::bNodeType ntype;
43
44 fn_node_type_base(&ntype, FN_NODE_INPUT_COLOR, "Color", NODE_CLASS_INPUT);
45 ntype.declare = node_declare;
46 ntype.initfunc = node_init;
52}
54
55} // namespace blender::nodes::node_fn_input_color_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:404
MINLINE void copy_v4_fl4(float v[4], float x, float y, float z, float w)
#define NOD_REGISTER_NODE(REGISTER_FUNC)
void uiTemplateColorPicker(uiLayout *layout, PointerRNA *ptr, const char *propname, bool value_slider, bool lock, bool lock_luminosity, bool cubic)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
local_group_size(16, 16) .push_constant(Type b
void node_type_storage(bNodeType *ntype, const char *storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
Definition node.cc:4632
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
static void node_init(bNodeTree *, bNode *node)
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_declare(NodeDeclarationBuilder &b)
static void node_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
Definition BLI_color.hh:337
void fn_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
void node_free_standard_storage(bNode *node)
Definition node_util.cc:46
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
Definition node_util.cc:58
void * storage
Defines a node type.
Definition BKE_node.hh:218
void(* initfunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:267
NodeMultiFunctionBuildFunction build_multi_function
Definition BKE_node.hh:336
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:238
NodeDeclareFunction declare
Definition BKE_node.hh:347
PointerRNA * ptr
Definition wm_files.cc:4126