Skip to content
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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

OliBomby
Copy link
Contributor

@OliBomby OliBomby commented Sep 16, 2024

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 a BindableNumber with user-defined precision and range. The previous API is bad because the range and precision are hidden because SliderBar.Current is not of type BindableNumber.

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.

@bdach
Copy link
Collaborator

bdach commented Sep 18, 2024

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

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 Step that the underlying bindable cannot support? Something like 0.05 step and 0.1 precision. I imagine things will begin to break down at that point.

@OliBomby
Copy link
Contributor Author

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.

That setup is actually not as bad as I initially thought. After implementing it the callback loop you create is not hard to fix.

@OliBomby OliBomby closed this Sep 18, 2024
@OliBomby OliBomby reopened this Nov 4, 2024
@pull-request-size pull-request-size bot added size/L and removed size/S labels Nov 4, 2024
@OliBomby OliBomby changed the title Add custom mouse precision property for SliderBar Add custom mouse step and range properties to SliderBar Nov 4, 2024
@peppy peppy self-requested a review November 13, 2024 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants