Blender V5.0
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"
11#include "UI_resources.hh"
12
14
16{
17 b.add_output<decl::Color>("Color").custom_draw([](CustomSocketDrawParams &params) {
18 params.layout.alignment_set(ui::LayoutAlign::Expand);
19 uiLayout &col = params.layout.column(false);
20 uiTemplateColorPicker(&col, &params.node_ptr, "value", true, false, false, true);
21 col.prop(&params.node_ptr, "value", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
22 });
23}
24
32
33static void node_init(bNodeTree * /*tree*/, bNode *node)
34{
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, "FunctionNodeInputColor", 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:447
#define FN_NODE_INPUT_COLOR
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, blender::StringRefNull propname, bool value_slider, bool lock, bool lock_luminosity, bool cubic)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
BMesh const char void * data
uint col
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
static void node_init(bNodeTree *, bNode *node)
static void node_declare(NodeDeclarationBuilder &b)
static void node_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
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