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.
This commit is contained in:
@@ -1135,7 +1135,7 @@ static void std_node_socket_draw(
|
||||
}
|
||||
|
||||
const StringRefNull label = text;
|
||||
text = (socket_decl && socket_decl->hide_label) ? "" : text;
|
||||
text = (socket_decl && socket_decl->optional_label) ? "" : text;
|
||||
|
||||
/* Some socket types draw the gizmo icon in a special way to look better. All others use a
|
||||
* fallback default code path. */
|
||||
|
||||
@@ -110,7 +110,7 @@ class SocketTooltipBuilder {
|
||||
if (socket_.type == SOCK_MENU) {
|
||||
return true;
|
||||
}
|
||||
if (socket_.runtime->declaration && socket_.runtime->declaration->hide_label) {
|
||||
if (socket_.runtime->declaration && socket_.runtime->declaration->optional_label) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -215,7 +215,11 @@ class SocketDeclaration : public ItemDeclaration {
|
||||
eNodeSocketInOut in_out;
|
||||
/** Socket type that corresponds to this socket declaration. */
|
||||
eNodeSocketDatatype socket_type;
|
||||
bool hide_label = false;
|
||||
/**
|
||||
* Indicates that the meaning of the socket values is clear even if the label is not shown. This
|
||||
* can result in cleaner UIs in some cases. The drawing code will still draw the label sometimes.
|
||||
*/
|
||||
bool optional_label = false;
|
||||
bool hide_value = false;
|
||||
bool compact = false;
|
||||
bool is_multi_input = false;
|
||||
@@ -316,7 +320,7 @@ class BaseSocketDeclarationBuilder {
|
||||
public:
|
||||
virtual ~BaseSocketDeclarationBuilder() = default;
|
||||
|
||||
BaseSocketDeclarationBuilder &hide_label(bool value = true);
|
||||
BaseSocketDeclarationBuilder &optional_label(bool value = true);
|
||||
|
||||
BaseSocketDeclarationBuilder &hide_value(bool value = true);
|
||||
|
||||
|
||||
@@ -45,10 +45,10 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
|
||||
b.add_input<decl::String>("A", "A_STR")
|
||||
.translation_context(BLT_I18NCONTEXT_ID_NODETREE)
|
||||
.hide_label();
|
||||
.optional_label();
|
||||
b.add_input<decl::String>("B", "B_STR")
|
||||
.translation_context(BLT_I18NCONTEXT_ID_NODETREE)
|
||||
.hide_label();
|
||||
.optional_label();
|
||||
|
||||
b.add_input<decl::Float>("C").default_value(0.9f);
|
||||
b.add_input<decl::Float>("Angle").default_value(0.0872665f).subtype(PROP_ANGLE);
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace blender::nodes::node_fn_find_in_string_cc {
|
||||
|
||||
static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_input<decl::String>("String").hide_label();
|
||||
b.add_input<decl::String>("String").optional_label();
|
||||
b.add_input<decl::String>("Search");
|
||||
b.add_output<decl::Int>("First Found");
|
||||
b.add_output<decl::Int>("Count");
|
||||
|
||||
@@ -33,7 +33,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
b.use_custom_socket_order();
|
||||
b.allow_any_socket_order();
|
||||
|
||||
b.add_input<decl::String>("Format").hide_label().description(
|
||||
b.add_input<decl::String>("Format").optional_label().description(
|
||||
"Format string using a Python and path template compatible syntax. For example, \"Count: "
|
||||
"{}\" would replace the {} with the first input value.");
|
||||
b.add_output<decl::String>("String").align_with_previous();
|
||||
|
||||
@@ -36,9 +36,9 @@ const EnumPropertyItem rna_enum_node_match_string_items[] = {
|
||||
|
||||
static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_input<decl::String>("String").hide_label().is_default_link_socket();
|
||||
b.add_input<decl::String>("String").optional_label().is_default_link_socket();
|
||||
b.add_input<decl::Menu>("Operation").static_items(rna_enum_node_match_string_items);
|
||||
b.add_input<decl::String>("Key").hide_label().description(
|
||||
b.add_input<decl::String>("Key").optional_label().description(
|
||||
"The string to find in the input string");
|
||||
b.add_output<decl::Bool>("Result");
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.use_custom_socket_order();
|
||||
b.allow_any_socket_order();
|
||||
b.add_input<decl::String>("String").hide_label();
|
||||
b.add_input<decl::String>("String").optional_label();
|
||||
b.add_output<decl::String>("String").align_with_previous();
|
||||
b.add_input<decl::String>("Find").description("The string to find in the input string");
|
||||
b.add_input<decl::String>("Replace").description("The string to replace each match with");
|
||||
|
||||
@@ -12,7 +12,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.use_custom_socket_order();
|
||||
b.allow_any_socket_order();
|
||||
b.add_input<decl::String>("String").hide_label();
|
||||
b.add_input<decl::String>("String").optional_label();
|
||||
b.add_output<decl::String>("String").align_with_previous();
|
||||
b.add_input<decl::Int>("Position");
|
||||
b.add_input<decl::Int>("Length").min(0).default_value(10);
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace blender::nodes::node_fn_string_length_cc {
|
||||
|
||||
static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_input<decl::String>("String").hide_label();
|
||||
b.add_input<decl::String>("String").optional_label();
|
||||
b.add_output<decl::Int>("Length");
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace blender::nodes::node_fn_string_to_value_cc {
|
||||
|
||||
static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_input<decl::String>("String").hide_label();
|
||||
b.add_input<decl::String>("String").optional_label();
|
||||
|
||||
const bNode *node = b.node_or_null();
|
||||
if (node != nullptr) {
|
||||
|
||||
@@ -27,7 +27,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
b.add_output<decl::Float>("Orthographic Scale")
|
||||
.description("Orthographic camera scale (similar to zoom)");
|
||||
|
||||
b.add_input<decl::Object>("Camera").hide_label();
|
||||
b.add_input<decl::Object>("Camera").optional_label();
|
||||
}
|
||||
|
||||
static void node_geo_exec(GeoNodeExecParams params)
|
||||
|
||||
@@ -27,7 +27,7 @@ NODE_STORAGE_FUNCS(NodeGeometryCollectionInfo)
|
||||
|
||||
static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_input<decl::Collection>("Collection").hide_label();
|
||||
b.add_input<decl::Collection>("Collection").optional_label();
|
||||
b.add_input<decl::Bool>("Separate Children")
|
||||
.description(
|
||||
"Output each child of the collection as a separate instance, sorted alphabetically");
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace blender::nodes::node_geo_get_named_grid_cc {
|
||||
static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_input<decl::Geometry>("Volume").description("Volume to take a named grid out of");
|
||||
b.add_input<decl::String>("Name").hide_label();
|
||||
b.add_input<decl::String>("Name").optional_label();
|
||||
b.add_input<decl::Bool>("Remove").default_value(true).translation_context(
|
||||
BLT_I18NCONTEXT_OPERATOR_DEFAULT);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace blender::nodes::node_geo_image_info_cc {
|
||||
|
||||
static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_input<decl::Image>("Image").hide_label();
|
||||
b.add_input<decl::Image>("Image").optional_label();
|
||||
b.add_input<decl::Int>("Frame").min(0).description(
|
||||
"Which frame to use for videos. Note that different frames in videos can "
|
||||
"have different resolutions");
|
||||
|
||||
@@ -22,7 +22,7 @@ NODE_STORAGE_FUNCS(NodeGeometryImageTexture)
|
||||
|
||||
static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_input<decl::Image>("Image").hide_label();
|
||||
b.add_input<decl::Image>("Image").optional_label();
|
||||
b.add_input<decl::Vector>("Vector")
|
||||
.implicit_field(NODE_DEFAULT_INPUT_POSITION_FIELD)
|
||||
.description("Texture coordinates from 0 to 1");
|
||||
|
||||
@@ -22,7 +22,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
b.add_input<decl::String>("Path")
|
||||
.subtype(PROP_FILEPATH)
|
||||
.path_filter("*.csv")
|
||||
.hide_label()
|
||||
.optional_label()
|
||||
.description("Path to a CSV file");
|
||||
b.add_input<decl::String>("Delimiter").default_value(",");
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
b.add_input<decl::String>("Path")
|
||||
.subtype(PROP_FILEPATH)
|
||||
.path_filter("*.obj")
|
||||
.hide_label()
|
||||
.optional_label()
|
||||
.description("Path to a OBJ file");
|
||||
|
||||
b.add_output<decl::Geometry>("Instances");
|
||||
|
||||
@@ -20,7 +20,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
b.add_input<decl::String>("Path")
|
||||
.subtype(PROP_FILEPATH)
|
||||
.path_filter("*.ply")
|
||||
.hide_label()
|
||||
.optional_label()
|
||||
.description("Path to a PLY file");
|
||||
|
||||
b.add_output<decl::Geometry>("Mesh");
|
||||
|
||||
@@ -22,7 +22,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
b.add_input<decl::String>("Path")
|
||||
.subtype(PROP_FILEPATH)
|
||||
.path_filter("*.stl")
|
||||
.hide_label()
|
||||
.optional_label()
|
||||
.description("Path to a STL file");
|
||||
|
||||
b.add_output<decl::Geometry>("Mesh");
|
||||
|
||||
@@ -19,7 +19,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
b.add_input<decl::String>("Path")
|
||||
.subtype(PROP_FILEPATH)
|
||||
.path_filter("*.txt")
|
||||
.hide_label()
|
||||
.optional_label()
|
||||
.description("Path to a text file");
|
||||
|
||||
b.add_output<decl::String>("String");
|
||||
|
||||
@@ -18,7 +18,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
b.add_input<decl::String>("Path")
|
||||
.subtype(PROP_FILEPATH)
|
||||
.path_filter("*.vdb")
|
||||
.hide_label()
|
||||
.optional_label()
|
||||
.description("Path to a OpenVDB file");
|
||||
|
||||
b.add_output<decl::Geometry>("Volume");
|
||||
|
||||
@@ -99,7 +99,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
input.supports_field();
|
||||
}
|
||||
/* Labels are ugly in combination with data-block pickers and are usually disabled. */
|
||||
input.hide_label(ELEM(data_type, SOCK_OBJECT, SOCK_IMAGE, SOCK_COLLECTION, SOCK_MATERIAL));
|
||||
input.optional_label(ELEM(data_type, SOCK_OBJECT, SOCK_IMAGE, SOCK_COLLECTION, SOCK_MATERIAL));
|
||||
input.structure_type(structure_type);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
const bNode *node = b.node_or_null();
|
||||
|
||||
b.add_input<decl::String>("Name").is_attribute_name().hide_label();
|
||||
b.add_input<decl::String>("Name").is_attribute_name().optional_label();
|
||||
|
||||
if (node != nullptr) {
|
||||
const NodeGeometryInputNamedAttribute &storage = node_storage(*node);
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace blender::nodes::node_geo_input_named_layer_selection__cc {
|
||||
|
||||
static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_input<decl::String>("Name").is_layer_name().hide_label();
|
||||
b.add_input<decl::String>("Name").is_layer_name().optional_label();
|
||||
b.add_output<decl::Bool>("Selection").field_source_reference_all();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace blender::nodes::node_geo_material_selection_cc {
|
||||
|
||||
static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_input<decl::Material>("Material").hide_label(true);
|
||||
b.add_input<decl::Material>("Material").optional_label(true);
|
||||
b.add_output<decl::Bool>("Selection").field_source();
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ static void node_declare(blender::nodes::NodeDeclarationBuilder &b)
|
||||
input.supports_field();
|
||||
}
|
||||
/* Labels are ugly in combination with data-block pickers and are usually disabled. */
|
||||
input.hide_label(ELEM(data_type, SOCK_OBJECT, SOCK_IMAGE, SOCK_COLLECTION, SOCK_MATERIAL));
|
||||
input.optional_label(ELEM(data_type, SOCK_OBJECT, SOCK_IMAGE, SOCK_COLLECTION, SOCK_MATERIAL));
|
||||
input.structure_type(value_structure_type);
|
||||
auto &item_output = b.add_output<decl::Bool>(enum_item.name, std::move(identifier))
|
||||
.align_with_previous()
|
||||
|
||||
@@ -29,7 +29,7 @@ NODE_STORAGE_FUNCS(NodeGeometryObjectInfo)
|
||||
|
||||
static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_input<decl::Object>("Object").hide_label();
|
||||
b.add_input<decl::Object>("Object").optional_label();
|
||||
b.add_input<decl::Bool>("As Instance")
|
||||
.description(
|
||||
"Output the entire object as single instance. "
|
||||
|
||||
@@ -34,7 +34,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
b.add_input<decl::Menu>("Pattern Mode")
|
||||
.static_items(pattern_mode_items)
|
||||
.description("How the attributes to remove are chosen");
|
||||
b.add_input<decl::String>("Name").is_attribute_name().hide_label();
|
||||
b.add_input<decl::String>("Name").is_attribute_name().optional_label();
|
||||
}
|
||||
|
||||
struct RemoveAttributeParams {
|
||||
|
||||
@@ -12,7 +12,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
b.allow_any_socket_order();
|
||||
b.add_input<decl::Geometry>("Geometry").description("Geometry to override the name of");
|
||||
b.add_output<decl::Geometry>("Geometry").propagate_all().align_with_previous();
|
||||
b.add_input<decl::String>("Name").hide_label();
|
||||
b.add_input<decl::String>("Name").optional_label();
|
||||
}
|
||||
|
||||
static void node_geo_exec(GeoNodeExecParams params)
|
||||
|
||||
@@ -37,7 +37,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
b.add_input<decl::Color>("Color")
|
||||
.default_value(ColorGeometry4f(1.0f, 1.0f, 1.0f, 1.0f))
|
||||
.field_on_all()
|
||||
.hide_label();
|
||||
.optional_label();
|
||||
b.add_input<decl::Float>("Opacity").default_value(1.0f).min(0.0f).max(1.0f).field_on_all();
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
.align_with_previous()
|
||||
.description("Geometry to assign a material to");
|
||||
b.add_input<decl::Bool>("Selection").default_value(true).hide_value().field_on_all();
|
||||
b.add_input<decl::Material>("Material").hide_label();
|
||||
b.add_input<decl::Material>("Material").optional_label();
|
||||
}
|
||||
|
||||
static void assign_material_to_id_geometry(ID *id,
|
||||
|
||||
@@ -39,7 +39,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
.description("Geometry to store a new attribute with the given name on");
|
||||
b.add_output<decl::Geometry>("Geometry").propagate_all().align_with_previous();
|
||||
b.add_input<decl::Bool>("Selection").default_value(true).hide_value().field_on_all();
|
||||
b.add_input<decl::String>("Name").is_attribute_name().hide_label();
|
||||
b.add_input<decl::String>("Name").is_attribute_name().optional_label();
|
||||
|
||||
if (node != nullptr) {
|
||||
const NodeGeometryStoreNamedAttribute &storage = node_storage(*node);
|
||||
|
||||
@@ -25,7 +25,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
b.add_default_layout();
|
||||
b.add_input<decl::Geometry>("Volume").description("Volume geometry to add a grid to");
|
||||
b.add_output<decl::Geometry>("Volume").align_with_previous();
|
||||
b.add_input<decl::String>("Name").hide_label();
|
||||
b.add_input<decl::String>("Name").optional_label();
|
||||
|
||||
const bNode *node = b.node_or_null();
|
||||
if (!node) {
|
||||
|
||||
@@ -29,7 +29,7 @@ NODE_STORAGE_FUNCS(NodeGeometryStringToCurves)
|
||||
|
||||
static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_input<decl::String>("String").hide_label();
|
||||
b.add_input<decl::String>("String").optional_label();
|
||||
b.add_input<decl::Float>("Size").default_value(1.0f).min(0.0f).subtype(PROP_DISTANCE);
|
||||
b.add_input<decl::Float>("Character Spacing").default_value(1.0f).min(0.0f);
|
||||
b.add_input<decl::Float>("Word Spacing").default_value(1.0f).min(0.0f);
|
||||
|
||||
@@ -24,7 +24,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
|
||||
b.add_input<decl::Bool>("Show").default_value(true).hide_value();
|
||||
b.add_output<decl::Bool>("Show").align_with_previous();
|
||||
b.add_input<decl::String>("Message").hide_label();
|
||||
b.add_input<decl::String>("Message").optional_label();
|
||||
}
|
||||
|
||||
class LazyFunctionForWarningNode : public LazyFunction {
|
||||
|
||||
@@ -538,9 +538,9 @@ BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::dependent_field(
|
||||
return *this;
|
||||
}
|
||||
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::hide_label(bool value)
|
||||
BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::optional_label(bool value)
|
||||
{
|
||||
decl_base_->hide_label = value;
|
||||
decl_base_->optional_label = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user