ui-contract: a cover from another component's parts spans each part's grown hit area

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
David MannandClaude Opus 5.5 committed 2026-11-29 17:55:45 +01:00
1 parent cd1ab777be
commit 6ae6d03cf0
1 file changed
+8 -3
+8 -3
View File
@@ -918,7 +918,7 @@ pub(crate) fn over_part(ctx: &Context, viewport: ViewportId, root: Id, part: Par
OverPart { widgets, above }
}
/// The bounds, in screen points and clipped to where each shows, of the press-taking shapes of the root whose egui widgets include `widget` in the
/// The hit areas, in screen points and clipped to where each shows, of the press-taking shapes of the root whose egui widgets include `widget` in the
/// running pass: where a press over that widget goes to the root's parts (8.3). `None` when no root recorded it, so it
/// is a plain egui widget that takes a press anywhere in its rect.
pub(crate) fn press_shapes_of_widget(ctx: &Context, viewport: ViewportId, widget: Id) -> Option<Vec<egui::Rect>> {
@@ -926,13 +926,18 @@ pub(crate) fn press_shapes_of_widget(ctx: &Context, viewport: ViewportId, widget
let mut found = None::<Vec<(Layer, Vec<egui::Rect>)>>;
for (layer, roots) in &record.this {
for entry in roots.values().filter(|entry| entry.widgets.contains(&widget)) {
// A press reaches a shape only where it shows through its clip (`find_under`).
// A press reaches a shape across its hit area, grown to its least size across (`Shape::hits`), and only
// where it shows through its clip (`find_under`).
let bounds = entry
.shapes
.iter()
.zip(&entry.placed)
.filter(|(shape, _)| shape.sense.takes_press())
.map(|(shape, placed)| shape.shape.bounds().intersect(placed.clip))
.map(|(shape, placed)| {
let bounds = shape.shape.bounds();
let grow = (egui::Vec2::splat(shape.min_across) - bounds.size()).max(egui::Vec2::ZERO) / 2.0;
bounds.expand2(grow).intersect(placed.clip)
})
.filter(|rect| rect.is_positive())
.collect();
found.get_or_insert_with(Vec::new).push((*layer, bounds));