Domain: - AppearanceSettings gains translucency_pct (u8, 0..=100, default 40) with a clamping setter and serde round-trip coverage. - DEFAULT_TRANSLUCENCY_PCT and MAX_TRANSLUCENCY_PCT exported for the shell. Core: - BrowserCore::set_translucency_pct delegates to the appearance struct; the existing reset_appearance covers the reset path. - Integration test covers persistence into snapshot.appearance. Render: - chrome::sidebar::panel_bg(snapshot) replaces the static PANEL_BG constant, mapping the user's translucency_pct linearly into the alpha byte 0xff..0xb3. Sidebar (expanded + compact) and main pane consume the helper so changing the setting at runtime updates every glass surface in lock-step. Form: - Translucency row in chrome::appearance_form mirrors the design's static track + thumb visual driven by the persisted percentage, plus three preset chips (Solid 0 / Default 40 / Glassy 75) that mutate the setting through shell.set_translucency_pct. Strict UX rule preserved: alpha never drops below 0xb3 so panels stay readable without backdrop blur (which GPUI 0.2.2 doesn't expose).
49 lines
1.7 KiB
Rust
49 lines
1.7 KiB
Rust
use std::error::Error;
|
|
|
|
use ely_browser_core::{BrowserCore, InitialBrowserConfig};
|
|
use ely_domain::{ThemeMode, WallpaperTheme};
|
|
|
|
#[test]
|
|
fn snapshot_starts_with_default_appearance() -> Result<(), Box<dyn Error>> {
|
|
let core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
|
let snapshot = core.snapshot()?;
|
|
|
|
assert_eq!(snapshot.appearance.wallpaper(), WallpaperTheme::Dawn);
|
|
assert_eq!(snapshot.appearance.theme_mode(), ThemeMode::System);
|
|
assert!(!snapshot.appearance.reduce_motion());
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn setters_persist_into_subsequent_snapshots() -> Result<(), Box<dyn Error>> {
|
|
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
|
|
|
core.set_wallpaper_theme(WallpaperTheme::Mint);
|
|
core.set_theme_mode(ThemeMode::Dark);
|
|
core.set_reduce_motion(true);
|
|
core.set_translucency_pct(75);
|
|
|
|
let snapshot = core.snapshot()?;
|
|
assert_eq!(snapshot.appearance.wallpaper(), WallpaperTheme::Mint);
|
|
assert_eq!(snapshot.appearance.theme_mode(), ThemeMode::Dark);
|
|
assert!(snapshot.appearance.reduce_motion());
|
|
assert_eq!(snapshot.appearance.translucency_pct(), 75);
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn reset_appearance_restores_defaults() -> Result<(), Box<dyn Error>> {
|
|
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
|
|
|
core.set_wallpaper_theme(WallpaperTheme::Slate);
|
|
core.set_theme_mode(ThemeMode::Light);
|
|
core.set_reduce_motion(true);
|
|
core.reset_appearance();
|
|
|
|
let snapshot = core.snapshot()?;
|
|
assert_eq!(snapshot.appearance.wallpaper(), WallpaperTheme::Dawn);
|
|
assert_eq!(snapshot.appearance.theme_mode(), ThemeMode::System);
|
|
assert!(!snapshot.appearance.reduce_motion());
|
|
Ok(())
|
|
}
|