Add custom mouse step and range properties to SliderBar #6376
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With this you can implement a slider bar with a user-defined range and precision without putting any constraints on the backing bindable.
It improves the API because you don't have to use the previous API of setting the
SliderBar.Currentto aBindableNumberwith user-defined precision and range. The previous API is bad because the range and precision are hidden becauseSliderBar.Currentis not of typeBindableNumber.In UI I thought it would be be nice to have a slider bar with text input field with higher precision, so you can quickly change a integer value with the sliderbar but use the text field if you need more precision. Example video below using a Slider from WPF.
In osu! framework this behaviour is not possible because the text input and slider bar have to share a Bindable and that bindable determines the precision of the slider bar and text input. This PR fixes this by adding a custom mouse precision to the slider bar.
Mapping_Tools_gOeUE8Q1yx.mp4
The workaround of using two bindables with bi-directional value change callbacks does not work because the slider bar will display the wrong value in the tooltip. ppy/osu#29927 (review)
I also added custom range so you can do stuff like ppy/osu#30482 (comment) or ppy/osu#29971
The clamping behaviour when the current value is outside the custom range and using keyboard inputs, as outlined in
TestCustomRange, is consistent with how it behaves in WPF.