godot icon indicating copy to clipboard operation
godot copied to clipboard

Make EditorSpinSlider display a slider for floats with a step of 1.0

Open Calinou opened this issue 1 year ago • 1 comments

Integers still don't display a slider (and use up/down arrows instead), so that they can be quickly distinguished from floats in the inspector. The original issue mentioned that integers could be made to look like floats in the inspector, but it means we'd be losing this particular UX affordance, so I didn't go as far as making all integers have a slider for now.

However, this now makes floats with a step of 1.0 look different from integers in the inspector. This complements https://github.com/godotengine/godot/pull/47502 in that sense.

  • This partially addresses https://github.com/godotengine/godot/issues/42809.

Preview

@export_range(0, 10, 1) var integer_step_1 := 1
@export_range(0.0, 10.0, 1.0) var float_step_1 := 1.0
@export_range(0.0, 10.0, 0.1) var float_step_0_1 := 1.0

Before

Screenshot_20240805_190042

After

Screenshot_20240805_191712

Calinou avatar Aug 05 '24 17:08 Calinou

Actually I read a bit too fast, I see now that this is changing the current behavior where exported ints with a step != 1 actually show a slider. This does warrant some more discussion IMO to make sure this is the UX users will expect.

akien-mga avatar Aug 26 '24 21:08 akien-mga

To be honest, until I saw this PR, I thought spinners were for integers and sliders were for floats in the inspector :rofl:

timothyqiu avatar Aug 29 '24 10:08 timothyqiu

I feel this new editing_integer property sounds like what one would expect hide_slider to control - but hide_slider controls both the slider (float) and the SpinBox arrows (int).

I wonder if we shouldn't instead deprecate hide_slider, and introduce a new enum property to choose what kind of control should be shown, like edit_widget with options Slider, Arrows, None.

Then EditorPropertyFloat and other float editors can use edit_widget == EDIT_WIDGET_SLIDER, while EditorPropertyInteger would use edit_widget == EDIT_WIDGET_INTEGER.

And the hide_slider property hint would be deprecated and replaced by no_edit_widget I guess?

Better naming suggestions welcome, we don't really use "widget" in Godot speak currently.

This would also add the possibility to use a slider with integers if desired, by making a custom EditorProperty for ints that sets EDIT_WIDGET_SLIDER. There could possibly also be property hints for this (slider, arrows) if there's actual demand that warrants adding more hints.

akien-mga avatar Sep 05 '24 16:09 akien-mga

introduce a new enum property to choose what kind of control should be shown

You mean in EditorSpinSlider? It would be inconvenient to use without a dedicated hint.

KoBeWi avatar Sep 06 '24 14:09 KoBeWi

introduce a new enum property to choose what kind of control should be shown

You mean in EditorSpinSlider? It would be inconvenient to use without a dedicated hint.

I suggest we could add dedicated hints for it, but realistically, this is mostly an implementation detail and in the vast majority of cases users wouldn't need to think about it or specify it manually. int properties would use the SpinBox and float properties would use the slider automatically.

We can drop exposing the functionality to users for now and just keep it internally (thus no hint strings needed). My main concern with this PR is how it exposes an editor implementation detail as a public property.

akien-mga avatar Sep 17 '24 07:09 akien-mga

Thanks!

Repiteo avatar Jan 31 '25 15:01 Repiteo