-
Notifications
You must be signed in to change notification settings - Fork 422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom mouse step and range properties to SliderBar #6376
base: master
Are you sure you want to change the base?
Conversation
It's not immediately clear to me why this is an issue exactly? You steer mouse step by changing precision of the bindable. If you don't want the coupling, you can have a loose-coupled setup wherein the slider bindable is not bound to the other bindable but you set up bidirectional or one-directional value change callbacks to propagate the value. I'm personally going to require a more convincing rationale to try this because the OP is not doing it for me. In particular, consider this: what happens if you set a |
That setup is actually not as bad as I initially thought. After implementing it the callback loop you create is not hard to fix. |
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.Current
to aBindableNumber
with user-defined precision and range. The previous API is bad because the range and precision are hidden becauseSliderBar.Current
is 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.