From beced07ded4510518f48dcada4592aff38a88a9c Mon Sep 17 00:00:00 2001 From: skylar taylor-barrick Date: Thu, 22 Oct 2026 13:11:11 -0600 Subject: [PATCH] #2083: test that panel menu rows light up under the pointer The rows of the panels' menus did not light up under the pointer as the menu bar's items do, because they were drawn with no frame at all. The test hovers a menu_item_name row and checks that a filled rectangle appears behind it, and that none is there at rest. With frame(false) the hovered row stays unfilled. --- crates/ui-egui/src/widgets.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/crates/ui-egui/src/widgets.rs b/crates/ui-egui/src/widgets.rs index a78e9b259..79e84d746 100644 --- a/crates/ui-egui/src/widgets.rs +++ b/crates/ui-egui/src/widgets.rs @@ -3146,4 +3146,32 @@ pub(crate) mod look_tests { assert!((filled.min.x - rail.min.x).abs() < 1.0, "{brightness:?}: the fill starts at the rail's start"); } } + + // Regression test for #2083: the rows of the panels' menus didn't light up under the pointer, as + // the menu bar's items do. + #[test] + fn a_panel_menu_row_lights_up_under_the_pointer() { + let ctx = themed(Default::default()); + let row_at = std::cell::Cell::new(Rect::NOTHING); + let mut add = |ui: &mut Ui| { + row_at.set( + ui.scope(|ui| { + menu_item_name(ui, "Rename", true, false); + }) + .response + .rect, + ); + }; + // A filled rectangle behind the row's text. + let lit = |shapes: &[egui::Shape], row: Rect| { + shapes.iter().any(|s| matches!(s, egui::Shape::Rect(r) if r.fill != Color32::TRANSPARENT && r.rect.contains(row.center()))) + }; + frame(&ctx, 0.0, vec![], &mut add); + let row = row_at.get(); + let at_rest = frame(&ctx, 0.1, vec![], &mut add); + assert!(!lit(&at_rest, row), "no frame at rest"); + frame(&ctx, 0.2, vec![egui::Event::PointerMoved(row.center())], &mut add); + let hovered = frame(&ctx, 0.3, vec![], &mut add); + assert!(lit(&hovered, row), "the row under the pointer is lit: {row:?}"); + } }