Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix buggy interaction with widgets outside of clip rect #4675

Merged
merged 2 commits into from
Jun 19, 2024

Conversation

emilk
Copy link
Owner

@emilk emilk commented Jun 19, 2024

This fixes a bug which sometimes would make it possible to interact with widgets that were outside the parent clip_rect.

Interaction with a widget is done with the interact_rect, which is the intersection of the widget rect and the parent clip rect. If these rectangles are disjoint (the widget is outside the parent clip rect), this results in a negative rectangle (a rectangle with a negative width and/or height). The distance tests for negative rectangles were broken, causing the bug.

Breaking changes

Rect::distance_to_pos, distance_sq_to_pos, signed_distance_to_pos now all return f32::INFINITY if the rectangle is negative.

@emilk emilk added bug Something is broken egui emath Relates to the emath crate labels Jun 19, 2024
@emilk emilk changed the title Fix bug causing interaction with widgets outside of clip rect Fix buggy interaction with widgets outside of clip rect Jun 19, 2024
@emilk emilk merged commit 598dd53 into master Jun 19, 2024
38 checks passed
@emilk emilk deleted the emilk/fix-interaction-bug branch June 19, 2024 08:21
valadaptive pushed a commit to valadaptive/egui that referenced this pull request Jun 20, 2024
This fixes a bug which sometimes would make it possible to interact with
widgets that were outside the parent clip_rect.

Interaction with a widget is done with the `interact_rect`, which is the
intersection of the widget rect and the parent clip rect. If these
rectangles are disjoint (the widget is outside the parent clip rect),
this results in a _negative rectangle_ (a rectangle with a negative
width and/or height). The distance tests for negative rectangles were
broken, causing the bug.

* This is part of solving emilk#4475
* It is also likely this would have solved
emilk#4349 (which now has another fix for
it)


### Breaking changes
`Rect::distance_to_pos`, `distance_sq_to_pos`, `signed_distance_to_pos`
now all return `f32::INFINITY` if the rectangle is negative.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken egui emath Relates to the emath crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant