docs: clarify source viewing and host interaction boundaries
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//! 即时绘制控件的跨帧交互状态:稳定 WidgetId、悬停、按下捕获、键盘焦点和释放激活。
|
||||
//! 控件用语义 key 标识,而不是屏幕位置或行号。释放时必须仍命中同一个启用目标,拖出控件不能意外触发点击。
|
||||
//! 控件用语义 key 标识,而不是屏幕位置或行号。释放时必须命中原启用目标;在外释放不激活,移回后释放仍可激活。
|
||||
//!
|
||||
use crate::geometry::{Point, Rect};
|
||||
use std::hash::{Hash, Hasher};
|
||||
@@ -62,7 +62,9 @@ pub struct Target<A> {
|
||||
pub id: WidgetId,
|
||||
// 本帧逻辑命中矩形,通常与绘制一致,行/分隔条可显式用不同的绘制与交互范围。
|
||||
pub rect: Rect,
|
||||
// 决定焦点资格、指针光标和 TextField 的按下处理例外;不会直接执行 action。
|
||||
pub role: Role,
|
||||
// 禁用仍参与几何命中以遮挡下层控件,但不能被 press 捕获、Tab 聚焦或释放激活。
|
||||
pub enabled: bool,
|
||||
// 激活时克隆交给宿主处理;分隔条/滚动条没有点击动作,拖动参数由上层布局另存。
|
||||
pub action: Option<A>,
|
||||
@@ -70,8 +72,11 @@ pub struct Target<A> {
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
/// 绘制使用的组合交互状态,避免按钮自己重新推断焦点/捕获。
|
||||
pub struct VisualState {
|
||||
// enabled 且当前悬停身份匹配;与 selected 独立。
|
||||
pub hovered: bool,
|
||||
// 键盘捕获匹配或鼠标捕获且仍悬停;指针拖出只取消外观,不立即清掉捕获。
|
||||
pub pressed: bool,
|
||||
// 仅键盘来源焦点显示此状态;鼠标聚焦也能保存 focused 身份,但不会显示键盘焦点圈。
|
||||
pub focused: bool,
|
||||
// 由当前页面或工具数据决定的选中态,不从 hover/press 推断,禁用也不自动清除此数据状态。
|
||||
pub selected: bool,
|
||||
|
||||
@@ -7,9 +7,13 @@ pub const BG: Color = Color::rgb(255, 255, 255);
|
||||
pub const BAR: Color = Color::rgb(230, 233, 237);
|
||||
// 控件边框与未悬停分隔线共用,强调状态由 Theme.accent 覆盖而不是改写这个常量。
|
||||
pub const BORDER: Color = Color::rgb(226, 226, 226);
|
||||
// 宿主正文/按钮的默认前景,widgets 和各开发工具画文字时共用。
|
||||
pub const TEXT: Color = Color::rgb(35, 42, 53);
|
||||
// 次要说明、图标与禁用样式的基础灰色,具体状态仍可由控件混色。
|
||||
pub const MUTED: Color = Color::rgb(103, 114, 130);
|
||||
// 开发工具错误文本与失败状态使用的红色,不参与运行时错误判定。
|
||||
pub const ERROR: Color = Color::rgb(175, 42, 49);
|
||||
// 开发工具成功状态使用的绿色;是否成功由数据层决定,不由颜色反推。
|
||||
pub const OK: Color = Color::rgb(31, 121, 80);
|
||||
// 供设置页选择的六个强调色候选;Theme::new 还会按可读性规则调整传入颜色。
|
||||
pub const PALETTE: [Color; 6] = [
|
||||
|
||||
Reference in New Issue
Block a user