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 adjustment step setting for SliderBar #6142

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

Conversation

peppy
Copy link
Sponsor Member

@peppy peppy commented Jan 18, 2024

Picture this scenario: you have a bindable which you want to bind to a slider bar control to allow user adjustment. Generally, when adjusting via a slider bar, adjustments should be sane values, but a user might want to override with a textbox input also bound the to the same bindable.

Using precision becomes non-feasible because it will limit the bindable across all usages (foreshadowing ppy/osu#25862). Like with other UI frameworks, we want to set a tick/step value which governs inputs made via the slider bar.

There's an argument for "fix this locally" but I guarantee we will run into this scenario more and more, especially after we make textbox input for slider config settings more common and users ask for higher precision.

It's also hard to fix locally for one specific reason: when the value is set to a higher precision than we want to support from user input, having multiple bindables to work around this would mean that the slider bar doesn't show the correct value (unless its precision was updated dynamically?).

This allows restricting all adjustments via user input to a slider bar
to result in values on a step range. By default it is disabled.
@@ -27,7 +28,12 @@ public abstract partial class SliderBar<T> : Container, IHasCurrentValue<T>
/// <summary>
/// A custom step value for each key press which actuates a change on this control.
/// </summary>
public float KeyboardStep;
public double KeyboardStep { get; set; }
Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure whether double or float, indifferent but they should match.

@peppy
Copy link
Sponsor Member Author

peppy commented Jan 18, 2024

This works, but doesn't completely solve issues:

CleanShot.2024-01-18.at.10.52.47.mp4

Open to any general feedback on direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant