## Summary
Clipped table cells no longer contribute their overflowing content to a
sizing pass. Refresh non-resizable column widths during sizing so
clipped and truncated labels use the narrower available width when a
window is resized. Preserve minimum sizing for unclipped content and
full content measurements for column auto-sizing.
Fixes#8408.
## Testing
- Added sizing and window-drag regressions for exact, remainder, and
automatic columns and both strip directions, including unclipped and
explicitly truncated labels.
- Inspected headless wgpu renders during resizing; clipped/truncated
text and adjacent buttons remain correctly laid out.
- `cargo test --locked -p egui_extras -p egui --all-features --features
image/png,image/jpeg`
- `cargo clippy --locked -p egui_extras -p egui --all-targets
--all-features -- -D warnings`
- `cargo fmt --all --check`
- `python -X utf8 scripts/lint.py`
Preserve transparent viewport windows on Windows
Refactor window creation into create_window_for_viewport
## Description
`glutin_winit::finalize_window` may clear a window's requested
transparency when the selected GL config reports that transparency is
unsupported. On affected Windows GL paths, transparent native windows
and their GL surfaces may still composite correctly despite that report.
This can also cause a recreated root viewport to become opaque if its
transparent window is passed through `finalize_window`. Create
explicitly transparent Windows viewport windows directly instead,
including both root and child viewports. Keep using `finalize_window`
for opaque Windows windows and for windows on other platforms.
This extends the Windows workaround from the merged
[egui#8423](https://github.com/emilk/egui/pull/8423) to cover root
viewports, including when they are recreated.
eframe's glow backend asks for OpenGL 3.3 core, then for OpenGL ES 2.0.
Some Windows drivers reject both: Intel HD Graphics 3000 offers OpenGL
3.1 and lacks WGL_EXT_create_context_es2_profile, so eframe fails to
start with "extension to create ES context with wgl is not present",
although egui_glow runs fine on that hardware. A user on Windows 10 1903
got 0xC0072095 for 3.3 core, then that error for ES.
This adds a last attempt: a compatibility profile without a minimum
version, which drivers answer with the newest version they support.
egui_glow already handles GLSL 1.20 and 1.40. Every failed attempt is
logged at warn and the last error is returned.
The attempts and the try-in-order loop are small functions with unit
tests.
* [x] I have followed the instructions in the PR template
I'm working on an open-source UI toolkit that uses egui as one of its
backends, and I'd like to propose a few small patches. This is the
second one.
* [x] I have followed the instructions in the PR template
`Memory::layer_id_at`, which decides who gets the hover and the scroll
wheel, only finds layers that have an area state, and only `Area` can
set one. A layer an integration places itself, for instance with
`UiBuilder::layer_id` and `Context::set_transform_layer`, is skipped, so
the wheel and hover fall through to whatever is behind it.
This PR:
- makes `Areas::set_state` public (`AreaState` and `Memory::areas_mut`
already are);
- documents it: call it every pass the layer is shown, with the layer's
rect and whether it is interactable;
- adds a test, `set_state_makes_layer_hit_testable`: a layer registered
with `set_state` is returned by `layer_id_at` over its rect, and no
longer once it stops being registered.
Note about why not use an `Area`: it lays out its own content, and the
first time it is shown it does an invisible, non-interactable sizing
pass and asks for another repaint. A UI that has already measured and
placed its popup, such as a menu or popover, doesn't need that.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
<!--
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!
* Keep PR description short and to the point! No long LLM slop.
* 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 a human has reviewed it
* When you have addressed a PR comment, mark it as resolved.
Please be patient! I will review your PR, but my time is limited!
-->
Add same method like `Pos2` and `Vec2`: `floor()`, `round()`, `ceil()`
* Closes <https://github.com/emilk/egui/issues/THE_RELEVANT_ISSUE>
* [x] I have followed the instructions in the PR template
I'm working on an open-source UI toolkit that uses egui as one of its
backends, and I'd like to propose a few small patches. This is the first
one.
* [x] I have followed the instructions in the PR template
The callback set with `Context::set_request_repaint_callback` is only
called when a request makes the next repaint of a viewport come sooner.
So an integration can't see everything that was requested during a pass:
a `request_repaint_after(2s)` after a `request_repaint_after(1s)`, or
any request while an immediate repaint is already pending, never reaches
it. `ViewportOutput::repaint_delay` only has the soonest of all
requests, merged with egui's own follow-up repaint after input, and
`Context::repaint_causes` has no delays.
This PR:
- adds `Context::set_repaint_observer`, an optional second callback that
gets the same `RequestRepaintInfo` for every repaint request, on the
thread that made it;
- leaves the request callback and its throttling (#2126) unchanged, so
no integration gets more wakeups, and costs nothing when no observer is
set;
- adds a test, `test_repaint_observer_sees_every_request`: it requests a
repaint after 1 s, then after 2 s, and checks that the callback only
sees the first request while the observer sees both.
An integration can use the observer to schedule its own frames from what
the app actually asked for (for example, to settle an input in a single
pass instead of the usual follow-up passes), or to count repaint
requests in tests.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Expose the optional color set by `RichText::color()` so callers can read
it without keeping duplicate state. `color_override()` returns the
explicit override; theme and widget color resolution remain unchanged.
* Closes <https://github.com/emilk/egui/issues/7267>
* [x] I have followed the instructions in the PR template
<!--
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!
-->
https://github.com/emilk/egui/issues/4607 accidentally removed the
behavior where – once a menu is open – moving the mouse to another menu
opens that one instead (on hover, without requiring a click). This is a
pretty easy fix!
* Closes <https://github.com/emilk/egui/issues/7346>
* [X] I have followed the instructions in the PR template
---------
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
<!--
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
The PR makes it so a popup is closed on a press of a button but not
click (i.e. release) of a button - this fixes the issue of a popup
immediately closing after releasing a button.
I can reproduce the issue with the following code in `bevy_egui`:
```rust
let popup = egui::Popup::new(
egui::Id::new("A unique popup"),
ctx.clone(),
egui::PopupAnchor::PointerFixed,
egui::LayerId::new(egui::Order::Foreground, egui::Id::new("popup layer")),
);
let mut open_command = None;
for message in mouse_button_input_reader.read() {
if message.state.is_pressed() && message.button == MouseButton::Right {
open_command = Some(SetOpenCommand::Bool(true));
}
}
popup.open_memory(open_command).show(|ui| {
ui.label("This is a popup");
});
```
When a popup is open due to a "press" event, it will get closed on the
next "release" event (as they aren't likely to happen at the same
frame). One could argue that the intended usage here is to open a popup
only on a release of a button, but for users that have it open on a
button press the current `egui` behavior could be counterintuitive.
I haven't tested this extensively, but if you find that this fix breaks
any other behavior or some intended design where we do expect a popup
close only on a button release, feel free to close this.
---------
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Enable mouse wheel scrolling while dragging inside a `ScrollArea`
### Problem
When the pointer button is held down and a widget inside a `ScrollArea`
is being dragged (e.g. selecting text in `TextEdit`), mouse wheel
scrolling does not work. This happens because `ScrollArea` only
processes mouse wheel scrolling when `ctx.dragged_id().is_none()`, i.e.
when no widget is currently being dragged.
### Change
Relax the wheel-scrolling gating condition so that wheel scrolling is
allowed whenever the pointer is over the scroll area (or when
background-drag scrolling is active), even if another widget is
currently being dragged.
Concretely, we replace the `dragged_id().is_none()` requirement for the
mouse wheel path with:
- `pointer_over_outer = ui.rect_contains_pointer(outer_rect) ||
is_dragging_background`
- Use `pointer_over_outer` to decide whether to apply wheel scrolling
### Result
- Wheel scrolling works while dragging/selecting within widgets inside a
`ScrollArea` (notably `TextEdit`).
- This matches common desktop editor behavior: drag-select while
wheel-scrolling to extend selection.
### Notes / Potential behavior change
This enables wheel scrolling during any active drag (not only
`TextEdit`), as long as the pointer is over the `ScrollArea`. If
maintainers prefer limiting this to specific widgets (e.g. only text
selection), we can follow up with a more targeted approach (e.g. an
explicit option/flag).
**Files changed**
- `scroll_area.rs` (wheel scrolling hover gating logic)
Fix : an issue where double-clicks were judged as triple-clicks.
Fixed an issue where a double-click was sometimes recognized as a
triple-click.
---------
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Supersedes #7671 by @drewmiller (thanks!), implementing the
`command_only` suggestion from review.
In `egui-winit`, `Event::Cut`/`Copy`/`Paste` are now only emitted when
Cmd/Ctrl is held **without** Shift or Alt. Shortcuts like Cmd+Shift+V,
Cmd+Alt+V, Cmd+Shift+C (and their Ctrl equivalents) are now passed
through as normal key events, so apps can bind them to e.g.
paste-as-plain-text.
Unchanged: the dedicated Cut/Copy/Paste keys, and Shift+Delete /
Ctrl+Insert / Shift+Insert on Windows.
Note: on Linux this means Ctrl+Shift+C/V (terminal-style) no longer
copy/paste into egui text fields.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
## Summary
Only the root viewport now provides window information to the native
autosave flow.
## Details
When a deferred viewport autosaves, its window size and position could
overwrite the settings used to restore the root window on the next
launch. This change passes window information to autosave only for the
root viewport in both the Glow and WGPU integrations.
Autosaving application state and egui memory remains enabled for
deferred viewports.
AccessKit's `ScrollIntoView` (and kittest's `Node::scroll_to_me`) did
nothing for a `Ui` created with `UiBuilder::sense`, e.g. via
`ui.scope_builder`.
`Ui::new` registers the `Ui` with `Rect::NOTHING`, then
`remember_min_rect` registers it again with its real rect.
`Context::create_widget` consumed the `ScrollIntoView` request on the
first call, so it scrolled to an empty rect and the request was gone by
the second call.
`create_widget` now leaves action requests alone while the rect is
`Rect::NOTHING`, so they are handled once the real rect is known. `Drop
for Ui` always calls `remember_min_rect`, so a request is never left
unhandled.
Added `sensed_ui_can_be_scrolled_into_view` to
`egui_kittest/tests/accesskit.rs` (fails without the fix).
* [x] I have followed the instructions in the PR template
Closes#8495.
## Problem
`ScrollArea::scroll_bar_rect` is used when painting the scrollbar
(`outer_scroll_bar_rect` at lines 1360-1364) and when computing handle
geometry/travel (`from_content`, `handle_travel`), but the interaction
rect `max_bar_rect` (lines 1318-1322) was derived from `outer_rect`
along the scrolling axis.
When a caller passes a `scroll_bar_rect` smaller than `outer_rect` (as
`egui_table::SplitScroll` does to keep bars out of sticky row/column
regions), the two rects disagree along the scroll axis. Consequences:
1. A press in the region where no scrollbar is drawn is sensed as a
scrollbar press and snaps the offset to the minimum.
2. During a drag, that region behaves as a dead zone because
`scroll_start_offset_from_top_left` is latched for the whole drag and
the offset is pinned until the pointer crosses back into
`handle_travel`.
## Fix
Changed `max_bar_rect` to use `scroll_bar_rect.x_range()` for horizontal
bars and `scroll_bar_rect.y_range()` for vertical bars along the
scrolling axis, while keeping the existing cross-axis positioning
(`max_cross`, `full_width`, and the clip-rect adjustment that moves bars
into view).
The interactive region now matches the painted bar and handle travel
exactly. The default case (`scroll_bar_rect` is `None`, which resolves
to `inner_rect`) is unchanged in behavior since `inner_rect` and
`outer_rect` share the same min along the scroll axis (only the far edge
differs for scroll bar space).
- [x] `cargo check -p egui` and `cargo test -p egui` pass.
## Summary
Right now, `Panel`s and `Scene`s override the clip rect of their parent
container. This results in "overflow" during the window collapse
animation:
https://github.com/user-attachments/assets/453b6089-0312-4dc9-ac18-28d36ae66e13
This PR makes the clip rect intersect with the outer container, so that
the content is properly hidden:
https://github.com/user-attachments/assets/692db0eb-66c6-41d2-9ea6-e53c7733ef91
### Changes
- Modify `panel.rs` to use `intersect` when calling `set_clip_rect`
- Modify `scene.rs` to use `intersect` when calling `set_clip_rect`
<!--
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!
* Keep PR description short and to the point! No long LLM slop.
* 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 a human has reviewed it
* When you have addressed a PR comment, mark it as resolved.
Please be patient! I will review your PR, but my time is limited!
-->
* No associated issue that I could find
* [x] I have followed the instructions in the PR template
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This patch fixes the issue raised in #8652 whereby focusable widgets
that have been disabled still remain in the focus widget cache and can
be navigated to via the directional keys.
The fix adds a new function `ignore_focus` to `Memory` that does the
same as `surrender_focus` but additionally removes the widget in
question from `focus_widgets_cache`. `Context::create_widget` is updated
to call this function instead of `surrender_focus`.
A regression test is added to guarantee this behaviour. The test sets up
two buttons and a checkbox to enable/disable the first button. When the
first button is disabled, the arrow down/up keys are tested to ensure
that focus skips over the button.
<!--
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!
* Keep PR description short and to the point! No long LLM slop.
* 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 a human has reviewed it
* When you have addressed a PR comment, mark it as resolved.
Please be patient! I will review your PR, but my time is limited!
-->
* Addresses and resolves
<https://github.com/emilk/egui/discussions/8652>
* [x] I have followed the instructions in the PR template
---------
Co-authored-by: Lucas Meurer <hi@lucasmerlin.me>
- [x] I have followed the instructions in the PR template
Closes#8092.
Related to #8084.
Virtualized tables could shift the parent UI's automatic ID sequence
between sizing and rendering passes.
`StripLayout::skip_space` represented non-visible rows using
`allocate_rect(..., Sense::hover())`. This preserved the scroll extent,
but also registered a hover widget and consumed an automatic widget ID.
When virtual buffers differed between passes, subsequent table widget
IDs changed and triggered warnings such as:
> Widget rect changed id between passes
Multi-pass and data-driven layouts can also legitimately move existing
widgets into vacated rects or intentionally replace all widgets within a
region. These cases could produce the same warning even though the
widget IDs were stable or the replacement was intentional.
This PR:
- uses `expand_to_include_rect` for virtual row buffers, preserving the
scroll extent without registering a widget or consuming an automatic ID;
- assigns deterministic IDs to table header, body, and cell UIs;
- avoids warnings when an existing widget moves into a rect vacated
during the previous pass, while retaining warnings for genuinely new IDs
replacing widgets in place;
- adds `Context::allow_widget_id_changes_in` as a pass-local,
rect-scoped exclusion for regions that intentionally replace their
widget set;
- adds regression coverage for virtual spacer extent, automatic ID
preservation, moved widgets, genuine replacements, and scoped
exclusions.
There are no intended visual changes. The only public API change is
`Context::allow_widget_id_changes_in`, which affects this diagnostic
only; it does not change duplicate-ID checks or widget interaction.
### Testing
Verified locally with Rust 1.95.0:
- `cargo fmt --all -- --check`
- `python3 scripts/lint.py`
- `RUSTFLAGS="-D warnings" RUSTDOCFLAGS="-D warnings" cargo test -p egui
-p egui_extras --all-features --features image/png,image/jpeg --locked`
- `RUSTFLAGS="-D warnings" cargo clippy -p egui -p egui_extras
--all-targets --all-features --locked -- -D warnings`
- `RUSTFLAGS="-D warnings" cargo clippy -p egui -p egui_extras
--all-targets --all-features --release --locked -- -D warnings`
87 unit tests and 193 doc-tests passed; one existing doc-test is
ignored. The test command explicitly enables PNG/JPEG codecs required by
the image-loader fixtures.
Screenshots are not applicable because these changes do not affect
visual output.
---------
Co-authored-by: lucasmerlin <hi@lucasmerlin.me>
Co-authored-by: wfp-codex-bot <wfp-codex-bot@vlans.co>
<!--
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
SVG supports inlining raster images (PNG/JPEG), `egui-extras` as it
stands does not support this.
`resvg` has a feature for this, it's just a matter of enabling it, this
PR adds an `egui-extras` feature `svg_images` doing exactly that.
---------
Co-authored-by: Lucas Meurer <hi@lucasmerlin.me>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
The smithay-clipboard Clipboard::new method requires the display pointer
to remain valid for the lifetime of the Clipboard. Since egui-winit's
Clipboard::new cannot guarantee this invariant, it must be marked unsafe
and pass the safety requirement to the caller.
Fixes#7743 (more details there)
* Closes <https://github.com/emilk/egui/issues/7743>
* [x] I have followed the instructions in the PR template
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Add 25 new key variants to the Key enum to cover standard multimedia,
browser, launch, and Mac-specific keys:
- Browser keys: BrowserForward, BrowserRefresh, BrowserSearch,
BrowserHome, BrowserFavorites, BrowserStop
- Media keys: MediaPlayPause, MediaTrackNext, MediaTrackPrevious,
MediaStop, AudioVolumeMute, AudioVolumeDown, AudioVolumeUp
- Launch keys: LaunchMail, LaunchApp1, LaunchApp2
- Mac/system keys: Fn, Eject, Help, Power, Sleep, Clear
- Lock keys: CapsLock, NumLock, ScrollLock, PrintScreen, Pause, Menu
Also fix the 'Help' key name conflict - previously 'Help' was mapped to
Key::Insert, now it correctly maps to the new Key::Help.
<!--
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/THE_RELEVANT_ISSUE>
* [ ] I have followed the instructions in the PR template
---------
Co-authored-by: ans1ble <ans1ble@users.noreply.github.com>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Closes <https://github.com/emilk/egui/issues/7650>
[ X] I have followed the instructions in the PR template
Previously submitted as <https://github.com/emilk/egui/pull/7666> but
replaced to clean up the git history.
This feature allows building image viewers and similar applications
using a `Scene` container where the desired mouse wheel input without a
modifier is to zoom rather than scroll/pan.
Alternatives considered:
Swap zoom and scroll variables used in `Scene`
- Would cause touch input zoom to scroll/pan instead which would be
inconsistent with standard user interface interaction
- This also means there is no simple way to swap zoom and vertical
scroll modifiers for this use case e.g. ctrl+mousewheel pans vertically
while mousewheel alone zooms.
- What is implemented results in ctrl-mousewheel and mousewheel only
being identical inputs.
Modify `ctx.option.zoom_modifier`
- Doesn't work because `Modifiers:NONE` never matches to anything (and
therefore disables mouse wheel zoom globally).
- Refactoring this to provide a different option per container is a
large amount of work and does not seem to be a use case that is likely
to be used outside of `Scene`
The logic used inside `Scene` to achieve this is fairly simple and only
adds one extra dependency on `input_options.scroll_zoom_speed` to ensure
that the zoom speed setting change is consistent across the application.
---------
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
<!--
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
Compiler optimization will replace these later on, but when building
without optimization they will (most often) stay divisions and divisions
are clearly slower than multiplications.
Note that the `/ 2.5` replacement is not bit-exact (since 0.4 cannot be
represented exactly, but 2.5 can), but my guess is that the
approximation is good enough. The others should be bit-exact.
(Division by 2 for unsigned numbers will be replaced to >>1 earlier in
the compile chain, so no point in doing the same there.)
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Fix: Refresh Windows title bar after theme changes
**Description**
On Windows, changing the window theme updates egui immediately, but the
native title bar may keep its previous colors until the window
activation state changes.
This sends WM_NCACTIVATE after applying ViewportCommand::SetTheme,
forcing Windows to refresh the non-client title bar state without
changing the real focus.
* Related #8299
---------
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
- related #8282
- part of https://github.com/emilk/egui/issues/8142
A desktop entry with `StartupNotify=true` hands the launched process an
activation token through `XDG_ACTIVATION_TOKEN` (Wayland) or
`DESKTOP_STARTUP_ID` (X11). winit can apply one, but only at window
creation, via `WindowAttributesExtStartupNotify::with_activation_token`.
eframe never reads it, so the token our launcher went to the trouble of
issuing is thrown away.
winit's own docs are blunt about the consequence:
> The `ActivationToken` is essential to ensure that your newly created
window will obtain the focus, otherwise the user could be required to
click on the window.
That is what I ran into: under Mutter the window opens unfocused and
cannot recover, since `ViewportCommand::Focus` is precisely the request
focus-stealing prevention blocks. On a kiosk-style setup the cost goes
past a missing title-bar highlight — a compositor only grants a pointer
constraint to a focused surface, so `CursorGrab` silently does nothing
too.
This reads the variable when building the window attributes and passes
it to winit. The environment is cleared afterwards through winit's
`reset_activation_token_env()`, per the startup-notification spec: a
token is single-use, and leaving it around would have every later
viewport, and every child process, replay it.
Linux only, behind the existing `wayland`/`x11` features; a no-op when
the variables are absent.
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
The function to remove all entries of a type from IdTypeMap was
confusingly documented as "Note all state of the given type".
As far as I know, (not a native speaker), "noting" shares no meaning
with "removing", so I changed the doc to simply state what the function
does.
* Follows #8665
* Follows #8662
Content can now be pulled past the edge of a `ScrollArea` with
increasing resistance, and springs back when released, like iOS/macOS. A
flick that coasts into the edge bounces too.
**Input paths**
* **Drag-to-scroll** (touch): rubber-bands on drag, bounces on kinetic
coast.
* **Trackpad, fingers down**: rubber-bands mid-gesture, holds while
fingers rest, springs back on lift.
* **Trackpad, OS momentum phase** (macOS): bounces once off the edge,
then the rest of the momentum is ignored. Momentum arriving while
already past the edge is ignored, so it doesn't overshoot.
* **Mouse wheel / web** (no phases): still hard-clamps, like macOS.
* Scroll bars and `scroll_to_*` unchanged.
**Scroll chaining** is preserved: an inner scroll area already at its
edge when a trackpad gesture starts passes the delta to an enclosing
scroll area. The outermost area rubber-bands at its edge.
**Structure**: `scroll_physics.rs` holds the maths (iOS resistance
curve, exact critically damped spring, exact kinetic decay) and the
per-axis rules (`drag`, `step`, `wheel`) as a 1D stateless
`AxisPhysics`, with unit tests. `scroll_area.rs` keeps only the glue:
build the per-axis physics, call one method per input path, remember
which axes to leave unclamped this frame.
**API**
* `State::offset` is now private, since it may be outside the valid
range while rubber-banding. Read it via `State::clamped_offset()` (what
the old field used to be) or `State::unclamped_offset()` (where the
content is drawn), plus `State::overscroll()`. A deprecated
`State::offset()` returns the clamped one. `State::velocity()` is now in
offset space (positive = scrolling down/right).
* `KineticScrollStyle::rubber_band: bool` to turn it off. Slope (0.55)
and spring time (0.1 s) are constants.
**Tests**: 8 unit tests on the physics and rules (resistance curve,
spring, coast distance, frame-rate independence, chaining, momentum
bounce-once and no-overshoot), plus one kittest test wiring a touch drag
through `ScrollArea`.
* [x] I have followed the instructions in the PR template
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Also make some minor code changes because some structs have been renamed
in `accesskit` and `accesskit_consumer`.
As of today, this requires patching kittest, which has a commit bumping
its version of accesskit_consumer that isn't in a release yet.
I don't mind holding off on landing this for a little bit to see whether
they'll release a new version soon, if you prefer.
* (No issue, since this seems pretty small, but happy to file one if you
like)
* [x] I have followed the instructions in the PR template
---------
Signed-off-by: Alice Boxhall <alice@igalia.com>
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Lucas Meurer <hi@lucasmerlin.me>
When `debug_on_hover_with_all_modifiers` is enabled, holding down all
modifier keys lets you hover widgets to see where they were created.
Previously this didn't work for tooltips, since moving the pointer
towards a tooltip would close it.
Now, while all modifiers are held:
* An open tooltip stays open
* The tooltip is made interactable, so its contents can be
hovered/inspected
* Tooltips shown `at_pointer` freeze in place instead of following the
pointer
Includes a regression test.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Lets you tell what is driving a scroll: a mouse wheel, fingers on a
trackpad (not a touch screen), or the OS continuing a trackpad swipe
with momentum.
```rust
pub enum MouseWheelSource {
Unknown,
Wheel,
Trackpad,
Momentum,
}
```
* `Event::MouseWheel` gains `source: MouseWheelSource`. Integrations set
it to `Unknown` if they don't know.
* `InputState::scroll_source() -> Option<MouseWheelSource>`: what is
driving the current scrolling, `Some` while `is_scrolling()`. For a
trackpad that covers the whole gesture (`TouchPhase::Start`…`End`); for
a mouse wheel, until the smoothing of the last notch is done. Touch
screens scroll by dragging with the pointer, not with wheel events, so
`None` there.
Use cases: a `ScrollArea` can rubber-band and hold while fingers rest on
the trackpad, but bounce during momentum (#8663, built on this). A
slider or plot can ignore `Momentum` so a flick doesn't keep changing a
value after the fingers lift.
**Where the source is known**
* macOS (eframe): `Wheel`, `Trackpad` or `Momentum`. winit folds the
macOS momentum phase into the regular `TouchPhase`, so egui-winit reads
`NSEvent::momentumPhase` itself through a local event monitor
(`macos_scroll_momentum.rs`, owned by `State`, removed on drop). Precise
deltas are `Trackpad`, line deltas `Wheel`. Goes away once we are on a
winit with rust-windowing/winit#4732; marked with TODOs.
* winit `PanGesture`: `Trackpad`.
* Everywhere else: `Unknown`. Web `WheelEvent`s carry no phase or source
at all.
**Also**: the 150 ms scroll-action timeout from #8636 is tuned for
flowing events. Fingers resting on a trackpad produce none, so a known
`Trackpad` gesture now survives a 1 s gap before being considered over.
The enum mirrors the one proposed for winit.
* [x] I have followed the instructions in the PR template
🤖 Generated with [Claude Code](https://claude.com/claude-code)
* Closes <https://github.com/emilk/egui/issues/8325>
* Closes <https://github.com/emilk/egui/issues/8443>
* [x] I have followed the instructions in the PR template
winit on Wayland sends `TouchPhase::Start` for some mouse wheels, but
never `TouchPhase::End` (winit's own comment in its Wayland pointer
handler: "the `Ended` is not guaranteed to be sent for mouse wheels").
Since #7678, `WheelState` then stays `InTouch` for good, and in
`InTouch` the modifiers are only ever added to. So after a single
ctrl+scroll, every later scroll is a zoom, which is what #8325 bisected
to 1b77d7047. `is_scrolling()` also stays `true`, and with
`show_tooltips_only_when_still` that keeps tooltips from showing.
This ends an `InTouch` scroll action after 150 ms without scroll events,
the same timeout `Smoothing` already uses. The check runs in
`after_events`, and also when the next wheel event arrives, because an
idle app may not run a pass after the timeout has passed. While events
keep coming, the modifiers stay latched as #7678 intended.
Tests, in `wheel_state.rs`:
* `modifiers_should_not_stick_when_touch_phase_end_never_arrives`:
`Start`+`Move` with ctrl, then 1 s later a `Move` without ctrl. Before
the fix it zoomed (`left: 0.9753099`, `right: 1.0`).
* `scroll_action_should_end_when_touch_phase_end_never_arrives`:
`is_scrolling()` is `false` after a second without scroll events. Before
the fix it stayed `true`.
* `modifiers_should_stick_until_touch_phase_end`: letting go of shift
mid-scroll still scrolls horizontally until `End` (the #7678 behavior).
Passes before and after.
`cargo test -p egui --all-features` passes (75 unit tests, 186
doc-tests), and so do `cargo fmt`, `./scripts/lint.py`, `cargo clippy -p
egui --all-features --all-targets -- -D warnings` and `cargo doc -p egui
--document-private-items`. The whole-workspace `cargo test
--all-features` on macOS (with the snapshot tests) passes too. I don't
have a niri or COSMIC setup, so the tests replay winit's event sequence
rather than a real wheel.
Kinetic (momentum) scrolling after a drag used a constant deceleration
(Coulomb friction), so coast distance was proportional to velocity².
Fast flicks flew way too far, slow flicks died instantly.
This switches to exponential velocity decay like `UIScrollView` on
iOS/macOS:
```
v(t) = v₀ · exp(-t / decay_time)
```
Coast distance is `v₀ · decay_time`, i.e. linear in release velocity.
Default `decay_time = 0.5 s`, matching
`UIScrollView.DecelerationRate.normal` (0.998/ms). Integration is exact
per frame, so the result is frame-rate independent.
| release velocity | before | after |
|---|---|---|
| 300 pt/s | 45 pt | 150 pt |
| 1000 pt/s | 500 pt | 500 pt |
| 2000 pt/s | 2000 pt | 1000 pt |
| 4000 pt/s | 8000 pt | 2000 pt |
The constants are exposed in the new `KineticScrollStyle` at
`Style::spacing.scroll.kinetic` (`decay_time`, `stop_distance`), with a
UI in the style settings. `decay_time = 0.0` disables kinetic scrolling.
Only affects drag-to-scroll (touch / mouse drag). Trackpad momentum on
macOS comes from the OS and is unaffected.
* [x] I have followed the instructions in the PR template
🤖 Generated with [Claude Code](https://claude.com/claude-code)
With wasm threads, `DroppedFileHandle` wasn't `Send + Sync`, so neither
was `Context`, which holds the dropped files.
That broke `egui_extras`'s `http` loader and any code moving a `Context`
to another thread, and contradicts the `context_impl_send_sync` test.
`DroppedFileHandle` is `Send + Sync` everywhere again, and eframe wraps
the `web_sys::File` in a `SendWrapper` (new dependency, `send_wrapper`
0.6).
Checked: the command from the issue, the `check_wasm_atomics` CI
command, and the regular wasm32 build of `egui_demo_app`.
This partly reverts the design of #8354, cc @grtlr.
Fixes#8401
`egui_extras`' built-in highlighter (used when the `syntect` feature is
off, e.g. by `egui_commonmark` without `better_syntax_highlighting`) now
highlights `json` code blocks: strings, numbers, and the
`true`/`false`/`null` keywords.
This came up in the Rerun Viewer's agent panel, where JSON code blocks
rendered as plain text.
* [x] I have followed the instructions in the PR template
🤖 This PR was written by Claude, an LLM, on behalf of @emilk.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Broken out of #8617.
* `TextEdit::margin` now makes room for the stroke inside the margin
(like the theme does), so the stroke width changing on hover/focus no
longer causes a layout shift.
* `TextEdit::clip_text(false)` now expands the widget to make all text
visible, as documented, instead of being capped at `desired_width`.
* The default `TextEdit` inner margin is now `spacing.button_padding`,
and the theme gives `TextEdit` the same min height (`interact_size.y`)
as a `Button`, so they always have the exact same height (previously off
by 1px).
Tests added to `test_widget_heights.rs`: text edit included in the
matching-heights test (now run for several `interact_size.y` values),
size stable on hover/focus (with and without custom margin), and
unclipped text edit grows to fit text.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Closes <https://github.com/emilk/egui/issues/7837>
* [x] I have followed the instructions in the PR template
With `update_while_editing(false)`, the value of a `DragValue` is only
updated once editing is done, but `response.changed()` was still `true`
on every keystroke. While the widget is focused, its response is the
inner `TextEdit` response, and a `TextEdit` marks every text edit as a
change.
The fix clears that flag in the text-edit branch. The existing check at
the end of `DragValue::ui` already marks the response as changed when
the value actually changed, so `changed()` now means "the value
changed", in both modes. `Slider` and `RangeSlider` take their value
box's response via `union`, so they get the same fix.
Tests (in `egui_kittest/tests/regression_tests.rs`):
*
`drag_value_should_not_report_changes_while_typing_without_update_while_editing`:
typing `42` reports no change, and pressing Enter reports exactly one
change, with the value `42`. Without the fix, this fails with 2 changes
while typing and the value still at `0`.
*
`drag_value_should_report_changes_while_typing_with_update_while_editing`:
with the default setting, each keystroke still reports a change.
Fallback to `arboard` with `wayland-data-control` if `smithay` does not
find a text MIME type in the clipboard.
---------
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Closes#8558
In debug builds, each `Id`/`IdSalt` stores its `Debug`-formatted source
chain. Using an `Id` as a salt copies its whole chain into the child.
`CollapsingHeader` does `ui.indent(header_id, …)`, where `header_id` is
derived from the parent `Ui` id, so the stored string doubles at every
level of nesting (≈640 kB at depth 11, and it keeps doubling).
The fix caps stored sources at 1024 bytes. It keeps the end, since that
is the most specific part.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Previously it was ignored since menu_style was applied within `Popup`
and the frame was created on the previous, unchanged outer ui.
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Follow-up to https://github.com/emilk/egui/pull/8621
`Ui::is_visible` is `false` for the rest of a pass once anything calls
`request_discard` (see `Context::will_discard`).
#8621 made invisible widgets not interested in focus, so a focused
widget drawn after any `request_discard` call would give up its focus,
and it stays lost because `Memory` persists across passes.
In Rerun this showed up as a focused list item losing focus whenever
some other part of the UI requested a discard.
This removes `w.visible` from `interested_in_focus`.
Invisible widgets are still hidden from accessibility, and their focus
is still not reported to AccessKit (the tree reports the root as focused
instead).
Added the regression test `keep_focus_in_discarded_pass`.
_This PR was written by Claude, an LLM, on behalf of @emilk._
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* [x] I have followed the instructions in the PR template
Adds `egui::Aligned`, a container that places its contents at a given
`Align2` within the available space of the parent `Ui`, e.g. in the
bottom-right corner.
Since the size of the contents isn't known up front, it remembers the
size from the previous pass. On the first pass the contents are added
invisibly and a new pass is requested with `request_discard`, so there
is no flicker.
```rust
egui::Aligned::new(egui::Align2::RIGHT_BOTTOM).show(ui, |ui| {
ui.label("Bottom right");
let _ = ui.button("Click me");
});
```
Like a `Panel`, `Aligned` reserves space in the parent `Ui` along its
main axis: if the contents are aligned to the end of that axis (e.g. the
bottom of a vertical `Ui`), widgets added afterwards go in the space
*before* them. So you can put something in the bottom-right corner and
keep adding widgets above it:
```rust
egui::Aligned::new(egui::Align2::RIGHT_BOTTOM).show(ui, |ui| {
let _ = ui.button("Bottom right");
});
ui.label("Placed above the button");
```
Rerun uses this to overlay the legend on a plot.
Extracted from Rerun's `re_ui::egui_ext` (where it is called `Group`).
Naming suggestions welcome.
Written by Claude (LLM).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>