diff --git a/crates/design-lint/src/workspace.rs b/crates/design-lint/src/workspace.rs index 2475ff7b7..5e6a187c9 100644 --- a/crates/design-lint/src/workspace.rs +++ b/crates/design-lint/src/workspace.rs @@ -58,6 +58,7 @@ const CLOSED: &[&str] = &[ "ReorderMove", // built or matched in craft-ui-patterns "RowState", // built or matched in craft-ui-widgets "RuleLook", // built or matched in craft-ui-canvas + "RulerFace", // matched by every ruler (craft-text, craft-pages, craft-ui-canvas): a new face must be drawn by each "ShellRegions", // built or matched in craft-ui-shell "SizeLimits", // built or matched in craft-ui-panels "StoryOutput", // built or matched in craft-ui-widgets diff --git a/crates/pages/src/ui/page_rulers.rs b/crates/pages/src/ui/page_rulers.rs index e19df84a0..ea8be6eb3 100644 --- a/crates/pages/src/ui/page_rulers.rs +++ b/crates/pages/src/ui/page_rulers.rs @@ -17,7 +17,7 @@ use craft_ui::contract::{ Access, Bind, Common, Component, Cx, Focus as _, IdSource, Input, MeasureCx, Name, NoValue, Numeric, Outcome, PaintUi, PartsCx, Pointer as _, Props as _, Remember as _, Role, Show as _, Styled as _, WordSetCx as _, }; -use craft_ui::primitives::{PaintShape, StrokeWidth, TextRun, Tick, TickEdge, TickRank}; +use craft_ui::primitives::{PaintShape, RulerFace, StrokeWidth, TextRun, Tick, TickEdge, TickRank}; use craft_ui::runtime::env::{Env, Label}; use craft_ui::runtime::focus::{ActivateKeys, FocusShape, KeyUse}; use craft_ui::style::{ComponentStyle, FocusLook, StyleColor, StyleCx, TextLook, TypeRole}; @@ -80,6 +80,10 @@ pub struct VerticalRulerStyle { metrics: Metrics, #[style(focus)] focus: FocusLook, + /// The face: the prop's, else the component set's. + face: RulerFace, + /// The strip round the centred face's bar. + strip: StyleColor, /// The text range. fill: StyleColor, /// The margins above and below it. @@ -113,6 +117,9 @@ struct Held(Option<(usize, f32)>); /// shaded as margin and the text range filled, and a drag of a grip is one gesture. /// /// - Ticks and numbers count from the page's top in the unit, through the canvas rulers' tick rule. +/// - The face ([`RulerFace`]) is the prop's, else the component set's: the edge face hangs the ticks from the strip's +/// inner edge with each number below its whole-unit tick; the centred face (Word's) draws a bar inset in the strip +/// with the ticks centred on it and the numbers in place of the whole-unit ticks, over the text range only. /// - A grip drag reports a [`RowDrag`]: Begin, Update per move, Commit on release, Cancel on Escape. It snaps to the /// ruler's step; Alt reports in `mods` that the drag is free of the snap and the position is not snapped. /// - The grips are one Tab stop: Page Down and Page Up pick the next or previous grip, the arrows nudge the focused one @@ -133,13 +140,17 @@ pub struct VerticalRuler<'a> { /// The table row bottoms, points from the page's top, each a grip. #[prop] rows: &'a [f32], + /// The face; unset, the scope's component set picks it ([`RulerFace::of`]). + #[style_key] + #[prop] + face: Option, report: Option, } impl<'a> VerticalRuler<'a> { /// The ruler named `label` along `page`. pub fn new(label: impl Into