From 011ee7857a09c596501f1a4db09d8dc33081c2d0 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Wed, 25 Nov 2026 12:00:05 +0000 Subject: [PATCH] next: design-lint findings and the components index - ui-panels iconic trial: the two literal 0.5 tolerances are relations (`first` above the gripped first icon; the rule `near` the middle of the room). - ui-shell Column start page: the bottom page margin is `add_space` of the token, not `allocate_space`. - ui-widgets Tile: `PAPER` (a blank page, data) and `Tile::page`'s width and height (a proportion in any one unit) are marked and listed as exceptions. - docs/components-index.md regenerated (Link's `LinkLook::Plain`). Co-Authored-By: Claude Opus 5.5 --- crates/ui-panels/src/docking/iconic/trials.rs | 4 ++-- crates/ui-shell/src/shell/start.rs | 2 +- crates/ui-widgets/src/tile_grid/tile.rs | 3 ++- .../exceptions/craft-ui-widgets/tile_grid.toml | 16 ++++++++++++++++ docs/components-index.md | 2 +- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/crates/ui-panels/src/docking/iconic/trials.rs b/crates/ui-panels/src/docking/iconic/trials.rs index aaa36e197..3e1ce73cd 100644 --- a/crates/ui-panels/src/docking/iconic/trials.rs +++ b/crates/ui-panels/src/docking/iconic/trials.rs @@ -717,7 +717,7 @@ fn icon_groups_apart_by_a_rule_show_one_level_rule_between_them() { let band = |group: u64| fixture.part_rect(id, GRIP.at(group)).expect("each group keeps a grip band"); let (first, last, next) = (cell(0), cell(1), cell(2)); let (top, lower) = (band(0), band(1)); - assert!(first.top() < gripped_first.top() - 0.5, "the first icon {first:?} stands higher than under a grip strip {gripped_first:?}"); + assert!(first.top() < gripped_first.top(), "the first icon {first:?} stands higher than under a grip strip {gripped_first:?}"); for (group, band) in [top, lower].into_iter().enumerate() { assert!(grip_ticks(&shapes, band).is_none(), "group {group}: the band shows no marks"); } @@ -733,7 +733,7 @@ fn icon_groups_apart_by_a_rule_show_one_level_rule_between_them() { let between: Vec<_> = level.iter().filter(|(a, _, _)| a.y > last.bottom() && a.y < next.top()).collect(); let [(a, b, ink)] = between.as_slice() else { panic!("one rule between the groups: {level:?}") }; let middle = (last.bottom() + next.top()) / 2.0; - assert!((a.y - middle).abs() <= 0.5, "the rule {a:?} lies in the middle of the room from {last:?} to {next:?}"); + assert!(near(a.y, middle), "the rule {a:?} lies in the middle of the room from {last:?} to {next:?}"); let (left, right) = (a.x.min(b.x), a.x.max(b.x)); let span = right - left; assert!(left > 0.0 && right < RAIL && span > RAIL - span, "the rule reaches across the column, short of its sides: {a:?} to {b:?}"); diff --git a/crates/ui-shell/src/shell/start.rs b/crates/ui-shell/src/shell/start.rs index 4f9e776ba..4f0e53ff2 100644 --- a/crates/ui-shell/src/shell/start.rs +++ b/crates/ui-shell/src/shell/start.rs @@ -878,7 +878,7 @@ impl StartScreen<'_> { column_links(&page, ui, links_title.as_ref(), links); }); }); - ui.allocate_space(vec2(0.0, margin)); + ui.add_space(env.tokens.size.page.margin); }); return StartOutput { response: shown.output, actions: actions.into_inner() }; } diff --git a/crates/ui-widgets/src/tile_grid/tile.rs b/crates/ui-widgets/src/tile_grid/tile.rs index 202fd4b8a..1cadb97c0 100644 --- a/crates/ui-widgets/src/tile_grid/tile.rs +++ b/crates/ui-widgets/src/tile_grid/tile.rs @@ -305,7 +305,7 @@ pub struct TileStyle { } /// The paper of a page picture (`Tile::page`): a document's blank page, which is data, not a theme surface. -const PAPER: DataColor = DataColor::new(Color32::WHITE); +const PAPER: DataColor = DataColor::new(Color32::WHITE); // design: allow[raw-colour/const](a document's blank page is data, not a theme surface) /// A `width` by `height` page centred in `picture` on the knob's shadow, the theme's short hard shadow of a part lifted /// just off the surface under it. The page's longer side spans the largest square the picture holds with the shadow, @@ -554,6 +554,7 @@ impl<'a> Tile<'a> { /// that stands for a document size shows it this way (New Document's presets in `PresetCardLook::Page`, a start /// page's page templates). #[must_use] + // design: allow[props/point-size](only the page's shape counts: `width` and `height` are a proportion in any one unit) pub fn page(self, width: f64, height: f64) -> Self { self.flat_thumbnail().thumb(ThumbAspect::new(2, 1), move |cx: &ContentPainterCx<'_>, picture: Rect| paint_page(cx, picture, width, height)) } diff --git a/design/exceptions/craft-ui-widgets/tile_grid.toml b/design/exceptions/craft-ui-widgets/tile_grid.toml index 88f56e78b..6d44c5ef4 100644 --- a/design/exceptions/craft-ui-widgets/tile_grid.toml +++ b/design/exceptions/craft-ui-widgets/tile_grid.toml @@ -1 +1,17 @@ config_version = 1 + +[[exception]] +name = "tile-page-paper-white" +kind = "marker" +rule = "raw-colour/const" +path = "crates/ui-widgets/src/tile_grid/tile.rs" +reason = "A page picture's paper is a document's blank page, which is data (`DataColor`), not a theme surface." +count = 1 + +[[exception]] +name = "tile-page-proportion" +kind = "marker" +rule = "props/point-size" +path = "crates/ui-widgets/src/tile_grid/tile.rs" +reason = "`Tile::page` takes a page's width and height in any one unit: only their proportion counts, never a size in points." +count = 1 diff --git a/docs/components-index.md b/docs/components-index.md index a0bbf32a2..a5fef53b3 100644 --- a/docs/components-index.md +++ b/docs/components-index.md @@ -64,7 +64,7 @@ Grouped by gallery level, then shape, then name. | `Disclosure` | Leaf | `craft_ui_widgets::controls::disclosure` | A button bound to an open state, with the expanded state | | `IconButton` | Leaf | `craft_ui_widgets::buttons::icon_button` | A square button showing only an icon | | `Kbd` | Leaf | `craft_ui_widgets::display::kbd` | A key chord | -| `Link` | Leaf | `craft_ui_widgets::buttons::link` | A link: drawn in the accent colour in a type role (body by default) and underlined, so colour is not its only cue | +| `Link` | Leaf | `craft_ui_widgets::buttons::link` | A link: drawn in the accent colour in a type role (body by default) and underlined, so colour is not its only cue (`LinkLook::Plain` drops the underline of a link standing alone) | | `LinkedFields` | Leaf | `craft_ui_widgets::text::linked` | `N` number fields joined by a link toggle | | `NumberField` | Leaf | `craft_ui_widgets::text::number` | A number field: a text part over [`NumberCodec`]; empty text is `None` | | `PointPicker` | Leaf | `craft_ui_widgets::value_drag::point_picker` | A point `[x, y]` picked on a well: x grows to the right and y downwards, as image coordinates do, in either reading direction |