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.
This commit is contained in:
aiongg
2026-11-20 18:16:52 +00:00
parent 866ddeaaf7
commit ef60cb99a5
6 changed files with 12 additions and 3 deletions
Generated
+2
View File
@@ -4152,6 +4152,8 @@ name = "craft-theme"
version = "0.1.0"
dependencies = [
"bitflags 2.13.2",
"craft-tracked",
"craft-ui-macros",
"ecolor",
"log",
"proptest",
-1
View File
@@ -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<LabelColor>,
/// Smart Object: the kinds toggled on, in the order they were toggled.
pub smart: Vec<SmartKind>,
-1
View File
@@ -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<LabelColor>,
/// The layer's locks: any of them shows the lock indicator.
pub locks: LayerLocks,
+2
View File
@@ -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 }
+1 -1
View File
@@ -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,
+7
View File
@@ -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.