diff --git a/crates/menu/src/ribbon.rs b/crates/menu/src/ribbon.rs index 50132d0f3a..4bcb2c3687 100644 --- a/crates/menu/src/ribbon.rs +++ b/crates/menu/src/ribbon.rs @@ -359,7 +359,8 @@ fn show_row( let row = Row::new().id(owner).scroll(scroll).fill_width().least_height(least + title_line).show(ui, |ui, _| { // The groups start a regular pad in from the row's start edge, as the old ribbon's did. craft_ui::layout::place_in_flow(ui, Vec2::new(start, 0.0)); - let mut row = RibbonRow { ui, base, groups: Vec::new(), title_line, launcher_side, icons, launcher: launcher.clone() }; + let mut row = + RibbonRow { ui, base, groups: Vec::new(), title_line, launcher_side, icons, launcher: launcher.clone(), chevron }; body(&mut row, key); row.groups }); @@ -414,7 +415,8 @@ fn row_request(region: &RegionOutput, recorded: Option<&inspect::Recorded>) -> O .max_by_key(|(element, _)| element.depth) }); match control { - Some((element, rect)) => Some(RibbonMenuRequest { command: element.command.clone(), at: rect.left_bottom() }), + // A control's menu hangs from its middle, over the control. + Some((element, rect)) => Some(RibbonMenuRequest { command: element.command.clone(), at: rect.center() }), None => region.own.map(|rect| RibbonMenuRequest { command: None, at: rect.left_bottom() }), } } @@ -454,6 +456,8 @@ pub struct RibbonRow<'a> { icons: RibbonLook, /// The icon of every group's dialog launcher (`Ribbon::launcher_icon`). launcher: IconId, + /// The width of an edge chevron's slot, which no group shown in a scrolling row reaches into. + chevron: f32, } /// What the ribbon reports for a pass. diff --git a/crates/menu/src/ribbon/group.rs b/crates/menu/src/ribbon/group.rs index 07207d8296..e7782f470d 100644 --- a/crates/menu/src/ribbon/group.rs +++ b/crates/menu/src/ribbon/group.rs @@ -201,7 +201,15 @@ impl RibbonRow<'_> { RibbonFit::Scroll => 1, _ => LEVELS.len(), }; + // A scrolling row shows whole groups only: a group that does not lie wholly inside the view, short of the edge + // chevrons' slots when the row overflows on that side, is not drawn and takes no pointer. + let (body, view, chevron) = (self.ui.max_rect(), self.ui.clip_rect(), self.chevron); + let slots = (if body.min.x < view.min.x - 0.5 { chevron } else { 0.0 }, if body.max.x > view.max.x + 0.5 { chevron } else { 0.0 }); levelled_unit(self.ui, id, levels, |ui, at| { + let unit = ui.max_rect(); + if unit.min.x < view.min.x + slots.0 - 0.5 || unit.max.x > view.max.x - slots.1 + 0.5 { + ui.set_clip_rect(Rect::NOTHING); + } let level = LEVELS.get(at).copied().unwrap_or(GroupLevel::Collapsed); // A ribbon's controls take the ribbon's look: flat buttons, fields as long as the ribbon's. let rect = with_env(