Commit Graph
392 Commits
Author SHA1 Message Date
Emil Ernerfeldt 37119162c7 Make the internals of ColorImage private (#8714)
`ColorImage` fields are now private. Use `resolution()`, `pixels()`,
`pixels_mut()`, and `source_size()` instead.

Also renames `size` to `resolution` in several texture-related APIs
(`ImageData`, `TextureHandle`, `TextureMeta`, `TextureAtlas`,
`Fonts::font_image_resolution`).

`ColorImage::new` now panics if `width * height != pixels.len()`.

## Motivation
A) Make `ColorImage` always valid
B) Stop confusing using the confusing word `size` where `resolution` is
better
2026-10-19 09:22:26 +02:00
Lucas MeurerandClaude Opus 5.5 86099aca12 Release 0.37.0 - Color emojis (#8725)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-15 17:52:45 +02:00
Lucas MeurerandClaude Opus 5.5 4166a93ffd Fix missing Chinese characters from system fonts on Windows (#8688)
* Related: #5233, upstream
https://github.com/linebender/parley/issues/644
* [ ] I have followed the instructions in the PR template

On Windows with a non-Chinese locale, fontique's Han fallback is a
single Japanese font (Yu Gothic UI), which lacks many Simplified Chinese
characters like 这 and 还. These rendered as tofu even with Microsoft
YaHei installed.

The example text from the added demo without the fix fails to show some
glyphs:

<img width="582" height="146" alt="image"
src="https://github.com/user-attachments/assets/1f37a778-6d67-431f-9aad-c7bd23e0e360"
/>


`SystemFontProvider` now tries the other Han locales
(Simplified/Traditional Chinese, Japanese, Korean) when the font for the
preferred locale can't render a char.

Simplified Chinese is looked up as `zh-SG` instead of `zh-CN`: fontique
treats `zh-CN` as the default Han locale and caches the result of the
locale-less Han lookup (which every `Query::set_fallbacks` makes) as
that default. So `zh-CN` lookups often returned the Japanese font,
depending on which scripts were looked up first. A TODO points at
linebender/parley#689, which should make this workaround unnecessary.

Also adds a collapsed "System font fallback" section to the Misc Demos
window to check the fallback by eye.

## Testing
Verified on Windows 11 (de-DE): all samples in Misc Demos → System font
fallback render, and `cargo test -p egui_system_fonts --
--include-ignored` passes.

**Still needs testing on macOS and Linux**: open Misc Demos → System
font fallback in `egui_demo_app` and run the ignored tests above. Both
platforms also pick a single fallback font per script in fontique, so
they could have the same problem in milder form, e.g. a Japanese-locale
Mac, or a Linux system with only a Japanese CJK font.

The Misc Demos snapshot was updated on Windows; if CI disagrees,
`./scripts/update_snapshots_from_ci.sh` should fix it.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 08:05:43 +00:00
Emil Ernerfeldt b148f131ca Add CCursor::end_of_str and CCursorRange::select_all_str (#8680)
`CCursor::new` was a bit of a foot-gun: it had no docstring, and it's
easy to accidentally pass it a byte offset instead of a character
offset.

* Document that `CCursor::new` takes a character offset, NOT a byte
offset
* Add `CCursor::end_of_str(text)`: a cursor after the last character of
`text` (i.e. `text.chars().count()`)
* Add `CCursorRange::select_all_str(text)`: select all of `text`
* Use these in `DragValue` and the `TextEdit` demo

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-10-08 14:25:31 +00:00
Emil Ernerfeldt 2e3c091065 Add simple SQL syntax highlighting to egui_extras (#8673)
The non-`syntect` fallback highlighter in `egui_extras` now supports SQL
(`"sql"`):

* `-- line comments`
* `'single-quoted'` strings
* Case-insensitive keywords (`SELECT`, `select`, …)

Also: `_` is now treated as part of a word for all languages, so
identifiers like `order_id` (SQL) or `self_ref` (Rust) no longer get a
keyword highlighted inside them.

Snapshot test in `egui_demo_lib/tests/misc.rs` renders SQL with both
backends (`sql_fallback_*` / `sql_syntect_*`). Note: CI runs
`--all-features`, so only the syntect snapshots are checked there; the
fallback ones are checked by `cargo test -p egui_demo_lib`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-10-06 15:17:38 +02:00
n4n5andEmil Ernerfeldt 71f847fc94 Add CollapsingHeader::custom for collapsing headers with a custom header UI (#8549)
`CollapsingHeader::custom(ui, id_salt, add_header, add_body)` is a
convenience wrapper around `CollapsingState::show_header(…).body(…)`,
letting you put arbitrary widgets (checkboxes, buttons, …) in the header
of a collapsing section without manually managing a `CollapsingState`.

The "Custom Collapsing Header" demo in the misc demo window now uses it.

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

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-10-06 07:06:40 +00:00
Tristan117andEmil Ernerfeldt e145cd59a2 Add option ``scroll_zooms` for mouse wheel to zoom instead of scroll inside a `Scene`` container (#7891)
Closes <https://github.com/emilk/egui/issues/7650>
[ X] I have followed the instructions in the PR template

Previously submitted as <https://github.com/emilk/egui/pull/7666> but
replaced to clean up the git history.

This feature allows building image viewers and similar applications
using a `Scene` container where the desired mouse wheel input without a
modifier is to zoom rather than scroll/pan.

Alternatives considered:

Swap zoom and scroll variables used in `Scene`
- Would cause touch input zoom to scroll/pan instead which would be
inconsistent with standard user interface interaction
- This also means there is no simple way to swap zoom and vertical
scroll modifiers for this use case e.g. ctrl+mousewheel pans vertically
while mousewheel alone zooms.
- What is implemented results in ctrl-mousewheel and mousewheel only
being identical inputs.

Modify `ctx.option.zoom_modifier`
- Doesn't work because `Modifiers:NONE` never matches to anything (and
therefore disables mouse wheel zoom globally).
- Refactoring this to provide a different option per container is a
large amount of work and does not seem to be a use case that is likely
to be used outside of `Scene`

The logic used inside `Scene` to achieve this is fairly simple and only
adds one extra dependency on `input_options.scroll_zoom_speed` to ensure
that the zoom speed setting change is consistent across the application.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-10-05 12:54:58 +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 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 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
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 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
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
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
Lucas MeurerandClaude Opus 5 9396036534 Paint SubMenuButton arrow as a triangle instead of a glyph (#8525)
Eguis built in widgets should work right even if there are no
default/system fonts. This renders the submenubutton triangle with
epaint so it will always look right and isn't system-font dependent.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-10 12:08:47 +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
Lucas Meurer 416dd85acb Make ViewportCommand::Screenshot callback based (#8489)
Migration guide for the changelog:
`ViewportCommand::Screenshot` was changed to be callback based.
Previously you needed to iter the input events to check for the
screenshot (but didn't need interior mutability):
```rs
[derive(Default)]
struct MyApp {
    screenshot: Option<Arc<egui::ColorImage>>,
}
impl eframe::App for MyApp {
    fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
        if ui.button("Screenshot").clicked() {
            ui.send_viewport_cmd(ViewportCommand::Screenshot(UserData::default()));
        }

        let image = ui.input(|i| {
            i.events
                .iter()
                .filter_map(|e| {
                    if let egui::Event::Screenshot { image, .. } = e {
                        Some(Arc::clone(image))
                    } else {
                        None
                    }
                })
                .next_back()
        });
        
        if let Some(image) = image {
            self.screenshot = Some(image);
        }
    }
}
```

Now you need to use a mutex, channel, or some other sync primitive to
get the result:
```rs
#[derive(Default)]
struct MyApp {
    screenshot: Arc<Mutex<Option<Arc<egui::ColorImage>>>>,
}
impl eframe::App for MyApp {
    fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
        if ui.button("Screenshot").clicked() {
            let ctx = ui.ctx().clone();
            let screenshot_mutex = self.screenshot.clone();
            ui.request_screenshot(move |screenshot| {
                screenshot_mutex.lock().replace(screenshot);
                ctx.request_repaint();
            });
        }
    }
}
```
----



This implements a callback-based screenshot api for egui

Upsides over `ViewportCommand::Screenshot`:
- More convenient api: `ctx.request_screenshot(|screnshot| ...)` (and no
need to downcast UserData)
- Reading screenshot data doesn't require rendering another frame
- Should allow us to add recording as a plugin without special hooks in
egui_kittest (otherwise capturing the last frame would have required
custom hooks in kittest)
- This was also a problem in
[kittest_inspector](https://github.com/rerun-io/kittest_inspector): When
streaming a real app, the frame seen was always a couple frames behind
when the app was idle
2026-09-08 16:06:18 +02:00
ishuowang e2850d138b Fix color picker RGB drift when editing alpha (#8483)
Closes #8478.

Editing the alpha `DragValue` rebuilt the full HSVA color from the
displayed RGBA values, which could re-quantize RGB. This tracks RGB and
alpha edits separately so alpha-only edits preserve RGB.

Adds regression coverage for gamma-byte and linear numeric color spaces.

- [x] I have followed the instructions in the PR template
2026-09-07 12:15:57 +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
Emil ErnerfeldtandClaude Fable 5.1 e39e793d5c Remove the Font borrow-bag; put its methods on FontsImpl (#8504)
`Font<'a>` was a hand-rolled split borrow of every field of `FontsImpl`,
and it grew a new `&'a mut` for each new feature. `text_layout` now
calls `FontsImpl` directly (`resolve_face`, `glyph_info`,
`allocate_glyph`, `rasterize_cluster`, …) with a cheap `FamilyKey` index
instead of re-hashing the `FontFamily` per glyph.

`font.rs` is renamed to `font_face.rs`, since only `FontFace` is left in
it. `FontsView::characters` replaces `f.fonts.font(family).characters()`
in the font book demo.

`FontsImpl` and `epaint::text::layout` are now crate-private: nothing
outside `epaint` used them, and `Fonts` / `FontsView` cover the public
API. The `fonts` fields of `Fonts` and `FontsView` are private too. The
benchmark that used `layout` directly now calls the new
`Fonts::layout_uncached`.

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

PR chain, in order:
* #8490
* #8500
* #8501
* #8502
* #8503
* #8504
* #8491
* #8492
* #8493

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-05 17:01:45 +00: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 2b34fe0c1c Add Align2 helpers (#8485)
Add utilities to make it easier to construct and use `Align2`

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 15:55:33 +02:00
Joaquim Monteiro 080d512f45 Fix widgets shifting around on hover in interactive container demo (#8471)
This happens because `bg_stroke`'s width isn't constant.

| Before | After |
|--------|--------|
| <img width="320" height="320" alt="before"
src="https://github.com/user-attachments/assets/0101e5fb-0781-4867-9891-c91d49dbb969"
/> | <img width="320" height="320" alt="after"
src="https://github.com/user-attachments/assets/4223218a-2f5f-4542-9fe2-67be5799ca81"
/> |

---

<!--
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!
* Keep PR description short and to the point! No long LLM slop.
* 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 a human has reviewed it
* 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
2026-09-01 11:27:47 +02:00
limo520 5d3e958ecf Fix the constrain option not working in the window options demo (#8433)
<!--
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!
-->
`constrain_to` overrides `constrain`, so I adjusted it to call
`constrain_to` before `constrain`.

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

Signed-off-by: limo520 <247564335@qq.com>
2026-08-27 01:14:01 +00:00
Emil ErnerfeldtandClaude Fable 5 726b995608 Round the corners of the color picker (#8439)
The color picker's gradients and background checkers now follow the
style's corner radius, giving it a softer look.

This required changing the painting from being Mesh-based to being
texture-based

it's subtle with the default settings:

<img width="286" height="397" alt="Screenshot 2026-08-21 at 15 08 18"
src="https://github.com/user-attachments/assets/3a9d5289-71fb-4f34-8a20-1fe96891ba36"
/>


But you can [increase it](https://github.com/emilk/egui/pull/8445):


<img width="285" height="391" alt="Screenshot 2026-08-21 at 15 08 41"
src="https://github.com/user-attachments/assets/b0dfa7da-5b96-40e0-a80d-1da385d57a1a"
/>


### Before
for reference
<img width="286" height="392" alt="Screenshot 2026-08-21 at 19 08 27"
src="https://github.com/user-attachments/assets/7c754f36-795c-4381-9f9f-1fc8dd9a0264"
/>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-24 09:28:14 +00: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 Ernerfeldt 00dc6e814b Make kittest's predictable texture filtering honor TextureOptions::NEAREST (#8441) 2026-08-21 01:33:29 -07:00
Emil ErnerfeldtandClaude Opus 5 34b39d564b Enable the clippy::pedantic lint group (#8429)
Instead of opting in to pedantic lints one by one, enable the whole
group and opt out of the noisy ones.

64% of the pedantic lints were already listed individually. This deletes
90 explicit lint lines, enables 51 pedantic lints we never listed, and
picks up new pedantic lints for free. Each opt-out carries its hit
count, so the cost of turning one back on is visible.

`restriction` and `nursery` stay opt-in per lint.

Stacked on top of #8430, which fixes the one real bug the new lints
found.

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

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-18 06:55:53 +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 Ernerfeldt 90e03028f7 Fix a few nightly clippy lints (#8388) 2026-08-04 21:40:56 +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
limo520andEmil Ernerfeldt 2e7a92bc37 Fix incorrect feature name in the code editor demo (#8330)
Change the feature name from syntax_highlighting to syntect.

<!--
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

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-08-03 14:51:17 +02: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
Emil Ernerfeldt b06f5fea09 Remove clip_rect_margin (#8366)
* Closes https://github.com/emilk/egui/issues/5605
 
It has been zero by default for a few months now, and I do not wish to
support it. It was always an ugly hack, and it is no longer needed.
2026-07-31 23:21:17 +02:00
Lucas MeurerandClaude Opus 5 6268c84d8a Prevent accidentally dropping TexturesDelta (#8356)
We had a ton of issues around `TexturesDelta` that weren't properly
applied because we early-out of some function:
* https://github.com/emilk/egui/pull/8313
* https://github.com/emilk/egui/pull/8250
* https://github.com/emilk/egui/pull/8279

This PR changes texture updates, so that we always store them after
taking them out of `FullOutput` and keep the delta around until it's
actually applied (by passing &mut refs and draining instead of
iterating). So even if we add a new early return somewhere, that can't
break texture updates.

It also optimizes `TexturesDelta::append` by dropping any previous
deltas if there's a new `whole` delta or a `free`.

It also adds a debug assert that any `TexturesDelta` is empty when
dropped, as an additional safeguard in case the bug sneaks back in.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-29 16:16:48 +00:00
Lucas MeurerandClaude Opus 4.8 2e26b70ae9 Call logic even while browser tab is in background (#8257)
* Closes https://github.com/emilk/egui/issues/5112

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 14:59:45 +02:00
Emil ErnerfeldtandClaude Opus 4.8 0fce065f85 Update a lot of dependencies (#8252)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 05:20:06 +02:00
Emil Ernerfeldt 858c8fd99f Improve Debug-formatting of Id in debug-builds (#8190)
The Debug-formatting of `Id` in debug-builds now contain the full
lineage:

```rs
#[test]
fn with_chain() {
    let id = Id::new("a").with("b").with("c").with(7_i32);
    assert_eq!(
        format!("{id:?}"),
        r#"Id::new("a").with("b").with("c").with(7)"#
    );
}
```


## Related
* https://github.com/emilk/egui/pull/5851
* https://github.com/emilk/egui/pull/7988
2026-06-10 09:39:33 +02:00
Gábor Gyebnár 71c4ff3c33 Fixes color picker hue drift at low alpha values (#8208)
<!--
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

At low apha values, premultiplied colors lose precision.
This PR makes the color picker use unmultiplied colors internally.

Before:


https://github.com/user-attachments/assets/4617a355-daa9-4911-86e6-518ac6867014

After:


https://github.com/user-attachments/assets/d9681b01-50d8-418e-b5a5-79b4bd1bbddf
2026-06-05 15:58:36 +02:00
Emil Ernerfeldt 71f22ff1a5 Improve panel example (#8200) 2026-05-25 15:45:00 +02:00
Emil Ernerfeldt 46c20810ba Remove impl Into<f32> arguments (#8194)
* Closes https://github.com/emilk/egui/issues/8179
2026-05-25 10:59:03 +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 3888087dc5 Add AsId and IdSalt (#8184)
## Related
* https://github.com/emilk/egui/pull/5851
* https://github.com/emilk/egui/pull/7988

## What
We want to make it easier to understand the lineage of a `Id` (which is
the parent `Id`, and the parent of that, etc?)

As a first step of that, we want to clarify the different between a
globally unique `Id`, and an `IdSalt`

I also introduced the `AsId` and `AsIdSalt` traits, which are
implemented of anything that implements `Hash` and `Debug`. The `Debug`
half of that is unused here, but will later be used in `Debug` builds to
produce a proper tree.
2026-05-22 15:19:55 +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