PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust
Merge origin/main into fix/document-properties-layout
alehel16d2b2ef50eb
diff --cc crates/ui-egui/tests/it/dialog_chrome.rsindex ce8c9d5a6,57f549305..b6be218ec--- a/crates/ui-egui/tests/it/dialog_chrome.rs+++ b/crates/ui-egui/tests/it/dialog_chrome.rs@@@ -103,118 -96,3 +103,118 @@@ fn document_properties_long_filename_dolet card = card(&h, "dialog");assert!(card.width() <= 700.0, "dialog card should not blow out horizontally on long filename, width was: {}", card.width());}++#[test]+fn document_properties_values_line_up_and_long_fields_wrap() {+ let info = "<< /Title (Showcase) /Subject (A specimen document exercising typography, world scripts, vector art, forms and annotations) /Creator (demo-pdf) >>";+ let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(move |_cc| {+ let mut app = PdfCraftApp::new();+ app.set_option("language", "en").unwrap();+ app.open_bytes("doc.pdf", None, fixture_with_info(Some(info))).unwrap();+ app.set_option("dialog", "properties").unwrap();+ app+ });+ h.run_steps(4);+ let card = card(&h, "dialog");+ let title = h.get_by_role_and_label(Role::TextInput, "Title").rect();+ // The fields reach the card's padding instead of stopping short of it.+ assert!(card.right() - title.right() <= 24.0, "title field {title:?} in {card:?}");+ // Plain values start where the fields' text does.+ for value in ["doc.pdf", "demo-pdf"] {+ // The file name is also the document tab's label.+ let v = h.query_all_by_label(value).map(|n| n.rect()).find(|r| card.contains_rect(*r)).unwrap_or_else(|| panic!("{value} in the dialog"));+ assert!((v.left() - (title.left() + 10.0)).abs() <= 1.0, "{value} at {v:?}, title field {title:?}");+ }+ // A long subject wraps onto a second line rather than running past the field's edge.+ let subject = h.get_by_role_and_label(Role::MultilineTextInput, "Subject").rect();+ assert!(subject.height() > title.height() + 8.0, "subject field {subject:?}, title field {title:?}");+}++#[test]+fn space_audit_tab_measures_the_file_and_stays_in_the_card() {+ use pdfcraft_ui_egui::{Dialog, PropsTab};+ let open = |dialog: Dialog| {+ let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(move |_cc| {+ let mut app = PdfCraftApp::new();+ app.set_option("language", "en").unwrap();+ app.open_bytes("doc.pdf", None, fixture()).unwrap();+ app.dialog = Some(dialog);+ app+ });+ h.run_steps(4);+ h+ };+ let fonts = card(&open(Dialog::Properties(PropsTab::Fonts)), "dialog");+ // The tab is reachable by name, like the other Properties tabs.+ let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(|_cc| {+ let mut app = PdfCraftApp::new();+ app.set_option("language", "en").unwrap();+ app.open_bytes("doc.pdf", None, fixture()).unwrap();+ app.set_option("dialog", "space-audit").unwrap();+ app+ });+ h.run_steps(4);+ assert_eq!(h.state().dialog, Some(Dialog::Properties(PropsTab::SpaceAudit)));+ assert!(!h.state().space_audit.is_empty(), "the tab measures the file when it opens");+ h.get_by_label("Total");+ // Switching tabs keeps the dialog the same size, and the table stays inside its padding,+ // in the tab and in the Optimizer's own Audit Space Usage dialog.+ let tab = card(&h, "dialog");+ assert!((tab.width() - fonts.width()).abs() < 0.5, "space audit card {tab:?}, fonts card {fonts:?}");+ for h in [h, open(Dialog::AuditSpace)] {+ let card = card(&h, "dialog");+ let pct = h.get_by_label("Percentage").rect();+ assert!(pct.right() <= card.right() - 16.0, "Percentage {pct:?} in {card:?}");+ }+}++#[test]+fn dialog_buttons_follow_the_content_after_a_taller_tab() {+ use pdfcraft_ui_egui::{Dialog, PropsTab};+ let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(|_cc| {+ let mut app = PdfCraftApp::new();+ app.set_option("language", "en").unwrap();+ app.open_bytes("doc.pdf", None, fixture()).unwrap();+ app.dialog = Some(Dialog::Properties(PropsTab::InitialView));+ app+ });+ h.run_steps(4);+ h.state_mut().dialog = Some(Dialog::Properties(PropsTab::Description));+ h.run_steps(4);+ // The card shrinks back to the shorter tab: Close sits under the last row, not halfway+ // down the room the taller tab left behind.+ let last = h.get_by_label("PDF producer").rect();+ let close = h.get_by_role_and_label(Role::Button, "Close").rect();+ assert!(close.top() - last.bottom() <= 40.0, "Close {close:?} under the last row {last:?}");+ let card = card(&h, "dialog");+ assert!(card.bottom() - close.bottom() <= 24.0, "Close {close:?} at the foot of {card:?}");+}++#[test]+fn page_hover_cursors_stay_off_while_a_dialog_is_open() {+ let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(|_cc| {+ let mut app = PdfCraftApp::new();+ app.set_option("language", "en").unwrap();- app.open_bytes("form.pdf", None, include_bytes!("data/form.pdf").to_vec()).unwrap();++ app.open_bytes("form.pdf", None, include_bytes!("../data/form.pdf").to_vec()).unwrap();+ // Small enough that the check box sits above the dialog card.+ app.set_option("zoom", "100").unwrap();+ app+ });+ for _ in 0..30 {+ h.run_steps(2);+ }+ // The middle of the "agree" check box (/Rect [20 310 36 326] on a 300 × 400 page).+ let page = h.state().views[0].page_screen_rect(0).expect("on screen");+ let k = page.width() / 300.0;+ let check = page.min + egui::vec2(28.0 * k, (400.0 - 318.0) * k);+ h.hover_at(check);+ h.run_steps(2);+ assert_eq!(h.output().platform_output.cursor_icon, egui::CursorIcon::PointingHand, "the check box takes clicks");+ h.state_mut().set_option("dialog", "security").unwrap();+ h.run_steps(4);+ let card = card(&h, "dialog");+ assert!(!card.contains(check), "the check box {check:?} is beside the dialog {card:?}, under its backdrop");+ h.hover_at(check + egui::vec2(1.0, 0.0));+ h.run_steps(2);+ assert_eq!(h.output().platform_output.cursor_icon, egui::CursorIcon::Default, "nothing under the dialog's backdrop can be clicked");+}diff --cc parity/acrobat-features.tomlindex ac182f822,362c2aa77..b296ee2b4--- a/parity/acrobat-features.toml+++ b/parity/acrobat-features.toml@@@ -3436,8 -3448,8 +3448,8 @@@ milestone = "M3status = "shipped"commands = ["file.properties"]tools = ["doc_info"]- evidence = ["crates/ui-egui/tests/editing.rs::document_properties_edit_is_one_undoable_step", "crates/ui-egui/tests/editing.rs::cancelling_properties_discards_the_draft", "crates/ui-egui/tests/dialog_chrome.rs::document_properties_values_line_up_and_long_fields_wrap", "crates/ui-egui/tests/dialog_chrome.rs::space_audit_tab_measures_the_file_and_stays_in_the_card"]-evidence = ["crates/ui-egui/tests/it/editing.rs::document_properties_edit_is_one_undoable_step", "crates/ui-egui/tests/it/editing.rs::cancelling_properties_discards_the_draft"]-notes = ""++evidence = ["crates/ui-egui/tests/it/editing.rs::document_properties_edit_is_one_undoable_step", "crates/ui-egui/tests/it/editing.rs::cancelling_properties_discards_the_draft", "crates/ui-egui/tests/it/dialog_chrome.rs::document_properties_values_line_up_and_long_fields_wrap", "crates/ui-egui/tests/it/dialog_chrome.rs::space_audit_tab_measures_the_file_and_stays_in_the_card"]+notes = "Description, Initial View, Security, Fonts and Advanced, plus a Space Audit tab Acrobat does not have (its audit is only in the PDF Optimizer); the audit runs when the tab opens and again after an edit. No Custom tab (organize.custom-properties)"[[feature]]id = "organize.edit-metadata"@@@ -7596,8 -7625,8 +7625,8 @@@ milestone = "M11status = "shipped"commands = ["optimize.advanced"]tools = ["doc_audit_space"]- evidence = ["crates/optimize/tests/optimize.rs::space_audit_shares_the_file_out_by_kind", "crates/optimize/tests/optimize.rs::space_audit_counts_what_fields_and_comments_draw_with_by_kind", "crates/optimize/tests/optimize.rs::space_audit_survives_deeply_nested_forms", "crates/automation/tests/automation.rs::auditing_space_through_tools", "crates/ui-egui/tests/viewer.rs::optimizer_audits_space_usage", "crates/ui-egui/tests/viewer.rs::space_audit_numbers_line_up_under_their_headers"]+ evidence = ["crates/optimize/tests/optimize.rs::space_audit_shares_the_file_out_by_kind", "crates/optimize/tests/optimize.rs::space_audit_counts_what_fields_and_comments_draw_with_by_kind", "crates/optimize/tests/optimize.rs::space_audit_survives_deeply_nested_forms", "crates/automation/tests/it/automation.rs::auditing_space_through_tools", "crates/ui-egui/tests/it/viewer.rs::optimizer_audits_space_usage", "crates/ui-egui/tests/it/viewer.rs::space_audit_numbers_line_up_under_their_headers"]-notes = "PDF Optimizer ▸ Audit space usage: what the file's bytes are spent on now (not what optimizing would save), in 16 categories (images, content streams, fonts, X Object forms, structure, bookmarks, thumbnails, comments, forms, named destinations, colour spaces, shadings, patterns, graphics states, embedded files, overhead) with bytes and percentages. Resources are counted by kind wherever they are used, so the fonts and images form fields and comments draw with count as fonts and images. Still missing: sizes are each object as it would be written uncompressed, so objects packed in compressed object streams count larger than they take on disk (overhead, the rest of the file, shrinks to match)"+notes = "PDF Optimizer ▸ Audit space usage, and Document Properties ▸ Space Audit: what the file's bytes are spent on now (not what optimizing would save), in 16 categories (images, content streams, fonts, X Object forms, structure, bookmarks, thumbnails, comments, forms, named destinations, colour spaces, shadings, patterns, graphics states, embedded files, overhead) with bytes and percentages. Resources are counted by kind wherever they are used, so the fonts and images form fields and comments draw with count as fonts and images. Still missing: sizes are each object as it would be written uncompressed, so objects packed in compressed object streams count larger than they take on disk (overhead, the rest of the file, shrinks to match)"[[feature]]id = "optimize.optimizer-presets"