Commit Graph

3717 Commits

Author SHA1 Message Date
Lucas Meurer 5c372a7b36 Release 0.31.0 - Scene container, improved rendering quality 2025-02-04 16:47:56 +01:00
Emil Ernerfeldt d97cd82338 Update RELEASES.md 2025-02-04 16:31:10 +01:00
Emil Ernerfeldt f162c3bcbf Explain how to set up generate_changelog.py 2025-02-04 16:30:32 +01:00
Emil Ernerfeldt 95ab92ca4a Protect against mistyping "tessellator" 2025-02-04 16:28:27 +01:00
Emil Ernerfeldt 7ec1fbf467
Fix minor glitch in rendering of selected windows (#5678) 2025-02-04 16:05:36 +01:00
Emil Ernerfeldt c6bda9a38c
Make the ends of vline/hline sharper (#5676)
TL;DR: line caps are annoying in two ways:

A) we only add them for lines wider than a pixel
B) they always make the line longer (if added)
2025-02-04 15:31:51 +01:00
Emil Ernerfeldt c90b97f4ef
Fix sharp corners for rectangles with StrokeKind != Inside (#5675)
Oops!
2025-02-04 14:36:29 +01:00
lucasmerlin b8051cc301
Add `SnapshotResults` struct to egui_kittest (#5672)
I got annoyed by all the slightly different variations of "collect
snapshot results and unwrap them at the end of test" I've written, so I
added a struct to make this nice and simple.

One controversial thing: It panics when dropped. I wanted to ensure
people cannot forget to unwrap the results at the end, and this was the
best thing I could come up with. I don't think this is possible via
clippy lint or something like that.

* [x] I have followed the instructions in the PR template
2025-02-04 14:01:32 +01:00
Emil Ernerfeldt 23ed49334e
⚠️ Rename `Rounding` to `CornerRadius` (#5673)
Breaking change!

* `Rounding` -> `CornerRadius`
* `rounding` -> `corner_radius`

This is to:
* Clarify
* Conform to other systems (e.g. Figma)
* Avoid confusion with `GuiRounding`
2025-02-04 12:53:18 +01:00
Emil Ernerfeldt 3c07e01d08
Improve tessellation quality (#5669)
## Defining what `Rounding` is
This PR defines what `Rounding` means: it is the corner radius of
underlying `RectShape` rectangle. If you use `StrokeKind::Inside`, this
means the rounding is of the outer part of the stroke. Conversely, if
you use `StrokeKind::Outside`, the stroke is outside the rounded
rectangle, so the stroke has an inner radius or `rounding`, and an outer
radius that is larger by `stroke.width`.

This definitions is the same as Figma uses.

## Improving general shape rendering
The rendering of filled shapes (rectangles, circles, paths, bezier) has
been rewritten. Instead of first painting the fill with the stroke on
top, we now paint them as one single mesh with shared vertices at the
border. This has several benefits:

* Less work (faster and with fewer vertices produced)
* No overdraw (nicer rendering of translucent shapes)
* Correct blending of stroke and fill

The logic for rendering thin strokes has also been improved, so that the
width of a stroke of `StrokeKind::Outside` never affects the filled area
(this used to be wrong for thin strokes).

## Improving of rectangle rendering
Rectangles also has specific improvements in how thin rectangles are
painted.
The handling of "Blur width" is also a lot better, and now works for
rectangles with strokes.
There also used to be bugs with specific combinations of corner radius
and stroke width, that are now fixed.

##  But why?
With the new `egui::Scene` we end up with a lot of zoomed out shapes,
with sub-pixel strokes. These need to look good! One thing led to
another, and then I became obsessive 😅

## Tessellation Test
In order to investigate the rendering, I created a Tessellation Test in
the `egui_demo_lib`.

[Try it
here](https://egui-pr-preview.github.io/pr/5669-emilkimprove-tessellator)

![Screenshot 2025-02-04 at 08 45
50](https://github.com/user-attachments/assets/20b47a30-de6a-4ff5-885b-2e2fd6d88321)


![image](https://github.com/user-attachments/assets/e17c50eb-5ae7-48d4-bb0d-4f2165075897)
2025-02-04 11:30:12 +01:00
Juan Campa 9e1117019a
Add `Color32::CYAN` and `Color32::MAGENTA` (#5663)
I often find myself reaching out for these two colors so I figured I'd
just add the constants next to `YELLOW` to have CMYK
2025-02-04 10:29:26 +01:00
lucasmerlin bac8ea09ac
Add docs to `Frame::new` (#5670)
* [x] I have followed the instructions in the PR template
2025-02-04 10:17:15 +01:00
lucasmerlin b6aa897b9d
Fix the format + check + test workflow (#5671)
* [x] I have followed the instructions in the PR template

This broke because upload-artefact v3 was deprecated:
https://github.com/emilk/egui/actions/runs/13112546294/job/36579426301?pr=5670
2025-02-04 10:16:51 +01:00
Michael Grupp 99369666ee
Fix typo in kittest docs (#5667)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/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/THE_RELEVANT_ISSUE>~
(just a quick typo fix)
* [x] I have followed the instructions in the PR template
2025-02-03 14:26:02 +01:00
Emil Ernerfeldt 50294b5d9f
Be smarter when rounding rectangles to the pixel grid (#5656) 2025-01-30 21:04:36 +01:00
Emil Ernerfeldt 4b9da5f650
Remove `StrokeKind::default` (#5658)
Since there is no natural default for `RectShape`.
2025-01-30 21:02:50 +01:00
Emil Ernerfeldt 04fca9c324
Remove date button from Scene demo, so as not to fail tests each day (#5657) 2025-01-30 20:51:12 +01:00
Emil Ernerfeldt ee5f0d6d52
eframe web: forward cmd-S/O to egui app (stop default browser action) (#5655)
This allow eframe apps to capture cmd-S and cmd-O to trigger their own
save and open actions, instead of having the browser do something
annoying.
2025-01-30 20:37:29 +01:00
Emil Ernerfeldt 8eda32ec64
egui_kittest: succeed and keep going when `UPDATE_SNAPSHOTS` is set (#5649)
It used to be that `UPDATE_SNAPSHOTS=true cargo test --all-features`
would stop on the first crate with a failure, requiring you to run it
multiple times, which is annoying, and a waste of time.
2025-01-30 09:34:22 +01:00
Emil Ernerfeldt 525d435a84
Require a `StrokeKind` when painting rectangles with strokes (#5648)
This is a breaking change, requiring users to think about wether the
stroke is inside/centered/outside the rect.

When in doubt, add `egui::StrokeKind::Inside` to the function call.
2025-01-29 15:52:49 +01:00
Emil Ernerfeldt 8d2c8c203c generate_changelog.py: add sections for "Performance" and "Removed" 2025-01-29 13:07:05 +01:00
Emil Ernerfeldt 6be17136f2
`RectShape`: add control over where the stoke goes (#5647)
Adds `RectShape::stroke_kind` so you can select if the stroke goes
inside, outside, or is centered on the rectangle.

Also adds `RectShape::round_to_pixels` so you can override
`TessellationOptions::round_rects_to_pixels`.
2025-01-29 12:46:12 +01:00
Emil Ernerfeldt 83649f2e29 Improve changelog generator 2025-01-29 08:44:56 +01:00
Emil Ernerfeldt e343125f70 deny.toml: point users to `cargo tree --duplicates` 2025-01-29 08:44:47 +01:00
Emil Ernerfeldt 10523ec22d Improve README.md slightly 2025-01-29 08:44:29 +01:00
Emil Ernerfeldt f86f62bb3d Improve deprecation text for `open_url/copied_text` 2025-01-29 08:44:13 +01:00
Emil Ernerfeldt 7d87acb5fa Remove dead code from CI 2025-01-29 08:43:18 +01:00
Jochen Görtler e8f351b729
Add `egui::Scene` for panning/zooming a `Ui` (#5505)
This is similar to `ScrollArea`, but:
* Supports zooming
* Has no scroll bars
* Has no limits on the scrolling

## TODO
* [x] Automatic sizing of `Scene`s outer bounds
* [x] Fix text selection in scenes
* [x] Implement `fit_rect`
* [x] Document / improve API

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2025-01-28 20:06:10 +01:00
Emil Ernerfeldt 37c564be2c Remove unnecessary profiling scope 2025-01-28 19:50:05 +01:00
Pandicon 93d2144294
Save state on suspend on Android and iOS (#5601)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/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!
-->

This pull request fixes a subset of #5492 by saving the application
state when the `suspended` event is received on Android. This way, even
if the user exits the app and closes it manually right after changing
some state, it will be saved since `suspended` gets fired when the app
is exited. It does not fix the `on_exit` function not being fired - this
seems to be a winit bug (the `exiting` function in the winit application
handler trait is not called on exit). Once it gets fixed, it may be
possible to remove logic introduced by this PR (however, I am not sure
how it would handle the app being killed by the system when in the
background, that would have to be tested).

I've tested the logic by:
* Leaving from the app to the home screen, then killing it from the
"recent apps" menu
 * Leaving from the app to the "recent apps" menu and killing it
 * Restarting the device while the app was running

In all of these instances, the state was saved (the last one being a
pleasant surprise). It was tested on the repository mentioned in #5492
with my forked repository as the source for eframe (I unfortunately am
not able to test it in a larger project of mine due to dependence on
"3rd party" egui libraries (like egui_notify) which do not compile along
with the master branch of eframe (different versions of egui), but I
believe it should work in the same manner in all scenarios). Tests were
conducted on a Galaxy Tab S8 running Android 14, One UI 6.1.1.

CI passed on my fork.

* [x] I have followed the instructions in the PR template
2025-01-27 08:14:49 +01:00
Emil Ernerfeldt bc5f908b80
Fix initial paint of web app (#5633)
* Broke in https://github.com/emilk/egui/pull/5631 (for _some_ apps)
2025-01-23 13:47:52 +01:00
Emil Ernerfeldt edbf4e8998 clean up deny.toml 2025-01-23 12:17:20 +01:00
Emil Ernerfeldt 6680e9c079
Web: Fix incorrect scale when moving to screen with new DPI (#5631)
* Closes https://github.com/emilk/egui/issues/5246

Tested on
* [x] Chromium
* [x] Firefox
* [x] Safari

On Chromium and Firefox we get one annoying frame with the wrong size,
which can mess up the layout of egui apps, but this PR is still a huge
improvement, and I don't want to spend more time on this right now.
2025-01-23 12:11:29 +01:00
Emil Ernerfeldt 304c6518e3
Update cargo-deny-action to v2 (#5632) 2025-01-23 11:07:51 +01:00
Emil Ernerfeldt 2815ff5a06 Allow `Ubuntu-font-1.0` license 2025-01-23 10:57:40 +01:00
Yerkebulan Tulibergenov 7129418289
Use Python 3 in `scripts/lint.py` (#5617)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/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

## Changes

- Use Python 3 in `scripts/lint.py`.

## Why

Some modern OS and distributions do not provide Python 2 by default.
This includes recent macOS versions.
I see that `scripts/generate_changelog.py` already uses Python 3, so I
don't think this change should be controversial.
Without this change, I am unable to run `./scripts/check.sh` on macOS
15.2 without installing Python 2 or adding alias for `python`
executable.
2025-01-22 15:28:38 +01:00
Joshua Holmes 97bdb2851c
Remove references to glium (#5626)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/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!
-->

* Remove references to `glium` backend, because it is deprecated since
egui v0.18.0
* [x] I have followed the instructions in the PR template
2025-01-22 15:28:23 +01:00
n4n5 bdf7bfddd7
Add keys for `!`, `{`, `}` (#5548)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/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!
-->

* Help on https://github.com/emilk/egui/issues/3653 
* [x] I have followed the instructions in the PR template
2025-01-22 15:20:06 +01:00
Philippe Ombredanne e53bb53795
Update `egui_default_fonts` license (#5361)
Ubuntu-font-1.0 is now in SPDX

Reference: https://spdx.org/licenses/Ubuntu-font-1.0.html
Reference:
824163fa6f/src/licensedcode/data/licenses/ubuntu-font-1.0.LICENSE (L11)

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
2025-01-22 15:16:50 +01:00
Mads Marquart a04e25af63
Prepare for `objc2` frameworks v0.3 (#5624)
The next version of the `objc2` framework crates will have a bunch of
default features enabled, see
https://github.com/madsmtm/objc2/issues/627, so this PR pre-emptively
disables them, so that your compile times down blow up once you upgrade
to the next version (which is yet to be released, but will be soon).

* [x] I have followed the instructions in the PR template
2025-01-22 15:13:34 +01:00
Emil Ernerfeldt 71f7bdc919
Implement `nohash_hasher::IsEnabled` for `Id` (#5628)
`egui:🆔:IdSet` and `egui:🆔:IdMap` were already optimized to not do
additional hashing (because the `Id` already is a hash), but now they
are just type aliases for `nohash_hasher::IntSet/IntMap`.

See https://crates.io/crates/nohash-hasher for more
2025-01-22 13:18:02 +01:00
Matthias Kronberg 493d5d0982
Fix hovering through custom menu button (#5555)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/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!
-->

This change discards widgets which are fully covered by another widget
in a higher layer from the hit test algorithm.

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

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2025-01-22 13:17:51 +01:00
Emil Ernerfeldt 5b740f97ac
Remove `egui::special_emojis::TWITTER` (#5622)
Twitter is gone, as is its icon.

Also, fuck Elon Musk

Find me on https://bsky.app/profile/ernerfeldt.bsky.social
2025-01-21 11:56:45 +01:00
Andreas Reich 30e66e4575
Wgpu resources are no longer wrapped in `Arc` (since they are now `Clone`) (#5612)
Co-authored-by: Nicolas <bircni@icloud.com>
2025-01-20 18:06:35 +01:00
Emil Ernerfeldt cf965aaa30 Update awalsh128/cache-apt-pkgs-action to 1.4.3 to fix CI 2025-01-16 21:13:02 +01:00
TÖRÖK Attila a5d7cf5bd7
Upgrade to wgpu 24 (#5610) 2025-01-16 17:00:29 +01:00
Alix Bott 366900c550
implement Debug for RichText (#5596)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/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!
-->

* Derive Debug for RichText
* [x] I have followed the instructions in the PR template
2025-01-14 08:44:39 +01:00
Emil Ernerfeldt 164f56f554
Fix some clippy issues found by 1.84.0 (#5603) 2025-01-13 08:29:13 +01:00
Andreas Reich 1339639706
Fix Windows clippy issues (#5593)
These have been a lil bit annoying when running `cargo clippy
--all-features --all-targets` on windows
2025-01-11 18:05:57 +01:00
Andreas Reich f0d7c74e83
`response` module is now public, allowing access to `egui::response::Flags` (#5592) 2025-01-08 15:45:46 +01:00