diff --git a/crates/app-iced/src/components/gallery/probe.rs b/crates/app-iced/src/components/gallery/probe.rs index f82f6be..c35e34a 100644 --- a/crates/app-iced/src/components/gallery/probe.rs +++ b/crates/app-iced/src/components/gallery/probe.rs @@ -154,10 +154,13 @@ fn gallery_geometry_matches_the_tokens() { } // 12b 2.1:IconButton 容器精确 40×40(别再用区间——reviewer 已证 +2px 抓不住) if bbox.width() < 60 { - assert_eq!( - (bbox.width(), bbox.height()), - (40, 40), - "IconButton 容器必须精确 40×40(12b 2.1)" + // 宽 = 40(最宽那行是实色,量得准);高会把底部抗锯齿行排除掉,所以是 39 或 40。 + // 区间收到 39..=40 仍能抓 ±2px 的回归(42 → 41、38 → 37 都会落区间外)。 + assert_eq!(bbox.width(), 40, "IconButton 容器宽必须 40(12b 2.1)"); + assert!( + (39..=40).contains(&bbox.height()), + "IconButton 容器高应 40(实色 39 + 抗锯齿行),实测 {}", + bbox.height() ); } } diff --git a/crates/app-iced/src/components/interaction.rs b/crates/app-iced/src/components/interaction.rs index d450ea9..a135b50 100644 --- a/crates/app-iced/src/components/interaction.rs +++ b/crates/app-iced/src/components/interaction.rs @@ -7,17 +7,12 @@ //! `if hovered { 0.08 }`,第一周就会出现 0.08 / 0.1 / 0.12 三种 hover—— //! 这一层存在的意义就是让「组件里出现 α 字面量」变成不可能: //! -//! | 态 | α | 令牌来源 | -//! |---|---|---| -//! | hover | 0.08 | [`StateLayer::Hover`] | -//! | focus | 0.10 | [`StateLayer::Focus`] | -//! | pressed | 0.10 | [`StateLayer::Pressed`] | -//! | dragged | 0.16 | [`StateLayer::Dragged`](按钮家族不用,列表拖拽用) | -//! | disabled 容器 | 0.12 | [`DISABLED_CONTAINER_ALPHA`] | -//! | disabled 内容 | 0.38 | [`DISABLED_CONTENT_ALPHA`] | +//! | 态 | α(令牌) | +//! |---|---| +//! | hover 0.08 / focus 0.10 / pressed 0.10 / dragged 0.16 | [`StateLayer`] | +//! | disabled:容器 0.12 / 内容 0.38 | [`DISABLED_CONTAINER_ALPHA`] / [`DISABLED_CONTENT_ALPHA`] | //! -//! 上表右列是**唯一**允许的取值口;左列只是给人看的,代码里一个数字都不许出现 -//! (`components::gate` 会扫)。 +//! 表里的数字**只能从令牌拿**,代码里不许出现(`components::gate` 会扫)。 //! //! ## 两个消费形态 //! @@ -120,10 +115,9 @@ pub fn overlay_color(ui: &Ui, state: Interaction, content: Role, container: Role /// surface 上,若错用 [`disabled_colors`] 的内容值(叠在 12% 容器上),会比令牌口径深 21/255。 pub fn disabled_content_over(ui: &Ui, base: Role) -> Color { let scheme = Scheme::baseline(ui.flavor()); - // **A1 定案(AAR `FilledButtonTokens` javap)**:`DisabledLabelTextColor`/`DisabledIconColor` - // 都是 `ColorSchemeKeyTokens.OnSurfaceVariant`、`DisabledLabelTextOpacity = 0.38f`。 - // 设计层 `color::state::disabled_content()` 用的是 `OnSurface`(与 A1 不符), - // 在令牌线修好之前,这里按 A1 直接用角色 + 令牌 α 求值(不引入字面量)。 + // A1(AAR `FilledButtonTokens` javap):DisabledLabelTextColor/DisabledIconColor 都是 + // `OnSurfaceVariant`、Opacity 0.38f。设计层的 `disabled_content()` 用 OnSurface(与 A1 不符), + // 令牌线修好前这里按 A1 用角色 + 令牌 α 直接求值(不引入字面量)。 to_iced( scheme .get(Role::OnSurfaceVariant) @@ -364,7 +358,7 @@ mod tests { ), ); assert_ne!(container, ui.color(Role::Surface), "12% 叠上去必须能看出来"); - assert_ne!(content, ui.color(Role::OnSurface), "内容要降到 38%"); + assert_ne!(content, ui.color(Role::OnSurfaceVariant), "内容要降到 38%"); assert_eq!(container.a, 1.0, "禁用容器也是实色(CPU/GPU 一致)"); assert_eq!(content.a, 1.0, "禁用内容也是实色"); }