Commit Graph
94 Commits
Author SHA1 Message Date
Lucas MeurerandClaude Opus 5.5 bb622334e2 Fix not being able to click autocomplete items (#8690)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 15:02:33 +02:00
Mud BungieandEmil Ernerfeldt 9c7bf826eb Add double-click-and-drag and triple-click-and-drag text selection (#8370)
* Closes <https://github.com/emilk/egui/issues/2550>
* [x] I have followed the instructions in the PR template

Double-click-and-drag now extends the selection by whole words, and
triple-click-and-drag by whole lines — in both `TextEdit` and labels,
including selections spanning multiple labels.

![double-click-and-drag selecting by
words](https://raw.githubusercontent.com/mudbungie/egui/media/double_click_drag.gif)

The reason this was missing: clicks are only counted on pointer
*release*, so at the start of a drag nothing knew it began with a
double-click.

* `PointerState` now also computes the would-be click count at *press*
time (`pub(crate)` only, same heuristics as the click counting on
release).
* On a second/third press, `TextCursorState` selects the word/line under
the pointer immediately and remembers it as the anchor; while dragging,
the selection is the union of the anchor and the word/line under the
pointer. A side effect is that plain double-click selection now appears
on press rather than release, matching other UI toolkits.
* `LabelSelectionState` carries the anchor across passes, so the drag
can extend into neighboring labels.

No public API changes. Covered by unit tests for the range math and
kittest tests for `TextEdit` (forward/backward/lines) and cross-label
drags in `tests/egui_tests/tests/test_text_selection.rs`.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-10-06 08:01:15 +00:00
Hallvard YstadandEmil Ernerfeldt aba5c857ea Support the X11/Wayland PRIMARY selection (#8428)
* Closes <https://github.com/emilk/egui/issues/5852>
  * [x] I have followed the instructions in the PR template

Selecting text in a `Label` or a `TextEdit` now fills the PRIMARY
selection, and middle-clicking a `TextEdit` pastes it. This is what all
other X11 and Wayland applications do.

Testing: `tests/egui_tests/tests/test_primary_selection.rs`. Publishing
from labels and text edits, no publishing of passwords, no re-claiming
of an unchanged selection, nothing at all on non-PRIMARY platforms,
pasting at the click position rather than at the cursor, and no paste
from a click outside the widget.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-10-06 07:53:01 +00:00
Peder BerganandEmil Ernerfeldt 9ebef5d10e Preserve drop-zone frame styling when idle (#8633)
An idle `dnd_drop_zone` now keeps the supplied frame's fill and stroke
instead of replacing them with the inactive widget style. Drag
highlighting stays the same. Callers that previously relied on idle
colors being ignored will now see their supplied frame styling.

* Closes <https://github.com/emilk/egui/issues/5695>
* [x] I have followed the instructions in the PR template


## Screenshots
From the new snapshot test `tests/egui_tests/tests/test_drop_zone.rs`.
A frame with no styling of its own (transparent fill and no stroke, e.g.
`Frame::default()`) still falls back to the inactive widget style, so
plain drop zones look the same as before.

| | Before (`main`) | After |
|---|---|---|
| Idle | ![before
idle](https://raw.githubusercontent.com/emilk/egui/emilk/pr-8633-screenshots/before_idle.png)
| ![after
idle](https://raw.githubusercontent.com/emilk/egui/emilk/pr-8633-screenshots/after_idle.png)
|
| Dragging over the styled zone (unchanged) | ![before
dragging](https://raw.githubusercontent.com/emilk/egui/emilk/pr-8633-screenshots/before_dragging.png)
| ![after
dragging](https://raw.githubusercontent.com/emilk/egui/emilk/pr-8633-screenshots/after_dragging.png)
|

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-10-06 08:33:36 +01:00
ilya sheprutandEmil Ernerfeldt deb9ed9feb Show tooltips of container responses when hovering their children (#7909)
I have found that `ui.horizontal(...).response.on_hover_text(...)`
doesn't work, although [documentation says
otherwise](https://docs.rs/egui/latest/egui/struct.Ui.html#method.horizontal):


> The returned
[Response](https://docs.rs/egui/latest/egui/response/struct.Response.html)
will only have checked for mouse hover but can be used for tooltips
(on_hover_text). It also contains the
[Rect](https://docs.rs/egui/latest/egui/struct.Rect.html) used by the
horizontal layout.The returned
[Response](https://docs.rs/egui/latest/egui/response/struct.Response.html)
will only have checked for mouse hover but can be used for tooltips
(on_hover_text). It also contains the
[Rect](https://docs.rs/egui/latest/egui/struct.Rect.html) used by the
horizontal layout.

So I added fix to this into tooltip, but this looks like a hack, and I
don't know a better place to do so. Do you have a better idea?

This PR is split into two commits: first commit adds test, and you can
see wrong behaviour in the image. Second commit fixes this and also
regenerates the image and you can now see tooltip.

I have used LLM to help me with this PR (codex). And I retained LLM
comment, because such hacks should have some comments, and it seems ok
to me.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-10-06 07:28:36 +00:00
Oscar GustafssonandEmil Ernerfeldt 2078a31e09 Replace constant divisions with constant multiplications (#8412)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/main/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

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

Compiler optimization will replace these later on, but when building
without optimization they will (most often) stay divisions and divisions
are clearly slower than multiplications.

Note that the `/ 2.5` replacement is not bit-exact (since 0.4 cannot be
represented exactly, but 2.5 can), but my guess is that the
approximation is good enough. The others should be bit-exact.

(Division by 2 for unsigned numbers will be replaced to >>1 earlier in
the compile chain, so no point in doing the same there.)

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-10-05 12:44:07 +00:00
Emil Ernerfeldt 85f1a57719 Rubber-band when drag-scrolling past the edge of a ScrollArea (#8663)
* Follows #8665
* Follows #8662

Content can now be pulled past the edge of a `ScrollArea` with
increasing resistance, and springs back when released, like iOS/macOS. A
flick that coasts into the edge bounces too.

**Input paths**
* **Drag-to-scroll** (touch): rubber-bands on drag, bounces on kinetic
coast.
* **Trackpad, fingers down**: rubber-bands mid-gesture, holds while
fingers rest, springs back on lift.
* **Trackpad, OS momentum phase** (macOS): bounces once off the edge,
then the rest of the momentum is ignored. Momentum arriving while
already past the edge is ignored, so it doesn't overshoot.
* **Mouse wheel / web** (no phases): still hard-clamps, like macOS.
* Scroll bars and `scroll_to_*` unchanged.

**Scroll chaining** is preserved: an inner scroll area already at its
edge when a trackpad gesture starts passes the delta to an enclosing
scroll area. The outermost area rubber-bands at its edge.

**Structure**: `scroll_physics.rs` holds the maths (iOS resistance
curve, exact critically damped spring, exact kinetic decay) and the
per-axis rules (`drag`, `step`, `wheel`) as a 1D stateless
`AxisPhysics`, with unit tests. `scroll_area.rs` keeps only the glue:
build the per-axis physics, call one method per input path, remember
which axes to leave unclamped this frame.

**API**
* `State::offset` is now private, since it may be outside the valid
range while rubber-banding. Read it via `State::clamped_offset()` (what
the old field used to be) or `State::unclamped_offset()` (where the
content is drawn), plus `State::overscroll()`. A deprecated
`State::offset()` returns the clamped one. `State::velocity()` is now in
offset space (positive = scrolling down/right).
* `KineticScrollStyle::rubber_band: bool` to turn it off. Slope (0.55)
and spring time (0.1 s) are constants.

**Tests**: 8 unit tests on the physics and rules (resistance curve,
spring, coast distance, frame-rate independence, chaining, momentum
bounce-once and no-overshoot), plus one kittest test wiring a touch drag
through `ScrollArea`.

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

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-10-05 13:59:11 +02:00
Emil ErnerfeldtandClaude Opus 5.5 4fd6f81d5d Keep tooltips open while holding all modifiers to inspect widgets (#8639)
When `debug_on_hover_with_all_modifiers` is enabled, holding down all
modifier keys lets you hover widgets to see where they were created.
Previously this didn't work for tooltips, since moving the pointer
towards a tooltip would close it.

Now, while all modifiers are held:
* An open tooltip stays open
* The tooltip is made interactable, so its contents can be
hovered/inspected
* Tooltips shown `at_pointer` freeze in place instead of following the
pointer

Includes a regression test.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 12:02:31 +02: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
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
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 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 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
14a010bda7 Add RangeSlider, a two-handled slider sharing Slider's core (#8580)
* 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>
2026-09-17 14:16:58 +02:00
Emil ErnerfeldtandClaude Fable 5.1 235f24eb9e Rename Ui::id to Ui::scope_id and clarify its docstring (#8542)
`Ui::id` was easy to confuse with `Ui::unique_id`. It is the id of the
_scope_ the `Ui` belongs to: stable across frames, shared by sibling
`Ui`s, and the base for widget state ids. `Ui::unique_id` is unique per
`Ui` but unstable.

This renames `Ui::id` to `Ui::scope_id` (old name deprecated) and
rewrites both docstrings to say so.

Follow-up to discussion in:
* https://github.com/emilk/egui/pull/8534#discussion_r3969041538

* [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-15 19:38:48 +02:00
Lucas Meurer 441971a776 Split AtomLayout into WidgetAtom and ContainerAtom (#8222)
`AtomLayout` kinda combined two seperate concerns, this logically
seperates them.

Also makes nested atoms a lot more lightweight, not requiring a
`Response`.
2026-09-11 14:06:19 +02:00
Emil ErnerfeldtandClaude Fable 5.1 5270bc17a2 Add CompletionPopup: a code completion popup over TextEdit (#8529)
New widget `egui::CompletionPopup`: a code completion popup over a
`TextEdit`. ↑/↓ selects, Enter or Tab accepts, Escape closes, click
accepts. Keyboard focus never leaves the text field. The caller supplies
suggestions for the word under the cursor:

```rust
CompletionPopup::new(id).show(ui, TextEdit::singleline(&mut text), |query| suggest(query));
```

New example `code_completion` shows slash-command completion, with
headless `egui_kittest` tests for the arrow/Enter/Tab/Escape behavior,
including a multiline chat composer.

Builds on:
* https://github.com/emilk/egui/pull/8530

Note on Escape: egui surrenders focus on Escape in `Memory::begin_pass`,
before any widget runs. So an app that wants "Escape does X while the
text field is focused" must set `TextEdit::event_filter(EventFilter {
escape: true, .. })`, or the handler never sees the field focused. The
popup does this for you while it is open.


![screenshot](https://github.com/emilk/egui/raw/emilk/code-completion-example/examples/code_completion/screenshot.png)

* Related: <https://github.com/emilk/egui/issues/122>
* [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-10 13:43:49 +02:00
Emil ErnerfeldtandClaude Fable 5.1 24c6061a58 Allow multiple GlyphRasterizers, with priority over installed fonts (#8545)
`GlyphRasterizer` now has a `FontPriority`:

* `FontPriority::Highest`: asked about every cluster, before any font.
Use it to override how specific glyphs looks
* `FontPriority::Lowest` (default): a fallback, only asked about
clusters no installed font (or `FontProvider`) has. Same as before.

Several rasterizers can be installed; within a tier they are asked in
order, and the first `Some` wins.

```rust
ctx.add_glyph_rasterizer(
    egui::GlyphRasterizer::new(|request| (request.cluster == "…").then(|| my_ellipsis(request)))
        .with_priority(egui::FontPriority::Highest),
);
```

API changes (all unreleased): `Context::set_glyph_rasterizer(Option)` →
`add_glyph_rasterizer` / `set_glyph_rasterizers(Vec)`, same on
`epaint::Fonts`.

Follow-up to:
* https://github.com/emilk/egui/pull/8512

* [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-10 13:09:13 +02:00
e7c7b00a93 Deprecate Id::new and From<&str> for Id (#8534)
`Id::new` and `From<&str> for Id` etc are foot-guns: they hide the fact
that an `Id` MUST be globally unique (well, at least unique within your
app).

So this PR removes both and replaces them with `Id::unique`, which is
very explicit.
In places where non-uniqueness is desired, you can use `IdSalt`, which
has the convenient `From<&str>`.

Most changes are in tests.

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Lucas Meurer <hi@lucasmerlin.me>
2026-09-09 16:03:15 +02:00
Emil ErnerfeldtandClaude Fable 5.1 f2de65f636 Render any glyph and colored emoji on native 🚀 (#8512)
Add full emoji support to eframe on native! Also supports any glyph that
your system fonts support.

Test string: ✨ We support ไทย, 한국어, and 🦀 🚀 🤖/🦾/📷/🎞️

Chain, in order, all merged into `emilk/emojis`:

* https://github.com/emilk/egui/pull/8491
* https://github.com/emilk/egui/pull/8492
* https://github.com/emilk/egui/pull/8493
* https://github.com/emilk/egui/pull/8508
* https://github.com/emilk/egui/pull/8509
* https://github.com/emilk/egui/pull/8510
* https://github.com/emilk/egui/pull/8511

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-06 08:27:50 +02:00
Lucas MeurerandClaude Opus 5 9cb53feab4 Add tests for StyleProvider and ensure every property works (#8477)
Follow up to #8455

Based on #8485

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 16:50:30 +02:00
Lucas MeurerandClaude Opus 5 7c38c552e4 StyleProvider for TextEdit and DragValue (#8455)
Implements `StyleProvider` for `TextEdit`, so you can fully style it as
you please

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-02 11:42:31 +02:00
Lucas MeurerandClaude Opus 5 5cb3a4f89e Add AtomLayoutStyle (#8465)
Extracts a shared struct with things that once might want to override
for any atomlayout-based widget.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-02 11:27:17 +02:00
Lucas Meurerandemilk e1507d031d Properly respect min_size in TextEdit (#8420)
TextEdit has a min_size field but we completely ignored in the y
direciton. (I probably broke it in #7140).

---------

Co-authored-by: emilk <1148717+emilk@users.noreply.github.com>
2026-09-01 09:39:32 +00:00
Lucas MeurerandClaude Opus 5 de077b92d3 Rename classes, more button options via StyleProvider (#8464)
Moves global classnames to e.g. `egui::class::ROOT`.

Widget specific classes live on the widgets struct. 

Adds some more classes for our buttons styling options (`CLASS_SMALL`
etc), so that custom `StyleProvider`s can choose to implement them
differently or ignore them altogether.


Also removes some styleproviders that were partly or completely unused
(e.g. basestyle / labelstyle). We can add them back once we actually
implement styling for those.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-01 11:39:13 +02:00
Emil Ernerfeldt a15a7e6611 Increase widget corner radius to 4 (#8445)
A little more round and friendly!

* See also https://github.com/emilk/egui/pull/8439
2026-08-24 11:07:06 +02:00
97603fc082 Theme plugin system (experimental) (#8153)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/main/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

# What it does

Addition of a new system of theme plugins which allow the user to use
different rules engine to compute the style for the available
specialised widget style.

# How to use

Create a engine implementing the trait `ThemePlugin` and `ThemeStyle<S:
StyleStruct>` and implement the necessary methods, then register this
way (example for `ButtonStyle`):
```ui.add_theme::<ButtonStyle>(&mycustomengine);```

Now all button will call the `ThemeStyle<ButtonStyle>` method to compute the correct style and later use the cached value to avoid the costly computation.

If no valid `ThemeStyle<S>` or engine is available then it fallback to the default style.

* Closes part of <https://github.com/emilk/egui/issues/3284>
* [x] I have followed the instructions in the PR template

---------

Co-authored-by: adrien <221212@umons.ac.be>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Lucas Meurer <hi@lucasmerlin.me>
2026-08-21 13:05:45 +00:00
Emil ErnerfeldtandClaude Fable 5 fd54387eac Clean up clippy lint config (#8437)
* [x] I have followed the instructions in the PR template

Remove clippy lint groups already covered by `all` (`complexity`,
`perf`, `suspicious`, and the misspelled `correctnesss`), and two
individual lints covered by the `cargo` group (`negative_feature_names`,
`wildcard_dependencies`).

Add `publish = false` to the two internal crates that were missing it
(`popups`, `egui_tests`), which silences the
`clippy::cargo_common_metadata` warnings.

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

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-20 08:42:12 +00:00
65e827e23a Fix Sense::drag detecting drags when clicking widget above it (#8396)
Co-authored-by: Lucas Meurer <lucas@rerun.io>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-07 14:26:26 +02:00
Emil Ernerfeldt 6aea7eff94 Enable the clippy::std_instead_of_core lint (#8394)
Prefer `core::` over `std::` where either work

* Part of https://github.com/emilk/egui/issues/5735
2026-08-06 13:19:13 +02:00
Emil ErnerfeldtandClaude Opus 5 e37d44ad8a Never run an egui pass when nothing will be shown (#8387)
* Closes <https://github.com/emilk/egui/issues/8266>
* Alternative to #8385

Not the most simple or beautiful code, but it works, and makes sense.

What makes it complex: `app.logic` should still see some input (e.g.
what viewports are visible) and emit some output (e.g. "open this link",
or "focus and repaint").

## TODO
* [x] test multiple viewports

## Clanker says
Instead of teaching egui to skip book-keeping during a pass where no ui
is shown, we simply run no pass at all. Then there is nothing to
special-case: all ui state is left untouched, and the app finds
everything where it left it when the window is shown again.

* New `Context::run_logic(&raw_input, f)`: ticks app logic without a
pass, returning the `LogicOutput` (platform output + viewport commands)
that a pass would otherwise have carried, so e.g.
`ViewportCommand::Focus` still reaches the integration.
* All three eframe backends (glow, wgpu, web) call `run_logic` instead
of `run_ui` when the viewport is minimized/occluded (and has no visible
descendant viewport) or, on web, when the tab is hidden.
* `App::logic` is still called from inside the pass when the window is
visible, so it sees the current frame's input.

While hidden, `run_logic` fills in only the window state
(`RawInput::viewports` / `focused`), so the app can tell that it is
hidden. The ui input (events, time, …) is not interpreted, and is
instead given to the next real pass.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 09:14:35 +02:00
Emil ErnerfeldtandClaude Opus 5 622bbbeccc Add drag-to-open for collapsible panels (#8363)
A fully collapsed `show_collapsible` panel now leaves a thin grab handle
at its fixed edge, invisible until hovered. Dragging it out past
`min_size` (or double-clicking it) reopens the panel. Opt out with
`panel.drag_to_open(false)`.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-04 09:20:25 +00:00
Emil ErnerfeldtandClaude Opus 5 98eab50577 Treat a press that leaves a widget as a drag (#8365)
A widget that senses both clicks and drags postpones the
click-versus-drag decision until the pointer moves past `max_click_dist`
or is held for `max_click_duration`. But a click has to be released *on*
the widget — so once the pointer leaves, the gesture can only be a drag,
and there is nothing left to wait for.

This matters for widgets thinner than `max_click_dist` (6px), such as
panel resize handles. The pointer leaves such a widget almost
immediately, which hands the hover to whatever is underneath, while
`dragged()` was not true yet. So a handle highlighting on `hovered() ||
dragged()` blinked out mid-gesture.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-04 11:09:27 +02:00
Emil ErnerfeldtandClaude Opus 5 ddec5f3e4c Fix where Panel puts its separator line, and how much room it reserves (#8382)
Two fixes to the separator line of `Panel` (`resolve_frame` was added in
#8367):

* **Reserve room only when the line is always drawn.** Before,
`show_separator_line || resizable` reserved the line's thickness, so a
resizable panel that opted out still got a permanently visible gap along
its inner edge — space held for a line only drawn transiently, while
hovering or dragging the resize handle.
* **Paint the line outside the frame's outline**, in room reserved in
`Frame::outer_margin` rather than `inner_margin`, so going outwards from
the panel contents you get:

  `contents | inner_margin | stroke | separator line | outer_margin`

Previously the line landed on top of the frame's outline (or outside its
outer margin). Default panels — no stroke, no outer margin — are
unchanged pixel-wise.

Found in the Rerun viewer: the time panel is
`.resizable(true).show_separator_line(false)` and draws its own top
line, so the extra 1pt landed above the top bar's buttons, making them
look 1pt too low.

Tests in `tests/egui_tests/tests/test_panel_separator_line.rs`, both
spanning `show_separator_line` on/off × resize handle hovered/not:
snapshots of a top panel with a garish outline, plus a pixel probe
across the inner edge of a panel on each of the four sides. Both fail on
`main`.

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

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

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 10:32:56 +00:00
Emil Ernerfeldt 4471969a16 Panels: Take separator line width into account (#8367)
This fixes a small styling bug: the width of the panel's
resize-handle-line was not included in the outer width of the panel. Now
it is.
2026-08-01 10:13:52 +00:00
Lucas MeurerandClaude Opus 5 36341c21fe Make non-interactive tooltips not interactable (#8362)
Fixes two bugs around tooltips:
- During sizing pass tooltips would render at a different size, at which
point they might overlap the interacted widget causing the hover state
to change and the tooltip to never be shown
- Fix: During sizing pass make the area `interactable: false` so events
pass through
- When hovering close to the boarder of a widget (in the area where
`interact_radius` takes effect), there could be a feedback loop where
the tooltip is shown one frame and hidden the next.
- Fix: Always make tooltips `interactable: false` when they don't have
interactive contents

This PR changes the behavior of `Area::interactable` to it's original
behavior: Now interactions will pass through the area background _and_
it's containing widgets. It worked this way initially but got changed in
#4026

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-31 14:30:46 +02:00
Emil Ernerfeldt 8c1711ff9f Disable warn_if_rect_changes_id, even in debug builds (#8349)
Too many false positives (spurious red rectangles)
2026-07-28 09:27:38 +00:00
Antoine CellerierandClaude Opus 4.7 5a49d895bf Announce pressed state of selectable buttons to screen readers (#8130)
A `Button` used as a toggle (via `Button::selected(true)`,
`Button::selectable(...)`, or `Ui::selectable_label`) now announces its
pressed / not-pressed state to screen readers. Plain buttons that never
call `.selected(...)` stay un-toggled, so their announcement doesn't
change. `Checkbox` and the pre-existing selectable-label code path
already did this; `Button` was the odd one out.

No public API change: the field is private, `Button::selected(bool)`
keeps its signature, and visuals are identical. Internally the field
becomes `Option<bool>` so we can distinguish "plain button" from "toggle
button currently off".

Regression test added in `regression_tests.rs`, do let me know if some
other file would be a better location.

### Note for manual testing

`egui_demo_app` pulls in `eframe` with `default-features = false` and
doesn't re-enable `accesskit`, so `cargo run -p egui_demo_app` publishes
no AccessKit tree at all. To verify manually:
`cargo run -p egui_demo_app --features accessibility_inspector`
Happy to send a small follow-up PR enabling `accesskit` in the demo
app's defaults if that's desirable, since that makes a11y work much
easier to smoke-test locally.

### Use of AI

This PR was drafted with Claude Code. I understand different projects
have different policies regarding AI generated code. Do let me know if
this is not acceptable here. Also happy to take any other feedback.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-24 13:58:30 +02:00
Lucas Meurer 080ce81c8b Add AtomLayout::direction (#8221)
* To be merged after #8219 

Adds support for vertical atom layout. Together with #8219 this
basically creates a minimal flex layout engine
2026-06-24 13:56:54 +02:00
冷凍アカギ 172fb54f7f Add AtomLayout::selectable for opt-in text selection (#8224)
* Closes https://github.com/emilk/egui/issues/8217
* [x] I have followed the instructions in the PR template

## What

`AllocatedAtomLayout::paint` painted text via
`ui.painter().galley(...)`, so text in atom-based widgets could never be
selected. As discussed in #8217, routing it through
`LabelSelectionState::label_text_selection` unconditionally would break
`Button` / `Checkbox` / `RadioButton` / `TextEdit` (whose labels should
not be selectable, and whose click/drag handling would fight the
selection drag).

So this adds an **opt-in** `AtomLayout::selectable(bool)` (default
`false`). When enabled, the layout also senses clicks and drags
(mirroring `Label::layout_in_ui`) and paints its text through the
label-selection machinery. The underline is `Stroke::NONE`, so when
nothing is selected the painted output is identical to the existing path
— the default (`selectable == false`) behaviour, and existing snapshots,
are unchanged.

## Tests

Two tests in `tests/egui_tests/tests/test_atoms.rs`:

- `test_atom_selectable_senses_click_and_drag` — a `selectable(true)`
layout senses click+drag; the default stays inert.
- `test_atom_selectable_text_can_be_copied` — selecting (drag) the text
of a selectable layout and copying yields the text via
`OutputCommand::CopyText`, while a non-selectable layout yields nothing.

## Notes

- Verified locally: `cargo fmt --all -- --check`, `cargo clippy -p egui`
(clean), and the two new tests pass. I haven't run the full
`./scripts/check.sh` (wasm/typos) locally, hence opening as a draft.
- This only adds the opt-in API; no existing widget is made selectable.
Happy to wire it up on a specific widget and/or add an `egui_demo_lib`
demo if you'd like — just let me know.
2026-06-13 20:25:00 +02:00
Ammar Abou ZorandEmil Ernerfeldt a66f0dbd4f Fix ScrollArea::scroll_to_* calls when stick_to_bottom is Active (#8033)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/main/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

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


It includes:
* Fix for `ScrollArea` when `scroll_to_*` could be ignored when
`stick_to_bottom(true)` was active and the viewport was already stuck to
the bottom.
* The fix is by making explicit per-axis scroll movement take priority
over sticky-end snapping for that frame, and avoid immediately
re-marking animated scrolls as still stuck.
* I've also added a regression test for this issue to ensure it will be
caught on further code changes.

The code snippets form the original issue can be used for testing here
as well

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-05-26 16:01:55 +02:00
Emil Ernerfeldt 27559ef3fd Rename Panel methods (#8192)
The three methods for showing a `Panel` are now:

* `panel.show`: always show the panel.
* `panel.show_collapsible`: show or hide the panel, with a slide
animation in between.
* `Panel::show_switched`: animate between two different panels: a
thin/collapsed one and a thick/expanded one.
2026-05-24 12:22:32 +02:00
Emil Ernerfeldt 3cf844c542 Drag-to-close panels (#8182)
* Closes https://github.com/emilk/egui/pull/7254

You can now drag-to-close a panel. Also drag-to-expand panels.

This is a breaking change: the animated panel functions now take a
`open: &mut bool` instead of `open: bool`.

This is only enabled for resizable panels
2026-05-22 16:05:39 +02:00
Emil Ernerfeldt bea47a2ce7 Window: move only by dragging title bar (#8183)
* Part of https://github.com/emilk/egui/issues/8180

So far, you've been able to move any `egui::Window` by dragging anywhere
on it. This makes sense on touch screens with thick fingers, but less so
on non-touch-screens.

With this PR, you can now control it with a new enum `WindowDrag`
2026-05-22 12:39:43 +02:00
Emil Ernerfeldt 85ad9cac7e Rework Window margins and set clip_rect_margin to zero (#7725)
* Follows https://github.com/emilk/egui/pull/7722
* Part of https://github.com/emilk/egui/issues/5605
* Closes https://github.com/emilk/egui/issues/3385

## What
Sets `clip_rect_margin` to zero, and moves the margin of `Window`s with
`ScrollAreas`, so that the scroll bars are now on the very edge of the
windows they are in.

Windows with a bulit-in scroll area now lets the content go all the way
to the edges (left image).
However, if you just manually add a `ScrollArea` to a `Window`, you
won't get this effect (right image).
<img width="763" height="345" alt="Screenshot 2026-05-18 at 22 04 01"
src="https://github.com/user-attachments/assets/e41cdfcb-b0a6-4e5e-9691-d132a602d6a7"
/>

## Required
* #7803
* #7804
* #7805
* #7806
* https://github.com/emilk/egui/pull/7807
* https://github.com/emilk/egui/pull/7808
2026-05-19 15:43:42 +02:00
Lucas Meurer 902906f989 Fix centered & right aligned TextEdit (#8082)
A couple improvements to centered and right-aligned text edits:
- Fix text selection in centered and right aligned text edits
(ironically, this broke in #8076)
- Fix cursor movement in centered and right aligned text edits
(horizontal cursor position will be retained on vertical movement)
- Multiline text edit exceeding available width if there are atoms
- Added atoms & alignment options to text edit demo
- Improve how vertical_align and horizontal_align are applied
- Textedit atom is grow now, removing the need for the extra seperate
grow atom
- This allows us to apply the `align` on the text edit atom instead of
the whole AtomLayout
  - Fixes https://github.com/emilk/egui/pull/8022
  - Fixes https://github.com/emilk/egui/issues/7999
2026-04-14 13:13:59 +02:00
Emil Ernerfeldt db87c712a1 Replace cargo machete with cargo shear (#8094)
We've had good experiences with `cargo shear` at Rerun
2026-04-13 17:48:43 +02:00