mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-11 08:51:27 +00:00
UI: size the rail's bottom cluster for the history buttons, fix a pixel-fragile flick test (#1913)
The rail's page-navigation cluster measures 360 pt since the two view-history buttons landed; RAIL_BOTTOM_H was 316, so in a short window the cluster overflowed its allocation and overlapped. The min-window test now uses the minimum height and checks the page box, history and zoom buttons. a_quick_flick_on_either_edge_rewraps_the_paragraph grabbed the widened edge 2 px outside the box, at the limit of the grab zone; the rail's scroll area moved the canvas width by 3 px and the press missed. It now grabs 1 px outside. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c3cf27558a
commit
fb7f7252db
3 files changed
+15
-5
No files matched your search
@@ -648,8 +648,8 @@ fn main_menu(app: &mut PdfCraftApp, ui: &mut egui::Ui) {
|
||||
});
|
||||
}
|
||||
|
||||
/// Height the rail's page-navigation cluster (zoom, fit, page box) needs; below it the rail scrolls.
|
||||
const RAIL_BOTTOM_H: f32 = 316.0;
|
||||
/// Height the rail's page-navigation cluster (zoom, fit, page, history buttons, page box) needs (360 pt measured); below it the rail scrolls.
|
||||
const RAIL_BOTTOM_H: f32 = 364.0;
|
||||
|
||||
pub fn right_rail(app: &mut PdfCraftApp, ui: &mut egui::Ui) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
|
||||
@@ -3487,7 +3487,9 @@ fn a_quick_flick_on_either_edge_rewraps_the_paragraph() {
|
||||
assert_eq!(text, ["Page", "1"], "narrowed from the right edge");
|
||||
// Flick the right edge outward, past the box and its handle: back onto one line.
|
||||
let b = block(&h);
|
||||
let edge = screen(b.rect[2], grip_y(&b)) + egui::vec2(2.0, 0.0);
|
||||
// 1 px outside the box: the grab zone's outer limit sits near 2 px, where a pixel of page
|
||||
// scale (the canvas width depends on the rail) decides whether the press lands on the handle.
|
||||
let edge = screen(b.rect[2], grip_y(&b)) + egui::vec2(1.0, 0.0);
|
||||
flick(&mut h, edge, edge + egui::vec2(80.0 * k, 0.0));
|
||||
let text: Vec<String> = lines(&h).iter().map(|l| l.text.clone()).collect();
|
||||
assert_eq!(text, ["Page 1"], "widened by a fast drag that left the handle at once");
|
||||
|
||||
@@ -101,11 +101,11 @@ fn the_stacked_notice_keeps_its_buttons_in_view() {
|
||||
assert!(!unlock.intersects(settings), "the buttons do not overlap: {unlock:?} {settings:?}");
|
||||
}
|
||||
|
||||
/// #1913 (1182 x 556): the rail's top buttons and its page-navigation cluster must not overlap.
|
||||
/// #1913 (the minimum height): the rail's top buttons and its page-navigation cluster must not overlap.
|
||||
#[test]
|
||||
fn a_short_window_does_not_overlap_the_rail_clusters() {
|
||||
let h = {
|
||||
let mut h = Harness::builder().with_size(egui::vec2(1182.0, 556.0)).build_eframe(|_cc| {
|
||||
let mut h = Harness::builder().with_size(egui::vec2(1182.0, MIN_WINDOW_SIZE[1])).build_eframe(|_cc| {
|
||||
let mut app = PdfCraftApp::new();
|
||||
app.set_option("language", "en").unwrap();
|
||||
app.open_bytes("a.pdf", None, fixture(2)).unwrap();
|
||||
@@ -117,4 +117,12 @@ fn a_short_window_does_not_overlap_the_rail_clusters() {
|
||||
let tags = h.get_by_label("Tags").rect();
|
||||
let next = h.get_by_label("Previous page").rect();
|
||||
assert!(next.top() >= tags.bottom(), "page navigation sits below the rail buttons: {tags:?} vs {next:?}");
|
||||
// The history buttons are the cluster's topmost buttons (above the page box).
|
||||
let history = h.get_by_label_contains("Previous view").rect();
|
||||
assert!(history.top() >= tags.bottom(), "view history sits below the rail buttons: {tags:?} vs {history:?}");
|
||||
// The topmost thing in the cluster is the page box; the lowest is the zoom-out button.
|
||||
let page_box = h.get_by_role(Role::TextInput).rect();
|
||||
assert!(page_box.top() >= tags.bottom(), "the page box sits below the rail buttons: {tags:?} vs {page_box:?}");
|
||||
let zoom_out = h.get_by_label_contains("Zoom out").rect();
|
||||
assert!(zoom_out.top() >= history.bottom(), "zoom sits below view history: {history:?} vs {zoom_out:?}");
|
||||
}
|
||||
Reference in new issue
Block a user