Files
test2/source/blender/nodes/function/nodes/node_fn_string_length.cc
Jacques Lucke 469a70dba9 Cleanup: Nodes: rename hide_label to optional_label internally
The new name better represents the actual meaning of the value.
"hide_value" was wrong because it didn't even hide the label in
many cases.

This property just indicates that the input is still understandable
even if the label is not drawn. It's up to the drawing code to make
the final decision whether the label should be drawn or not. This
option just gives it the opportunity to skip the label if that results
in a cleaner UI.
2025-09-28 17:30:21 +02:00

40 lines
1.2 KiB
C++

/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BLI_string_utf8.h"
#include "node_function_util.hh"
namespace blender::nodes::node_fn_string_length_cc {
static void node_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::String>("String").optional_label();
b.add_output<decl::Int>("Length");
}
static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
{
static auto str_len_fn = mf::build::SI1_SO<std::string, int>(
"String Length", [](const std::string &a) { return BLI_strlen_utf8(a.c_str()); });
builder.set_matching_fn(&str_len_fn);
}
static void node_register()
{
static blender::bke::bNodeType ntype;
fn_node_type_base(&ntype, "FunctionNodeStringLength", FN_NODE_STRING_LENGTH);
ntype.ui_name = "String Length";
ntype.ui_description = "Output the number of characters in the given string";
ntype.enum_name_legacy = "STRING_LENGTH";
ntype.nclass = NODE_CLASS_CONVERTER;
ntype.declare = node_declare;
ntype.build_multi_function = node_build_multi_function;
blender::bke::node_register_type(ntype);
}
NOD_REGISTER_NODE(node_register)
} // namespace blender::nodes::node_fn_string_length_cc