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

4150 Commits

Author SHA1 Message Date
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
Emil Ernerfeldt
4f6eabffb8 Fix jitter when hovering edge of scroll area close to resize splitter (#7803)
* Closes https://github.com/emilk/egui/issues/7749

## What
In our hit test code we have special handling for thin widgets, to make
them easier to hit.
The widths of our scroll bars are animated.
Together, the heuristic would trigger as the scroll bars were shrinking,
leading to the scroll bars being _hovered_ which lead them being too
wide, making the heuristic fail, which would again make them shrink,
causing the bug.

## Bonus
Now the scroll bar is only shown as hovered if the mouse is actually
hovering them and nothing else. Previously they would show as long as
the cursor were in the general area (but maybe actually hovering
something else).
2025-12-22 21:13:24 +01:00
Emil Ernerfeldt
4169d2c196 Enable more clippy lints (#7801) 2025-12-21 21:57:29 +01:00
Jasper Riedel
661d5f9173 Update MSRV from 1.88 to 1.92 (#7793) 2025-12-20 13:52:34 +01:00
Emil Ernerfeldt
8d98763fe1 Replace #[allow attributes with expect (#7796)
We do have `clippy::allow_attributes` turned on, but it doesn't seem to
work properly
2025-12-19 20:55:50 +01:00
Emil Ernerfeldt
7fe58bbfd4 Forbid uses of unwrap() in the code (#7795) 2025-12-19 20:34:18 +01:00
Jinwoo Park
646fea2133 Apply preferred font weight when loading variable fonts (#7790)
Previously, when loading a variable font (e.g. via
`egui::FontData::from_static`),
the font was rendered using the default (often the lightest) weight,
ignoring any preferred weight configuration.

This change applies the specified weight to skrifa's `Location` for the
`wght` axis,
ensuring that variable fonts are rendered with the intended font weight.

## Summary
Fixes variable font weight not being applied during rendering. The
`FontData::weight()` method now properly configures the font variation
axis.

## Changes
- Add `location: Location` field to `FontFace` to store variation
coordinates
- Pass `location` parameter through to glyph rendering functions
- Apply weight to skrifa's `LocationRef` in `DrawSettings` and
`HintingInstance`

## Weight Priority
1. `preferred_weight` from `FontData::weight()`
2. OS/2 table's `us_weight_class` 
3. Variable font's fvar default value
4. `Location::default()`

## Related Issue
- #3218 : Not follow font id, but goal would be same

## Todo
* [x] Apply preferred font weight when loading variable fonts
* [ ] Add small size variable fonts for docs and egui (need discussion)
2025-12-19 20:24:48 +01:00
Emil Ernerfeldt
011c59c2ad Apply nightly clippy suggestions/fixes (#7794)
* Reduce the diff for https://github.com/emilk/egui/pull/7793
2025-12-19 18:43:58 +01:00
Emil Ernerfeldt
f1e0b2e565 Deprecate Context::used_size and Context::available_rect (#7788) 2025-12-17 21:18:36 +01:00
Emil Ernerfeldt
ca1e76f38b Constrain demo windows to the space left after the panels (#7785) 2025-12-17 21:03:52 +01:00
Emil Ernerfeldt
51493be066 Better framing of demo snapshots (#7787) 2025-12-17 18:06:26 +01:00
Emil Ernerfeldt
4d63502338 Heed constrain rect when auto-positioning windows (#7786)
The default `Window` and `Area` position will now respect `constrain_to`
rectangle
2025-12-17 17:31:43 +01:00
Emil Ernerfeldt
986c2c0ffb Use explicit Arc::clone to clarify when clones are cheap (#7784) 2025-12-17 17:19:18 +01:00
Emil Ernerfeldt
6157a35985 Deprecate CentralPanel::show (#7783)
* Part of https://github.com/emilk/egui/issues/3524

Use `show_inside` instead, with a `Ui` instead of a `Context`
2025-12-17 16:39:13 +01:00
Kelvin Leung
53ec7333c3 Fix media type with optional parameters (#7739)
<!--
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!
-->

I am having an issue loading this image
"https://stacks.stanford.edu/image/iiif/wy534zh7137/SULAIR_rosette/full/400,/0/default.jpg".
It has a mime type of "image/jpeg; charset=utf-8", which is not common.

The code doesn't parse the full string that includes the optional
parameter "charset=utf-8" to create the jpeg image format.

A line is added to take only the mime type in the media type before the
";" and ignore the optional parameters.

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

Co-authored-by: leungkkf <leungkkf@gmail.com>
2025-12-17 16:08:51 +01:00
Emil Ernerfeldt
14bf7b74a3 CI: disable link checker (#7782) 2025-12-16 18:53:03 +01:00
AdrienZ.
9c3a0bb37c Per-widget style (#7667)
* Closes <https://github.com/emilk/egui/issues/7586>

Implementation of the per-widget style of the action plan to add better
styling option to egui

---------

Co-authored-by: adrien <221212@umons.ac.be>
Co-authored-by: Adrien Zianne <adrien@iq002.ipa.iqrypto.com>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2025-12-16 18:49:27 +01:00
Emil Ernerfeldt
14643b56a8 Deprecate using Panel directly on a Context (#7781)
Use `Panel::show_inside(ui)` instead!
2025-12-16 17:20:42 +01:00
Emil Ernerfeldt
2f6fe9c572 eframe: Replace Frame::update with fn logic and fn ui (#7775)
* Part of https://github.com/emilk/egui/issues/5113
* Part of https://github.com/emilk/egui/issues/3524

## What
This deprecates `eframe::App::update` and replaces it with two new
functions:

```rs
pub trait App {
	/// Called just before `ui`, and in the future this will
    /// also be called for background apps when needed.
	fn logic(&mut self, ctx: &egui::Context, frame: &mut Frame) { }
	
    /// Show your user interface to the user.
	fn ui(&mut self, ui: &mut egui::Ui, frame: &mut Frame);

	…
}
```

Similarly, `Context::run` is deprecated in favor of `Context::run_ui`.

`Plugin`s are now handed a `Ui` instead of just a `Context` in
`on_begin/end_frame`.

## TODO
…either in this PR or a later one
* [x] Deprecate `App::update`
* [x] Deprecate `Context::run`
* [x] Change plugins to get a `Ui`
* [x] Update kittest
* [x] Change viewports to get UI:s (`show_viewport_immediate` etc)
  - https://github.com/emilk/egui/pull/7779

## Later PRs
* [ ] Deprecate `Panel::show`
* [ ] Deprecate `CentralPanel::show`
* [ ] Deprecate `CentralPanel` ?
2025-12-16 17:05:50 +01:00
Emil Ernerfeldt
9487dc35ec Viewports: give the caller a Ui instead of Context (#7779)
* Part of https://github.com/emilk/egui/issues/3524

This is a breaking change, as it changes the how embedded viewports
work.
Before it was up to the user to display a `egui::Window` if they wanted.
Now egui creates an `egui::Window` for you, so you only need to add the
contents.

To signal this change in behavior, `ViewportClass::Embedded` is gone and
is now called `ViewportClass::EmbeddedWindow`.
2025-12-15 18:51:57 +01:00
Emil Ernerfeldt
4a81ca8dcf Fix: ensure CentralPanel::show_inside allocates space in parent (#7778)
If the `CentralPanel` is the only thing in e.g. a `Window`, it needs to
let the parent `Ui` know how much space was used. Now it does.
2025-12-15 18:20:55 +01:00
Emil Ernerfeldt
bfaf1b44f2 Replace ui.ctx().foo with ui.foo in a few places (#7774)
Internal code cleanup after
* https://github.com/emilk/egui/pull/7770
2025-12-14 17:12:10 +01:00
Emil Ernerfeldt
453e34b4df Rename functions in Context to avoid confusion (#7773)
It's important to avoid confusion after
* https://github.com/emilk/egui/pull/7770
2025-12-14 16:49:51 +01:00
Emil Ernerfeldt
bc48599f65 Rename Context::style to global_style; avoid confusion w/ Ui::style (#7772)
This is important after
* https://github.com/emilk/egui/pull/7770
2025-12-14 16:41:13 +01:00
Emil Ernerfeldt
5ea94dd0d7 Add Deref<Target = Context> for Ui (#7770)
* Closes https://github.com/emilk/egui/issues/4033
* Closes https://github.com/emilk/egui/pull/4072

This means you don't have to type `ui.ctx().foo` but just `ui.foo`

---------

Co-authored-by: obellish <obellish@mpilabels.com>
Co-authored-by: obellish <125279760+obellish@users.noreply.github.com>
2025-12-14 16:25:28 +01:00
Emil Ernerfeldt
ce17f6c518 Fix warnings when compiling kittest without all features (#7771) 2025-12-14 16:21:07 +01:00
Justin Symonds
8ef7f10367 Fixes for doc comments (#7668)
* [x] I have followed the instructions in the PR template

- Some typos/grammos
- Attempt to finish incomplete comment
- Broken link
- I understand the colon is a convention for pluralizing symbol names,
but it seems redundant in the presence of other punctuation

---------

Co-authored-by: Lucas Meurer <hi@lucasmerlin.me>
2025-12-14 15:24:08 +01:00
Johnchoi913
06e632535b Enable feature for example custom_3d_glow (#7730)
<!--
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!
-->

* Small fix, no issue opened
* [x] I have followed the instructions in the PR template
2025-12-14 15:23:41 +01:00
Emil Ernerfeldt
a0bb4cfef8 Release 0.33.3: update cargo version and changelog 2025-12-11 15:42:15 +01:00
switch
2115ca941b egui-wgpu: attach stencil buffer (#7702) 2025-12-07 23:34:26 +01:00
Nico Burns
6277a310b9 Disable the Skrifa traversal feature (#7758)
- Followup to https://github.com/emilk/egui/pull/7694
- Disables the `traversal` feature of `skrifa` which is not needed
except internally by the fontations project
- Should save a little compile time, and possibly some binary size.

Signed-off-by: Nico Burns <nico@nicoburns.com>
2025-12-07 09:33:51 +01:00
valadaptive
609dd2d28e Replace ab_glyph with Skrifa + vello_cpu; enable font hinting (#7694)
<!--
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

I'll probably come back to this and clean it up a bit. This PR
reimplements ab_glyph's functionality on top of Skrifa, a somewhat
lower-level font API that's being used in Chrome now.

Skrifa doesn't perform rasterization itself, so I'm using
[vello_cpu](https://github.com/linebender/vello) from the Linebender
project for rasterization. It's still in its early days, but I believe
it's already quite fast. It also supports color and gradient fills, so
color emoji support will be easier.

Skrifa also supports font hinting, which should make text look a bit
nicer / less blurry.

Here's the current ab_glyph rendering:

<img width="1592" height="1068" alt="image"
src="https://github.com/user-attachments/assets/2385b66e-23f8-4c6e-b8c2-ea90e0eea4e4"
/>

Here's Skrifa *without* hinting--it looks almost identical, but there
are some subpixel differences, probably due to rasterizer behavior:

<img width="1592" height="1068" alt="image"
src="https://github.com/user-attachments/assets/a815f3e9-65ac-4940-bc00-571177bef53d"
/>

Here's Skrifa  *with* hinting:

<img width="1592" height="1068" alt="image"
src="https://github.com/user-attachments/assets/d6cc0669-3537-4377-bba9-ed5ef09664db"
/>

Hinting does make the horizontal strokes look a bit bolder, which makes
me wonder once again about increasing the font weight from "light" to
"regular".

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2025-12-06 16:11:33 +01:00
Jan Procházka
2174b309bd Bump ehttp to 0.6.0 (#7757) 2025-12-06 11:33:56 +01:00
Jochen Görtler
2dbfe3a083 Enable or_fun_call lint to avoid unnecessary allocations (#7754)
### What

From the [lint
description](https://rust-lang.github.io/rust-clippy/master/index.html?search=or_fu#or_fun_call):

> The function will always be called. This is only bad if it allocates
or does some non-trivial amount of work.

But also:

> If the function has side-effects, not calling it will change the
semantic of the program, but you shouldn’t rely on that.
> 
> The lint also cannot figure out whether the function you call is
actually expensive to call or not.

Still worth it to keep our happy paths clean, imo.
2025-12-05 10:46:34 +01:00
Ryan
3fcdab4ebd Typo fix in drag-and-drop documentation (#7750)
* [x] I have followed the instructions in the PR template

Adding periods to the end of sentences and fixes a grammar mistake on
documentation for the drag-and-drop code to become consistent with the
rest of the documentation.

The documentation for `Ui::dnd_drop_zone` could've used the word "its"
instead of "the" to replace "it", but I think "the" more clearly refers
to the `Frame` since "its" has been used to refer to the drop-zone
already.
2025-12-05 10:44:06 +01:00
Lucas Meurer
de907612b7 Enforce consistent snapshot updates (#7744)
* Closes https://github.com/emilk/egui/issues/7647


This collects SnapshotResults within the Harness and adds a check to
enforce snapshot results are merged in case multiple Harnesses are
constructed within a test.

This should make snapshot updates via kitdiff/accept_snapshots.sh way
more useful since it should now always update all snapshots instead of
only the first one per test.
2025-11-26 14:56:19 +01:00
Lucas Meurer
a19629ef4a Add kittest.toml config file (#7643)
* part of https://github.com/rerun-io/rerun/issues/10991

---------

Co-authored-by: lucasmerlin <8009393+lucasmerlin@users.noreply.github.com>
2025-11-25 14:51:18 +01:00
Emil Ernerfeldt
8b8595b45b Treat . as a word-splitter in text navigation (#7741)
When using option + arrow keys (Mac) or ctrl + arrow keys (Windows), you
navigate a full word.
Previously egui would ignore `.` in the text, so that `www.example.com`
would be considered a full word.
This is inconsistent with how the rest of macOS works.

With this PR, cursor navigation in `www.example.com` will move the
cursor between the dots.
This makes editing code with egui a lot nicer.
2025-11-25 13:15:28 +01:00
Emil Ernerfeldt
a624f37e2d Add Context::run_ui (#7736)
* Part of https://github.com/emilk/egui/issues/3524

Adds `Context::run_ui` as a convenience wrapper around `Context::run`.

This on the path to deprecate `run` and use a top-level `Ui` as the
entry-point for all of egui.
2025-11-25 08:52:16 +01:00
Yichi Zhang
8d3539b6da test_viewports: fix assertion (#7693)
<!--
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
These assertions allows col == COLS, while when col == COLS, array may
be out of bounds. In `fn init`, `for i in 0..COLS {self.insert(...`
confirms the assertions' predicate col <= COLS should be changed into
col < COLS.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2025-11-24 09:56:24 +01:00
Emil Ernerfeldt
d5869bfeaf Remove some uses of top-level panels in our examples (#7729)
We're phasing out top-level panels (panels that use `Context` directly,
instead of being inside another `Ui`).
As a first step, stop using them in our demo library and application.

* Part of https://github.com/emilk/egui/issues/3524
2025-11-21 20:22:01 +01:00
Emil Ernerfeldt
d53a4a9c1d Update docs to reflect that wgpu is the default renderer (#7719)
I missed a few parts when merging
* https://github.com/emilk/egui/pull/7615
2025-11-18 15:56:35 +01:00
Bruno Paré-Simard
5b6a0196f9 Add Panel to replace SidePanel and TopBottomPanel (#5659)
This combines `SidePanel` and `TopBottomPanel` into a single `Panel`.

The old types are still there as type aliases, but are deprecated.

`.min_width(…)` etc are now called `.min_size(…)` etc.

Again, the old names are still there, but deprecated.

(edited by @emilk)

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2025-11-18 15:46:01 +01:00
Emil Ernerfeldt
178f3c9198 Add ScrollArea::content_margin (#7722)
* Part of https://github.com/emilk/egui/issues/5605
* Part of https://github.com/emilk/egui/issues/3385
2025-11-18 15:30:02 +01:00
Emil Ernerfeldt
f74b7c7e79 Paint mouse cursor in kittest snapshot images (#7721)
Very simple triangle shape, but helps understand why a widget has a
hovered effect
2025-11-18 06:24:03 +01:00