From 7b53a47250a014e8166520ca62e56af692e9290b Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Thu, 19 Nov 2026 23:48:00 -0500 Subject: [PATCH] pipe fill_sign-2: fixes for fill_sign (7 tests) --- crates/ui-egui/src/tools/comments/bridge.rs | 3 ++- crates/ui-egui/src/tools/fill_sign.rs | 15 +++++++++------ crates/ui-egui/tests/it/fill_sign.rs | 13 +++++-------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/crates/ui-egui/src/tools/comments/bridge.rs b/crates/ui-egui/src/tools/comments/bridge.rs index 7c8892b921..6574d08f6b 100644 --- a/crates/ui-egui/src/tools/comments/bridge.rs +++ b/crates/ui-egui/src/tools/comments/bridge.rs @@ -447,7 +447,8 @@ pub(crate) fn parts( return vec![PagePart::new(owner, page, shape, PageLayer::Comment).context_only()]; } let tip = tips(info, prefs, tool).into_iter().find(|(t, _)| *t == id).map(|(_, tip)| tip); - let part = PagePart::new(owner, page, shape, PageLayer::Comment).passes_drag().cursor(icon); + let layer = if engine(info, page, index).is_some_and(|a| a.fill_sign) { PageLayer::Placed } else { PageLayer::Comment }; + let part = PagePart::new(owner, page, shape, layer).passes_drag().cursor(icon); vec![match tip { Some(tip) => part.tip_now(tip), None => part, diff --git a/crates/ui-egui/src/tools/fill_sign.rs b/crates/ui-egui/src/tools/fill_sign.rs index 97bc52038d..0773314fab 100644 --- a/crates/ui-egui/src/tools/fill_sign.rs +++ b/crates/ui-egui/src/tools/fill_sign.rs @@ -14,7 +14,7 @@ use craft::ui::contract::{ActivateOn, Bind, CollectionEvent, Props as _, SelectM use craft::ui::list::ThumbAspect; use craft::ui::primitives::Draw; use craft::ui::style::DataColor; -use craft::ui::tile_grid::{Tile, TileActionPlace, TileGrid}; +use craft::ui::tile_grid::{Tile, TileActionPlace, TileGrid, TilePartEvent}; use egui::Pos2; use pdfcraft_engine::{BorderShape, Edit, FillMark, NewAnnotation, Rgb, Shape, Style}; use pdfcraft_render::{DocInfo, PageInfo}; @@ -549,13 +549,16 @@ pub(crate) fn signature_entries(ui: &mut egui::Ui, app: &mut crate::PdfCraftApp) .thumb(ThumbAspect::new(3, 1), move |cx, rect| { cx.with_draw(|draw| paint_signature(cx.painter.ctx(), draw, rect, saved, DataColor::new(cx.ink()))); }) - .action(IconId::new("pencil"), CommandRef::new(slot.change_id)) - .action(IconId::new("x"), CommandRef::new(slot.remove_id)) + .action_named(IconId::new("pencil"), CommandRef::new(slot.change_id), ctx_less_label("Change {what}", slot.what)) + .action_named(IconId::new("x"), CommandRef::new(slot.remove_id), ctx_less_label("Remove saved {what}", slot.what)) }); for event in out.response.events { - if let CollectionEvent::Activate(key) = event { - command = shown.get(key).map(|s| s.use_id); - } + command = match event { + CollectionEvent::Activate(key) => shown.get(key).map(|s| s.use_id), + CollectionEvent::Item(key, TilePartEvent::Action(0)) => shown.get(key).map(|s| s.change_id), + CollectionEvent::Item(key, TilePartEvent::Action(1)) => shown.get(key).map(|s| s.remove_id), + _ => command, + }; } command } diff --git a/crates/ui-egui/tests/it/fill_sign.rs b/crates/ui-egui/tests/it/fill_sign.rs index 06b2d831c4..8e3b1d8ee3 100644 --- a/crates/ui-egui/tests/it/fill_sign.rs +++ b/crates/ui-egui/tests/it/fill_sign.rs @@ -2024,10 +2024,10 @@ fn settle_scan(h: &mut Harness<'static, PdfCraftApp>) -> bool { /// Draw a new scan frame on the pad's photo from one point of the photo (800 × 600) to another. fn drag_frame(h: &mut Harness<'static, PdfCraftApp>, from: (f32, f32), to: (f32, f32)) -> bool { let area = h.get_by_label("Photo").rect(); - let fit = area.shrink(8.0); - let scale = (fit.width() / 800.0).min(fit.height() / 600.0); - let origin = fit.center() - egui::vec2(400.0, 300.0) * scale; - let to_screen = |p: (f32, f32)| origin + egui::vec2(p.0, p.1) * scale; + let mut view = craft::behavior::CanvasView::new(area, craft::behavior::kurbo::Point::ORIGIN, 1.0); + let target = craft::ui::canvas::ViewTarget::new(craft::behavior::kurbo::Size::new(800.0, 600.0)); + craft::ui::canvas::ViewCommands::FitOnScreen.apply(&mut view, &target, None, h.ctx.pixels_per_point()); + let to_screen = |p: (f32, f32)| view.to_screen(craft::behavior::kurbo::Point::new(f64::from(p.0), f64::from(p.1))); let (a, b) = (to_screen(from), to_screen(to)); h.hover_at(a); h.run_steps(1); @@ -2785,10 +2785,7 @@ fn typing_a_fill_text_size_that_rounds_to_the_stored_one_adds_no_undo_step() { h.get_by_label("Font size").click(); h.run_steps(2); let type_size = |h: &mut Harness<'static, PdfCraftApp>, value: &str| { - h.query_all_by_role(egui::accesskit::Role::SpinButton) - .find(|n| n.value().is_some_and(|v| v.ends_with(" pt"))) - .expect("the Font size control") - .click(); + h.get_by_role_and_label(egui::accesskit::Role::SpinButton, "Font size").click(); h.run_steps(2); h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A); h.event(egui::Event::Text(value.into()));