diff --git a/crates/app-iced/src/components/interaction.rs b/crates/app-iced/src/components/interaction.rs index a135b50..39c842b 100644 --- a/crates/app-iced/src/components/interaction.rs +++ b/crates/app-iced/src/components/interaction.rs @@ -109,10 +109,10 @@ pub fn overlay_color(ui: &Ui, state: Interaction, content: Role, container: Role .map(|layer| ui.state_over(layer, content, container)) } -/// 禁用态内容色:`OnSurface` @ 38% 叠在 **`base` 角色**上(不经过 12% 容器)。 +/// 禁用态内容色:`OnSurfaceVariant` @ 38% 叠在 **`base` 角色**上(不经过 12% 容器)。 /// -/// 给**不画容器**的三式(Text / Outlined / standard IconButton)用:它们的禁用内容直接落在 -/// surface 上,若错用 [`disabled_colors`] 的内容值(叠在 12% 容器上),会比令牌口径深 21/255。 +/// 给**不画容器**的三式(Text / Outlined / standard IconButton)用:错用 [`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 都是 @@ -154,14 +154,9 @@ pub fn disabled_colors(ui: &Ui, surface: Role) -> (Color, Color) { /// 自定义 `Widget` 的状态机:把 iced 事件折成 [`Interaction`]。 /// -/// 这是 D39 §3 说的「状态机的公共部分」。用法(自定义 Widget 的 `update` 里): -/// -/// ```ignore -/// if self.tracker.event(event, cursor.is_over(layout.bounds())) { -/// shell.request_redraw(); // 只有真变了才重绘 -/// } -/// let style = style_of(self.tracker.state()); -/// ``` +/// D39 §3 说的「状态机的公共部分」。自定义 `Widget` 的 `update` 里: +/// `if tracker.event(event, cursor.is_over(bounds)) { shell.request_redraw(); }`, +/// 画的时候读 `tracker.state()`。`event()` 只在**视觉态真的变了**时返回 `true`。 // 本 mission 的按钮家族全部走 iced 的 `button`,没有自绘控件,所以 Tracker 目前只有单测在用; // 它在这里是给四个后续家族(Slider / Switch 轨道这类要自绘的)准备的公共状态机。 #[allow(dead_code)]