-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
DragValue
range clamping (#5118)
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: ```rs let mut x = 42.0; ui.add(DragValue::new(&mut x).range(0.0..=1.0)); // What will `x` be here? ``` With this PR, we now can get the three behaviors with: * A): don't call `.range()` (or use `-Inf..=Inf`) * B) call `.range()` and `.clamp_existing_to_range(false)` * C) call `.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 * #4728 * #4881 * #4882
- Loading branch information
Showing
2 changed files
with
60 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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