Skip to content

Make it more clear how a Ui Id was derived#7988

Open
lucasmerlin wants to merge 2 commits intolucas/experiments/helpful-id-debugfrom
lucas/better-ui-id-bookkeeping
Open

Make it more clear how a Ui Id was derived#7988
lucasmerlin wants to merge 2 commits intolucas/experiments/helpful-id-debugfrom
lucas/better-ui-id-bookkeeping

Conversation

@lucasmerlin
Copy link
Copy Markdown
Collaborator

With this, we can see the full tree of how auto ids are derived:

image

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 20, 2026

Preview available at https://egui-pr-preview.github.io/pr/7988-lucasbetter-ui-id-bookkeeping
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

View snapshot changes at kitdiff

@emilk
Copy link
Copy Markdown
Owner

emilk commented Mar 20, 2026

I'm not a big fan of that UI. It has A LOT of repetition (Id(…), Source: , Parent: ). It also uses a tree view for something that is really a linked list.

I also think showing all the Ids of all the ancestors is a bit overkill, though I can see how hovering them to find them in the UI would be useful.

So I suggest something like this:

Id(C4BF):
6
0
"child"
0
"child"
0
"child"
"ID Test" (root)

where each row is hoverable, and shows the Id of that widget and where it is in the Ui (its Rect)

…actually, turning it upside down would look even better:

"ID Test" (root)
"child"
0
"child"
0
"child"
0
6
= Id(C4BF)


/// Get auto id and advance auto id counter by 1.
#[inline]
pub fn get_auto_id(&mut self) -> Id {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get sounds like it doesn't change anything, which it does

Suggested change
pub fn get_auto_id(&mut self) -> Id {
pub fn allocate_auto_id(&mut self) -> Id {

Copy link
Copy Markdown
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@lucasmerlin
Copy link
Copy Markdown
Collaborator Author

lucasmerlin commented Mar 20, 2026

I'm not a big fan of that UI. It has A LOT of repetition (Id(…), Source: , Parent: ). It also uses a tree view for something that is really a linked list.

But it is indeed a tree. When you create an Id like this: Id::new(Id::new("a")).with(Id::new("b")) the id has two parents (a and b).
I think the ideal way to disaplay these would be a graph view, but unfortunately egui doesn't have one yet.

I guess we could show the source with the debug format instead, since source usually is pretty flat. But if you e.g. pass a widget id as a source via with(response.id), the source tree would be huge.

@emilk emilk added this to the 0.34.0 milestone Mar 24, 2026
@lucasmerlin lucasmerlin modified the milestones: 0.34.0, 0.35.0 Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants