From 361654b708e0fc40f1b3eb7828a1c9763489cdc2 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Tue, 1 Dec 2026 20:07:40 +0100 Subject: [PATCH] Restore wide document scrollbars at rest --- crates/ui-egui/src/canvas.rs | 1 - crates/ui-egui/tests/it/viewer.rs | 50 +++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 08dcc4d24d..4fbd10d588 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -1857,7 +1857,6 @@ pub fn document_area_at(app: &mut PdfCraftApp, index: usize, rect: Rect, ui: &mu let out = ui .push_id(view_key, |ui| { PageView::new(tl!("Pages"), &source, state, DataColor::new(paper)) - .floating_scrollbars() .pixel_aligned_pages() .navigation(navigation) .border(border) diff --git a/crates/ui-egui/tests/it/viewer.rs b/crates/ui-egui/tests/it/viewer.rs index 6b83349815..eebff9882b 100644 --- a/crates/ui-egui/tests/it/viewer.rs +++ b/crates/ui-egui/tests/it/viewer.rs @@ -414,6 +414,46 @@ fn a_search_flash_preserves_following_while_an_unrelated_drag_is_held() { ); } +/// #9001: the document thumb is visibly wide at rest and can be dragged from that width. +#[test] +fn document_scrollbar_is_wide_at_rest_and_draggable() { + let mut h = harness(); + h.state_mut().active = Some(0); + h.run_steps(5); + let bar = h.get_by_role_and_label(egui::accesskit::Role::ScrollBar, "Vertical scroll bar").rect(); + assert!(bar.width() >= 14.0, "the document target is comfortably wide: {bar:?}"); + let thumb = h + .output() + .shapes + .iter() + .filter_map(|shape| match &shape.shape { + egui::Shape::Rect(paint) + if paint.fill.a() > 0 + && bar.expand(1.0).contains_rect(paint.rect) + && paint.rect.width() >= bar.width() - 1.0 + && paint.rect.height() > paint.rect.width() + && paint.rect.height() < bar.height() - 1.0 => + { + Some(paint.rect) + } + _ => None, + }) + .next() + .expect("a full-width thumb is painted before hovering"); + let start = egui::pos2(thumb.left() + 2.0, thumb.center().y); + let before = h.state().views[0].page_screen_rect(0).expect("first page visible").top(); + h.hover_at(start); + h.run_steps(2); + h.drag_at(start); + h.run_steps(2); + h.hover_at(start + egui::vec2(0.0, bar.height() * 0.3)); + h.run_steps(3); + h.drop_at(start + egui::vec2(0.0, bar.height() * 0.3)); + h.run_steps(3); + let after = h.state().views[0].page_screen_rect(0).map(|r| r.top()); + assert!(after.is_none_or(|top| top < before - 10.0), "dragging the visible thumb moves the document: {before} -> {after:?}"); +} + /// The document scroll bar is its own scroll surface: a track click moves the offset with no /// pointer motion, and dragging from that press keeps moving it. Both are the reader scrolling, /// so automatic following ends. A global "any drag is scrolling" check would miss the click. @@ -422,11 +462,9 @@ fn scroll_bar_track_click_and_drag_end_automatic_search_following() { let mut h = harness(); let view = find_one_match_per_page(&mut h); h.run_steps(4); - let vp = h.state().views[view].viewport_rect(); - // Floating bars sit in the outer few points of the document area (see theme). Aim 75% down - // the vertical track: below the handle at this scroll position, and clear of the corner - // where the horizontal bar's track overlaps. - let track = egui::pos2(vp.right() - 4.0, vp.top() + vp.height() * 0.75); + // Aim below the handle, clear of the horizontal bar and independent of the bar width. + let bar = h.get_by_role_and_label(egui::accesskit::Role::ScrollBar, "Vertical scroll bar").rect(); + let track = egui::pos2(bar.center().x, bar.top() + bar.height() * 0.75); let before = h.state().views[view].page_screen_rect(0).expect("page 1 is on screen").top(); h.event(egui::Event::PointerMoved(track)); h.run_steps(2); @@ -440,7 +478,7 @@ fn scroll_bar_track_click_and_drag_end_automatic_search_following() { } // Keep dragging from the press: the scroll bar follows the pointer, still reader scrolling. - let dragged = egui::pos2(vp.right() - 4.0, vp.top() + vp.height() * 0.4); + let dragged = egui::pos2(bar.center().x, bar.top() + bar.height() * 0.4); h.event(egui::Event::PointerMoved(dragged)); h.run_steps(2); assert!(late_match_leaves_current(&mut h, view), "the track drag is the reader scrolling");