Commit Graph
4550 Commits
Author SHA1 Message Date
Emil Ernerfeldt e45775e450 Add MouseWheelSource and InputState::scroll_source() (#8665)
Lets you tell what is driving a scroll: a mouse wheel, fingers on a
trackpad (not a touch screen), or the OS continuing a trackpad swipe
with momentum.

```rust
pub enum MouseWheelSource {
    Unknown,
    Wheel,
    Trackpad,
    Momentum,
}
```

* `Event::MouseWheel` gains `source: MouseWheelSource`. Integrations set
it to `Unknown` if they don't know.
* `InputState::scroll_source() -> Option<MouseWheelSource>`: what is
driving the current scrolling, `Some` while `is_scrolling()`. For a
trackpad that covers the whole gesture (`TouchPhase::Start`…`End`); for
a mouse wheel, until the smoothing of the last notch is done. Touch
screens scroll by dragging with the pointer, not with wheel events, so
`None` there.

Use cases: a `ScrollArea` can rubber-band and hold while fingers rest on
the trackpad, but bounce during momentum (#8663, built on this). A
slider or plot can ignore `Momentum` so a flick doesn't keep changing a
value after the fingers lift.

**Where the source is known**
* macOS (eframe): `Wheel`, `Trackpad` or `Momentum`. winit folds the
macOS momentum phase into the regular `TouchPhase`, so egui-winit reads
`NSEvent::momentumPhase` itself through a local event monitor
(`macos_scroll_momentum.rs`, owned by `State`, removed on drop). Precise
deltas are `Trackpad`, line deltas `Wheel`. Goes away once we are on a
winit with rust-windowing/winit#4732; marked with TODOs.
* winit `PanGesture`: `Trackpad`.
* Everywhere else: `Unknown`. Web `WheelEvent`s carry no phase or source
at all.

**Also**: the 150 ms scroll-action timeout from #8636 is tuned for
flowing events. Fingers resting on a trackpad produce none, so a known
`Trackpad` gesture now survives a 1 s gap before being considered over.
The enum mirrors the one proposed for winit.

* [x] I have followed the instructions in the PR template

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-10-04 18:45:20 +00:00
Suliman Abdulrazzaq 69a8b71eb5 Fix scroll modifiers getting stuck when TouchPhase::End never arrives (#8636)
* Closes <https://github.com/emilk/egui/issues/8325>
* Closes <https://github.com/emilk/egui/issues/8443>
* [x] I have followed the instructions in the PR template

winit on Wayland sends `TouchPhase::Start` for some mouse wheels, but
never `TouchPhase::End` (winit's own comment in its Wayland pointer
handler: "the `Ended` is not guaranteed to be sent for mouse wheels").
Since #7678, `WheelState` then stays `InTouch` for good, and in
`InTouch` the modifiers are only ever added to. So after a single
ctrl+scroll, every later scroll is a zoom, which is what #8325 bisected
to 1b77d7047. `is_scrolling()` also stays `true`, and with
`show_tooltips_only_when_still` that keeps tooltips from showing.

This ends an `InTouch` scroll action after 150 ms without scroll events,
the same timeout `Smoothing` already uses. The check runs in
`after_events`, and also when the next wheel event arrives, because an
idle app may not run a pass after the timeout has passed. While events
keep coming, the modifiers stay latched as #7678 intended.

Tests, in `wheel_state.rs`:
* `modifiers_should_not_stick_when_touch_phase_end_never_arrives`:
`Start`+`Move` with ctrl, then 1 s later a `Move` without ctrl. Before
the fix it zoomed (`left: 0.9753099`, `right: 1.0`).
* `scroll_action_should_end_when_touch_phase_end_never_arrives`:
`is_scrolling()` is `false` after a second without scroll events. Before
the fix it stayed `true`.
* `modifiers_should_stick_until_touch_phase_end`: letting go of shift
mid-scroll still scrolls horizontally until `End` (the #7678 behavior).
Passes before and after.

`cargo test -p egui --all-features` passes (75 unit tests, 186
doc-tests), and so do `cargo fmt`, `./scripts/lint.py`, `cargo clippy -p
egui --all-features --all-targets -- -D warnings` and `cargo doc -p egui
--document-private-items`. The whole-workspace `cargo test
--all-features` on macOS (with the snapshot tests) passes too. I don't
have a niri or COSMIC setup, so the tests replay winit's event sequence
rather than a real wheel.
2026-10-04 20:25:31 +02:00
Emil Ernerfeldt 23348e9fa7 Make kinetic scrolling feel like iOS (#8662)
Kinetic (momentum) scrolling after a drag used a constant deceleration
(Coulomb friction), so coast distance was proportional to velocity².
Fast flicks flew way too far, slow flicks died instantly.

This switches to exponential velocity decay like `UIScrollView` on
iOS/macOS:

```
v(t) = v₀ · exp(-t / decay_time)
```

Coast distance is `v₀ · decay_time`, i.e. linear in release velocity.
Default `decay_time = 0.5 s`, matching
`UIScrollView.DecelerationRate.normal` (0.998/ms). Integration is exact
per frame, so the result is frame-rate independent.

| release velocity | before | after |
|---|---|---|
| 300 pt/s | 45 pt | 150 pt |
| 1000 pt/s | 500 pt | 500 pt |
| 2000 pt/s | 2000 pt | 1000 pt |
| 4000 pt/s | 8000 pt | 2000 pt |

The constants are exposed in the new `KineticScrollStyle` at
`Style::spacing.scroll.kinetic` (`decay_time`, `stop_distance`), with a
UI in the style settings. `decay_time = 0.0` disables kinetic scrolling.

Only affects drag-to-scroll (touch / mouse drag). Trackpad momentum on
macOS comes from the OS and is unaffected.

* [x] I have followed the instructions in the PR template

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-10-04 14:14:41 +02:00
Emil ErnerfeldtandClaude Fable 5.1 6b420bc1b1 Replace #[test] Send + Sync assertions with compile-time const asserts (#8649)
This ensures they hold on wasm32 too

* See https://github.com/emilk/egui/pull/8638

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-29 17:11:39 +00:00
Teo Mal e9f2025890 Keep egui::Context Send + Sync with wasm threads (#8638)
With wasm threads, `DroppedFileHandle` wasn't `Send + Sync`, so neither
was `Context`, which holds the dropped files.
That broke `egui_extras`'s `http` loader and any code moving a `Context`
to another thread, and contradicts the `context_impl_send_sync` test.
`DroppedFileHandle` is `Send + Sync` everywhere again, and eframe wraps
the `web_sys::File` in a `SendWrapper` (new dependency, `send_wrapper`
0.6).

Checked: the command from the issue, the `check_wasm_atomics` CI
command, and the regular wasm32 build of `egui_demo_app`.

This partly reverts the design of #8354, cc @grtlr.

Fixes #8401
2026-09-29 16:58:23 +00:00
Emil ErnerfeldtandClaude Opus 5.5 ee9cc58c80 Add JSON to the simple syntax highlighter in egui_extras (#8632)
`egui_extras`' built-in highlighter (used when the `syntect` feature is
off, e.g. by `egui_commonmark` without `better_syntax_highlighting`) now
highlights `json` code blocks: strings, numbers, and the
`true`/`false`/`null` keywords.

This came up in the Rerun Viewer's agent panel, where JSON code blocks
rendered as plain text.

* [x] I have followed the instructions in the PR template

🤖 This PR was written by Claude, an LLM, on behalf of @emilk.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-29 09:50:32 +00:00
Emil ErnerfeldtandClaude Opus 5.5 6e35807686 Style tweak: slightly roomier buttons (#8617)
### Before
<img width="380" height="523" alt="image"
src="https://github.com/user-attachments/assets/f0ea9470-2090-4ebf-8170-4e26f9a1c83b"
/>

### After
<img width="380" height="564" alt="image"
src="https://github.com/user-attachments/assets/fd7b2b2c-1f95-4af7-9e22-6112ed560b4b"
/>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 10:16:12 +02:00
Emil ErnerfeldtandClaude Opus 5.5 8a4b632f34 Fix TextEdit layout shift with custom margin; unclipped TextEdit grows to fit text (#8628)
Broken out of #8617.

* `TextEdit::margin` now makes room for the stroke inside the margin
(like the theme does), so the stroke width changing on hover/focus no
longer causes a layout shift.
* `TextEdit::clip_text(false)` now expands the widget to make all text
visible, as documented, instead of being capped at `desired_width`.
* The default `TextEdit` inner margin is now `spacing.button_padding`,
and the theme gives `TextEdit` the same min height (`interact_size.y`)
as a `Button`, so they always have the exact same height (previously off
by 1px).

Tests added to `test_widget_heights.rs`: text edit included in the
matching-heights test (now run for several `interact_size.y` values),
size stable on hover/focus (with and without custom margin), and
unclipped text edit grows to fit text.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 08:04:34 +00:00
Suliman Abdulrazzaq 7eb71da0bd Fix DragValue reporting changes while typing with update_while_editing(false) (#8627)
* Closes <https://github.com/emilk/egui/issues/7837>
* [x] I have followed the instructions in the PR template

With `update_while_editing(false)`, the value of a `DragValue` is only
updated once editing is done, but `response.changed()` was still `true`
on every keystroke. While the widget is focused, its response is the
inner `TextEdit` response, and a `TextEdit` marks every text edit as a
change.

The fix clears that flag in the text-edit branch. The existing check at
the end of `DragValue::ui` already marks the response as changed when
the value actually changed, so `changed()` now means "the value
changed", in both modes. `Slider` and `RangeSlider` take their value
box's response via `union`, so they get the same fix.

Tests (in `egui_kittest/tests/regression_tests.rs`):
*
`drag_value_should_not_report_changes_while_typing_without_update_while_editing`:
typing `42` reports no change, and pressing Enter reports exactly one
change, with the value `42`. Without the fix, this fails with 2 changes
while typing and the value still at `0`.
*
`drag_value_should_report_changes_while_typing_with_update_while_editing`:
with the default setting, each keystroke still reports a change.
2026-09-25 08:04:03 +00:00
Emil ErnerfeldtandClaude Opus 5.5 7903bf6c4e kittest: mention how to disable the accessibility check in its failure message (#8630)
Broken out of #8617.

The panic message now points to
`HarnessBuilder::with_accessibility_check(false)`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 09:51:12 +02:00
b689ffde5b Use arboard if smithay does not find text in the clipboard (#8624)
Fallback to `arboard` with `wayland-data-control` if `smithay` does not
find a text MIME type in the clipboard.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 14:23:35 +00:00
Emil ErnerfeldtandClaude Opus 5.5 fe6d63efa4 Fix exponential memory use of the debug Id source tracker (#8619)
* Closes #8558

In debug builds, each `Id`/`IdSalt` stores its `Debug`-formatted source
chain. Using an `Id` as a salt copies its whole chain into the child.
`CollapsingHeader` does `ui.indent(header_id, …)`, where `header_id` is
derived from the parent `Ui` id, so the stored string doubles at every
level of nesting (≈640 kB at depth 11, and it keeps doubling).

The fix caps stored sources at 1024 bytes. It keeps the end, since that
is the most specific part.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 14:04:32 +02:00
Lucas MeurerandClaude Opus 5 bc94cac5a7 Respect the menu style config in sub menus (#8572)
Previously it was ignored since menu_style was applied within `Popup`
and the frame was created on the previous, unchanged outer ui.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-24 12:03:07 +00:00
Lucas MeurerandClaude Opus 5 ab7d768a80 Allow transforming after shapes were tessellated and rounded (#8587)
Via a new `TransformedShape`. When the transform is applied before
rounding during an animation, it introduces a ugly snap once the
transform ends:


https://github.com/user-attachments/assets/1e75cd21-4bc4-4869-b3fa-cde749991518

When the transform is applied after rounding it looks way smoother:


https://github.com/user-attachments/assets/ccba1562-66dc-4b93-b187-53928510c0b8

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-24 11:02:47 +00:00
Emil ErnerfeldtandClaude Opus 5.5 160090b20a Don't lose keyboard focus in a pass that will be discarded (#8623)
* Follow-up to https://github.com/emilk/egui/pull/8621

`Ui::is_visible` is `false` for the rest of a pass once anything calls
`request_discard` (see `Context::will_discard`).
#8621 made invisible widgets not interested in focus, so a focused
widget drawn after any `request_discard` call would give up its focus,
and it stays lost because `Memory` persists across passes.

In Rerun this showed up as a focused list item losing focus whenever
some other part of the UI requested a discard.

This removes `w.visible` from `interested_in_focus`.
Invisible widgets are still hidden from accessibility, and their focus
is still not reported to AccessKit (the tree reports the root as focused
instead).

Added the regression test `keep_focus_in_discarded_pass`.

_This PR was written by Claude, an LLM, on behalf of @emilk._

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 12:47:26 +02:00
Emil ErnerfeldtandClaude Fable 5.1 a99dc715f1 Add Aligned container for aligning a custom Ui in parent (#8540)
* [x] I have followed the instructions in the PR template

Adds `egui::Aligned`, a container that places its contents at a given
`Align2` within the available space of the parent `Ui`, e.g. in the
bottom-right corner.

Since the size of the contents isn't known up front, it remembers the
size from the previous pass. On the first pass the contents are added
invisibly and a new pass is requested with `request_discard`, so there
is no flicker.

```rust
egui::Aligned::new(egui::Align2::RIGHT_BOTTOM).show(ui, |ui| {
    ui.label("Bottom right");
    let _ = ui.button("Click me");
});
```

Like a `Panel`, `Aligned` reserves space in the parent `Ui` along its
main axis: if the contents are aligned to the end of that axis (e.g. the
bottom of a vertical `Ui`), widgets added afterwards go in the space
*before* them. So you can put something in the bottom-right corner and
keep adding widgets above it:

```rust
egui::Aligned::new(egui::Align2::RIGHT_BOTTOM).show(ui, |ui| {
    let _ = ui.button("Bottom right");
});
ui.label("Placed above the button");
```

Rerun uses this to overlay the legend on a plot.

Extracted from Rerun's `re_ui::egui_ext` (where it is called `Group`).
Naming suggestions welcome.

Written by Claude (LLM).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-24 12:47:05 +02:00
Emil ErnerfeldtandClaude Opus 5.5 b4ebd0f910 Build ComboBox from atoms, and take impl IntoAtoms (#8618)
* Closes https://github.com/emilk/egui/issues/7903
* Part of https://github.com/emilk/egui/issues/7264

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 12:21:27 +02:00
Emil ErnerfeldtandClaude Opus 5.5 a1c276fc98 Hide invisible widgets from accessibility (#8621)
* Closes https://github.com/emilk/egui/pull/8606
* Root cause solution for https://github.com/rerun-io/reality/pull/3774

Our `Area`s mark themselves as invisible the first frame without calling
`request_discard`. They would still show up in the accessibility tree.

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 11:49:59 +02:00
Emil ErnerfeldtandClaude Opus 5.5 43a0913ec6 Fix NaN panic in Scene with zero scene_rect and unbounded zoom (#8622)
* Closes <https://github.com/emilk/egui/issues/8620>
* [x] I have followed the instructions in the PR template

With `scene_rect = Rect::ZERO`, `fit_to_rect_in_scene` computed an
infinite scale. The default zoom range (max `1.0`) clamps that, but
`0.0..=f32::INFINITY` does not, so the translation became `center - ∞ *
0 = NaN`, which ended up as a NaN widget rect and tripped the debug
assert in `create_widget`.

We now fall back to a 1:1 scale when the computed scale is not finite
and positive. This also covers the auto-reset path when the scene
contents are empty.

Added a regression test.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 08:25:06 +00:00
Emil ErnerfeldtandCopilot Autofix powered by AI a55f23a1ec Add BandShape (#8476)
Add `BandShape` to epaint, supporting and varying width band along some
direction.

This can be useful in egui_plot, e.g. for filling the area under a
curve, or for visualizing a audio waveform, for instance.

The band has feathering for the fill, plus an optional stroke that is
just drawn on top of the fill.

This solves a small subset of non-convex polygons (since the general
solution is quite difficult, at least if you want feathered edges).

<img width="493" height="180" alt="Screenshot 2026-09-01 at 20 56 33"
src="https://github.com/user-attachments/assets/f79ae9bc-3512-4c87-b166-d1240a8dd3e4"
/>

Includes an interactive waveform demo and alpha screenshot coverage.

Related work:

- https://github.com/emilk/egui/issues/513
- https://github.com/emilk/egui_plot/pull/260

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-09-22 12:27:54 +02:00
rustbasicandEmil Ernerfeldt 06921cda05 [performance] Avoid cross-viewport GalleyCache eviction (#8528)
[performance] Avoid cross-viewport GalleyCache eviction

This changes `Fonts` to keep `GalleyCache` entries partitioned by
viewport.

Previously, multiple viewports shared one galley cache. Since each
viewport flushes the cache at the start of its pass, root and child
viewports could repeatedly evict each other's text layouts.

As viewport text workload grows, this can force repeated layout of large
text contents and cause severe performance degradation, with the frame
rate dropping below 10 FPS in some cases.

Font data and the texture atlas remain shared. Only layout caches are
separated by an opaque viewport namespace.

* Closes #5249 
* Related #5836
* Related #7885 
* Related #8284
* Closes #8419

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-09-22 10:13:31 +00:00
Emil ErnerfeldtandClaude Fable 5.1 99df44a801 A TextEdit over an immutable buffer is read-only too (#8613)
Follow-up to #8611. Passing `&mut &str` is how `egui_commonmark` (and
the docs) show selectable text; it cannot be typed into any more than
`interactive(false)` can, so it now gets the same read-only mark, and
`egui_kittest` asks no name of it.

Written by Claude (an LLM) for @emilk.

* [x] I have followed the instructions in the PR template

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 19:34:46 +00:00
Emil ErnerfeldtandClaude Fable 5.1 8709bd14b4 Add Area::role and UiBuilder::accessibility_role (#8612)
A `Ui` gets its accessibility role from its `UiKind` (#8581). This lets
a caller pick another one, e.g. `Role::Alert` for a toast:
`Area::new(id).role(Role::Alert).accessible_name("Saved")`, or
`UiBuilder::new().accessibility_role(role)` for any `Ui`.

Rerun sets the toast role by reaching into the node from inside the `Ui`
today; @emilk asked for a builder method instead.

Written by Claude (an LLM) for @emilk.

* [x] I have followed the instructions in the PR template

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 19:10:35 +00:00
Emil ErnerfeldtandClaude Fable 5.1 f45d74baab A read-only text field needs no accessible name (#8611)
A non-interactive `TextEdit` (selectable text, e.g. the code blocks
`egui_commonmark` renders) now marks its node read-only, and the
`egui_kittest` check from #8589 leaves such fields alone: there is
nothing to type into, so nothing to reach by name.

Rerun was naming those code blocks "Code block" just to pass the check;
@emilk asked for this instead.

Written by Claude (an LLM) for @emilk.

* [x] I have followed the instructions in the PR template

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 19:09:54 +00:00
Emil ErnerfeldtandClaude Fable 5.1 1c7109d090 Add Ui::label_inputs_by and Ui::name_inputs (#8608)
Two ways to name every input a closure adds that has no accessible name
yet:

* `ui.label_inputs_by(label.id, |ui| …)`: after a row label, for
property rows and forms whose label is painted apart from its value
widgets, so the editors need not know the row label.
* `ui.name_inputs("Code block", |ui| …)`: a fixed name, for widgets that
cannot be named where they are built, e.g. the read-only `TextEdit`
`egui_commonmark` renders for a code block.

Only the widgets registered on the `Ui`'s layer during the closure are
inspected (the per-layer widget list is in creation order), so the cost
is one node lookup per widget added, not a walk over the whole tree per
call. Both are what #8589's check asks for and what Rerun does by poking
at `accesskit_state` from outside egui today.

`egui::accessibility::is_input(role)` decides which roles count, as an
exhaustive match over `accesskit::Role`; `egui_kittest` uses the same
function.

Written by Claude (an LLM) for @emilk.

* [x] I have followed the instructions in the PR template

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 15:21:41 +00:00
6def3661ec Add AccessKit support to panel resize handles (#8578)
Panel resize separators currently register no AccessKit content: screen
readers announce an empty node and cannot adjust the split (#8557). This
exposes the handle as a `Role::Splitter` (`WidgetType::ResizeHandle`)
labeled "Resize panel", with its orientation and the panel size as a
numeric value in `0..=1` of the available space.

AccessKit `Increment`/`Decrement`/`SetValue` requests on the handle are
translated into the same size-clamping path a pointer drag uses, and
`Increment` on a collapsed panel's grab handle expands the panel,
mirroring drag-to-expand. For headless testing, the `egui_kittest`
harness gains
`increment_accesskit`/`decrement_accesskit`/`set_value_accesskit` node
helpers. Tests assert the splitter node's label, orientation, numeric
bounds and supported actions, and verify that AccessKit actions move the
split.

Fixes #8557

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 14:21:02 +00:00
Lucas Meurer b30d20bca7 Ensure nested AtomLayouts have unique ids (#8556)
Buttons with nested atoms weren't fully clickable


https://github.com/user-attachments/assets/c9bc7075-9b32-4edc-9949-5eb047234e07
2026-09-21 13:09:01 +00:00
Emil ErnerfeldtandClaude Fable 5.1 4146d6366a Apply font changes right away while no text has been laid out this pass (#8609)
Generalizes #8602 from "no font loaded yet" to "nothing laid out yet
this pass": any font, provider, rasterizer or glyph-policy change made
before the first text of a pass takes effect in that pass, since nothing
is laid out with the old fonts.

#8602 missed the case where `default_fonts` is on: an app that installs
its own fonts during its first pass then laid that pass out with the
bundled fonts, and under `MissingGlyphPolicy::Panic` any glyph they lack
(Rerun's ⏎, on a Linux CI box with no system fonts) panics. New
`Fonts::used_since_begin_pass` is what the check reads.

Written by Claude (an LLM) for @emilk.

* [x] I have followed the instructions in the PR template

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 15:07:42 +02:00
60b5f05e9a Remove WidgetType in favor of accesskit::Role (#8555)
- closes https://github.com/emilk/egui/issues/8474

Its a required dependency now so we might as well their type for best
compatibility

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-21 15:03:46 +02:00
Emil ErnerfeldtandClaude Fable 5.1 0777ca67aa Name a Ui, Area, Popup or Tooltip in the accessibility tree (#8607)
Follow-up to #8581, which gave every `Ui` a role. This adds the name:
`UiBuilder::accessibility_label` sets the label on the `Ui`'s node, and
`Area`, `Popup` and `Tooltip` take an `accessible_name` and pass it on.

A floating container can then be found by name
(`get_by_role_and_label(Role::Dialog, "Options")`) instead of by
reconstructing its node id. Rerun does that reconstruction today for its
modals, toasts and hover tooltips.

Written by Claude (an LLM) for @emilk.

* [x] I have followed the instructions in the PR template

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 12:47:24 +00:00
Emil ErnerfeldtandClaude Fable 5.1 65bf96beae Add Response::accessible_name (#8604)
Useful for adding an accessibility name to a widget

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 12:17:58 +00:00
Emil ErnerfeldtandClaude Fable 5.1 5705148d42 Apply set_fonts/add_font right away when no font is loaded yet (#8602)
An app built without `default_fonts` starts with no font at all and
installs its own, often from inside its first pass (an `egui_kittest`
harness has no earlier hook).
Fonts used to apply at the start of the *next* pass, so that first pass
laid out every string with an empty family, which since #8601 panics
under `MissingGlyphPolicy::Panic`. Rerun's tests hit this on every
harness.

Nothing laid out before the first font arrives could have used one, so
applying immediately in that case has nothing to keep consistent. With
`default_fonts` on, nothing changes.

Regression test in `egui_kittest/tests/missing_glyphs.rs`.

Written by Claude (an LLM) for @emilk.

* [x] I have followed the instructions in the PR template

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 14:08:43 +02:00
Emil ErnerfeldtandClaude Fable 5.1 4d831b13d2 Add Rangef::union (#8603)
Adds `Rangef::union`: the smallest range containing both ranges, the
counterpart of `intersection`.

Needed for building min/max envelopes (e.g. audio waveforms) in Rerun,
where we currently spell it out as `Rangef::new(a.min.min(b.min),
a.max.max(b.max))`.

Written with Claude Code (an LLM), reviewed by @emilk.

* [x] I have followed the instructions in the PR template

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 14:06:56 +02:00
Emil ErnerfeldtandClaude Fable 5.1 25f0cf491e Draw tofu for families without fonts, and add MissingGlyphPolicy (panics by default in egui_kittest) (#8601)
A font family with no font at all used to lay out to an *empty galley*:
the run had no face to shape with, so it was dropped.
`Galley::clamp_cursor` on that empty galley returns 0, so a `TextEdit`
lost its cursor the frame after typing — text stayed, cursor jumped to
0, and e.g. completion popups never opened. Found in rerun's tests after
dropping `default_fonts`, where nothing installed a font for the bare
kittest harness.

### Changes
* epaint: a family without fonts now lays out **one synthetic tofu box
per grapheme cluster**, with metrics derived from the font size.
`glyphs.len() == char_count` and non-zero row heights hold even with no
font.
* epaint: new `MissingGlyphPolicy { Tofu, Panic }` on `Fonts`, consulted
only after every font, `FontProvider` and `GlyphRasterizer` had its
turn. Control characters (`\t`, `\n`, …) never panic, since fonts have
no glyphs for them. The panic names the character, the family and the
installed fonts.
* egui: `Context::set_missing_glyph_policy` / `missing_glyph_policy`.
* egui_kittest: **panics on a missing glyph by default**, since tofu in
a snapshot is easy to miss. Opt out with
`HarnessBuilder::allow_missing_glyphs()`. One demo test needed it (the
emoji completion popup lists emoji the bundled fonts lack).

Top: with fonts, U+10FFFD drawn with Ubuntu's `.notdef`. Bottom: the
same UI with `FontDefinitions::empty()`, all synthetic tofu (3× zoom):

<picture>
<img
src="https://static.rerun.io/tofu_cmp/1c2a567a1f53c301897e716452974a0b6fbc8e12/full.png"
alt="">
<source media="(max-width: 480px)"
srcset="https://static.rerun.io/tofu_cmp/1c2a567a1f53c301897e716452974a0b6fbc8e12/480w.png">
<source media="(max-width: 768px)"
srcset="https://static.rerun.io/tofu_cmp/1c2a567a1f53c301897e716452974a0b6fbc8e12/768w.png">
</picture>

Written by Claude (LLM) together with @emilk.

* [x] I have followed the instructions in the PR template

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 13:03:24 +02:00
Emil ErnerfeldtandClaude Fable 5.1 9d7fee57e0 Make Context::add_glyph_rasterizer idempotent (#8600)
`Context::add_glyph_rasterizer` appended a rasterizer and requested a
repaint on every call. Calling it from a setup path that runs each frame
piled up duplicates and kept the UI repainting forever (we hit this in
rerun's tests, where `apply_style_and_install_loaders` runs every frame
and the harness never settled).

* `GlyphRasterizer::new` now takes a mandatory `key`: adding a
rasterizer whose key is already installed is a no-op.
* `Context`/`Fonts`/`FontsImpl::add_glyph_rasterizer` only reload fonts,
clear caches and request a repaint when something actually changed.
`Fonts::add_glyph_rasterizer` returns whether it did.
* `SvgGlyph::into_rasterizer` is keyed by cluster, the web canvas
rasterizer by a fixed name.

Written by an LLM (Claude) together with @emilk.

* [x] I have followed the instructions in the PR template

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 10:36:40 +00:00
Emil ErnerfeldtandClaude Fable 5.1 a92be313d4 Fail kittest tests when an input widget has no accessible name (#8589)
* Stacked on #8581

**⚠️ Breaking ⚠️**

`egui_kittest` that every input widget (button, checkbox, slider, combo
box, text field, …) has an accessible name.

Opt out with `HarnessBuilder::with_accessibility_check(false)`, or run
it by hand with `Harness::check_accessibility`.

Running it over egui's own tests found real gaps, fixed here:
* An empty label (`checkbox(&mut b, "")`) took precedence over
`labelled_by`; now it is not set at all.
* `DragValue` is named after its prefix or suffix (it used to clear the
name).
* The color button has a name, with the color as its value.
* `TextEdit` lost its placeholder on frames where the selection changed.
* `Margin`, `CornerRadius` and the font-size slider name their inputs.
* The demos and kittest tests name their remaining inputs.

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 11:45:40 +02:00
Emil ErnerfeldtandClaude Fable 5.1 f966bfd5d5 Use Ui::unique_id for WidgetRect::parent_id (#8543)
`WidgetRect::parent_id` used `Ui::id`, the stable id _scope_ shared by
sibling `Ui`s, while accesskit and `WidgetRect::id` use the per-`Ui`
`unique_id`. The `warn_if_rect_changes_id` debug check relies on
`parent_id` changing during a cascading id shift, but cascades propagate
through `unique_id`, not the scope id. So a parent's auto-id shifting
produced a false positive for every widget inside it.

Now `parent_id` is the parent's `unique_id`. Adds a regression test.

Known limitation: the child `Ui`'s own `WidgetRect` still warns in that
case, since its parent's id is genuinely unchanged. The heuristic cannot
tell that apart from a bug.

Found while working on:
* https://github.com/emilk/egui/pull/8542

* [x] I have followed the instructions in the PR template

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 11:20:35 +02:00
Emil ErnerfeldtandClaude Fable 5.1 e303ab7e14 Add KeyboardShortcut::conflicts_with_text_editing (#8536)
Moved over from Rerun

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 10:30:38 +02:00
Emil ErnerfeldtandClaude Fable 5.1 c95e3d14c0 Add WidgetText::concat for joining differently styled RichTexts (#8538)
* [x] I have followed the instructions in the PR template

Adds `WidgetText::concat(style, parts)`, which joins several `RichText`s
into a single `WidgetText` (backed by a `LayoutJob`).

This is the easy way to get e.g. a label that is partly bold, or a label
with a small colored badge at the end, without manually building a
`LayoutJob` with `RichText::append_to`.

```rust
ui.label(WidgetText::concat(ui.style(), [
    RichText::new("Normal, "),
    RichText::new("strong, ").strong(),
    RichText::new("and small").small(),
]));
```

Extracted from Rerun's `re_ui::egui_ext`.

Written by Claude (LLM).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 06:17:41 +00:00
Makro 9fbd2bcf5e Fix burst of extra repaints before request_repaint_after deadlines (#8595) 2026-09-21 06:13:11 +00:00
Lukas Karel e44f9f60d9 Add DragValue::clip_text to hold field's width while editing (#8588)
A DragValue cannot be held to a width while it is text-edited: the
TextEdit it builds for that state hardcodes clip_text(false), so the
widget grows to fit whatever has been typed and carries its layout with
it. A long entry can stretch a containing popup off-screen. range() does
not help, since it only applies once the edit commits.

clip_text(true) forwards to that TextEdit, so the widget keeps its width
and the text scrolls inside it, following the cursor. Defaults to false,
leaving existing behavior unchanged.

Example on egui.rs:
<img width="1418" height="696" alt="20260917-1900-19 6437910"
src="https://github.com/user-attachments/assets/4bc102ad-24e9-43ae-9e81-91c17a2c2c91"
/>

* Small fix; no corresponding issue created
* [X] I have followed the instructions in the PR template
2026-09-20 07:16:22 +00:00
Emil ErnerfeldtandClaude Fable 5.1 8fb03c9ae9 Improve accessibility of popups, menus, tooltips, modals and panels (#8581)
Found while making the Rerun viewer navigable by accessible name:
floating containers were anonymous `Unknown`/`GenericContainer` nodes at
the root of the tree, and icon-only buttons with a tooltip had no name.

* `Ui`s get an accesskit role from their `UiKind`: panels are `Pane`,
modals and popups `Dialog`, menus `Menu`, tooltips `Tooltip`.
* Popups and tooltips hang under the widget that opened them
(`Area::accessibility_parent`, set through `Popup::anchor_widget`)
instead of floating at the root.
* Combo box popups are `ListBox`.
* `on_hover_text` sets the widget's accessible description, and its name
if it has none.

Drafted with Claude Code (an LLM), tests included.

* [x] I have followed the instructions in the PR template

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-18 11:57:45 +02:00
Emil ErnerfeldtandClaude Opus 5 89cc9481c6 Take impl AsIdSalt in the Panel constructors (#8592)
`impl Into<IdSalt>` is an anti-pattern. `impl AsIdSalt` is the correct
shape.

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-18 09:21:03 +00:00
Emil ErnerfeldtandClaude Opus 5 7da69e484b Replace glob re-exports in egui/src/lib.rs with explicit lists (#8591)
Each `use foo::*` at the crate root is now spelled out, so it is obvious
what `egui` re-exports and where each name comes from.

In particular, `cargo doc -p egui` will now show all exported items

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-18 11:10:22 +02:00
Emil Ernerfeldt 6bc0a82e21 Add IdSaltSet and IdSaltMap (#8590) 2026-09-18 10:29:36 +02:00
Lucas Meurer 5931e21d1f Clarify what Id to pass in accessibility_parent (#8582) 2026-09-17 16:07:59 +02:00
Emil ErnerfeldtandClaude Opus 5 8961031123 Don't drop the fonts in the middle of a pass (#8585)
Four `Context` methods dropped the font cache immediately:

```rust
pub fn add_glyph_rasterizer(&self, glyph_rasterizer: GlyphRasterizer) {
    self.write(|ctx| {
        ctx.glyph_rasterizers.push(glyph_rasterizer);
        ctx.fonts = None;   // ← even if we are mid-pass
    });
}
```

Call any of them from inside a pass and the next text layout panics with
`No fonts available until first call to Context::run()`, or the
tessellator hits `.expect("No fonts loaded")`.

They now set a `reload_fonts` flag that `update_fonts_mut` acts on at
the start of the next pass, which is what `set_fonts` and `add_font`
already do, and each requests a repaint so the change still shows up
promptly.

Found in [Rerun](https://github.com/rerun-io/rerun): our style setup
calls `add_glyph_rasterizer` to draw a couple of glyphs from our own SVG
icons, and every `egui_kittest` test calls that setup inside its
`build_ui` closure. 592 tests on Linux and 590 on macOS died on those
two panics.

The new test fails on `main` with exactly that message and passes here.

* [x] I have followed the instructions in the PR template

Disclosure: this PR was written by Claude (an LLM).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-17 16:06:47 +02:00
Emil ErnerfeldtandClaude Opus 5 742d186879 Keep the AccessKit role a widget declared when its text is selectable (#8574)
`update_accesskit_for_text_widget` unconditionally called
`builder.set_role`, so the selectable-label pass overwrote the role a
widget had already reported through its `WidgetInfo`. A `Link` came out
as `Role::Label`, indistinguishable from static text to a screen reader.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 16:05:19 +02:00
Emil ErnerfeldtandClaude Opus 5 2007ec324b Bring back AsId, deprecated (#8586)
Removing `AsId` broke downstream crates that name the trait in their own
bounds or re-exports. It is back, but `#[deprecated]`

* https://github.com/emilk/egui/pull/8584

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-17 15:55:28 +02:00
Emil ErnerfeldtandClaude Opus 5 3690fb5b0e Remove the AsId trait (#8584)
We want to be explicit when constructing `Id`s as `Id::unique`. `AsId`
was the old implicit way. For implicit parameters, use `impl AsIdSalt`

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-17 12:43:49 +00:00