1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 22:53:14 -04:00
Commit Graph

4194 Commits

Author SHA1 Message Date
lucasmerlin
362cf8f227 Add Sense::scroll 2026-03-11 18:46:12 +01:00
Lucas Meurer
8b90dc60c6 ⚠️ Atom improvements: Atom::id, align, closure, max_size (#7958)
Migration guide:
- `AtomKind::Custom` has been removed. You can now set an id to any kind
via `Atom::custom` or `AtomExt::atom_id`.
2026-03-10 12:03:10 +01:00
Lander Brandt
9bc062c8ee Fix wgpu memory leak leading to panic when window is minimized (#7434) (#7928) 2026-03-05 12:47:57 +01:00
Emil Ernerfeldt
7633258219 Enforce 'suffix' for consistency 2026-03-05 10:51:12 +01:00
valadaptive
699fc7e887 Add font variations API (#7859)
<!--
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 N/A
* [x] I have followed the instructions in the PR template

This was mostly from last month, but I never got around to submitting
it.

This PR adds font variation coordinates to the `TextFormat` struct, and
uses them when rendering text. The coordinates are stored in a
`SmallVec`; I've chosen to store up to 2 inline, which makes it take up
24 bytes (the minimum possible for a `SmallVec`). The variation axis
tags are stored as the `font_types::Tag` type, which I've chosen to
re-export from `epaint::text`.

The variation coordinates are resolved to a `skrifa::Location` during
font rendering/scaling, and are cached in the same way as all the other
scaled metrics. I've renamed the `ScaledMetrics` struct to
`StyledMetrics`, since it now also contains the resolved variation
coordinates. I haven't benchmarked the performance of text layout with
variation coordinates, but the existing text layout performance is
unchanged.

I've replaced the API for manually overriding a font's weight
(https://github.com/emilk/egui/pull/7790) with an API for manually
overriding any variation coordinates via `FontTweak`. This should
support the same use case as #7790 while being substantially more
flexible.

I have *not* yet added any higher-level API for mapping style attributes
(weight, width, slant, etc) to variation coordinates or to different
font faces within a single family. That's a pretty huge can of worms,
and it'd involve rethinking the split between `FontId` and `TextFormat`
(and whether `FontId` is so big that we should provide a way to reuse
it). This API is intentionally pretty low-level for now.

Likewise, I've intentionally not used variation coordinates when
computing a font's row height. I can't think of any fonts that change
their vertical metrics depending on variation axes, so this should be
fine for now.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-03-03 22:58:42 +01:00
Emil Ernerfeldt
ee3e73bdf9 Fix: repaint on drag-and-drop files (#7953)
When someone drag-and-drops files onto an egui/eframe app, it makes
sense to wake it up
2026-03-03 17:02:30 +01:00
Emil Ernerfeldt
b733679760 Fix text color when selecting newline character (#7951)
* Closes https://github.com/emilk/egui/issues/7865
2026-03-03 13:27:56 +01:00
Lucas Meurer
a354c02e76 Add Atom prefix/suffix support to DragValue (#7949) 2026-03-03 11:35:29 +01:00
Dion Bramley
20f3cb52cc Make Galley::pos_from_layout_cursor pub (#7864)
* [x] I have followed the instructions in the PR template

This PR just exposes the pos_from_layout_cursor function as public.

Hi, I'm trying to make a git gui with a merge editor, and for this I
need a much more efficient and flexible text editor than the one
currently in egui. So I'm working on building a more suitable one, which
I intend to contribute back once it's working, but for now I would like
to not need to fork the entirety of egui. By exposing this one function
I (and others) can much more easily reuse Galleys.
I suggest also exposing end_pos, but I'm not currently using that. Let
me know if I should update this PR to do so.

Thanks for the otherwise awesome tool :)
2026-03-03 09:13:56 +01:00
RndUsr123
124bde4883 Fixes the overly aggressive overflow elision in truncate() and similar for os scaling other than 100% (#7867)
* Closes #7818
* [x] I have followed the instructions in the PR template

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-03-03 08:46:45 +01:00
Emil Ernerfeldt
1b8a9fe95e Only run App::ui if the application is visible (#7950)
* Closes https://github.com/emilk/egui/issues/5113
* Part of https://github.com/emilk/egui/issues/5112
* Part of https://github.com/emilk/egui/issues/5136

If the application is invisible (occluded or minimized), and the user
calls `.request_repaint`, then we should call `App::logic`, but NOT
`App::ui`.

There are still some situations where `App::logic` is not called when it
should be, but at least now we can skip running the UI code when the app
is invisible.
2026-03-02 19:30:24 +01:00
Emil Ernerfeldt
2be6e225bf Add ViewportInfo::occluded and visible (#7948)
* Part of https://github.com/emilk/egui/issues/5112
* Part of https://github.com/emilk/egui/issues/5113
* Part of https://github.com/emilk/egui/issues/5136

Once we support calling `App::logic` when an app is occluded or
minimized, it is useful to know that it is, in fact, occluded or
minimized.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-02 18:36:04 +01:00
Matthew Runo
9276778181 Avoid repaints on device mouse motion outside window (#7866)
## Summary
- Ignore raw device mouse motion unless the window is focused and the
pointer is inside it
- Also handles pointers starting down and then moving into or out of the
window (drag & drop)
- Prevents global mouse motion from triggering continuous repaint loops
- Applies to both glow and wgpu backends

## Testing
- I ran the check script, nothing seemed to fail

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-03-02 13:00:18 +01:00
Jhynjhiruu
4e43e65756 Fix emoji icon font (#7940)
* Closes <https://github.com/emilk/egui/issues/1284> (again)
* [x] I have followed the instructions in the PR template

Short and simple PR, just moves the updated font to the right place. I
note that the license for that font says copyright 2014, which might
need to be updated to reflect when the font was modified.
2026-03-02 09:04:41 +01:00
Jiayi Zhuang
e505d98215 Fix: update get_proc_address to use Arc for better ownership management (#7922)
<!--
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

`get_proc_address` was introduced in #4145, but its lifetime was
designed to be tied to the lifetime `'s` of `CreationContext`. This
means that using `get_proc_address` outside the lifetime of
`CreationContext` is undefined behavior. This contradicts the original
intent behind introducing `get_proc_address`, as this API is intended
for integration with external libraries that cannot easily guarantee
alignment with egui's lifetimes. This PR changes the type of
`get_proc_address` from a reference to an `Arc`, decoupling its lifetime
from `CreationContext` to achieve safer memory management.
2026-03-02 08:59:29 +01:00
Carter Schmidt
bd63647177 Fix crash when dragging a DragValue through small floats. (#7939)
Increased smart_aim `NUM_DECIMALS` from 15 to 16 to fix crash in
`best_in_range_f64`
The f64 value 0.09999999999999995, when multiplied by `scale_factor` and
rounded, becomes 16 digits (999999999999999.5 -> 1000000000000000) and
the leading 1 is clipped off by `to_decimal_string` resulting in all 0s
and triggering the debug_assert! message "Bug in smart aim code"

<!--
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 <https://github.com/emilk/egui/issues/7747 >
* [x] I have followed the instructions in the PR template
2026-03-02 08:54:47 +01:00
Oscar Gustafsson
4f99b4fd8d Update selected dependencies (#7920)
<!--
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

A number of separate commits to possibly easily revert some of them.

General idea: selectively update dependencies to remove transitive
dependencies and multiple versions etc. As well as updating "major" (the
one that `cargo update` doesn't update) version for some in Cargo.toml.

Rendering pipelines in `vello_cpu` wasn't obvious. Now both are used.
2026-03-02 08:52:16 +01:00
Umaĵo
c89a4d1b38 Fix TextEdit demo consuming cmd+Y while not being focused (#7846)
The demo should check whether its `TextEdit` is focused before consuming
<kbd>cmd+Y</kbd>, in case there are other demos that do the same and
come after it. (I found this while experimenting with my own PoC binding
and replicating this demo.)

| | |
|-|-|
| before |
![before](https://github.com/user-attachments/assets/7b89b511-473d-43a2-82d2-7c4e732b2f23)
|
| after |
![after](https://github.com/user-attachments/assets/0b82a092-1603-476c-9f1b-2558afcd29c2)
|

* Closes N/A
* [x] I have followed the instructions in the PR template
2026-02-26 10:09:43 +01:00
Lucas Meurer
fd257b2e95 Use FnMut in __run_test_ui (#7933)
Matches the `__run_test_ctx` implementation
2026-02-24 14:27:45 +01:00
Lucas Meurer
e0bac4e260 Pass in an explicit id in UiBuilder, to avoid wrapping passed in ids with Id::new() (#7925)
I was really confused why I couldn't find the response for my ui with
explicit id. Turns out the id I passed in was wrapped by `Id::new`
2026-02-24 11:07:55 +01:00
Lucas Meurer
08f3fd2dc1 Fix scroll area not consuming scroll events (#7904)
This fixes scrolling in a nested scroll area also scrolling the outer
scroll area


https://github.com/user-attachments/assets/ade40b1e-c974-4806-8045-881bea590d4a
2026-02-17 11:08:18 +01:00
Emil Ernerfeldt
64a96ef391 Stop ctrl+arrow etc from moving focus (#7897)
Previously any pressing of arrow keys would move the focus, but now we
check that there are no modifier keys pressed down
2026-02-10 12:24:30 +01:00
Emil Ernerfeldt
3cd52881b4 Update crate 2026-02-10 11:57:43 +01:00
Roman Popov
f1cde5aab4 Fix CentralPanel::show_inside_dyn to round panel_rect (#7868)
While using CentralPanel::show_inside_dyn inside egui_tiles I've noticed
that sometimes it renders "Unaligned" message with certain tile
positions. Match SidePanel behavior by calling round_ui() on the panel
rect.
<img width="364" height="173" alt="image"
src="https://github.com/user-attachments/assets/08a9cef3-67f8-49af-9ea7-75aff711186a"
/>

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-02-04 17:52:39 +01:00
Emil Ernerfeldt
e33050f14b Update bytes crate 2026-02-04 16:59:12 +01:00
Emil Ernerfeldt
67d87233ff use #[track_caller] in kitdiff 2026-02-03 14:48:04 +01:00
Emil Ernerfeldt
91a1e6f23e Ignore that bincode is unmaintained 2026-02-03 11:05:37 +01:00
Yuri Kunde Schlesner
fa78d25564 egui_kittest: Close debug_open_snapshot temp file before viewing it (#7841)
The image file written by debug_open_snapshot was being kept open by the
`tempfile` object. On Windows, this prevented `open::that` from
successfully launching the viewer sometimes because the file remained
locked, which can be avoided by first releasing the file handle.
2026-01-19 14:47:10 +01:00
Emil Ernerfeldt
83e61c6fb0 Improve docs of key/button "down" state (#7851) 2026-01-19 09:01:11 +01:00
Lucas Meurer
b3ffbca2ab Prevent snapshot update workflow to run on main (#7842)
Turns out if you don't give the gh workflow dispatch a ref it runs it on
main, oops
2026-01-13 11:39:53 +01:00
lucasmerlin
73b7b9e225 Update snapshot images 2026-01-13 10:22:14 +00:00
Trương Hoàng Long
7fb4627dad Make FrameCache::get return a reference instead of cloning the cached value (#7834)
This is a breaking change.

- Enables using `FrameCache` in cases where the cached value cannot be
cloned.
- Improves use cases where only a reference to the cached value is
needed.
- If the user needs an owned value, they can clone it themselves.

Adding a `get_ref` method instead of changing `get` would avoid the
breaking change, but I didn't want to do so because it is kind of
expected for `get` to return `&V` when querying a collection.
2026-01-11 16:31:58 +01:00
Belu Antonie-Gabriel
a9e92525c0 Implemented distance threshold for double/triple clicks (#7817)
This change introduces a distance check to double and triple clicks.
Previously, double/triple clicks were determined solely by timing,
allowing clicks on different UI elements to trigger a
double_clicked()/triple_clicked() event.

By requiring consecutive clicks to occur within a specific radius
(max_multiple_click_dist), we prevent double_clicked()/triple_clicked()
events from triggering when a user clicks on two different, distant UI
elements in rapid succession.

<!--
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 <https://github.com/emilk/egui/issues/3508>
* [x] I have followed the instructions in the PR template
2026-01-07 16:20:16 +01:00
Emil Ernerfeldt
f8e763378a Remove CacheTrait::as_any_mut (#7833)
* Part of https://github.com/emilk/egui/issues/5876

No longer needed on modern MSRV
2026-01-05 18:33:38 +01:00
n4n5
f26d7d8072 fix: CodeTheme functions - ui and add builder (#7684)
Following this MR https://github.com/emilk/egui/pull/7375

Without Syntect, the urrent theme selector is
`global_theme_preference_buttons`. It should be the dark_theme variable
of the local CodeTheme - same as syntect


Tested with

```sh
cargo run
# and
cargo run --features syntect 
```

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


thanks for this amazing library!
2026-01-05 17:54:18 +01:00
Ivor Wanders
0566fb17a5 Allow specifying override_redirect x11 window attribute (#7830) 2026-01-05 13:16:00 +01:00
Umaĵo
6d416fab2e Fix backspacing leaving last character in IME prediction not removed on macOS native and Safari (#7810)
<!--
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 N/A
* [x] I have followed the instructions in the PR template

## Before the fix

| Platform | Screenshot |
| - | - |
| macOS native |
![before-macos15-apple_shuangpin](https://github.com/user-attachments/assets/8397b236-7adf-4eca-9eb6-337e42c9efae)
|
| Safari |
![before-safari26](https://github.com/user-attachments/assets/1f4162a2-ccb7-4b42-960d-95aa3310f908)
|

## After the fix

| Platform | Screenshot |
| - | - |
| macOS native |
![after-macos15-apple_shuangpin](https://github.com/user-attachments/assets/8f50d43c-21bc-4c47-a7fb-86d0543c5088)
|
| Safari |
![after-safari26](https://github.com/user-attachments/assets/be4a69cd-8a0e-4512-865b-d6ebed2fd6c7)
|

(The font used in the screenshots is [GNU
Unifont](https://unifoundry.com/unifont/index.html), licensed under
[OFL-1.1.txt](https://unifoundry.com/OFL-1.1.txt).)
2026-01-05 12:51:09 +01:00
Lucas Meurer
f9bf0ee6c4 Don't focus Areas, Windows and ScrollAreas (#7827)
Currently, tabbing through egui demo app, there are a lot of widgets
that have invisible focus. Tabbing into a window for example takes 10
(!) presses of the tab key before the first widget within the window is
focused. Before that, the focus moves to each resize handle, the scroll
area and the scroll bar. At that point a user might think the focus is
entirely broken.

This pr removes the focusable sense from all these elements. Anything
that can be focused should somehow indicate that it currently has focus,
or the user could get frustrated.

It also adds a debug flag to always show the focused widget, so it's
easier to debug these cases
2026-01-05 12:50:52 +01:00
n4n5
06e491c5ec feat: add documentation to structs (#7800)
feat: add documentation to structs
2026-01-05 12:11:14 +01:00
n4n5
0a5cf3156e Improve docstring for egui_extras features (#7813)
It's nice to have


* [x] I have followed the instructions in the PR template
2026-01-05 11:44:21 +01:00
Bayley Foster
457f8f4467 plugin: export TypedPluginGuard and TypedPluginHandle (#7780)
We have made this patch internally on our fork as we use
`TypedPluginGuard` and `TypedPluginHandle` internally

* [x] I have followed the instructions in the PR template
2026-01-05 09:57:00 +01:00
valadaptive
9f1f3fca38 Remove font_weight API (#7811)
* Closes N/A
* [x] I have followed the instructions in the PR template

This appears to have snuck in as part of
https://github.com/emilk/egui/pull/7790, which claimed to only be a
bugfix but introduced a new `font_weight` method.

I believe there's no way to access the method from *public* code since
it's only defined on `FontsImpl`, not the public-facing `FontsView`.
It's also not used *privately* in epaint, meaning it's completely dead
code.

Even if we *do* want some sort of future API for getting a font's
weight, it requires more consideration. For instance, this API will
return the default weight for variable fonts, which is not documented
anywhere and might not be what we want.
2026-01-05 09:32:58 +01:00
Lucas Meurer
db76c5ca3b Fix new move_to_top flag breaking widget order (#7825)
* closes https://github.com/emilk/egui/issues/7812
* related https://github.com/emilk/egui/pull/7805

That pr introduced a bug that caused a mismatch in the `by_layer` /
`by_id` widget rects. This should fix it by updating the index of all
following widgets. Not super pretty and efficient, but I'm not sure if
there's a better way.

Maybe we could also just leave a "tombstone" / duplicate there in the
by_layer map so we don't need to update the indexes?
2026-01-05 08:22:54 +01:00
Emil Ernerfeldt
9e95b9ca50 Don't expand widgets on hover (#7808)
* Part of https://github.com/emilk/egui/issues/5605

This changes the default style of egui.

The problem with "expanding" widgets is that they now want to paint
outside their own bounds, which then requires all parent UIs to have
proper margins.

It also means hovered things are no longer properly aligned with every
other widget.
2025-12-22 22:30:53 +01:00
Emil Ernerfeldt
f53a9c96d5 Small refactor of debug assert 2025-12-22 22:03:29 +01:00
Emil Ernerfeldt
ec4313d8a8 Refactor: don't call ctx.global_style more than once 2025-12-22 22:01:23 +01:00
Emil Ernerfeldt
2984ff07cd Move window resize interaction to be over contents (#7807)
When resizing a window, it makes more sense that the resize "splitters"
are on top of the content. It makes them easier to hit.
2025-12-22 21:57:00 +01:00
Emil Ernerfeldt
e0e372ae7e Slightly change interact behavior around thin splitters (#7806)
* Added in https://github.com/emilk/egui/pull/5468
* Related to https://github.com/emilk/egui/pull/7803

The code doesn't seem to longer be needed. Interacting with a resize
splitter isn't very difficult, and I never liked that special case.
2025-12-22 21:45:35 +01:00
Emil Ernerfeldt
1fdc741ebb Allow moving existing widgets to the top of interaction stack (#7805)
This adds `Ui::interact_opt` which is a version of `Ui::interact` that
lets you specify that if this widget already exists, it should be moved
to the top of the interaction stack.

This lets you easily more easily "read a response from the future", by
simply calling interact twice, instead of calling
`Context::read_response`.
2025-12-22 21:34:03 +01:00
Emil Ernerfeldt
24ac9e193d Make scroll bars and resize splitters visible to accesskit (#7804) 2025-12-22 21:25:12 +01:00