egui/crates
Emil Ernerfeldt 7d6c83b37f
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
* https://github.com/emilk/egui/pull/4728
* https://github.com/emilk/egui/issues/4881
* https://github.com/emilk/egui/pull/4882
2024-09-17 14:44:20 +02:00
..
ecolor Use precomputed lookup table in Color32::from_rgba_unmultiplied (#5088) 2024-09-10 09:50:56 +02:00
eframe Fix: call `save` when hiding tab, and `update` when focusing it (#5114) 2024-09-16 16:28:54 +02:00
egui Fix `DragValue` range clamping (#5118) 2024-09-17 14:44:20 +02:00
egui-wgpu Add opt-out `fragile-send-sync-non-atomic-wasm` feature for wgpu (#5098) 2024-09-13 13:00:18 +02:00
egui-winit Add `Context::request_discard` (#5059) 2024-09-13 14:20:51 +02:00
egui_demo_app Use `log` crate instead of `eprintln` & remove some unwraps (#5010) 2024-09-13 14:23:13 +02:00
egui_demo_lib Add `Context::request_discard` (#5059) 2024-09-13 14:20:51 +02:00
egui_extras Make Light & Dark Visuals Customizable When Following The System Theme (#4744) 2024-09-11 17:52:53 +02:00
egui_glow Update `glow` to 0.14 (#4952) 2024-09-09 14:02:06 +02:00
egui_plot Move `egui_plot` to its own repo (#4828) 2024-07-15 18:45:19 +02:00
egui_web Fix typos (#2866) 2023-04-18 15:52:45 +02:00
emath Use `log` crate instead of `eprintln` & remove some unwraps (#5010) 2024-09-13 14:23:13 +02:00
epaint Use `log` crate instead of `eprintln` & remove some unwraps (#5010) 2024-09-13 14:23:13 +02:00
epaint_default_fonts Enable rustdoc `generate-link-to-definition` feature on docs.rs (#5030) 2024-08-30 11:22:29 +02:00