Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion crates/ui-egui/src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ impl Tokens {
guide: Color32::from_rgb(0xE8, 0x5D, 0x2A),
caret: Color32::BLACK,
text_selection: Color32::from_rgba_unmultiplied(0x5A, 0x8F, 0xE0, 90),
field_bg: Color32::WHITE,
// Controls drawn from this (checkboxes, slider troughs, fields) must stand out on
// the white card and the chrome, which have no border of their own (#826).
field_bg: Color32::from_rgb(0xE3, 0xE3, 0xE3),
shadow: Color32::from_black_alpha(28),
}
}
Expand Down Expand Up @@ -265,4 +267,20 @@ mod tests {
assert!(ink, "{c:?} ({:04X}) draws nothing at {size} px", c as u32);
}
}

/// Checkbox fills and slider troughs come from `field_bg`; they must stand out against the
/// dialog background in both themes (#826: white-on-white controls in light mode).
#[test]
fn field_backgrounds_stand_out_on_dialogs() {
let lum = |c: egui::Color32| 0.2126 * c.r() as f32 + 0.7152 * c.g() as f32 + 0.0722 * c.b() as f32;
for t in [super::Tokens::light(), super::Tokens::dark()] {
let ctx = egui::Context::default();
super::apply(&ctx, &t);
let v = ctx.global_style().visuals.clone();
for bg in [v.extreme_bg_color, v.widgets.inactive.bg_fill] {
let delta = (lum(bg) - lum(v.window_fill)).abs();
assert!(delta >= 8.0, "dark={}: control {:?} is invisible on dialog {:?}", t.dark, bg, v.window_fill);
}
}
}
}
Loading