fix(ui): show Preferences checkbox outlines in every theme
Reapply on current upstream main.
This commit is contained in:
parent
dec085e1e5
commit
85bbc35176
|
|
@ -363,9 +363,10 @@ fn picas_in_use(d: &Dialog) -> bool {
|
|||
}
|
||||
|
||||
fn bool_row(ui: &mut egui::Ui, d: &mut Dialog, key: &str, label: &str) {
|
||||
let mut b = d.bool(key);
|
||||
if ui.checkbox(&mut b, tl!(label)).changed() {
|
||||
d.fields.insert(key.into(), json!(b));
|
||||
// Use the same outlined checkbox as the rest of the app. egui's default
|
||||
// checkbox inherits an invisible resting border from the panel theme.
|
||||
if widgets::check(ui, tl!(label), d.bool(key), ui.is_enabled()) {
|
||||
d.fields.insert(key.into(), json!(!d.bool(key)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -386,6 +387,30 @@ mod tests {
|
|||
use crate::Services;
|
||||
use vectorcraft_engine::Session;
|
||||
|
||||
/// A resting checkbox must have a visible outline in both states and every brightness.
|
||||
#[test]
|
||||
fn preference_checkboxes_draw_outlines_without_hover() {
|
||||
for brightness in Brightness::ALL {
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
theme::apply(&ctx, brightness);
|
||||
for checked in [false, true] {
|
||||
let mut d = Dialog::new("preferences", json!({"showToolTips": checked}));
|
||||
let raw = egui::RawInput {
|
||||
screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(400.0, 200.0))),
|
||||
..Default::default()
|
||||
};
|
||||
let mut out = ctx.run_ui(raw, |ui| bool_row(ui, &mut d, "showToolTips", "Show Tool Tips"));
|
||||
out.textures_delta.clear();
|
||||
let outlined = out.shapes.iter().any(|shape| match &shape.shape {
|
||||
egui::Shape::Rect(r) => r.stroke.width > 0.0 && r.rect.width() <= 24.0 && r.rect.height() <= 24.0,
|
||||
_ => false,
|
||||
});
|
||||
assert!(outlined, "{brightness:?}, checked={checked}: no checkbox outline");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// User Interface › Canvas Color (#663): White and the three greys paint the canvas around the
|
||||
/// artboards; Match User Interface Brightness keeps the theme's.
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in New Issue