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

3947 Commits

Author SHA1 Message Date
Emil Ernerfeldt
707a339047 Bump version numbers to 0.32.1 0.32.1 2025-08-15 13:33:47 +02:00
Emil Ernerfeldt
ead6926895 Update changelogs 2025-08-15 13:29:55 +02:00
Emil Ernerfeldt
03fb443669 Only update snapshot if we didn't pass (#7455)
* Closes https://github.com/emilk/egui/issues/7449
2025-08-15 12:22:07 +02:00
Tamo
d739a4b880 Request a redraw when the url change through the popstate event listener (#7403)
<!--
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!
-->

Hey, I added an event listener on the [`popstate`
event](https://developer.mozilla.org/en-US/docs/Web/API/Window/popstate_event).
That fixed my issue


https://github.com/user-attachments/assets/a621dac9-b7c3-426a-968b-dc73c5702eea

* Closes https://github.com/emilk/egui/issues/7402
* [x] I have followed the instructions in the PR template
2025-08-15 12:21:14 +02:00
YgorSouza
b732992f69 Fix debug-panic in ScrollArea if contents fit without scrolling (#7440)
If the ScrollArea's contents are smaller than the inner rect, but the
scrollbar is set to always visible, clicking on it led to a remap from
an empty range to calculate the new offset, which triggered a debug
assertion in the remap function, because the result is indeterminate.

Since in this case there is no need to scroll, we just skip the remap
and set the offset to 0 directly.

* Closes <https://github.com/emilk/egui/issues/7362>
* [x] I have followed the instructions in the PR template
2025-08-15 12:20:45 +02:00
YgorSouza
7036d6a982 Fix override_text_color priority (#7439)
The override_text_color is now used when rendering text from a String or
&str. This is consistent with the RichText variant and makes the option
behave as advertised, taking precedence over WidgetVisuals and
overriding the color for all text unless explicitly changed for a single
widget (via RichText or LayoutJob).

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

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2025-08-15 12:20:38 +02:00
Lucas Meurer
97fe124443 Fix WidgetText::Text ignoring fallback font and overrides (#7361)
* closes https://github.com/emilk/egui/issues/7356
2025-08-15 12:20:27 +02:00
Emil Ernerfeldt
4fcd1d13e3 Update to winit 0.30.12 (#7420) 2025-08-15 12:20:16 +02:00
Lucas Meurer
1ad374f255 Fix manual Popup not closing (#7383)
Fixes manually created popups (via `Popup::new`) not closing, since
widget_clicked_elsewhere was always false.

This example would never close:

```rs
    let mut open = true;

    eframe::run_simple_native("My egui App", options, move |ctx, _frame| {
        egui::CentralPanel::default().show(ctx, |ui| {
            let response = egui::Popup::new(
                Id::new("popup"),
                ctx.clone(),
                PopupAnchor::Position(Pos2::new(10.0, 10.0)),
                LayerId::new(Order::Foreground, Id::new("popup")),
            )
            .open(open)
            .show(|ui| {
                ui.label("This is a popup!");
                ui.label("You can put anything in here.");
            });

            if let Some(response) = response {
                if response.response.should_close() {
                    open = false;
                }
            }
        });
    })
```

I also noticed that the Color submenu in the popups example had a double
arrow (must have been broken in the atoms PR):

<img width="248" height="110" alt="Screenshot 2025-08-07 at 13 42 28"
src="https://github.com/user-attachments/assets/a4e0c267-ae71-4b2c-a1f0-f53f9662d026"
/>

Also fixed this in the PR.
2025-08-15 12:19:59 +02:00
Lucas Meurer
1afbb9791a Add ComboBox::popup_style (#7360)
* Closes #7349  
* [x] I have followed the instructions in the PR template
2025-08-15 12:19:51 +02:00
Emil Ernerfeldt
85c4b1dce7 Fix glyph rendering: clamp coverage to [0, 1] (#7415)
* Closes  #7366
* Closes https://github.com/emilk/egui/pull/7388
2025-08-15 12:19:32 +02:00
Hubert Głuchowski
2f7bcf26f2 Fix multi-line TextShape rotation (#7404)
* Closes <https://github.com/emilk/egui/issues/7397>
* [X] I have followed the instructions in the PR template
I do admit I got a peak NixOS `RequestDeviceError` and deemed it
entirely not worth it to think about that.

https://github.com/emilk/egui/pull/5411 broke rotation of multi-line
`TextShape`s because `PlacedRow::pos` was no longer being rotated, so
let's rotate it.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Co-authored-by: Lucas Meurer <hi@lucasmerlin.me>
2025-08-15 12:19:23 +02:00
Lucas Meurer
aef9015e34 Enable wgpu default features in eframe / egui_wgpu default features (#7344) 2025-08-15 12:19:11 +02:00
Emil Ernerfeldt
fabd4aa7a5 Release 0.32.0 - Atoms, popups, and better SVG support (#7329) 0.32.0 2025-07-10 16:58:39 +02:00
Lucas Meurer
a9124af00d Update kittest to 0.2 (#7332) 2025-07-10 16:38:52 +02:00
Lucas Meurer
c0325e9be2 Add more docs to menu (#7331)
Improves the docs a bit
2025-07-10 15:35:04 +02:00
Lucas Meurer
14c2e5d3d5 Set intrinsic size for Label (#7328)
Sets intrinsic size for labels
2025-07-10 10:48:14 +02:00
Emil Ernerfeldt
9478a6223b Rename egui::containers::menu::Bar to egui::MenuBar (#7327)
The old name is still there, just deprecated.
2025-07-10 10:33:48 +02:00
Emil Ernerfeldt
8d2f39fc08 Improve release checklist (#7322)
* See https://github.com/emilk/egui/issues/7321
2025-07-09 19:36:38 +02:00
Lucas Meurer
087e56abae Fix wrong galley split behavior when text ends with new line (#7320)
* Fixes a bug introduced by #7316 

The last `\n` was ignored for texts ending with `\n` in the galley split
logic.
2025-07-09 18:18:06 +02:00
Lucas Meurer
9fd0ad36e0 Implement BitOr and BitOrAssign for Rect (#7319) 2025-07-09 15:29:51 +02:00
Lucas Meurer
207e71c2ae Exclude \n when splitting Galleys (#7316)
* Follow up to #7146 

Previously when galleys were splitted, each exept the last had an extra
empty row that had to be removed when they were concated. This changes
it to remove the `\n` from the layout jobs when splitting.
2025-07-09 14:53:19 +02:00
Emil Ernerfeldt
a7f14ca176 Deprecate Memory::popup API in favor of new Popup API (#7317)
* Closes  #7037
* Closes #7297

This deprecates all popup-related function in `Memory`, replacing them
with the new `egui::Popup`.

The new API is nicer in all ways, so we should encourage people to use
it.
2025-07-09 12:55:06 +02:00
Emil Ernerfeldt
fbe0aadf63 Add Popup::from_toggle_button_response (#7315)
Adds a convenience constructor for `Popup`
2025-07-09 10:12:47 +02:00
Lucas Meurer
508c60b2e2 Add Galley::intrinsic_size and use it in AtomLayout (#7146)
- part of https://github.com/emilk/egui/issues/5762
- also allows me to simplify sizing logic in egui_flex
2025-07-09 08:19:04 +02:00
Emil Ernerfeldt
f46926aaf1 Improve texture filtering by doing it in gamma space (#7311)
* Closes https://github.com/emilk/egui/pull/5839

This makes some transparent images look a lot nicer when blended:


![image](https://github.com/user-attachments/assets/7f370aaf-886a-423c-8391-c378849b63ca)

Cursive text will also look nicer.

This unfortunately changes the contract of what
`register_native_texture` expects

---------

Co-authored-by: Adrian Blumer <blumer.adrian@gmail.com>
2025-07-07 17:46:27 +02:00
Emil Ernerfeldt
dd1052108e Add snapshot test for image blending (#7309)
This adds a test that can be used to see the improvements made by this
PR (if any):
* https://github.com/emilk/egui/pull/5839
2025-07-07 13:58:22 +02:00
Emil Ernerfeldt
09596a5e7b egui_kittest: more ergonomic functions taking Impl Into<String> (#7307) 2025-07-07 13:50:53 +02:00
Emil Ernerfeldt
b11b77e85f Save a few CPU cycles with earlier early-out from Popup::show (#7306) 2025-07-07 12:07:13 +02:00
Emil Ernerfeldt
933d305159 Improve doc-string for Image::alt_text 2025-07-07 12:06:59 +02:00
Emil Ernerfeldt
93d562221b Change Rect::area to return zero for negative rectangles (#7305)
Previously a single-negative rectangle (where `min.x > max.x` XOR `min.y
> max.y`) would return a negative area, while a doubly-negative
rectangle (`min.x > max.x` AND `min.y > max.y`) would return a positive
area. Now both return zero instead.
2025-07-07 12:03:03 +02:00
Emil Ernerfeldt
3622a03a46 Mark Popup with #[must_use] 2025-07-07 12:02:51 +02:00
Emil Ernerfeldt
6d80707422 Fix tooltips sometimes changing position each frame (#7304)
There was a bug in how we decide where to place a `Tooltip` (or other
`Popup`), which could lead to tooltips jumping around every frame,
especially if it changed size slightly.

The new code is simpler and bug-free.
2025-07-07 12:02:01 +02:00
Emil Ernerfeldt
a811b975c2 Better deprecation of SelectableLabel 2025-07-07 09:33:08 +02:00
valadaptive
7ac137bfc1 Make the font atlas use a color image (#7298)
* [x] I have followed the instructions in the PR template

Splitting this out from the Parley work as requested. This removes
`FontImage` and makes the font atlas use a `ColorImage`. It converts
alpha to coverage at glyph-drawing time, not at delta-upload time.

This doesn't do much now, but will allow for color emoji rendering once
we start using Parley.

I've changed things around so that we pass in `text_alpha_to_coverage`
to the `Fonts` the same way we do with `pixels_per_point` and
`max_texture_side`, reusing the existing code to check if the setting
differs and recreating the font atlas if so. I'm not quite sure why this
wasn't done in the first place.

I've left `ImageData` as an enum for now, in case we want to add support
for more texture pixel formats in the future (which I personally think
would be worthwhile). If you'd like, I can just remove that enum
entirely.
2025-07-04 13:15:48 +02:00
Emil Ernerfeldt
d94386de3d Fix debug_assert triggered by menu/intersect_ray (#7299) 2025-07-04 09:55:03 +02:00
Lucas Meurer
47a2bb10b0 Remove SelectableLabel (#7277)
* part of https://github.com/emilk/egui/issues/7264
* removes SelectableLabel (Use `Button::selectable` instead)
* updates `Ui::selectable_value/label` with IntoAtoms support

Had to make some changes to `Button` since the SelecatbleLabel had no
frame unless selected.
2025-07-03 16:34:47 +02:00
Lucas Meurer
2b62c68598 Add egui::Sides shrink_left / shrink_right (#7295)
This allows contents (on one of the sides) in egui::Sides to shrink. 

* related https://github.com/rerun-io/rerun/issues/10494
2025-07-03 14:31:35 +02:00
Nicolas
77df407f50 egui_kittest: add failed_pixel_count_threshold (#7092)
I thought about this - so we have two options here:
1. adding it to `SnapshotOptions` 
2. adding it to every function which I do not like as this would be a
huge breaking change

## Summary

This pull request introduces a new feature to the `SnapshotOptions`
struct in the `egui_kittest` crate, allowing users to specify a
permissible percentage of pixel differences (`diff_percentage`) before a
snapshot comparison is considered a failure. This feature provides more
flexibility in handling minor visual discrepancies during snapshot
testing.

### Additions to `SnapshotOptions`:

* Added a new field `diff_percentage` of type `Option<f64>` to the
`SnapshotOptions` struct. This field allows users to define a tolerance
for pixel differences, with a default value of `None` (interpreted as 0%
tolerance).
* Updated the `Default` implementation of `SnapshotOptions` to
initialize `diff_percentage` to `None`.

### Integration into snapshot comparison logic:

* Updated the `try_image_snapshot_options` function to handle the new
`diff_percentage` field. If a `diff_percentage` is specified, the
function calculates the percentage of differing pixels and allows the
snapshot to pass if the difference is within the specified tolerance.
[[1]](diffhunk://#diff-6f481b5866b82a4fe126b7df2e6c9669040c79d1d200d76b87f376de5dec5065R204)
[[2]](diffhunk://#diff-6f481b5866b82a4fe126b7df2e6c9669040c79d1d200d76b87f376de5dec5065R294-R301)

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

---------

Co-authored-by: lucasmerlin <hi@lucasmerlin.me>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2025-07-03 14:23:15 +02:00
Emil Ernerfeldt
ba577602a4 Fix crash when using infinite widgets (#7296)
* Closes https://github.com/emilk/egui/issues/7100
2025-07-03 13:40:02 +02:00
Blackberry Float
db3543d034 Update area struct to allow force resizing (#7114)
This is a really small PR so I am skipping the issue (based on
contributing.md). This change adds an optional field and thus non
breaking for the API.

I ran into an issue during my development of an alerts manager widget
([see PR](https://github.com/blackberryfloat/egui_widget_ext/pull/2))
where I needed a scrollable overlay that did not block clicking areas of
a parent widget when my alerts did not take up the entire parent. To
achieve this I detect the sizing pass via the invisible flag and only
render the alerts content and then on the next pass I add the scroll bar
in around the alert content. Whenever the alert content changed though I
would need to create a new Area with a new id to get proper sizing. That
is a memory leak so I wanted to reset the size state to trigger a sizing
pass. Memory is rightfully protected enough that the path to remove
memory was dropped and I just added a hook to set a resize flag.

I am sure there are better ways but this is what made sense to me.
Looking forward to thoughts.

~~Logistics wise, I have proposed it as a patch because I was based off
0.31.1 for testing. I was also thinking it could be released quickly. I
am happy to cherry pick onto main after. If that is not allowed I can
rebase to main and pull against that.~~ (rebased on main)

---------

Co-authored-by: Wesley Murray <murraywj97@gmail.com>
2025-07-03 13:14:07 +02:00
Lucas Meurer
6d312cc4c7 Add support for scrolling via accesskit / kittest (#7286)
I need to scroll in a snapshot test in my app, and kittest had no
utilities for this. Event::MouseWheel is error prone. This adds support
for some accesskit scroll actions, and uses this in kittest to add
helpers to scroll to a node / scroll the scroll area surrounding a node.

The accesskit code says down/up/left/right `Scrolls by approximately one
screen in a specific direction.`. Unfortunately it's difficult to get
the size of a "screen" (I guess that would be the size of the containing
scroll area)where I implemented the scrolling, so for now I've hardcoded
it to 100px. I think scrolling a fixed amount is still better than not
scrolling at all.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2025-07-03 12:02:05 +02:00
Emil Ernerfeldt
378e22e6ec Improve the ThemePreference selection UI slightly 2025-07-03 09:16:13 +02:00
Emil Ernerfeldt
40c69cd1ba Respect and detect prefers-color-scheme: no-preference (#7293)
I don't think this will make a difference in practice, but technically
there are three preference states:

* `dark`
* `light`
* `no-preference`

Previously we would only check for `dark`, and if not set would assume
`light`.
Not we also check `light` and if we're neither `dark` or `light` we
assume nothing.
2025-07-03 08:58:45 +02:00
Andreas Reich
1878874f7d Free textures after submitting queue instead of before with wgpu renderer on Web (#7291) 2025-07-02 16:14:46 +02:00
Emil Ernerfeldt
dc79998044 Improve text rendering in light mode (#7290)
This changes how we convert glyph coverage to alpha (and ultimately a
color), but only in light mode.

This is a bit of a hack, because it doesn't fix dark-on-light text in
_dark mode_ (if you have any), but for the common case this PR is a huge
improvement.

You can also tweak this yourself now using
`Visuals::text_alpha_from_coverage` or from the UI (bottom of the
image):


![image](https://github.com/user-attachments/assets/350210d4-c0bb-44b6-84cc-47c2e9d4b9f0)



## Before / After

![widget_gallery_light_x1](https://github.com/user-attachments/assets/21f5a2a0-6b4e-4985-b17f-cd1c7cc01b46)
![widget_gallery_light_x1](https://github.com/user-attachments/assets/5dfec04a-c81c-43ef-8d86-fc48ef7958f1)


## Black text Before/after
If you think the text above looks too weak, it's only because of the
default text color. Here's how it looks like with perfectly `#000000`
black text:


![image](https://github.com/user-attachments/assets/56a4a4f3-c431-4991-b941-a566a4ae94ed)
![Screenshot 2025-07-02 at 13 59
30](https://github.com/user-attachments/assets/df5a91ad-0bb8-4a0f-81a2-50852e7556c1)
2025-07-02 14:58:37 +02:00
Emil Ernerfeldt
8bedaf6e5b Add light-mode Widget Gallery screenshot test (#7288)
Part of some work to improve text rendering in light mode (again!)
2025-07-02 12:00:36 +02:00
Emil Ernerfeldt
22c6a9ae69 egui_kittest: Add HarnessBuilder::theme (#7289)
Makes it ergonomic to snapshot test light vs dark mode
2025-07-02 12:00:22 +02:00
Emil Ernerfeldt
0857527f1d Add Visuals::weak_text_alpha and weak_text_color (#7285)
* Closes https://github.com/emilk/egui/issues/7262

This also makes the default weak color slightly less weak in most cases.
2025-07-01 20:42:54 +02:00
Emil Ernerfeldt
9d1dce51eb Extend .typos.toml to enforce american english (#7284)
More or less the same list we use at Rerun
2025-07-01 15:54:00 +02:00