Add slider::Scale trait and implementations#3370
Open
edwloef wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request adds a new
slider::Scaletrait and two implementations of that trait throughslider::discreteandslider::continuous.slider::Scalegeneralizes over the previousstepandshift_stepmethods ofSliderandVerticalSlider, allowing for custom snapping and stepping behavior.slider::discreteimplements the previous stepped behavior, andslider::continuousis a straight pass-through of the un-snapped value, which wasn't available before. The default, beingslider::discrete(1), matches the old behavior.Some more hopefully illustrative examples of why this is useful:
This is an implementation of a
slider::Scalethat snaps the value to a given "default" when it's within some radius of that value, and is continuous otherwise. A concrete use-case for this scale could be a volume slider snapping to full volume, while allowing continuous adjustment both above and below that value.This is an implementation of a
slider::Scalethat snaps to exponentially spaced steps (or linearly spaced steps on a logarithmic scale). A concrete use-case for this scale could be a slider setting the app scale factor, since app scale factor lies on a logarithmic scale (1.0 is halfway between 0.5 and 2.0).