Ribbon: a scrolling row shows whole groups clear of the chevrons; control menus hang over the control

A group that does not lie wholly inside the row's view, short of an edge
chevron's slot on a side the row overflows, is not drawn and takes no
pointer, so the row ends on whole groups and the chevron stands in clear
space. A control's context menu hangs from its middle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Dylan M. TaylorandClaude Opus 5.5 committed 2026-11-29 22:07:45 +00:00
1 parent 693ce7da8f
commit b535e91d90
2 files changed
+14 -2

No files matched your search

+6 -2
View File
@@ -359,7 +359,8 @@ fn show_row<T: Clone + Eq + Hash + Send + Sync + Debug + 'static>(
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.
+8
View File
@@ -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(