Merge pull request #1080 from Ni-zav/fix/885-checkbox-visibility-rebased-20261011

fix(ui): show Preferences checkbox outlines in every theme
This commit is contained in:
BFlat 2026-10-11 07:44:34 +07:00 committed by GitHub
commit 5d847ffc88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

@ -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));
// The app's outlined checkbox (it translates `label`): egui's own has no border at rest.
let on = d.bool(key);
if widgets::check(ui, label, on, ui.is_enabled()) {
d.fields.insert(key.into(), json!(!on));
}
}
@ -386,6 +387,28 @@ 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]