⚠️ Atom improvements: Atom::id, align, closure, max_size#7958
Merged
Conversation
|
Preview available at https://egui-pr-preview.github.io/pr/7958-lucasatom-improvements View snapshot changes at kitdiff |
e8e2fa4 to
c2e9f55
Compare
Atom::id, align, closure, max_size
Change the signature from `impl IntoAtoms` to `Self` to avoid lifetime issues when working with atoms of different lifetimes. Use `push_left`/`push_right` in a loop as an alternative.
- Add `id` field to Atom/SizedAtom for custom rendering identification - Add `align` field (Align2) for per-atom alignment within available space - Add `AtomExt::atom_id` and `AtomExt::atom_align` builder methods - Deprecate `AtomKind::Custom` in favor of `Atom::custom(id)` + `atom_id()` - Replace `SizedAtomKind::Custom` with `SizedAtomKind::Sized` - Move custom rect tracking from SizedAtomKind to SizedAtom::id - Migrate DragValue to use new `atom.id` field
Add a closure-based atom kind for custom sizing logic. The closure receives available size, wrap mode, and font selection, and returns the intrinsic size and a SizedAtomKind. Also hoists `wrap_mode` resolution out of the `Text` match arm so all variants can use it.
Allows limiting the widget size below the available Ui size. Has no effect in justified layouts to avoid content/frame mismatch.
c2e9f55 to
324e188
Compare
emilk
reviewed
Mar 5, 2026
emilk
reviewed
Mar 5, 2026
crates/egui/src/atomics/atom_kind.rs
Outdated
Comment on lines
75
to
76
| #[deprecated = "Use Atom::custom(id) instead"] | ||
| Custom(Id), |
Owner
There was a problem hiding this comment.
We could also remove this variant and add a deprecated function called fn Custom (sic). Might make the rest of the PR simpler
Collaborator
Author
There was a problem hiding this comment.
That won't work since we can't set the Id that way. I've now removed Custom though, I doubt that saw much direct usage and migration should be simple enough.
Atom::id, align, closure, max_sizeAtom::id, align, closure, max_size
Owner
|
I'm turning this into a draft until my comments above are resolved |
emilk
approved these changes
Mar 10, 2026
Masterchef365
pushed a commit
to Masterchef365/egui
that referenced
this pull request
Apr 3, 2026
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.
Migration guide:
AtomKind::Customhas been removed. You can now set an id to any kind viaAtom::customorAtomExt::atom_id.