docs: 逐模块细化中文逻辑注释并覆盖测试与示例
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
//!
|
||||
use super::*;
|
||||
|
||||
/// 根据当前输入构造本模块的派生结果,具体的验证与资源边界见函数内步骤。
|
||||
/// 绘制强调色候选、自定义颜色编辑框及主题预览;实际应用和错误校验由输入动作处理。
|
||||
pub(super) fn build(p: &mut Painter, state: &mut DeveloperToolsState, viewport: Rect) {
|
||||
let x = viewport.x;
|
||||
let w = viewport.width;
|
||||
@@ -16,6 +16,7 @@ pub(super) fn build(p: &mut Painter, state: &mut DeveloperToolsState, viewport:
|
||||
MUTED,
|
||||
false,
|
||||
);
|
||||
// 色块动作携带调色板索引,绘制仅比较当前 accent 标记选中;实际修改由统一动作处理器执行。
|
||||
for (i, color) in PALETTE.iter().enumerate() {
|
||||
let r = Rect::new(x + 24.0 + i as f32 * 44.0, 122.0, 32.0, 32.0);
|
||||
p.ui.swatch(r, Action::Theme(i), *color, *color == state.accent);
|
||||
@@ -27,6 +28,7 @@ pub(super) fn build(p: &mut Painter, state: &mut DeveloperToolsState, viewport:
|
||||
MUTED,
|
||||
false,
|
||||
);
|
||||
// 自定义颜色框显示尚未应用的编辑文本;聚焦只改变外观和输入接收位置,不在这里解析 hex。
|
||||
let custom = Rect::new(x + 24.0, 204.0, 200.0, 32.0);
|
||||
p.ui.text_field(
|
||||
custom,
|
||||
@@ -49,11 +51,13 @@ pub(super) fn build(p: &mut Painter, state: &mut DeveloperToolsState, viewport:
|
||||
true,
|
||||
);
|
||||
|
||||
// 校验错误由输入处理路径写入,设置页只显示;错误不会在每次重绘时重复执行或清除。
|
||||
if !state.input_error.is_empty() {
|
||||
p.label(x + 24.0, 245.0, &state.input_error, ERROR, false);
|
||||
}
|
||||
p.fill(Rect::new(x + 24.0, 285.0, w - 48.0, 1.0), BORDER);
|
||||
p.label(x + 24.0, 305.0, "Theme preview", TEXT, false);
|
||||
// 预览复用当前强调色和标准成功色,让用户看到主题如何影响执行分隔线;示例文字不送入 VM。
|
||||
p.fill(Rect::new(x + 24.0, 340.0, w - 48.0, 2.0), state.accent);
|
||||
p.label(x + 32.0, 353.0, "› \"Hello\"", TEXT, true);
|
||||
p.label(x + 32.0, 380.0, "‹ \"Hello\"", OK, true);
|
||||
|
||||
Reference in New Issue
Block a user