egui/crates
mkalte 114460c1de
Change popup memory to be per-viewport (#6753)
Starting with 77244cd4c5 the popup
open-state is cleaned up per memory pass.

This becomes problematic for implementations that share memory between
viewports (i.e. all of them, as far as i understand it), because each
viewport gets a context pass, and thus a memory pass, which cleans out
popup open state.

To illustrate my issue, i have modifed the multiple viewport example to
include a popup menu for the labels:
https://gist.github.com/mkalte666/4ecd6b658003df4c6d532ae2060c7595
(changes not included in this pr).

Then, when i try to use the popups, i get this: 


https://github.com/user-attachments/assets/7d04b872-5396-4823-bf30-824122925528

Immediate viewports just break popup handling in general, while deferred
viewports kinda work, or dont. In this example ill be honest, it kind of
still did, sometimes. In my more complex app with multiple viewports
(where i encountered this first) it also just broke - even when just
showing root and one nother. Probably to do with the order wgpu vs glow
draws the viewports? Im not sure. In any case:

This commit adds `Memory::popup` (now `Memory::popups`) to the
per-viewport state of memory, including viewport aware cleanup, and
adding it to the list of things cleaned if a viewport goes away.

This results in the expected behavior:



https://github.com/user-attachments/assets/fd1f74b7-d3b2-4edc-8dc4-2ad3cfa2160e

I will note that with this, changing focus does not cause a popup to be
closed, which is consistent with current behavior on a single app.

Hope this helps 

~Malte 

<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

* Closes <https://github.com/emilk/egui/issues/THE_RELEVANT_ISSUE>
* [x] I have followed the instructions in the PR template
* [x] ~~I have run check.sh locally~~ CI on the fork, including checks,
went through.
2025-04-22 11:38:17 +02:00
..
ecolor Add assert messages and print bad argument values in asserts (#5216) 2025-03-25 09:20:29 +01:00
eframe Use lychee link checker instead of linkinator (#5868) 2025-04-03 09:26:49 +02:00
egui Change popup memory to be per-viewport (#6753) 2025-04-22 11:38:17 +02:00
egui-wgpu Release 0.31.1 - text_edit and kittest fixes 2025-03-05 08:37:34 +01:00
egui-winit Fix text input on Android (#5759) 2025-03-21 14:35:46 +01:00
egui_demo_app Make text underline and strikethrough pixel perfect crisp (#5857) 2025-03-28 20:37:38 +01:00
egui_demo_lib Update failing snapshot tests (#5894) 2025-04-09 12:11:46 +02:00
egui_extras Support SVG Text Rendering in egui_extras (#5979) 2025-04-14 11:13:17 +02:00
egui_glow Add assert messages and print bad argument values in asserts (#5216) 2025-03-25 09:20:29 +01:00
egui_kittest Add tests for layout and visuals of most egui widgets (#6752) 2025-04-16 18:58:58 +02:00
egui_plot Move `egui_plot` to its own repo (#4828) 2024-07-15 18:45:19 +02:00
egui_web Fix typos (#2866) 2023-04-18 15:52:45 +02:00
emath Optimize editing long text by caching each paragraph (#5411) 2025-04-01 18:55:39 +02:00
epaint Optimize editing long text by caching each paragraph (#5411) 2025-04-01 18:55:39 +02:00
epaint_default_fonts Release 0.31.1 - text_edit and kittest fixes 2025-03-05 08:37:34 +01:00