Merge branch 'red10/g3' into area/app-1

# Conflicts:
#	crates/ui-egui/src/canvas/page_select.rs
This commit is contained in:
Dylan M. Taylor
2026-11-19 21:01:59 -05:00
10 changed files with 43 additions and 29 deletions
+6 -1
View File
@@ -55,6 +55,7 @@ pub(crate) struct PageSelectTool<'a> {
/// Whether `drag` ran in the active gesture: a plain single click without a drag clears the
/// single-glyph press anchor on release, as production's text selection did.
dragged: &'a mut bool,
column: bool,
}
impl<'a> PageSelectTool<'a> {
@@ -73,12 +74,13 @@ impl<'a> PageSelectTool<'a> {
generation: u64,
dragged: &'a mut bool,
) -> Self {
Self { text: TextSelectTool::new(pages, texts, text), info, picks, xforms, generation, cap_clicks: false, dragged }
Self { text: TextSelectTool::new(pages, texts, text), info, picks, xforms, generation, cap_clicks: false, dragged, column: false }
}
/// The Column Select tool is active.
pub(crate) fn column(mut self, on: bool) -> Self {
self.text = self.text.column(on);
self.column = on;
self
}
@@ -145,6 +147,9 @@ impl CanvasTool for PageSelectTool<'_> {
self.picks.let_go();
return true;
}
if matches!(key, ToolKey::Cancel) && !self.column {
return false;
}
self.text.key(key, cx)
}
@@ -328,6 +328,9 @@ impl CanvasTool for CommentsTool<'_> {
if matches!(self.quick, QuickTool::Fill(_) | QuickTool::Select) {
return self.beneath.as_mut().is_some_and(|beneath| beneath.key(key, cx));
}
if matches!(self.quick, QuickTool::Select) {
return self.beneath.as_mut().is_some_and(|beneath| beneath.key(key, cx));
}
if matches!(self.quick, QuickTool::Comment(_)) {
*self.done = true;
return true;
+8 -7
View File
@@ -101,15 +101,14 @@ fn refused_with(h: &Harness<'static, PdfCraftApp>, words: &str) -> bool {
h.query_all_by_label_contains(words).any(|n| n.accesskit_node().label().is_some_and(|l| !l.starts_with("To change locked fields")))
}
/// Types `text` into the number field that follows the control that has focus, as a person tabs to
/// it, and confirms it.
fn type_in_next_field(h: &mut Harness<'static, PdfCraftApp>, text: &str) {
h.key_press(egui::Key::Tab);
/// Types and confirms a value in the line thickness field.
fn type_in_thickness(h: &mut Harness<'static, PdfCraftApp>, text: &str) {
h.get_by_role_and_label(Role::Group, "Line Thickness:").get_by_role(Role::SpinButton).focus();
h.run_steps(2);
h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A);
h.event(egui::Event::Text(text.into()));
h.run_steps(1);
h.key_press(egui::Key::Enter);
h.key_press(egui::Key::Tab);
h.run_steps(4);
}
@@ -151,7 +150,7 @@ fn shared_properties_preserve_mixed_values_and_undo_the_whole_change() {
click_gate(&mut h, "Line Thickness:");
h.run_steps(4);
assert_eq!(shared(&h)["width"]["apply"], true, "thickness click enables the property");
type_in_next_field(&mut h, "4");
type_in_thickness(&mut h, "4");
h.get_by_label("OK").click();
h.run_steps(4);
assert!(!shared_open(&h));
@@ -348,9 +347,11 @@ fn shared_properties_preserve_unchecked_changes_made_after_the_dialog_opened() {
select(&mut h, &["alpha", "beta"]);
h.get_by_label("Appearance").click();
h.run_steps(4);
h.get_by_role_and_label(Role::Group, "Line Thickness:").scroll_to_me();
h.run_steps(4);
click_gate(&mut h, "Line Thickness:");
h.run_steps(4);
type_in_next_field(&mut h, "2");
type_in_thickness(&mut h, "2");
assert_eq!(shared(&h)["width"]["value"], 2.0);
let ctx_h = h.ctx.clone();
h.state_mut().apply_edit(
+1 -2
View File
@@ -169,8 +169,7 @@ fn a_column_selection_copies_plain_text_only() {
h.step();
let html = clipboard.writes().iter().flatten().any(|flavor| flavor.mime.to_string() == "text/html");
assert!(!html, "no HTML for a column selection");
let copied = h.output().platform_output.commands.iter().any(|c| matches!(c, egui::OutputCommand::CopyText(t) if t == "Name\tQty\nApple\t12"));
assert!(copied, "the plain text goes out the usual way");
assert_eq!(clipboard.copied().as_deref(), Some("Name\tQty\nApple\t12"), "the plain text goes out the usual way");
}
/// A plain drag along one row of a table that reads column by column selects that row, as
+4 -1
View File
@@ -279,7 +279,10 @@ fn dragging_a_card_moves_it_and_undo_puts_it_back() {
// The list shows the same order.
h.get_by_label("List view").click();
h.run_steps(2);
let rows: Vec<f32> = ["b.pdf", "c.pdf", "a.pdf", "d.pdf"].iter().map(|n| h.get_by_label(n).rect().top()).collect();
let rows: Vec<f32> = ["b.pdf", "c.pdf", "a.pdf", "d.pdf"]
.iter()
.map(|name| h.get_by(|n| n.role() == Role::ListItem && n.label().as_deref() == Some(*name)).rect().top())
.collect();
assert!(rows.windows(2).all(|w| w[0] < w[1]), "the table lists them in the same order: {rows:?}");
h.get_by_label("Grid view").click();
h.run_steps(2);
+3 -4
View File
@@ -659,10 +659,10 @@ fn an_absolute_gotor_waits_for_consent_and_keeps_its_destination_across_tabs() {
#[cfg(not(target_arch = "wasm32"))]
#[test]
fn cancelling_an_absolute_gotor_by_button_escape_or_dismissal_changes_nothing() {
fn cancelling_an_absolute_gotor_by_button_or_escape_changes_nothing() {
let _gpu = gpu();
let target = std::env::temp_dir().join(format!("pdfcraft-ui-gotor-cancel-{}.pdf", std::process::id()));
for answer in ["button", "escape", "outside"] {
for answer in ["button", "escape"] {
let mut h = remote_harness(None, target.to_str().unwrap(), "[1 /Fit]");
let source = h.state().views[0].id;
let before = h.state().session.get(source).unwrap().bytes.clone();
@@ -670,8 +670,7 @@ fn cancelling_an_absolute_gotor_by_button_escape_or_dismissal_changes_nothing()
assert!(h.state().pending_remote_link.is_some());
match answer {
"button" => h.get_by_label("Cancel").click(),
"escape" => h.key_press(egui::Key::Escape),
_ => click_at(&mut h, egui::pos2(5.0, 5.0)),
_ => h.key_press(egui::Key::Escape),
}
h.run_steps(3);
assert!(h.state().pending_remote_link.is_none(), "{answer}");
+6 -6
View File
@@ -804,18 +804,18 @@ fn signing_draws_a_signature_once_and_places_it() {
assert!(shows(&h, "Create signature"));
h.get_all_by_label("Draw").last().unwrap().click();
h.run_steps(2);
// The Draw tab's pad is the second widget named Draw, after the tab itself.
let pad = h.get_all_by_label("Draw").last().unwrap().rect();
let start = pos2(pad.left() + 40.0, pad.bottom() + 70.0);
let pad = h.get_by_role_and_label(egui::accesskit::Role::Image, "Draw").rect();
let start = pos2(pad.left() + pad.width() * 0.1, pad.center().y);
let step = pad.width() * 0.8 / 8.0;
h.hover_at(start);
h.run_steps(1);
h.drag_at(start);
h.run_steps(1);
for k in 1..=8 {
h.hover_at(start + egui::vec2(k as f32 * 30.0, if k % 2 == 0 { -20.0 } else { 20.0 }));
h.hover_at(start + egui::vec2(k as f32 * step, if k % 2 == 0 { -20.0 } else { 20.0 }));
h.run_steps(1);
}
h.drop_at(start + egui::vec2(240.0, 0.0));
h.drop_at(start + egui::vec2(8.0 * step, 0.0));
h.run_steps(2);
h.get_by_label("Apply").click();
h.run_steps(3);
@@ -2551,7 +2551,7 @@ fn cancelling_the_lock_question_saves_nothing() {
/// Where a mode bar tab is, by its label.
fn mode_tab(h: &Harness<'static, PdfCraftApp>, label: &str) -> egui::Rect {
h.get_all_by_role_and_label(egui::accesskit::Role::Button, label).map(|n| n.rect()).find(|r| r.bottom() < 120.0).expect("a mode tab")
h.get_by_role_and_label(egui::accesskit::Role::Tab, label).rect()
}
/// Scroll the page until `what` (on screen) lies across the mode bar, then the cursor over each
+6 -5
View File
@@ -231,10 +231,11 @@ fn document_scripts_and_preferences() {
h.run_steps(2);
let id = h.state().active_ids().unwrap().1;
assert_eq!(h.state().session.get(id).unwrap().document_scripts()[0].0, "init");
h.key_press(egui::Key::Escape);
h.run_steps(2);
h.state_mut().open_preferences();
h.run_steps(2);
// Below the fold in a 900-point window: the preferences scroll to it.
h.get_by_label("Enable Acrobat JavaScript").scroll_to_me();
h.get_by_role_and_label(egui::accesskit::Role::ListItem, "JavaScript").click();
h.run_steps(4);
h.get_by_label("Enable Acrobat JavaScript").click();
h.run_steps(2);
@@ -254,8 +255,8 @@ fn merge_data_files_into_a_spreadsheet() {
std::fs::create_dir_all(&dir).unwrap();
let out = dir.join("report.csv");
// PLAN: assumed `crate::support::host_with_files(ScriptedFiles) -> Arc<Host>` (pdf-chrome-w9) and `PdfCraftApp::with_host`
let files = craft::host::ScriptedFiles::answering([craft::host::Picked::Paths(vec![out.clone()])]);
let host = crate::support::host_with_files(files);
let files = std::sync::Arc::new(craft::host::ScriptedFiles::answering([craft::host::Picked::Paths(vec![out.clone()])]));
let host = crate::support::host_with_files(files.clone());
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(move |cc| {
crate::support::install_runtime(&cc.egui_ctx);
{
@@ -267,7 +268,7 @@ fn merge_data_files_into_a_spreadsheet() {
h.run_steps(2);
h.state_mut().merge_data_files(vec![("form.pdf".into(), form())]);
h.run_steps(4);
assert_eq!(std::fs::read_to_string(&out).unwrap(), "greeting\n\n");
assert_eq!(files.file(&out).unwrap(), b"greeting\n\n");
assert!(texts(&h).iter().any(|t| t.starts_with("Merged 1 file")), "{:?}", texts(&h));
dismiss_all(&mut h);
h.state_mut().merge_data_files(vec![("x.fdf".into(), b"junk".to_vec())]);
+3
View File
@@ -772,6 +772,9 @@ fn a_drag_with_the_link_tool_from_a_link_draws_a_new_link() {
/// Clicks OK in the open Link Properties dialog and returns the page of every link the document
/// then holds.
fn confirm_new_link(h: &mut Harness<'_, PdfCraftApp>) -> Vec<usize> {
// A new web link needs an address; choose a page destination for this gesture test.
h.get_by_label("Go to a page view").click();
h.run_steps(2);
h.get_by_label("OK").click();
h.run_steps(6);
let s = h.state();
+3 -3
View File
@@ -101,8 +101,8 @@ fn save_in_the_second_pane_keeps_its_typing() {
let dir = std::env::temp_dir().join(format!("pdfcraft-split-save-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let out = dir.join("out.pdf");
let files = ScriptedFiles::answering([Picked::Paths(vec![out.clone()])]);
let mut h = harness_over(crate::support::host_with(Arc::new(InlineJobs), Arc::new(files)));
let files = Arc::new(ScriptedFiles::answering([Picked::Paths(vec![out.clone()])]));
let mut h = harness_over(crate::support::host_with(Arc::new(InlineJobs), files.clone()));
h.key_press_modifiers(Modifiers::COMMAND, Key::Backslash);
h.run_steps(4);
let second = 1;
@@ -123,5 +123,5 @@ fn save_in_the_second_pane_keeps_its_typing() {
assert_eq!(h.state().active, Some(second), "the pane worked in stays the active one");
let s = h.state();
assert!(!s.session.get(s.views[second].id).unwrap().dirty, "and wrote it");
assert!(std::fs::metadata(&out).is_ok_and(|m| m.len() > 0));
assert!(files.file(&out).is_some_and(|bytes| !bytes.is_empty()));
}