M6: a long drop-down list keeps its scroll bar in view

This commit is contained in:
Eric Kaden
2026-10-19 18:17:04 -04:00
parent 42f09c156c
commit 034a1080b0
3 changed files with 36 additions and 1 deletions
+19
View File
@@ -605,6 +605,25 @@ pub(crate) fn overlay(ctx: &egui::Context, view: &mut DocView, info: &DocInfo, f
|ui| {
ui.style_mut().visuals = egui::Visuals::light();
ui.spacing_mut().item_spacing = vec2(0.0, 0.0);
// A scroll bar that stays shown beside the items, so a longer list says so and
// where it is scrolled to; it replaces the fade at the bottom edge.
ui.spacing_mut().scroll = egui::style::ScrollStyle {
bar_width: 8.0,
dormant_background_opacity: 1.0,
active_background_opacity: 1.0,
interact_background_opacity: 1.0,
dormant_handle_opacity: 1.0,
active_handle_opacity: 1.0,
interact_handle_opacity: 1.0,
..egui::style::ScrollStyle::solid()
};
ui.spacing_mut().scroll.fade.strength = 0.0;
// The bar's track and handle, gray on the white list.
let v = ui.visuals_mut();
v.extreme_bg_color = Color32::from_gray(236);
v.widgets.inactive.bg_fill = Color32::from_gray(168);
v.widgets.hovered.bg_fill = Color32::from_gray(132);
v.widgets.active.bg_fill = Color32::from_gray(100);
egui::Frame::new().fill(Color32::WHITE).stroke(Stroke::new(1.0, Color32::from_gray(64))).show(ui, |ui| {
let width = rect.width().max(24.0);
ui.set_width(width);
+16
View File
@@ -1122,3 +1122,19 @@ fn a_drop_downs_list_opens_as_wide_as_the_field_without_its_internal_name() {
h.run_steps(4);
assert_eq!(value(&h, "country"), ["fr"]);
}
#[test]
fn a_long_drop_down_list_keeps_its_scroll_bar_beside_the_items() {
let mut h = harness();
let options: Vec<String> = (0..30).map(|i| format!("{i:02}00")).collect();
assert!(h.state_mut().apply_edit(pdfcraft_engine::Edit::SetFieldProps {
name: "country".into(),
props: Box::new(pdfcraft_engine::FieldProps { options: Some(options), ..Default::default() }),
}));
h.run_steps(3);
click_field(&mut h, "country", 0);
let country = field_rect(&h, "country");
let first = egui_kittest::kittest::Queryable::get_by_label(&h, "0000").rect();
// A scroll bar that stays shown takes its own room, so people see there is more below.
assert!(first.right() <= country.right() - 6.0, "{first:?} leaves room for the bar in {country:?}");
}
+1 -1
View File
@@ -4441,7 +4441,7 @@ status = "shipped"
commands = ["form.fields"]
tools = ["form_fill"]
evidence = ["crates/ui-egui/tests/forms.rs::check_boxes_radios_and_choices", "crates/ui-egui/tests/forms.rs::a_drop_downs_list_opens_as_wide_as_the_field_without_its_internal_name", "crates/forms/src/tests.rs::choices_accept_exports_or_display_text"]
notes = "combo and list boxes, multi-select lists; editable combo boxes accept free text. A combo box shows its arrow on screen and opens its list under the field, as wide as the box and in its text size, black on white; the list takes no arrow keys yet"
notes = "combo and list boxes, multi-select lists; editable combo boxes accept free text. A combo box shows its arrow on screen and opens its list under the field, as wide as the box and in its text size, black on white, with a scroll bar shown beside a longer list; the list takes no arrow keys yet"
[[feature]]
id = "form.push-buttons"