Skip to content

Fix buggy interaction with widgets outside of clip rect - #4675

Merged
emilk merged 2 commits into
masterfrom
emilk/fix-interaction-bug
Jun 19, 2024
Merged

emilk merged 2 commits into
masterfrom
emilk/fix-interaction-bug

Conversation

@emilk

@emilk emilk commented Jun 19, 2024

Copy link
Copy Markdown
Owner

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
@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.
hacknus pushed a commit to hacknus/egui that referenced this pull request Oct 30, 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.

1 participant