Repository navigation
Merge egui main into the fork, and use the text layout API of egui main - #29
Merged
Merged
Conversation
`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>
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 emilk#8354, cc @grtlr. Fixes emilk#8401
…serts (emilk#8649) This ensures they hold on wasm32 too * See emilk#8638 Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
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)
…es (emilk#8636) * Closes <emilk#8325> * Closes <emilk#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 emilk#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 emilk#8325 bisected to 1b77d70. `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 emilk#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 emilk#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.
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 (emilk#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 emilk#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)
…ilk#8639) 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>
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>
…k#8663) * Follows emilk#8665 * Follows emilk#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)
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.
…ion (emilk#8406) - related emilk#8282 - part of emilk#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>
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 emilk#8299 --------- 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>
…ll inside a ```Scene``` container (emilk#7891) Closes <emilk#7650> [ X] I have followed the instructions in the PR template Previously submitted as <emilk#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>
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>
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 emilk#7743 (more details there) * Closes <emilk#7743> * [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 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>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
…passes (emilk#8316) - [x] I have followed the instructions in the PR template Closes emilk#8092. Related to emilk#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>
This patch fixes the issue raised in emilk#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 <emilk#8652> * [x] I have followed the instructions in the PR template --------- Co-authored-by: Lucas Meurer <hi@lucasmerlin.me>
## 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>
…emove dead zone) (emilk#8635) Closes emilk#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.
…ilk#8646) 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
## 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.
…#8668) Supersedes emilk#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)
…lk#7915) 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>
…ilk#7919) 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)
<!-- 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>
<!-- 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! --> emilk#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 <emilk#7346> * [X] I have followed the instructions in the PR template --------- Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* Closes <emilk#8659> * [x] I have followed the instructions in the PR template `is_cjk_break_allowed` keeps closing marks off the start of a row, but it only lists the ASCII and Japanese forms. Chinese writes full-width ones, so wrapped Chinese text could start a row with `,`. This adds the full-width forms (`!%),.:;?]`) and the closing quotes and ellipsis Chinese uses (`” ’ …`), from [Wikipedia's list](https://en.wikipedia.org/wiki/Line_breaking_rules_in_East_Asian_languages#Characters_not_permitted_on_the_start_of_a_line), with a test that wraps a Chinese line at every few-glyph width (it fails without the change). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Native views (with `Placement::Below`) clear a egui rect and show the native view below. This automatically makes the surface transparent (wgpu only) once such view is shown. - part of rerun-io/egui_crates#201
Fixes the `cargo-deny` advisories check, which fails on every target since [RUSTSEC-2026-0592](https://rustsec.org/advisories/RUSTSEC-2026-0592) (stack overflow in `Url::origin()` on nested `blob:` URLs) was published. Only `Cargo.lock` changes: `url` 2.5.8 → 2.5.9, `form_urlencoded` 1.2.2 → 1.2.3. `cargo deny check advisories` passes locally. * [x] I have followed the instructions in the PR template 🤖 Opened by a coding agent (Claude Opus 5.5).
BREAKING CHANGE: jiff is part of the public API of egui_extras so the major version change is breaking. Doing now so it can be included in the next release. <!-- 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! --> * [x] I have followed the instructions in the PR template
…ilk#8849) Characters such as `"`, `:`, `|`, `、`, and `。` have the Unicode script `Common`, so `SystemFontProvider` only searched the generic font families for them, and missed the installed CJK fonts. If no generic family has the character, this now tries the Han fallback fonts too, respecting the system locale. Characters that were already found are unaffected. Before / after on Windows 11 (ja-JP). Left: `main`, right: this PR. <img width="1234" height="289" alt="Image" src="https://github.com/user-attachments/assets/edc871c8-361f-48d9-b924-473fc66817db" /> The new test (ignored by default, since it depends on the installed fonts) passes on Windows, macOS, and Linux (with `fonts-noto-cjk`), with several locales. Android is not verified. * Closes emilk#8842
This fixes `egui-wgpu` not being able to build on wasm when default features are not enabled, as `egui-wgpu` depends on `wgpu` pulling in the dependency `web-sys` on wasm.
…e warning off in `egui_kittest` (emilk#8927) * emilk#8927 (this PR) * emilk#8926 After three frames in a row that call `Context::request_discard`, egui paints a red "egui PERF WARNING" overlay, and keeps it for one frame after the streak ends. In `egui_kittest` that overlay ends up in snapshots. * Adds `DebugOptions::consecutive_multipass_warning_cutoff: Option<usize>` (default `Some(3)`, so no change for apps). `None` turns the warning off. * `egui_kittest::Harness` sets it to `None`. A test can turn it on again with `harness.ctx.all_styles_mut(|style| style.debug.consecutive_multipass_warning_cutoff = Some(3))`. This PR was written and opened by a coding agent (Claude Fable 5.2). * [x] I have followed the instructions in the PR template 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…8693) <!-- 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! --> * Closes <emilk#7777> * [X] I have followed the instructions in the PR template The doc example for `Button::selectable` used `.frame_when_inactive(!selected)`, but the function itself does `.frame_when_inactive(selected)`. This updates the example to match the code.
… it (emilk#8892) Closes emilk#8829 When the zoom factor changes before the first pass, `begin_pass` scaled the 10000x10000 placeholder of the previous input, so the first frame got a 20000x20000 `content_rect`. On the first pass it now scales the `screen_rect` the backend sent. Later zoom changes still scale the previous pass's rect, so the anti-jitter behavior is unchanged. Tested with the repro from the issue on a 2x display (macOS): pass 0 went from 20000x20000 to 1600x1200, the same as the following passes. Two unit tests cover the first pass and a later zoom change.
…end (emilk#8905) `ViewportCommand::RequestUserAttention` is native only, but eframe's web backend logs `Unhandled egui viewport command: RequestUserAttention(…) - not implemented in web backend` as a warning whenever an app sends it. Apps that share code between native and web get this warning on every request, even though there is nothing the developer can fix. This gives the command its own arm in the web backend that logs a specific message at `info` level instead, and updates the docs on `RequestUserAttention` to say that `eframe` does not support it on web. Suggested in the discussion of rerun-io/rerun#12987. * [x] I have followed the instructions in the PR template. I could not get these to pass on my machine (Linux), maybe because of slightly different rendering behaviors, but they are unrelated to this change. -p egui_demo_app --test test_demo_app -p egui_demo_lib --lib -p egui_kittest --test tests -p egui_tests --test regression_tests -p egui_tests --test test_widgets
…ng(false)` (emilk#8924) With `update_while_editing(false)`, pressing Escape while typing in a `DragValue` should discard the text (emilk#4713). Since emilk#8210, `lost_focus` holds for two frames. The Escape frame skipped the stored text but didn't clear it, so the next frame applied it anyway. Now the text is always cleared when focus is lost, and only applied if Escape wasn't pressed. I added a kittest regression test, which fails without the fix. * Small fix; no corresponding issue created * [x] I have followed the instructions in the PR template 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…milk#8925) * [x] I have followed the instructions in the PR template With a context menu open, secondary-clicking another spot on the same widget reopened the menu at the new spot and then closed it in the same frame, so a third click was needed. The opening click is normally ignored by the close-on-click logic, but that guard only checked whether the popup was open last frame, which is true here since it is the same popup. Now a frame where `SetOpenCommand::Bool(true)` (re)opens the popup is treated like a fresh open. Found in an application; there is a regression test in `egui_kittest/tests/popup.rs`.
* emilk#8927 ✅ merged * emilk#8926 (this PR) A frame that calls `Context::request_discard` (a multi-pass frame) may request no repaint, so `Harness::run` could stop on it, before the ui had settled. Together with the "egui PERF WARNING" overlay (now turned off by emilk#8927), this made a snapshot test flaky. `Harness::run`, `try_run`, `run_ok`, and `try_run_realtime` now also wait until the last frame needed a single pass (`num_completed_passes == 1`). A ui that discards every frame still hits `max_steps`. `ExceededMaxStepsError` has a new `multipass` field, and its message says so. No existing snapshot changed, and single-pass uis need the same number of steps as before. This PR was written and opened by a coding agent (Claude Fable 5.2). * [x] I have followed the instructions in the PR template 🤖 Generated with [Claude Code](https://claude.com/claude-code)
* Closes <emilk#8894> * [x] I have followed the instructions in the PR template `dismissed_word` was only cleared when a suggestion was accepted, so after one Escape the popup stayed hidden for that word forever, even after typing something else and coming back, or refocusing the field. It is now cleared as soon as the word changes or the `TextEdit` gains focus, so Escape only hides the popup for the word it was pressed on. I extended `escape_closes_popup_and_keeps_focus` and added `refocusing_reopens_dismissed_popup` in `test_completion.rs`. Both fail on `main` and pass with this change.
…ilk#8885) `Memory::request_focus` interrupted IME composition unconditionally, including when the widget already had focus. `TextEdit` re-requests focus on every pass of a drag, so on Android every drag frame became a real hide + show of the soft keyboard (egui-winit turns an interrupt into `set_ime_allowed(false/true)`, which the winit Android backend maps to `hide_soft_input` / `show_soft_input`). The window resizes each time, so the UI flickers; logcat showed 125 show/hide pairs in one drag. Now the interrupt only fires when focus actually moves. `focused_widget` is still set unconditionally, so focus behaviour (including `focused_via`) is unchanged. Fixing it here rather than in `TextEdit` also covers `DragValue` and the public `Response::request_focus`, which apps often call every frame. Added `crates/egui/tests/ime.rs`: it drags inside a focused `TextEdit` and asserts `PlatformOutput::ime.should_interrupt_composition` stays false. It fails without this change. Tested on a Galaxy A20 (Android 11, Samsung Keyboard, NativeActivity + glow): the keyboard now stays open while dragging and selecting. An alternative would be to fix this in egui-winit instead, by not using the "IME allowed" toggle to interrupt composition on Android, where that toggle controls keyboard *visibility*. Happy to do that version as well or instead.
…#8895) Closes emilk#8803 `texture_to_image` copied the readback rows out of the mapped buffer one byte at a time. That memory can be uncached, and the issue measured 377 ms for a 1000x700 frame on an Intel iGPU, against 14 ms when copying whole rows. This copies each row with `extend_from_slice`. A unit test checks the unpadded bytes match the old per-byte copy. Rendering a 1000x700 harness with the wgpu renderer on macOS gives the same image bytes before and after. I couldn't measure the speedup myself, since Metal's readback memory is cached (about 60 µs either way here).
…milk#8915) Adds `eframe::try_get_value` to distinguish missing storage keys from deserialization failures while preserving the original RON error. The existing `get_value` API and behaviour are preserved. Includes documentation and regression tests, with no new dependencies or breaking changes. OpenAI ChatGPT assisted with implementation, documentation, tests and code review. Formatting, Clippy and test execution are pending. * Closes emilk#8898 * [x] I have followed the instructions in the PR template
Ctrl+A made the browser select the whole app; the next mouse-move then started a native drag of the selection, swallowing the pointer events egui needs for in-app dragging. Make the canvas (and the embedded-view input element) unselectable and cancel any native drag that still tries to start on them. Closes emilk#8876 <!-- 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! --> * [1 ] I have followed the instructions in the PR template Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* [x] I have followed the instructions in the PR template Adds `LayoutSection::wrap_indent`: the rows a paragraph wraps onto start at this x, so the wrapped rows of a list item can line up with the text after its bullet (a hanging indent). The paragraph takes the value of the section that holds its first character. The first row is unaffected (that is what `leading_space` is for). Centered and justified text ignore it. This is what [Membrane's egui fork](https://github.com/membrane-io/egui) uses `LeadingSpace::Indent` for in [`egui_markdown`](https://github.com/membrane-io/egui_markdown). This version keeps `leading_space: f32` and adds a separate field, so a section can have both. Breaking: struct literals of `LayoutSection` need the new field. This PR was written by an LLM (Claude), directed by `emilk`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…8940) * [x] I have followed the instructions in the PR template Adds `TextFormat::background_stroke`, an outline painted inside the edge of a section's background, with or without a fill, and `CodeVisuals::stroke`, which code labels use for it. The default is `Stroke::NONE`, so nothing changes visually. Breaking: `CodeVisuals` is no longer `Eq`, since `Stroke` is not. This lets [`egui_markdown`](https://github.com/membrane-io/egui_markdown) outline inline code without the Membrane egui fork. This PR was written by an LLM (Claude), directed by `emilk`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…ner_radius and bg_stroke
|
Preview is being built... Preview will be available at https://egui-pr-preview.github.io/pr/29-thomas/egui-main-merge View snapshot changes at kitdiff |
…t test, a RichText snapshot
…er target, and remove dead code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR brings the fork from egui 0.36.2 to egui
main(0.37.0). It merges eguimaintwo times and then removes the fork's own text layout API, so that a crate written for eguimaincompiles against the fork.Commits
17eb3263c: merges eguimainat a94068b, which hasLayoutSection::wrap_indent(AddLayoutSection::wrap_indentfor hanging indents emilk/egui#8939).4fe3ef4dc: merges eguimainat 35925b9, which hasCodeVisuals::strokeandTextFormat::background_stroke(AddCodeVisuals::strokeandTextFormat::background_strokeemilk/egui#8940).18c36bdb2: removes the fork's text API that eguimainnow replaces:LeadingSpaceandLayoutJob::push_with_leading_space. A hanging indent now usesLayoutSection::wrap_indent.LayoutJob::push.TextFormat::bg_corner_radiusandTextFormat::bg_stroke. A background now usesbackground_margin,background_corner_radiusandbackground_stroke.TextFormat::expand_bg: Vec2becomesf32again.Glyph::background_rect(), and the two mesh helpers for rounded corners.aa2709e05: makes a text background as tall as the font, not as the line height. Upstream paints the background overGlyph::logical_rect(), which is as tall asTextFormat::line_height. Whenline_heightis taller than the font, as in egui_markdown, the extra height goes under the text. Without a customline_height, nothing changes.LayoutSection::leading_spaceisf32again. Text backgrounds now paint with the code and the rect of upstream. One fork fix stays intext_layout.rs: a wrapped row that starts a section keeps its leading space, and the layout drops a negative leading space.Conflicts
The merge had 48 conflict hunks in 23 files. The resolution keeps each fork feature and takes each upstream change. These are the resolutions that change behavior:
syntax_highlighting.rs: takes upstream'spub enum TokenType, which adds aFunctionvariant. TypeScript is now upstream's JavaScript rules plus the 11 keywords that only the fork had. So TypeScript gets block comments and backtick strings, and more keywords are highlighted.memory/mod.rs: keeps one publicrequest_focus_next_framewith upstream's body. It now interrupts IME when the focus changes.pass_state.rs: keeps the fork'sdebug_rects: Vec, and adds upstream'swidget_id_change_warning_exclusions.scroll_area.rs: takes upstream's wheel logic, and adds the fork's!someone_else_scrolling.Checks
cargo check --workspace --all-targets --exclude custom_3d_glow: OK.custom_3d_glowalready failed onmembrane, because the fork changedCallbackFn.RUSTFLAGS: OK.cargo test -p epaint --features default_fonts: 110 passed.cargo test -p egui --lib: 113 passed.cargo test -p egui_extras --lib: 15 passed.default_fonts, 3 fork tests in epaint fail. They measure the widths of the default font but have nodefault_fontsgate. This is the same onmembrane.The gaze PR in mnode moves gaze to this branch.
Review fixes
e6f0f3518: takes the final version of Fix text background, underline and strikethrough leaving the row whenTextFormat::line_heightis set emilk/egui#8941.Glyph::font_recthas correct docs, one unit test replaces four, and the snapshot test usesRichText.f08d50350:memory::Focus, and documentsAreas::get,get_mutandremove. Upstream now exportsAreasand warns onunnameable_types, so the android, ios and "Run tests" jobs failed on these.Primitive::Clearin egui_glow uses the fork'sself.set_clip_rect, so a clear in a fork render target uses the offset of that target.let _ = copied_text;inapp_runner.rs, which referred to a binding that does not exist.request_focus_next_frame.