68 lines
2.0 KiB
Rust
68 lines
2.0 KiB
Rust
//! 绘制宿主设置页面和主题选择区域。
|
||
//! 这里只投影当前设置和交互目标,平台原生窗口行为由对应系统适配层负责。
|
||
//!
|
||
use super::*;
|
||
|
||
/// 根据当前输入构造本模块的派生结果,具体的验证与资源边界见函数内步骤。
|
||
pub(super) fn build(p: &mut Painter, state: &mut DeveloperToolsState, viewport: Rect) {
|
||
let x = viewport.x;
|
||
let w = viewport.width;
|
||
|
||
p.label(x + 24.0, 62.0, "Appearance", TEXT, false);
|
||
p.label(
|
||
x + 24.0,
|
||
90.0,
|
||
"Accent color · tabs, focus and execution separators",
|
||
MUTED,
|
||
false,
|
||
);
|
||
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);
|
||
}
|
||
p.label(
|
||
x + 24.0,
|
||
176.0,
|
||
"Custom hex · Enter to apply (bright colors adjusted)",
|
||
MUTED,
|
||
false,
|
||
);
|
||
let custom = Rect::new(x + 24.0, 204.0, 200.0, 32.0);
|
||
p.ui.text_field(
|
||
custom,
|
||
Action::Focus(Focus::Custom),
|
||
state.focus == Some(Focus::Custom),
|
||
);
|
||
p.label(
|
||
custom.x + 10.0,
|
||
custom.y + 6.0,
|
||
&format!(
|
||
"{}{}",
|
||
state.custom,
|
||
if state.focus == Some(Focus::Custom) {
|
||
"│"
|
||
} else {
|
||
""
|
||
}
|
||
),
|
||
TEXT,
|
||
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);
|
||
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);
|
||
p.label(
|
||
x + 24.0,
|
||
430.0,
|
||
"Settings last for this window session. Source is not persisted.",
|
||
MUTED,
|
||
false,
|
||
);
|
||
}
|