From ef60cb99a5ed100aa620100af0f4c9e7aa962701 Mon Sep 17 00:00:00 2001 From: aiongg Date: Fri, 20 Nov 2026 12:56:51 +0000 Subject: [PATCH] craft-theme: LabelColor is plain data and memo props craft-layers no longer marks its LabelColor fields: the type derives PlainData in craft-theme (a tier-0 crate, as craft-behavior is), and the contract crate keys it as it keys the other theme types. --- Cargo.lock | 2 ++ crates/layers/src/ui/filter/mod.rs | 1 - crates/layers/src/ui/tree.rs | 1 - crates/theme/Cargo.toml | 2 ++ crates/theme/src/parts.rs | 2 +- crates/ui-contract/src/contract/memo.rs | 7 +++++++ 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2fe181826..881c49f6c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4152,6 +4152,8 @@ name = "craft-theme" version = "0.1.0" dependencies = [ "bitflags 2.13.2", + "craft-tracked", + "craft-ui-macros", "ecolor", "log", "proptest", diff --git a/crates/layers/src/ui/filter/mod.rs b/crates/layers/src/ui/filter/mod.rs index d37261ae1..083aba700 100644 --- a/crates/layers/src/ui/filter/mod.rs +++ b/crates/layers/src/ui/filter/mod.rs @@ -354,7 +354,6 @@ pub struct LayerFilter { /// Color: the label colour; `None` (no label) at first. Serialized by name (`"none"`, `"red"`, /// … `"gray"`). #[serde(with = "label_name")] - #[memo_props(hash = "a plain enum with a derived Hash")] pub color: Option, /// Smart Object: the kinds toggled on, in the order they were toggled. pub smart: Vec, diff --git a/crates/layers/src/ui/tree.rs b/crates/layers/src/ui/tree.rs index 164295075..d8f10d5cd 100644 --- a/crates/layers/src/ui/tree.rs +++ b/crates/layers/src/ui/tree.rs @@ -127,7 +127,6 @@ pub struct LayerInfo { /// Whether the row draws faint: hidden itself or inside a hidden group (the app decides). pub dimmed: bool, /// The label colour that fills the eye cell; `None` for none. - #[plain_data(assume = "a plain Copy enum of colours")] pub label: Option, /// The layer's locks: any of them shows the lock indicator. pub locks: LayerLocks, diff --git a/crates/theme/Cargo.toml b/crates/theme/Cargo.toml index 4102c7127..6417fe894 100644 --- a/crates/theme/Cargo.toml +++ b/crates/theme/Cargo.toml @@ -10,6 +10,8 @@ repository.workspace = true [dependencies] bitflags = { workspace = true } +craft-tracked = { workspace = true } +craft-ui-macros = { workspace = true } ecolor = { workspace = true } serde = { workspace = true } smallvec = { workspace = true } diff --git a/crates/theme/src/parts.rs b/crates/theme/src/parts.rs index ad9512ab5..c08e1e7c2 100644 --- a/crates/theme/src/parts.rs +++ b/crates/theme/src/parts.rs @@ -330,7 +330,7 @@ pub struct BorderColors { } /// PhotoCraft's layer label colours (`LabelColor`). -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, craft_ui_macros::PlainData)] pub enum LabelColor { #[allow(missing_docs)] Red, diff --git a/crates/ui-contract/src/contract/memo.rs b/crates/ui-contract/src/contract/memo.rs index a6f800f5d..791e1a7f7 100644 --- a/crates/ui-contract/src/contract/memo.rs +++ b/crates/ui-contract/src/contract/memo.rs @@ -958,6 +958,13 @@ impl MemoProps for craft_theme::variant::Tone { } } +/// Derived `Hash` over a unit enum. +impl MemoProps for craft_theme::LabelColor { + fn key(&self, key: &mut MemoKey) { + key.feed_hash(self); + } +} + impl MemoProps for craft_behavior::IconId { fn key(&self, key: &mut MemoKey) { // The name is the whole id.