emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
20.61k stars 1.49k forks source link

Fix buggy interaction with widgets outside of clip rect #4675

Closed emilk closed 1 week ago

emilk commented 1 week ago

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.