Skip to content

Add DebugOptions::warn_if_rect_changes_id#7984

Merged
emilk merged 9 commits intomainfrom
emilk/warn-on-id-change
Mar 18, 2026
Merged

Add DebugOptions::warn_if_rect_changes_id#7984
emilk merged 9 commits intomainfrom
emilk/warn-on-id-change

Conversation

@emilk
Copy link
Copy Markdown
Owner

@emilk emilk commented Mar 18, 2026

If turned on (default in debug builds), if the exact same Rect exist in two subsequent frames but with different Ids, a warning is logged an a red rect is flashed on the screen.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 18, 2026

Preview available at https://egui-pr-preview.github.io/pr/7984-emilkwarn-on-id-change
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

Copy link
Copy Markdown
Collaborator

@aedm aedm left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this!

// and the label changes on hover:
let is_hovered = ui.rect_contains_pointer(button_rect);
let label = if is_hovered { "Hovering!" } else { "Click me" };
let id = ui.id().with(label);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sneaky :)

@emilk emilk added the egui label Mar 18, 2026
@emilk emilk merged commit 265cf7e into main Mar 18, 2026
46 checks passed
@emilk emilk deleted the emilk/warn-on-id-change branch March 18, 2026 14:08
emilk added a commit that referenced this pull request Mar 21, 2026
* Found thanks to #7984

If you put an animated `Panel` inside a `Ui`, then the automatic ids for
following widgets would differ when the panel was collapsed or open.
Masterchef365 pushed a commit to Masterchef365/egui that referenced this pull request Apr 3, 2026
If turned on (default in debug builds), if the exact same `Rect` exist
in two subsequent frames but with different `Id`s, a warning is logged
an a red rect is flashed on the screen.
Masterchef365 pushed a commit to Masterchef365/egui that referenced this pull request Apr 3, 2026
* Found thanks to emilk#7984

If you put an animated `Panel` inside a `Ui`, then the automatic ids for
following widgets would differ when the panel was collapsed or open.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants