From 46d6585cf0e921c52c222a93208c92f2ce708874 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Wed, 18 Nov 2026 21:36:08 +0000 Subject: [PATCH] rr-ribbon-w5: red round 2 (lead commit) --- crates/menu/src/keytips.rs | 12 ++++++------ crates/ui-contract/src/runtime/keys/route.rs | 7 ++++--- crates/ui-contract/src/testing/suite/shape.rs | 5 ----- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/crates/menu/src/keytips.rs b/crates/menu/src/keytips.rs index a78308c05e..358b0b9292 100644 --- a/crates/menu/src/keytips.rs +++ b/crates/menu/src/keytips.rs @@ -28,9 +28,9 @@ pub struct KeytipsStyle { /// The room around a badge's letters; its top is also a badge's inset from its control's corner. #[style(metrics)] metrics: Metrics, - /// A badge: the accent fill, with the ring that parts it from the control under it. - #[style(surface)] - surface: SurfaceLook, + /// A badge: the accent fill, with the ring that parts it from the control under it. Not the component's root + /// surface, which would fill the whole area the keytips show over. + badge: SurfaceLook, /// The badge letters. #[style(text)] text: TextLook, @@ -374,12 +374,12 @@ impl Component for Keytips<'_> { fn style(cx: &StyleCx<'_>, _: KeytipsStyleKey) -> KeytipsStyle { let colors = &cx.tokens.color; let pad = cx.tokens.space.pad.chip; - let surface = SurfaceLook::new(Stateful::new(cx.color(colors.accent.solid))) + let badge = SurfaceLook::new(Stateful::new(cx.color(colors.accent.solid))) .radius(UiTokens::corner(cx.tokens.shape.radius.sm)) .border(Stateful::new(cx.color(colors.overlay.halo)), cx.tokens.stroke.thin); KeytipsStyle { metrics: Metrics::new().padding(Insets::new(pad, pad, pad, pad)), - surface, + badge, text: TextLook::new(TypeRole::Caption, Stateful::new(cx.color(colors.text.on_accent))), } } @@ -462,7 +462,7 @@ impl Component for Keytips<'_> { let run = TextRun::new(badge.clone()).role(style.text.role).color(color); let layout = draw.layout(&run, f32::INFINITY); let rect = badge_rect(*control, layout.size(), style.metrics.padding, rtl); - draw.surface_look(rect, &style.surface, &at_rest); + draw.surface_look(rect, &style.badge, &at_rest); draw.galley(rect.center() - layout.size() / 2.0, &layout); } } diff --git a/crates/ui-contract/src/runtime/keys/route.rs b/crates/ui-contract/src/runtime/keys/route.rs index 2c435f8771..9cef2e2119 100644 --- a/crates/ui-contract/src/runtime/keys/route.rs +++ b/crates/ui-contract/src/runtime/keys/route.rs @@ -97,7 +97,8 @@ pub(crate) fn begin(ctx: &Context, press_captured: bool) -> EscapeRouting { } let focused = target.as_ref().map(|rec| rec.stop.id); let root = target.as_ref().filter(|rec| rec.stop.root != rec.stop.id && !rec.stop.text).map(|rec| rec.stop.root); - let menu = focus::record(ctx, crate::runtime::egui::pass::current_viewport(ctx)).menu; + let record = focus::record(ctx, crate::runtime::egui::pass::current_viewport(ctx)); + let (menu, menu_bar) = (record.menu, record.menu_bar); // The web sends a chord's key press and its clipboard event: the command reaches the component once. let mut clips = batch.clips.clone(); clips.dedup(); @@ -129,10 +130,10 @@ pub(crate) fn begin(ctx: &Context, press_captured: bool) -> EscapeRouting { Some(intent) => push(&mut routed, driven.map(|driven| driven.list), intent, false), None => { // A capture's owner, else the claim's: the focused component's own, then its arena root's, then its - // menu level's. + // menu level's, then the registered menu bar's (keytips hold their letters with no focus). let held = |owner: Option| held_claims.iter().find(|(id, held)| Some(*id) == owner && held == chord).map(|(id, _)| *id); let owner = captures.iter().find(|(_, held)| held == chord).map(|(owner, _)| *owner); - claimed.extend(owner.or_else(|| held(focused)).or_else(|| held(root)).or_else(|| held(menu)).or(focused).map(|id| (id, *chord))); + claimed.extend(owner.or_else(|| held(focused)).or_else(|| held(root)).or_else(|| held(menu)).or_else(|| held(menu_bar)).or(focused).map(|id| (id, *chord))); } } } diff --git a/crates/ui-contract/src/testing/suite/shape.rs b/crates/ui-contract/src/testing/suite/shape.rs index ca3658178e..a2d80820b3 100644 --- a/crates/ui-contract/src/testing/suite/shape.rs +++ b/crates/ui-contract/src/testing/suite/shape.rs @@ -43,11 +43,6 @@ fn small_rooms_paint_inside_the_shown_rect(subject: &Subject) -> Result<(), Stri if let Some((outside, _)) = shapes.into_iter().find(|(bounds, overshoot)| !areas.iter().any(|area| area.expand(ROUNDING + **overshoot).contains_rect(**bounds))) { - eprintln!( - "DIAG suite::craft_menu::keytips::Keytips<'_>::reads: story {} all shapes {:?} areas {areas:?}", - story.name, - fixture.shape_bounds() - ); return Err(format!("{}: in a room of {room:?} a shape paints at {outside:?}, outside {:?}", story.name, fixture.shown())); } let tree = fixture.tree();