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.
When using a
DragValue
, there are three common modes of range clamping that the user may want:A) no clamping
B) clamping only user input (dragging or editing text), but leave existing value intact
C) always clamp
The difference between mode B and C is:
With this PR, we now can get the three behaviors with:
.range()
(or use-Inf..=Inf
).range()
and.clamp_existing_to_range(false)
.range()
Slider clamping
Slider clamping is slightly different, since a slider always has a range.
For a slider, there are these three cases to consider:
A) no clamping
B) clamp any value that the user enters, but leave existing values intact
C) always clamp all values
Out of this, C should probably be the default.
I'm not sure what the best API is for this yet. Maybe an
enum
🤔I'll take a pass on that in a future PR.
Related
clamp_to_range
option to DragValue, renameclamp_range
torange
(deprecating the former) #4728clamp_to_range_on_drag
option toDragValue
andclamp_to_range_on_value_drag
option toSlider
#4882