From 2c20bcd30cc90dbe3573477778739f219ecaf917 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 20 Nov 2026 02:18:54 -0500 Subject: [PATCH] pipe view-1: fixes for view (10 tests) --- crates/ui-egui/src/canvas.rs | 6 +++++- crates/ui-egui/tests/it/view.rs | 21 +++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 96850f3db4..26805c3512 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -862,6 +862,8 @@ struct PageBodyCx<'a> { /// Full screen: the page, display and rotation it shows, captured before the page view holds the view state; /// `None` outside full screen. present_at: Option, + /// The incoming page cannot take input until its transition finishes. + veiled: bool, preparing: bool, calc_order: bool, editing_content: bool, @@ -944,7 +946,7 @@ fn page_parts_of(ui: &mut egui::Ui, body: &PageBody<'_>, session: &mut PageSessi let mut parts = Vec::new(); // Copied comments hanging on the pointer take the next click anywhere on a page, even over an // existing comment, link or field, so no page part may steal it from the paste tool. - if session.comments.paste.is_some() { + if cx.veiled || session.comments.paste.is_some() { return parts; } if cx.editing_content { @@ -1656,6 +1658,7 @@ pub fn document_area_at(app: &mut PdfCraftApp, index: usize, rect: Rect, ui: &mu let find_marks: Vec = view.find.as_ref().map(Find::marks).unwrap_or_default(); let present_at = presenting.then_some(presenter::PresentAt { current: view.view.current, display: view.view.display, rotation: view.view.rotation }); + let veiled = page_overlays::veiled(view); // Shadows only with the preference on, and only between gaps: they would darken the page before when pages touch. let border = if view.view.page_gaps && app.show_page_edge_shadows { PageBorder::DropShadow } else { PageBorder::None }; let keep = view.session.presenter.keep_pages(); @@ -1732,6 +1735,7 @@ pub fn document_area_at(app: &mut PdfCraftApp, index: usize, rect: Rect, ui: &mu tools, animates: !app.animation_effects.reduced(None), present_at, + veiled, preparing, calc_order, editing_content, diff --git a/crates/ui-egui/tests/it/view.rs b/crates/ui-egui/tests/it/view.rs index 1d9b138325..79ec4a1658 100644 --- a/crates/ui-egui/tests/it/view.rs +++ b/crates/ui-egui/tests/it/view.rs @@ -238,7 +238,12 @@ fn page_gaps_comparison_harness() -> Harness<'static, PdfCraftApp> { }); h.run_steps(4); let at = h.state().views[0].viewport_rect().center(); - h.event(egui::Event::PointerMoved(at)); + h.hover_at(at); + h.run_steps(1); + for pressed in [true, false] { + h.event(egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Modifiers::NONE }); + h.run_steps(1); + } h.run_steps(2); assert_eq!(h.state().compare.as_ref().unwrap().views.lead, craft::pages::ui::Lead::Left); assert_eq!(h.state().active, Some(1)); @@ -2388,7 +2393,7 @@ fn delete_with_a_menu_open_and_escape_closing_a_thumbnail_menu_leave_the_pages_p crate::support::open_menu(&mut h, "View"); h.hover_at(thumb); h.run_steps(1); - assert!(egui::Popup::is_any_open(&h.ctx), "the menu is open"); + assert!(h.query_by_role(egui::accesskit::Role::Menu).is_some(), "the menu is open"); h.key_press(Key::Delete); h.run_steps(3); let pages = |h: &Harness<'static, PdfCraftApp>| h.state().session.get(h.state().views[0].id).unwrap().info.pages.len(); @@ -2396,7 +2401,7 @@ fn delete_with_a_menu_open_and_escape_closing_a_thumbnail_menu_leave_the_pages_p assert_eq!(h.state().views[0].selected, selected, "Delete with a menu open dropped the page selection"); h.key_press(Key::Escape); h.run_steps(3); - assert!(!egui::Popup::is_any_open(&h.ctx), "Escape closed the menu"); + assert!(h.query_by_role(egui::accesskit::Role::Menu).is_none(), "Escape closed the menu"); // The thumbnail's own context menu, the panel keeping the keyboard: Escape closes the menu. h.hover_at(thumb); h.run_steps(1); @@ -2405,11 +2410,11 @@ fn delete_with_a_menu_open_and_escape_closing_a_thumbnail_menu_leave_the_pages_p h.run_steps(1); } h.run_steps(2); - assert!(egui::Popup::is_any_open(&h.ctx), "the thumbnail's menu is open"); + assert!(h.query_by_role(egui::accesskit::Role::Menu).is_some(), "the thumbnail's menu is open"); assert_eq!(h.state().views[0].selected, selected, "the right-click kept the page selection"); h.key_press(Key::Escape); h.run_steps(3); - assert!(!egui::Popup::is_any_open(&h.ctx), "Escape closed the thumbnail's menu"); + assert!(h.query_by_role(egui::accesskit::Role::Menu).is_none(), "Escape closed the thumbnail's menu"); assert_eq!(h.state().views[0].selected, selected, "the Escape that closed the thumbnail's menu dropped the page selection"); assert_eq!(pages(&h), 3); } @@ -2684,12 +2689,12 @@ fn full_screen_takes_no_page_input_until_the_page_is_on_screen() { click_with(&mut h, on_field, Modifiers::NONE); h.run_steps(2); assert!(h.state().views[0].presenting_a_transition(), "the Wipe is still playing"); - assert!(!h.ctx.egui_wants_keyboard_input(), "the field behind the transition isn't opened"); + assert!(h.state().views[0].session.forms.focus.is_none(), "the field behind the transition isn't opened"); frames_until(&mut h, |a| !a.views[0].presenting_a_transition()); h.run_steps(1); click_with(&mut h, on_field, Modifiers::NONE); h.run_steps(4); - assert!(h.ctx.egui_wants_keyboard_input(), "once page 2 is in, the field opens"); + assert_eq!(h.state().views[0].session.forms.focus.as_ref().map(|f| f.name.as_str()), Some("name"), "once page 2 is in, the field opens"); } /// [`FIELD_BEHIND_TRANSITION`] with a Wipe of 0.3 s, shorter than a click may be held. @@ -2724,7 +2729,7 @@ fn full_screen_press_made_during_a_transition_opens_nothing_when_released() { assert!(frames <= 4, "the Wipe ends within a click's time ({frames} frames of 0.1 s)"); h.event(egui::Event::PointerButton { pos: on_field, button: egui::PointerButton::Primary, pressed: false, modifiers: Modifiers::NONE }); h.run_steps(4); - assert!(!h.ctx.egui_wants_keyboard_input(), "released on the field once page 2 is in: nothing opens"); + assert!(h.state().views[0].session.forms.focus.is_none(), "released on the field once page 2 is in: nothing opens"); } /// In full screen a double-click on a note opens its pop-up, and turns no page: the pointer stays