Page MenuHome

Geometry Nodes: Add node labels to Attribute maths nodes
ClosedPublic

Authored by Charlie Jolly (charlie) on Mar 17 2021, 4:11 PM.

Details

Summary

This adds the operator name to the node label which is consistent with the shading nodes. The vector node has Vector as a prefix.

The Attribute nodes already have a different coloured header.

The same label is used when collapsing nodes, this helps readability.

Diff Detail

Repository
rB Blender
Branch
master
Build Status
Buildable 13570
Build 13570: arc lint + arc unit

Event Timeline

Charlie Jolly (charlie) requested review of this revision.Mar 17 2021, 4:11 PM
Charlie Jolly (charlie) created this revision.
Charlie Jolly (charlie) edited the summary of this revision. (Show Details)Mar 17 2021, 4:14 PM
Charlie Jolly (charlie) edited the summary of this revision. (Show Details)Mar 24 2021, 3:57 PM
Hans Goudey (HooglyBoogly) added inline comments.
source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc
161–163

Using std::string is nice and we should do it more, but in this case I think using BLI_snprintf would probably be simpler?

That or const std::string new_label = "Vector " + name; at least.

Charlie Jolly (charlie) marked an inline comment as done.
Charlie Jolly (charlie) edited the summary of this revision. (Show Details)Mar 24 2021, 6:12 PM
source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc
162

Hmm, do you think translation will work on the string after you've added "Vector " to it? I'm not sure it would. Sort of a tricky situation...

Charlie Jolly (charlie) marked an inline comment as done.Mar 26 2021, 10:27 AM
Charlie Jolly (charlie) added inline comments.
source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc
162

I think it should because BLI_strncpy is just copying the translated string back to itself. It is set in BLI_snprintf then translated then copied back.

source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc
162

My point is, IFACE will only work if the string already has a translation. And since the translations don't necessarily know about the string "Vector Add" (it is generated dynamically right here), it will likely not be translated.

A quick and dirty improvement is probably to simply use IFACE on "Vector %s", and just translate the two strings separately. Hopefully that makes sense for most languages.

Charlie Jolly (charlie) updated this revision to Diff 35647.EditedMar 27 2021, 12:24 AM
Charlie Jolly (charlie) marked an inline comment as done.

Use IFACE_ macro with both parts of the label.
Use Vector: instead of Vector as this maybe better for translations.
BLI_snprintf(label, maxlen, IFACE_("Vector: %s"), IFACE_(name));

Charlie Jolly (charlie) marked an inline comment as done.Mar 27 2021, 12:24 AM

I like this, the only thing I would change is not using the colon. I see why you used it but I'm not sure it's worth it. Maybe Pablo has an opinion on that.

Looking good!

the only thing I would change is not using the colon.

I agree, we are trying to avoid using colon for labels. Most of the time it adds noise as the label is self explanatory without it.

This revision is now accepted and ready to land.Jul 27 2021, 1:49 PM