Fix #1662: slider rails show on Medium Dark

The rail used the fields' border, which on Medium Dark (the default) is all but
the panel's colour; it now uses the buttons' border, which stands out on every
brightness.
This commit is contained in:
Ayberk A. 2026-10-13 21:16:58 +03:00 committed by bflatastic
parent 5fc0be5b85
commit 3024821c32
2 changed files with 14 additions and 1 deletions

View File

@ -350,4 +350,15 @@ mod tests {
}
assert!(!Tokens::for_brightness(Brightness::Light).dark);
}
/// #1662: a slider's rail (`button_border`, see `widgets::slider`) stands out from the panel
/// in every brightness.
#[test]
fn slider_rails_show_on_every_panel() {
for b in [Brightness::Dark, Brightness::MediumDark, Brightness::MediumLight, Brightness::Light] {
let t = Tokens::for_brightness(b);
let gap = (i32::from(t.button_border.r()) - i32::from(t.panel.r())).abs();
assert!(gap >= 24, "{b:?}: rail {:?} on panel {:?}", t.button_border, t.panel);
}
}
}

View File

@ -1014,7 +1014,9 @@ pub fn slider(ui: &mut Ui, slider: egui::Slider<'_>) -> Response {
let t = Tokens::get(ui.ctx());
ui.scope(|ui| {
let v = ui.visuals_mut();
v.widgets.inactive.bg_fill = t.input_border;
// The buttons' border shows against the panel in every brightness; the fields' border
// all but vanished on Medium Dark's panel (#1662).
v.widgets.inactive.bg_fill = t.button_border;
v.selection.bg_fill = t.accent;
ui.add(slider.trailing_fill(true))
})