Commit Graph

4086 Commits

Author SHA1 Message Date
Pēteris Pakalns 1a6f2aba08 Fix profiling::scope compile error when profiling using tracing backend (#7646)
* Closes https://github.com/emilk/egui/issues/7645
* [x] I have followed the instructions in the PR template
2025-11-13 11:53:50 +01:00
ASPCartman e541ba267f Fix jittering during window resize on MacOS for WGPU/Metal (#7641)
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2025-11-13 11:53:50 +01:00
Juan Campa e0561e1820 Add `Plugin::on_widget_under_pointer` to support widget inspector (#7652)
This PR adds `Plugin::on_widget_under_pointer` which gets called
whenever a widget is created whose rect contains the pointer.

The point of the hook is to capture a stack trace which can be used to
map widgets to their corresponding source code so it must be called
while the widget is being created. The obvious concern is performance
impact. However, since it's only called for rects under the cursor, the
effect seems negligible afaict. It's under `debug_assertions` just in
case.

This change is needed so we can publish the widget inspector we've been
working on. Basically a plugin that allows us to jump from any widget
back to their corresponding source code.

This video shows the plugin configured to open the corresponding code in
github, but normally it would open your local editor.

Update: [Live demo](https://membrane-io.github.io/egui/) (Firefox/Safari
not yet supported. `Cmd-I` to inspect. `Tab` to cycle filters. `Click`
to open). It will try to open a file under
`/home/runner/work/egui/egui/` so it won't work, but you get the idea.


https://github.com/user-attachments/assets/afe4d6af-7f67-44b5-be25-44f7564d9a3a

## What's next

After this gets merged I plan to publish the above plugin as its own
crate, that way we can iterate and release quickly while things are
still changing. I agree it would make sense to eventually merge it into
the main egui repo (like @emilk suggested in #4650).

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

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2025-11-13 11:52:19 +01:00
Ian Hobson 4833dd8720 Don't enable `arboard` on iOS (#7663)
`arboard` [doesn't support support iOS
yet](https://github.com/1Password/arboard/pull/103), so this PR adds iOS
to the conditions that prevent `arboard` from being enabled.

Launching an app on a physical device results in a long timeout (~8s)
while trying to connect to the X11 server (the timeout is immediate when
launching on a simulator), with the following trace:

```
egui_winit:📋 Failed to initialize arboard clipboard: Unknown error while interacting with the clipboard: X11 server connection timed out because it was unreachable
```

<!--
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
2025-11-13 11:47:53 +01:00
Lucas Meurer 6db4fcfda8 Fix kitdiff links in pr comments (#7639)
The pr data is not accessible in this workflow so I have to hardcode the
url with the pr number
2025-11-13 11:47:53 +01:00
Emil Ernerfeldt ea14da142a Release egui_kittest 0.33.1 2025-11-13 11:47:53 +01:00
Emil Ernerfeldt 9f5b797375 Add `egui_kittest::Harness::set_options` (#7638)
Makes it easier to set the same options for many tests

---------

Co-authored-by: Lucas Meurer <hi@lucasmerlin.me>
2025-11-13 11:47:53 +01:00
Lucas Meurer e3e7c9758e Release 0.33.0 - `egui::Plugin`, better kerning, kitdiff viewer (#7622)
We just released egui 0.33.0!

Highlights:
- `egui::Plugin` a improved way to create and access egui plugins
- [kitdiff](https://github.com/rerun-io/kitdiff), a viewer for
egui_kittest image snapshots (and a general image diff tool)
- better kerning (check the diff on
[kitdiff](https://rerun-io.github.io/kitdiff/?url=https://github.com/emilk/egui/pull/7431))

https://github.com/user-attachments/assets/971f0493-6dae-42e5-8019-58b74cf5d203

egui is an easy-to-use immediate mode GUI for Rust that runs on both web
and native.

Try it now: <https://www.egui.rs/>

egui development is sponsored by [Rerun](https://www.rerun.io/), a
startup building an SDK for visualizing streams of multimodal data.

Highlights from this release:
- `egui::Plugin` a improved way to create and access egui plugins
- [kitdiff](https://github.com/rerun-io/kitdiff), a viewer for
egui_kittest image snapshots (and a general image diff tool)
- better kerning

As a step towards using [parley](https://github.com/linebender/parley)
for font rendering, @valadaptive has refactored the font loading and
rendering code. A result of this (next to the font rendering code being
much nicer now) is improved kerning.
Notice how the c moved away from the k:

![Oct-09-2025
16-21-58](https://github.com/user-attachments/assets/d4a17e87-5e98-40db-a85a-fa77fa77aceb)

We've added a new trait-based plugin api, meant to replace
`Context::on_begin_pass` and `Context::on_end_pass`.
This makes it a lot easier to handle state in your plugins. Instead of
having to write to egui memory it can live right on your plugin struct.
The trait based api also makes easier to add new hooks that plugins can
use. In addition to `on_begin_pass` and `on_end_pass`, the `Plugin`
trait now has a `input_hook` and `output_hook` which you can use to
inspect / modify the `RawInput` / `FullOutput`.

At rerun we have a ton of snapshots. Some PRs will change most of them
(e.g. [the](https://github.com/rerun-io/rerun/pull/11253/files)
[one](https://rerun-io.github.io/kitdiff/?url=https://github.com/rerun-io/rerun/pull/11253/files)
that updated egui and introduced the kerning improvements, ~500
snapshots changed!).
If you really want to look at every changed snapshot it better be as
efficient as possible, and the experience on github, fiddeling with the
sliders, is kind of frustrating.
In order to fix this, we've made
[kitdiff](https://rerun-io.github.io/kitdiff/).
You can use it locally via
- `kitdiff files .` will search for .new.png and .diff.png files
- `kitdiff git` will compare the current files to the default branch
(main/master)
Or in the browser via
- going to https://rerun-io.github.io/kitdiff/ and pasting a PR or
github artifact url
- linking to kitdiff via e.g. a github workflow
`https://rerun-io.github.io/kitdiff/?url=<link_to_pr_or_artefact>`

To install kitdiff run `cargo install --git
https://github.com/rerun-io/kitdiff`

Here is a video showing the kerning changes in kitdiff ([try it
yourself](https://rerun-io.github.io/kitdiff/?url=https://github.com/rerun-io/rerun/pull/11253/files)):

https://github.com/user-attachments/assets/74640af1-09ba-435a-9d0c-2cbeee140c8f

- `egui::Mutex` now has a timeout as a simple deadlock detection
- If you use a `egui::Mutex` in some place where it's held for longer
than a single frame, you should switch to the std mutex or parking_lot
instead (egui mutexes are wrappers around parking lot)
- `screen_rect` is deprecated
- In order to support safe areas, egui now has `viewport_rect` and
`content_rect`.
- Update all usages of `screen_rect` to `content_rect`, unless you are
sure that you want to draw outside the `safe area` (which would mean
your Ui may be covered by notches, system ui, etc.)
2025-11-13 11:47:43 +01:00
Emil Ernerfeldt 7d33442ca1 Fix kerning snapshot test directory 2025-11-13 11:47:25 +01:00
lucasmerlin 28cbd73c5c Kittest 0.3 2025-10-09 16:45:47 +02:00
lucasmerlin 854cdfe90c Add todo to check git dependencies 2025-10-09 16:35:17 +02:00
lucasmerlin 59c410e9c1 Fix crate order 2025-10-09 16:34:56 +02:00
lucasmerlin 430a3fbc78 Typo 2025-10-09 16:28:14 +02:00
lucasmerlin a3c7351d58 Add changelog intro and reorder stuff 2025-10-09 16:27:52 +02:00
lucasmerlin aea3a49621 Update versions 2025-10-09 15:55:18 +02:00
lucasmerlin 38b072919e Merge branch 'main' into release-0.33.0
# Conflicts:
#	.typos.toml
2025-10-09 15:51:02 +02:00
Emil Ernerfeldt d50287b83c
Add `taplo.toml` for toml formatting (#7618) 2025-10-09 15:38:00 +02:00
lucasmerlin eb200855f0 Allow isse and tye usernames 2025-10-09 14:29:16 +02:00
lucasmerlin 01056695da Update changelogs 2025-10-09 14:23:58 +02:00
lucasmerlin 457fdbdef4 Update example screenshots 2025-10-09 12:57:39 +02:00
Emil Ernerfeldt 82b6b3c98d
Tweak Rust Analyzer settings (#7617)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-09 12:56:57 +02:00
Bryce Berger 0abeccebc9
Change Spinner widget to account for width as well as height (#7560)
Previously, when `rect` was taller than it was wide, the spinner would
render far outside the given rectangle. Now, it always renders inside
the smaller of the two dimensions.

I noticed this when upgrading from 0.30 to 0.32. I have an image that's
significantly taller than it is wide. In 0.32, when the image is
loading, it shows the spinner. Since the spinner radius is determined
solely based on rectangle height, the spinner ends up far too wide and
covers other elements.

* [x] I have followed the instructions in the PR template
2025-10-09 12:47:59 +02:00
Lucas Meurer da39198142
Some minor docs improvements (#7614) 2025-10-09 12:00:39 +02:00
Lucas Meurer cfca7ebd6d
Fix black flash on start in glow eframe backend (#7616)
Before:


https://github.com/user-attachments/assets/b31b7a4f-a5f7-45af-bfe0-4c8e174e209f

After:


https://github.com/user-attachments/assets/47544987-ca81-4efb-b778-5ca59b7fc0ac

I think to make things even nicer we could also try calling
request_discard when a window is shown
2025-10-09 11:44:10 +02:00
Anthony S. d1fcd740de
Include screenshot in popups README (#7562)
Add missing screenshot to README for popups example

Co-authored-by: Lucas Meurer <hi@lucasmerlin.me>
2025-10-09 09:41:20 +02:00
Lucas Meurer 32336e260b
Write .new.png file if snapshot is missing (#7610)
We should write the .new.png whenever the test fails and snapshots
aren't updated. Necessary for the kitdiff-snapshot-update-workflow to
work
2025-10-09 09:15:18 +02:00
Emil Ernerfeldt 9e13889589
Revert wasm-bindgen to 0.2.100 (#7612) 2025-10-09 08:56:33 +02:00
Lucas Meurer 917aaca991
Use custom github token for commiting snapshots (#7611)
... to ensure that workflows are run
2025-10-08 17:49:29 +02:00
Emil Ernerfeldt 94f2ed6334
Do not lock wasm-bindgen version (#7609) 2025-10-08 17:09:04 +02:00
Emil Ernerfeldt 47a437403f
Use software texture filtering in kittest (#7602) 2025-10-08 16:24:02 +02:00
Lucas Meurer 718a82b013
`Harness`: Add `remove_cursor`, `event` and `event_modifiers` (#7607)
* Closes https://github.com/emilk/egui/issues/7591
2025-10-08 13:47:00 +02:00
Emil Ernerfeldt 4d4f90eb31
kittest: No `debug_open_snapshot` on wasm (#7606) 2025-10-08 11:47:34 +02:00
Lucas Meurer 3fdc5641aa
Group AccessKit nodes by `Ui` (#7386)
* closes https://github.com/emilk/egui/issues/5674

This changes egui to create an AccessKit node for each `Ui`. I'm not
sure if this alone will directly improve accessibility, but it should
make it easier to create the correct parent / child relations (e.g.
grouping menus as children of menu buttons).
Instead of having a global stack of parent ids, they are now passed via
a parent_id field in `UiBuilder`.

If having all these `GenericContainer` nodes somehow is bad for
accessibility, the PR could also be changed to only create nodes if
there is actually some accessibility info with it (the relevant is
currently commented-out in the PR). But I think screen readers should
just ignore these nodes, so it should be fine? We could also use this as
motivation to git red of some unnecessary wrapped `Ui`s, e.g.
CentralPanel creates 3 Uis when 2 should be enough (the initial Ui and a
Frame, maybe we could even only show the `Frame` if we can give it an
UiBuilder and somehow show the Frame with `Ui::new`).

Here is a screenshot from the accessibility inspector
(https://github.com/emilk/egui/pull/7368) with this PR:

<img width="431" height="744" alt="Screenshot 2025-07-24 at 12 09 55"
src="https://github.com/user-attachments/assets/6c4e5ff6-5c38-450e-9500-0776c9018d8c"
/>

Without this PR:


https://github.com/user-attachments/assets/270e32fc-9c7a-4dad-8c90-7638c487a602
2025-10-08 11:30:32 +02:00
Emil Ernerfeldt 6a49c9ad6b Unwind minimum home version 2025-10-08 10:44:44 +02:00
Emil Ernerfeldt 0d47abcaa0
Better docs + deprecation for screen/content/viewport_rect (#7605) 2025-10-08 10:43:11 +02:00
Lucas Meurer c3c08fa38a
Fix preview build on contributor PRs (#7597)
- I broke this in #7577 

`pull_request` workflows don't have permission to comment, so we have to
do this via a `pull_request_target` workflow.

The point of this early comment is that the kitdiff link appears as soon
as possible and isn't dependent on the preview build suceeding.
2025-10-08 10:20:12 +02:00
Emil Ernerfeldt 683214bfe8
Add kittest snapshot test of italics (#7603) 2025-10-07 17:22:31 +02:00
Emil Ernerfeldt 9cb4e6a54e
Create `egui_wgpu::RendererOptions` (#7601) 2025-10-07 17:06:23 +02:00
Emil Ernerfeldt 56b1def064
Update to the latest dependencies (#7599) 2025-10-07 16:26:13 +02:00
Emil Ernerfeldt 86dc9ea64e
Inline log format args (#7600) 2025-10-07 16:14:43 +02:00
Emil Ernerfeldt ac4e04d0b8
`cargo upgrade` (#7598) 2025-10-07 15:30:00 +02:00
Emil Ernerfeldt 843ceea90c
Use more workspace dependencies (#7596) 2025-10-07 15:07:16 +02:00
Lucas Meurer 7fc80d8623
Accessibility inspector plugin (#7368)
Adds an accessibility inspector plugin that shows the current AccessKit
tree:


https://github.com/user-attachments/assets/78f4f221-1bd2-4ce4-adf5-fc3b00f5c16c

Macos has a built in accessibility inspector, but it doesn't seem to
work with AccessKit / eframe so this provides some insight into the
accesskit state.

This also showed a couple issues that are easy to fix:
- [ ] Links show up as `Label` instead of links
- [ ] Not all supported actions are advertised (e.g. scrolling)
- [ ] The resize handles in windows shouldn't be focusable
- [ ] Checkbox has no value
- [ ] Menus should have the button as parent widget (not 100% sure on
this one)


Currently the plugin lives in the demo app, but I think it should be
moved somewhere else. Maybe egui_extras?

This could also be relevant for #4650
2025-10-07 14:39:49 +02:00
Lucas Meurer d83f4500a3
Add `Harness::debug_open_snapshot` helper (#7590)
Adds a helper to quickly see whats going on in a kittest test.

Not all test have snapshots, but when debugging tests it might still be
useful to see whats actually going on, so this adds a helper fn that
renders a snapshot image to a temporary file and opens it with the
default image viewer:



https://github.com/user-attachments/assets/08785850-0a12-4572-b9b5-cea36951081c
2025-10-07 14:39:22 +02:00
Emil Ernerfeldt ab461f4115
Fix eframe window not being focused on mac on startup (#7593)
* Workaround for https://github.com/rust-windowing/winit/issues/4371
* Closes https://github.com/emilk/egui/issues/7588

Tested manually
2025-10-07 14:21:10 +02:00
Emil Ernerfeldt 78fffc7707
clean up the clippy.toml:s (#7594) 2025-10-07 14:12:51 +02:00
Emil Ernerfeldt 0281b95bd9
CI: use latest typos (#7595) 2025-10-07 14:12:30 +02:00
Ian Hobson 30277233ce
Add support for the safe area on iOS (#7578)
This PR is a continuation of #4915 by @frederik-uni and @lucasmerlin
that introduces support for keeping egui content within the 'safe area'
on iOS (avoiding the notch / dynamic island / menu bar etc.), with the
following changes:

- `SafeArea` now wraps `MarginF32` and has been renamed to
`SafeAreaInsets` to clarify its purpose.
- `InputState::screen_rect` is now marked as deprecated in favour of
either `viewport_rect` (which contains the entire screen), or
`content_rect` (which is the viewport rect with the safe area insets
removed).
- I added some comments to the safe area insets logic pointing out the
[safe area API coming in winit
v0.31](https://github.com/rust-windowing/winit/issues/3910).

---------

Co-authored-by: frederik-uni <147479464+frederik-uni@users.noreply.github.com>
Co-authored-by: Lucas Meurer <hi@lucasmerlin.me>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2025-10-07 12:30:09 +02:00
Lucas Meurer 65249013c4
Fix stuck menu when submenu vanishes (#7589)
* Closes https://github.com/rerun-io/rerun/issues/11301

This fixes a bug where a menu could get stuck, not closing at all, when
the currently open submenu stops being shown.
I also added a way to reproduce this to the demo, as well as a test
ensuring that there is no race condition in the fix.
2025-10-07 10:16:35 +02:00
Lucas Meurer f0faacc7d1
Add workflow to accept snapshots via kitdiff (#7577)
This adds a new workflow `update_kittest_snapshots.yml` that can be
triggered through the [kitdiff](https://github.com/rerun-io/kitdiff) ui
when viewing a ci artefact.
Also adds a link to kitdiff to view the pr changes to each commit (via
the preview build comment)

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-06 15:57:31 +02:00