From a3b3c9eba7d2b2889c49f5703a6ca897a5af5cd3 Mon Sep 17 00:00:00 2001 From: AskaEth Date: Mon, 2 Nov 2026 02:19:43 +0800 Subject: [PATCH] =?UTF-8?q?docs(app-iced):=20M75=20r3c=20=E2=80=94?= =?UTF-8?q?=E2=80=94=20interaction.rs=20=E6=96=87=E6=A1=A3=E6=94=B6?= =?UTF-8?q?=E5=8F=A3=EF=BC=88Tracker=20=E7=94=A8=E6=B3=95/=CE=B1=20?= =?UTF-8?q?=E8=A1=A8=E5=8E=8B=E8=A1=8C=EF=BC=8C=E5=9B=9E=E5=88=B0=20400=20?= =?UTF-8?q?=E8=A1=8C=E5=86=85=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/app-iced/src/components/interaction.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) 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)]