Atom improvements: Atom::id, align, closure, max_size#7958
Open
lucasmerlin wants to merge 5 commits intomainfrom
Open
Atom improvements: Atom::id, align, closure, max_size#7958lucasmerlin wants to merge 5 commits intomainfrom
Atom::id, align, closure, max_size#7958lucasmerlin wants to merge 5 commits intomainfrom
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
crates/egui/src/atomics/atom_kind.rs
Outdated
| /// } | ||
| /// # }); | ||
| /// ``` | ||
| #[deprecated = "Use Atom::custom(id) instead"] |
Owner
There was a problem hiding this comment.
Suggested change
| #[deprecated = "Use Atom::custom(id) instead"] | |
| #[deprecated = "Use Atom::custom(id, $what size do I put here?) instead"] |
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
| Text(Arc<Galley>), | ||
| Image(Image<'a>, Vec2), | ||
| Custom(Id), | ||
| Sized(Vec2), |
crates/egui/src/atomics/atom_kind.rs
Outdated
| TextWrapMode, | ||
| FontSelection, | ||
| ) -> ( | ||
| Vec2, |
Owner
There was a problem hiding this comment.
What is this? Can this return a named struct instead? And maybe group (some) of the params as a struct too?
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.
idfield to Atom/SizedAtom for custom rendering identificationalignfield (Align2) for per-atom alignment within available spaceAtomKind::Closurefor custom sizing logicmax_size/max_width/max_heightto AtomLayoutAtomKind::Customin favor ofAtom::custom(id)/atom_id()SizedAtomKind::CustomwithSizedAtomKind::SizedAtoms::extend_left/extend_rightto takeSelfinstead ofimpl IntoAtomsAtomExt::atom_idandAtomExt::atom_alignbuilder methods