A Slider and EditBox "hybrid"
Huoi opened this issue · comments
I would love to see new type of Widget that mimics the behaviour of the variable inspectors in the Unity game engine. Basically an edit box that you can drag left to right to change the value inside it, and there's no limit.
I looked into the topic a bit, and found some examples where this is used in other programs.
For example the Godot Engine has a class called EditorSpinSlider,
which exactly represents the proposed widget. Although the name of the class seems to be a bit wrong, as spin widgets normally refer to the arrows which allow you to change a numerical value, like in @texus's screenshot of the blender widget, which then probably would be called SpinSlider
.
The wanted widget here would then be something like EditBoxSlider
, an EditBox whose numerical value can be changed through a slider, or through dragging the mouse.
Another tgui widget which would probably benefit from adding the mouse dragging option, as it is quite similar, is SpinControl
.
So, I would maybe propose to create two new Widgets SpinSlider
and EditBoxSlider
, as well as adding the option to SpinControl
, to change its numerical value through dragging the mouse.
If SpinSlider
gets implemented it would probably be beneficial to change the name of SpinControl
to SpinBox
, as it then better represents its actual use.
I would be happy to contribute a lot of these changes, but of course I would need some feedback to these ideas first 😄.
Something that just came to mind with Blender's SpinSlider
is, that maybe it shouldn't even be named SpinSlider
, as there is no slider involved with the widget. Instead it's just a horizontal SpinBox
instead of the normal vertical SpinBox
. Which also gives the question if there maybe should be a HSpinBox
and a VSpinBox
.
Although the name of the class seems to be a bit wrong, as spin widgets normally refer to the arrows which allow you to change a numerical value
Interesting.
It doesn't appear to be something that everyone agrees on though, e.g. in wxWidgets the SpinButton is also just the arrows while the SpinCtrl is the edit box with arrows. (I believe I might have even used wxWidgets' documentation originally to choose the "SpinButton" name)
I would normally go with the Windows definition, but changing the names now would really break everyone's code that uses either one of these widgets (renaming a widget is fine, it's renaming to something that previously existed that causes issues).
Although if the names would swap, then now would actually be the best moment to do it as it will get even more painful to change after I release the 1.0 release candidate.
Another tgui widget which would probably benefit from adding the mouse dragging option, as it is quite similar, is SpinControl.
How do you imagine dragging in SpinControl exactly? Changing the value when dragging up or down on the text?
So, I would maybe propose to create two new Widgets SpinSlider and EditBoxSlider, as well as adding the option to SpinControl, to change its numerical value through dragging the mouse.
I wouldn't add too many new widgets. All those widgets will be very similar, so it can create a lot of extra maintenance work each time a change is needed to them (and I'm not convinced SpinControl needs dragging for this reason as well). These are also extremely niche widgets, so it might be a lot of work to write widgets that almost nobody is going to use.
I definitely see a use case for a widget that combines an edit box and a slider (even if it is niche), I just don't think we need to go and provide every single possible combination of such a widget.
Something that just came to mind with Blender's SpinSlider is, that maybe it shouldn't even be named SpinSlider, as there is no slider involved with the widget.
Blender's SpinSlider isn't just a horizontal spin box though, you can drag in the middle to move the value.
Although if the names would swap, then now would actually be the best moment to do it as it will get even more painful to change after I release the 1.0 release candidate.
Of course SpinBox
would make it more readable as a combination of the SpinButton
and EditBox
widgets, so I'm a bit conflicted on this. But I think if we are not implementing the other widgets, there should be no need for renaming SpinControl
then, as well as it being just too drastic of a name change for users of TGUI.
How do you imagine dragging in SpinControl exactly? Changing the value when dragging up or down on the text?
Exactly, though I previously thought that this was implemented in Godot, which is why I suggested it. But the only widget there, that uses the mouse dragging functionality is EditorSpinSlider
, so combined with your thoughts about it, its implementation is probably not required.
I definitely see a use case for a widget that combines an edit box and a slider (even if it is niche), I just don't think we need to go and provide every single possible combination of such a widget.
It definitely isn't a necessity to implement every possible variation of this type of widget. So it's really only important to add the EditBoxSlider
, which certainly is enough.
Blender's SpinSlider isn't just a horizontal spin box though, you can drag in the middle to move the value.
Yes, that is true, but what I meant with my comment was more so, that the Slider widget isn't involved with it. It uses mouse dragging to change the value, but doesn't have the slider knob, which I think defines the widget.