Ribbon look row height reaches check boxes: View Show rows at the 22-point pitch

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FypgCZhHKRuRB5wZUiw6BE
This commit is contained in:
Martin Ball
2026-11-20 03:04:24 +00:00
co-authored by Claude Opus 5.5
parent ace9547545
commit ed5b2b06b5
3 changed files with 11 additions and 9 deletions
+2 -8
View File
@@ -283,7 +283,7 @@ pub(super) fn metrics(cx: &StyleCx<'_>, parts: &VariantParts) -> Metrics {
// (`ControlPlace::Ribbon`): its sides take the control's padding, as a ribbon's controls sit close.
let side = if super::flat_in_ribbon(cx) { control.pad_x } else { control.pad_x.max(round + control.gap) };
// A ribbon look's row height (`RibbonLook::row`) stands in for the control's.
Metrics::new().padding(Insets::horizontal(side)).min_size(Vec2::new(0.0, row_height(cx, control.height))).gap(control.gap)
Metrics::new().padding(Insets::horizontal(side)).min_size(Vec2::new(0.0, super::row_height(cx, control.height))).gap(control.gap)
}
/// The metrics of a stacked face: `metrics`, with the control's gap above and below the stack, so its height is the
@@ -336,12 +336,6 @@ pub(super) fn on_surface(cx: &StyleCx<'_>, off: &VariantParts, on: &VariantParts
look
}
/// The height of a non-stacked button in `cx`: a ribbon look's row height (`RibbonLook::row`), else `height`.
pub(super) fn row_height(cx: &StyleCx<'_>, height: f32) -> f32 {
let look = cx.env::<RibbonLook>();
if look.row > 0 && cx.env::<ControlPlace>() == ControlPlace::Ribbon { f32::from(look.row) } else { height }
}
/// The look of a button that shows only its icon: an icon button, or a toggle button that is `icon_only`.
pub(super) struct IconFace {
pub surface: SurfaceLook,
@@ -369,7 +363,7 @@ pub(super) fn icon_face(cx: &StyleCx<'_>) -> IconFace {
}
IconFace {
surface: on_surface(cx, &off, &on).radius(UiTokens::corner(cx.tokens.shape.radius.control)),
metrics: Metrics::new().min_size(Vec2::splat(row_height(cx, cx.control().height))),
metrics: Metrics::new().min_size(Vec2::splat(super::row_height(cx, cx.control().height))),
glyph: IconLook::new(side, ink.on(on.text.off)),
}
}
+7
View File
@@ -121,6 +121,13 @@ impl RibbonLook {
}
}
/// The height of a one-line control in `cx` (a non-stacked button, a check box): a ribbon look's row height
/// (`RibbonLook::row`) in a ribbon, else `height`.
pub(crate) fn row_height(cx: &crate::style::StyleCx<'_>, height: f32) -> f32 {
let look = cx.env::<RibbonLook>();
if look.row > 0 && cx.env::<ControlPlace>() == ControlPlace::Ribbon { f32::from(look.row) } else { height }
}
/// The side of a non-stacked button's icon or glyph in `cx`: the ribbon's small side where one is set, else `side`.
pub(crate) fn small_icon(cx: &crate::style::StyleCx<'_>, side: f32) -> f32 {
let small = cx.env::<RibbonLook>().small;
+2 -1
View File
@@ -49,7 +49,8 @@ impl Component for Checkbox<'_> {
fn style(cx: &StyleCx<'_>, _: CheckboxStyleKey) -> CheckboxStyle {
let control = cx.control();
CheckboxStyle {
metrics: Metrics::new().min_size(Vec2::new(0.0, control.height)),
// In a ribbon, the look's row height (`RibbonLook::row`), so check boxes stand at its buttons' pitch.
metrics: Metrics::new().min_size(Vec2::new(0.0, crate::buttons::row_height(cx, control.height))),
focus: cx.focus_look(),
well: super::indicator(cx, cx.surface(SurfaceKind::Well).radius),
mark: super::mark(cx),