From 6575942aedd016abc41c98529d49a474cdb05d2e Mon Sep 17 00:00:00 2001 From: aiongg Date: Fri, 20 Nov 2026 14:01:00 +0000 Subject: [PATCH] MemoProps by the derive where it expresses the key; the tool rail trials' rooms are trial rooms ShapePreset derives (a fieldless enum: its variant), UnderVeil and the gallery card's Look derive with their foreign fields keyed by Hash. The rail trials' fixture room is exempt from literal-size as the iconic column trials' are. --- crates/draw/src/geometry/presets.rs | 1 + crates/draw/src/ui/shape_presets.rs | 7 ------- crates/ui-contract/src/contract/steps/paint.rs | 10 ++-------- crates/ui-gallery/src/chrome/card.rs | 13 ++++--------- design-lint.toml | 5 +++++ design/exceptions/craft-ui-panels/rails.toml | 8 ++++++++ 6 files changed, 20 insertions(+), 24 deletions(-) diff --git a/crates/draw/src/geometry/presets.rs b/crates/draw/src/geometry/presets.rs index 06febb2b3..fd6a38483 100644 --- a/crates/draw/src/geometry/presets.rs +++ b/crates/draw/src/geometry/presets.rs @@ -32,6 +32,7 @@ const HEART_POINTS: usize = 32; /// One entry of the shape menu. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "ui", derive(craft_ui::contract::MemoProps))] #[non_exhaustive] pub enum ShapePreset { /// A rectangle. diff --git a/crates/draw/src/ui/shape_presets.rs b/crates/draw/src/ui/shape_presets.rs index d9687fde8..579b431a7 100644 --- a/crates/draw/src/ui/shape_presets.rs +++ b/crates/draw/src/ui/shape_presets.rs @@ -84,13 +84,6 @@ impl ShapePreset { } } -/// A preset glyph keys by its preset: a fieldless enum whose derived `Hash` is its variant. -impl craft_ui::contract::MemoProps for ShapePreset { - fn key(&self, key: &mut craft_ui::contract::MemoKey) { - key.feed_hash(self); - } -} - /// Presets never mirror: each glyph shows the document shape its tool creates, and document geometry does not follow /// the reading direction. impl Glyph for ShapePreset { diff --git a/crates/ui-contract/src/contract/steps/paint.rs b/crates/ui-contract/src/contract/steps/paint.rs index a74d2b58a..9effbc8ec 100644 --- a/crates/ui-contract/src/contract/steps/paint.rs +++ b/crates/ui-contract/src/contract/steps/paint.rs @@ -27,14 +27,8 @@ pub(crate) struct Fade { /// The layer whose open veil the components shown here lie under: set by `PaintUi` for the children a faded /// component shows while its paint runs, which its veil covers. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub(crate) struct UnderVeil(pub Option); - -impl crate::contract::MemoProps for UnderVeil { - fn key(&self, key: &mut crate::contract::MemoKey) { - key.feed_hash(&self.0); - } -} +#[derive(Clone, Copy, Debug, PartialEq, Eq, crate::contract::MemoProps)] +pub(crate) struct UnderVeil(#[memo_props(hash = "an egui layer id is its order and id")] pub Option); impl EnvValue for UnderVeil { fn root() -> Self { diff --git a/crates/ui-gallery/src/chrome/card.rs b/crates/ui-gallery/src/chrome/card.rs index fbc99e022..2eb9fed86 100644 --- a/crates/ui-gallery/src/chrome/card.rs +++ b/crates/ui-gallery/src/chrome/card.rs @@ -45,25 +45,20 @@ pub enum CardCommands { } /// The appearance values a card sets for its story beyond the window's. -#[derive(Clone, Copy, Debug, Default, PartialEq)] +#[derive(Clone, Copy, Debug, Default, PartialEq, MemoProps)] #[non_exhaustive] pub struct Look { /// The mode the story's tokens resolve in. + #[memo_props(hash = "a fieldless enum of the theme")] pub mode: Option, /// The layout direction. + #[memo_props(hash = "a fieldless enum of the i18n crate")] pub direction: Option, /// The control size. + #[memo_props(hash = "a fieldless enum of the theme")] pub size: Option, } -/// The theme's own enums, by their derived `Hash`. -impl MemoProps for Look { - fn key(&self, key: &mut craft_ui::contract::MemoKey) { - let Look { mode, direction, size } = *self; - key.feed_hash(&(mode, direction, size)); - } -} - /// One story a card shows. #[non_exhaustive] pub struct CardStory<'a> { diff --git a/design-lint.toml b/design-lint.toml index f7a665b12..fda8cc3ec 100644 --- a/design-lint.toml +++ b/design-lint.toml @@ -7,3 +7,8 @@ deny-unused = true path = "crates/ui-panels/src/docking/iconic/trials.rs" rules = ["literal-size"] reason = "trial rooms, not looks" + +[[exempt]] +path = "crates/ui-panels/src/rails/tool/trials.rs" +rules = ["literal-size"] +reason = "trial rooms, not looks" diff --git a/design/exceptions/craft-ui-panels/rails.toml b/design/exceptions/craft-ui-panels/rails.toml index 28f5e71f2..29dafe7a8 100644 --- a/design/exceptions/craft-ui-panels/rails.toml +++ b/design/exceptions/craft-ui-panels/rails.toml @@ -7,3 +7,11 @@ rule = "contract/memory" path = "crates/ui-panels/src/rails/tool/stories.rs" reason = "The story gives the rail the width of its chosen columns, as a dock column does." count = 1 + +[[exception]] +name = "tool-rail-trial-rooms" +kind = "exempt" +rule = "literal-size" +path = "crates/ui-panels/src/rails/tool/trials.rs" +reason = "Trial rooms, not looks." +count = 1