feat(a11y): add Theme.is-high-contrast flag to gate HC-only borders
P4 foundation for the redundant-encoding accessibility pass. Adds a single flag that High-Contrast-only affordances (1px control borders, slider-thumb borders) read so they never leak into the polished normal themes, mirroring the existing is-system wiring. - qbz-theme: `pub fn is_high_contrast(id)` at the crate root next to `is_light` (true for HighContrast + HighContrastLight), with a unit test `high_contrast_flag_only_for_hc_themes` asserting exactly the two HC themes. - qbz-slint theme.slint: `in-out property <bool> is-high-contrast: false;` beside is-system; re-exported via semantic-colors.slint so all ~145 components get `Theme.is-high-contrast` with no per-file import change. Embedded the canonical HC border gate and the non-layout focus-ring snippet as a comment for the cluster agents to copy verbatim. - qbz-slint theme.rs: apply_theme sets it via `qbz_theme::is_high_contrast(id)`. cc
This commit is contained in:
3 files changed
+45
No files matched your search
@@ -54,6 +54,14 @@ pub fn is_light(id: ThemeId) -> bool {
|
||||
relative_luminance(palette(id).surface_main) >= 0.5
|
||||
}
|
||||
|
||||
/// Whether a theme is one of the two High-Contrast accessibility themes.
|
||||
/// Drives the Slint `Theme.is-high-contrast` flag, which gates HC-only
|
||||
/// redundant-encoding affordances (1px control borders, slider-thumb borders)
|
||||
/// so they never leak into the polished normal themes (P4 a11y pass).
|
||||
pub fn is_high_contrast(id: ThemeId) -> bool {
|
||||
matches!(id, ThemeId::HighContrast | ThemeId::HighContrastLight)
|
||||
}
|
||||
|
||||
/// Build the full Settings theme list in display order. The frontend filters by
|
||||
/// `is_light` and may hide `!implemented` rows during P1/P2.
|
||||
pub fn theme_list() -> Vec<ThemeListEntry> {
|
||||
@@ -145,4 +153,20 @@ mod tests {
|
||||
fn full_list_has_all_entries() {
|
||||
assert_eq!(theme_list().len(), ALL.len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn high_contrast_flag_only_for_hc_themes() {
|
||||
// True for exactly the two High-Contrast themes.
|
||||
assert!(is_high_contrast(ThemeId::HighContrast));
|
||||
assert!(is_high_contrast(ThemeId::HighContrastLight));
|
||||
// False for everything else, including the other a11y themes.
|
||||
assert!(!is_high_contrast(ThemeId::WcagLight));
|
||||
assert!(!is_high_contrast(ThemeId::WcagDark));
|
||||
assert!(!is_high_contrast(ThemeId::Colorblind));
|
||||
assert!(!is_high_contrast(ThemeId::Dark));
|
||||
assert!(!is_high_contrast(ThemeId::Oled));
|
||||
assert!(!is_high_contrast(ThemeId::System));
|
||||
// Exactly two themes in ALL are high-contrast.
|
||||
assert_eq!(ALL.iter().filter(|&&id| is_high_contrast(id)).count(), 2);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user