mirror of
https://github.com/storytold/egui.git
synced 2026-11-21 18:12:42 +01:00
* Closes #2744. Adds `RangeSlider`: two handles selecting a sub-range, an editable value at each end, and the accent fill between them. Three commits: **1. Move `Slider`'s geometry, painting and interaction into a private `slider_core`.** No new `Visuals` field. The one rendering change: the trailing fill is clamped to the rail, which moves it by under a pixel for narrow rect handles. **2. Add `RangeSlider` on top of it.** Rail, handles, hover growth, `HandleShape` and the fill are the same code `Slider` runs, so the two do not look different. ** 3. Added per-handle keyboard and screen-reader support. Each handle is its own focus stop, so Tab reaches either end and the arrow keys move the focused one. Each handle reports itself to AccessKit bounded by its neighbour rather than by the end of the rail. A separate widget rather than a mode on `Slider`, because none of this means anything with one handle: - the grabbed handle is remembered for the whole drag, so dragging one handle past the other does not hand the pointer to its neighbour - when the handles coincide, the side the pointer is on decides which one moves - `min_separation` sets how close they may come One change: `paint_fill` takes a `Rangef` instead of a handle centre. API changes from the review follow-ups: - `Slider::prefix`/`suffix` take `impl IntoAtoms`, like `DragValue`, so images and styled text work. Plain `char` or number arguments no longer do. - A prefix goes in front of any prefix already set, and a suffix after any suffix already set, on `DragValue`, `Slider`, `RangeSlider`, and `TextEdit`. `Slider` and `TextEdit` used to replace. - `ValueFormat`, `SliderSpec`, and `DragValueSettings` are public, with `format()`, `spec()`, and `drag_value()` builders on both sliders. - `DragValue::atoms()` returns `Atoms` by value. Snapshots: the new gallery row changes `widget_gallery_*` and `demos/Scene` (the Scene demo embeds a Widget Gallery). `RangeSlider` is also added to `test_widgets.rs`, which adds two new snapshots. Written with Claude (llm), I (gavrelina) have reviewed the code myself (I did!). --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Test apps
Some application to tests various parts of egui and eframe.
At some point it would be nice to have automatic screenshot regression tests for these.