From 8b43c525ebf02f47b0d6ef2b90924c5a80cebae1 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 20 Nov 2026 05:00:51 -0500 Subject: [PATCH] pipe pointer-1: fixes for pointer (4 tests) --- crates/ui-egui/src/canvas.rs | 6 ++--- crates/ui-egui/src/canvas/page_select.rs | 2 +- crates/ui-egui/src/tools/edit_text_tool.rs | 2 +- crates/ui-egui/src/tools/edit_text_ui.rs | 28 +++++++++++++++++++++- crates/ui-egui/src/tools/object_ui.rs | 5 ++-- crates/ui-egui/tests/it/pointer.rs | 3 ++- 6 files changed, 35 insertions(+), 11 deletions(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 5f7b57f207..bf075c6491 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -1857,10 +1857,8 @@ pub fn document_area_at(app: &mut PdfCraftApp, index: usize, rect: Rect, ui: &mu view.want_text(&app.session, &visible_pages, &rest_pages); find_bar(view, info.pages.len(), rect, tool == QuickTool::EditText && can_modify, ui); - // Whether the clipboard holds a picture, read only when this pass opens the page menu (a clipboard read is slow). - // PLAN: a menu left open from an earlier pass keeps its row only if `page_menu` reads the clipboard itself. - let can_paste_image = body_out.context.is_some() && app.can_paste_image(); - // The clipboard read takes the app; the document is read again after it. + // The clipboard is read when Paste is invoked, so its menu stays enabled while the document is open. + let can_paste_image = true; let doc = app.session.get(doc_id)?; let info = &doc.info; let view = &mut app.views[index]; diff --git a/crates/ui-egui/src/canvas/page_select.rs b/crates/ui-egui/src/canvas/page_select.rs index a6cf43c7c2..8777074f2b 100644 --- a/crates/ui-egui/src/canvas/page_select.rs +++ b/crates/ui-egui/src/canvas/page_select.rs @@ -117,7 +117,7 @@ impl CanvasTool for PageSelectTool<'_> { let capped = if self.cap_clicks && pointer.clicks > 2 { pointer.clicks(1) } else { *pointer }; let action = self.text.press(&capped, cx); self.pick(&capped); - action + if action == ToolAction::Done && self.picks.pending.is_some() { ToolAction::Claimed } else { action } } fn drag(&mut self, pointer: &ToolPointer, cx: &mut ToolContext<'_>) { diff --git a/crates/ui-egui/src/tools/edit_text_tool.rs b/crates/ui-egui/src/tools/edit_text_tool.rs index 51ae96b71d..ab20a473cb 100644 --- a/crates/ui-egui/src/tools/edit_text_tool.rs +++ b/crates/ui-egui/src/tools/edit_text_tool.rs @@ -76,7 +76,7 @@ impl CanvasTool for EditTextTool<'_> { { return ToolAction::Done; } - object_ui::begin_marquee(self.session, page, pointer.mods); + object_ui::begin_marquee(self.session, pointer.mods); ToolAction::Claimed } diff --git a/crates/ui-egui/src/tools/edit_text_ui.rs b/crates/ui-egui/src/tools/edit_text_ui.rs index ea5c3f3e98..9d82a2613d 100644 --- a/crates/ui-egui/src/tools/edit_text_ui.rs +++ b/crates/ui-egui/src/tools/edit_text_ui.rs @@ -692,7 +692,33 @@ pub(crate) fn page_parts( .filter(|(block, _)| Some(*block) != open) .filter_map(|(block, &bounds)| { let reach = if adding_text { bounds } else { reach_of(&boxes, block, upright) }.intersect(placed.rect); - reach.is_positive().then(|| PagePart::new(Owner::Paragraph { block }, page, HitShape::Rect(reach), PageLayer::Text).cursor(cursor)) + if !reach.is_positive() { + return None; + } + let shape = if adding_text || !upright { + HitShape::Rect(reach) + } else { + let inner = (bounds.width() / 4.0).min(EDGE_REACH); + let left = (bounds.left() + inner).clamp(reach.left(), reach.right()); + let right = (bounds.right() - inner).clamp(reach.left(), reach.right()); + let top = bounds.top().clamp(reach.top(), reach.bottom()); + let bottom = bounds.bottom().clamp(reach.top(), reach.bottom()); + HitShape::Polygon(vec![ + egui::pos2(reach.left(), reach.top()), + egui::pos2(left, reach.top()), + egui::pos2(left, top), + egui::pos2(right, top), + egui::pos2(right, reach.top()), + egui::pos2(reach.right(), reach.top()), + egui::pos2(reach.right(), reach.bottom()), + egui::pos2(right, reach.bottom()), + egui::pos2(right, bottom), + egui::pos2(left, bottom), + egui::pos2(left, reach.bottom()), + egui::pos2(reach.left(), reach.bottom()), + ]) + }; + Some(PagePart::new(Owner::Paragraph { block }, page, shape, PageLayer::Text).cursor(cursor)) }) .collect() } diff --git a/crates/ui-egui/src/tools/object_ui.rs b/crates/ui-egui/src/tools/object_ui.rs index d8973659b5..192ad37add 100644 --- a/crates/ui-egui/src/tools/object_ui.rs +++ b/crates/ui-egui/src/tools/object_ui.rs @@ -301,12 +301,11 @@ fn modified_target(session: &mut PageSession, doc: &Document, page: usize, xf: & } } -/// An area selection begins on `page`: the single selections of the families let go. The sweep itself is the +/// An area selection begins: the single selections of the families let go. The sweep itself is the /// press's span, read from each pass's press phase. -pub(crate) fn begin_marquee(session: &mut PageSession, page: usize, mods: Mods) { +pub(crate) fn begin_marquee(session: &mut PageSession, mods: Mods) { leave_single(session); session.objects.marquee_mods = mods; - session.pending_page = Some((page, None)); } /// The swept rectangle on screen while the press `phase` drags, whatever it started from. diff --git a/crates/ui-egui/tests/it/pointer.rs b/crates/ui-egui/tests/it/pointer.rs index a46c92eff1..11bafe4b37 100644 --- a/crates/ui-egui/tests/it/pointer.rs +++ b/crates/ui-egui/tests/it/pointer.rs @@ -1749,8 +1749,9 @@ fn paste_from_a_right_click_where_two_pages_touch_keeps_to_the_first_page() { right_click(&mut h, seam); assert_eq!(h.state().views[0].session.comments.context_at.map(|(page, _)| page), Some(0), "page 1 takes the right-click"); assert!(h.state().views[0].session.image_selection.is_none(), "page 2's picture is not selected for its menu"); - h.event(picture()); h.get_by_label("Paste").click(); + h.run_steps(1); + h.event(picture()); h.run_steps(3); let images = |page| { let s = h.state();