1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-28 07:23:13 -04:00
Files
egui/crates/egui_extras
Alexander Schütz 1c9f74b8bd Add raw key methods to TypeIdMap (#8007)
This PR fundamentally solves the same problem as
https://github.com/emilk/egui/pull/5827 just implemented with a lot less
ambition and api surface on my end. It contains the bare minimum amount
of changes that I need in order to be able to solve my problem.

My Problem:
I am still suffering from the problem that the TypeIdMap blows up over a
very long time when using my application. (The user generally never
turns off the application, it is intended to be just kept running
forever, some users also never restart their computers) My application
generates a lot of content dynamically so it may for some time display
widgets with a certain set of TypeId's + Id's later hiding them. Some of
the elements that were hidden may turn visible again once an external
event occurs, some may forever be discarded.
I do know myself when which sections of the UI have to be purged because
they will never become visible again, so this PR contains the minimum
amount of necessary functions that allow me to implement this
housekeeping logic on my end.

The existing facilities are insufficient to handle this as the type T
which the TypeId and the hash is derived from are sometimes pub(crate)
privates of widget subcrates or even pub(crate) of egui internals
itself, so its impossible to manually remove those from the TypeIdMap
the only build-in method to remove them is to call "clear" on the
TypeIdMap, however that gets rid of everything, even the elements that
are still shown and should still be in the TypeIdMap.

If the changes in this PR are agreeable to you and you want me to write
unit test for the 4 functions that I have added then tell me and I will
write the tests for you.

If you need anything else changed please tell me.

I ran cargo clippy and cargo fmt, but your check.sh does not work on my
computer.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-03-26 08:03:39 +01:00
..
2026-03-24 13:58:21 +01:00
2024-05-13 13:35:15 +02:00

egui_extras

Latest version Documentation unsafe forbidden MIT Apache

This is a crate that adds some features on top top of egui. This crate is for experimental features, and features that require big dependencies that do not belong in egui.

Images

One thing egui_extras is commonly used for is to install image loaders for egui:

egui_extras = { version = "*", features = ["all_loaders"] }
image = { version = "0.25", features = ["jpeg", "png"] } # Add the types you want support for
egui_extras::install_image_loaders(egui_ctx);