-
-
Notifications
You must be signed in to change notification settings - Fork 105
Description
Describe the project you are working on
Godot etc.
Describe the problem or limitation you are having in your project
Right now SpinBox has these two properties - suffix and prefix. One is a string that appears before value the other is after value. When the value is changed, these strings are merged to form the final text.
The user has no control over the actual text. You can set just these two strings and they will always appear with with this format: [prefix] [value] [suffix]. You can't remove the spaces. You can't format the value string to pad zeros or decimals or whatever. It's just very rigid.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Instead of having two properties, let's have one: format.
When format is empty, nothing really happens. The SpinBox will display its numeric value.
When format is non-empty, the SpinBox will display the text as: format % value. This way you have absolute control over how the value is displayed. You can add prefix, suffix, separators, change precision. Basically do anything, the only limitation is that you need to provide exactly one placeholder value, %s, %d or %f. The solution is very flexible overall.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
When
formatis non-empty, the SpinBox will display the text as:format % value.
I originally came up with this idea for my SliderLabel custom node. E.g. with format %2.f%% the value is displayed like this:

The value is padded to 2 decimal numbers and adds % prefix without any space.
If this enhancement will not be used often, can it be worked around with a few lines of script?
You can hack this by editing value of SpinBox's LineEdit manually, but this won't even work lol
Is there a reason why this should be core and not an add-on in the asset library?
It's about a core node.