diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 387f40d76b..bdb51f1dd6 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -547,6 +547,13 @@ impl PdfCraftApp { root.sizes = Arc::clone(sizes); // Every parameter dialog lays out as a document dialog: inline captions, shaded groups, buttons across the foot. root.values.set(craft::ui::patterns::form_dialogs::DialogLayout(craft::ui::patterns::form_dialogs::ParamLayout::Document)); + // PdfCraft's looks, opt-in over the framework's defaults: the filled dropdown triangle, shrinking document + // tabs with the modified dot, quiet (ghost) Cancel and Don't Save, and the theme's page insets. + root.values + .set(craft::ui::controls::disclosure::DropdownArrow::Triangle) + .set(craft::ui::tabs::DocumentTabLook::Shrinking) + .set(craft::ui::sections::DialogButtonLook::Quiet) + .set(craft::pages::ui::PageInsets::Theme); root.motion = self.animation_effects; // Today is the session's day, the one its date formats and Fill & Sign's Date tool use: the calendars ring it // and pick it. diff --git a/crates/ui-egui/src/app/prefs.rs b/crates/ui-egui/src/app/prefs.rs index 6f26446826..bfc33c62e4 100644 --- a/crates/ui-egui/src/app/prefs.rs +++ b/crates/ui-egui/src/app/prefs.rs @@ -54,6 +54,9 @@ impl PdfCraftApp { if cfg!(target_os = "linux") { options.middle_button = craft::behavior::MiddleButton::AutoScroll; } + // Production's autoscroll: the speed grows with the pointer's whole distance from the mark, a release inside a + // short hold keeps it running, and it ends when the page view loses the keys. + options.middle_autoscroll = craft::ui::canvas::MiddleAutoscrollFeel::Reader; let eased = !self.animation_effects.reduced(None); options.animated_zoom = eased; options.eased_wheel = eased; diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 5b7cf3b6c4..eff7d08b73 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -10,7 +10,9 @@ use std::sync::Arc; use craft::behavior::{CanvasView, PointerButton, PressPhase, Selection}; use craft::host::queue::{JobQueue, QueueOptions}; -use craft::pages::ui::{PageBody, PageView, PageViewOutput, PageViewState, PlacedPage, TextMark, TextMarks, TextSelectState, TextSelection}; +use craft::pages::ui::{ + GoToPlace, PageBody, PageView, PageViewOutput, PageViewState, PlacedPage, TextMark, TextMarks, TextSelectState, TextSelection, +}; use craft::review::ui::annotate::AnnotateWords; use craft::ui::canvas::{ContextRequest, Momentary, NavigationOptions, PageBorder, PasteboardColor, ToolHost}; use craft::ui::contract::{Props as _, Show as _}; @@ -1722,8 +1724,8 @@ pub fn document_area_at(app: &mut PdfCraftApp, index: usize, rect: Rect, ui: &mu }); 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. - // Full screen filling the screen: the page alone on black, edge to edge (#576), so no shadow either. The framework's - // edge-to-edge spacing (PageView::fill_screen, L-314) is owed; until it lands the page keeps the view's margins. + // Full screen filling the screen: the page alone on black, edge to edge (#576, PageView::fill_screen), so no shadow + // either. let fill_screen = view.fills_screen(); let border = if view.view.page_gaps && app.show_page_edge_shadows && !fill_screen { PageBorder::DropShadow } else { PageBorder::None }; let keep = view.session.presenter.keep_pages(); @@ -1830,6 +1832,9 @@ pub fn document_area_at(app: &mut PdfCraftApp, index: usize, rect: Rect, ui: &mu .border(border) .pasteboard(surround) .keep(&keep) + // Production's Go To: the page gap above the page's top. + .go_to_place(GoToPlace::GapAbove) + .fill_screen(fill_screen) .show_at_with(ui, rect, &mut callbacks, page_before, page_body) }) .inner; @@ -1859,6 +1864,11 @@ pub fn document_area_at(app: &mut PdfCraftApp, index: usize, rect: Rect, ui: &mu } match view.session.pending_page.take() { Some((page, Some(rect))) => view.reveal_rect(page, rect, info), + // A page already on screen in a continuous view (an object selected on it, Set Page Boxes' page) becomes the + // current page where it stands: a Go To would scroll it to the gap above its top (GoToPlace::GapAbove). + Some((page, None)) if view.view.continuous && view.session.placed.iter().any(|placed| placed.page == page) => { + view.view.current = page; + } Some((page, None)) => view.go_to_page(page), None => {} } diff --git a/crates/ui-egui/src/commands/catalog.rs b/crates/ui-egui/src/commands/catalog.rs index 0eb319db15..b9601bd7a5 100644 --- a/crates/ui-egui/src/commands/catalog.rs +++ b/crates/ui-egui/src/commands/catalog.rs @@ -147,7 +147,8 @@ pub(crate) fn command_input(app: &mut PdfCraftApp, ctx: &egui::Context) -> Comma fn state_of(app: &PdfCraftApp, ctx: &egui::Context, command: &CommandRef, gated: bool) -> CommandState { let enabled = enabled(app, ctx, command); - let mut state = CommandState::new().enabled(enabled); + // L-72: on a control whose label shows whole, the tooltip is the hint alone (with the chord), as production's. + let mut state = CommandState::new().enabled(enabled).hint_alone(true); if let Some(checked) = checked(app, command) { state = state.checked(checked); } diff --git a/crates/ui-egui/src/dialogs/signature.rs b/crates/ui-egui/src/dialogs/signature.rs index a53b3b8dd3..b58f22cd5f 100644 --- a/crates/ui-egui/src/dialogs/signature.rs +++ b/crates/ui-egui/src/dialogs/signature.rs @@ -64,6 +64,8 @@ pub(crate) fn ask_lock(app: &mut PdfCraftApp, pending: PendingLock) { .button(PromptChoice::Proceed, tl!("Lock and save").to_string()) .button(PromptChoice::Alternate, tl!("Keep editable").to_string()) .button(PromptChoice::Cancel, tl!("Cancel").to_string()) + // Production's order: Keep editable between Cancel and Lock and save. + .alternate_role(craft::ui::sections::DialogRole::Alternative) .dont_show_again() .tag(id) .instance("lock-signatures"); diff --git a/crates/ui-egui/src/editing/save.rs b/crates/ui-egui/src/editing/save.rs index 7b5fa49131..8881be9c57 100644 --- a/crates/ui-egui/src/editing/save.rs +++ b/crates/ui-egui/src/editing/save.rs @@ -188,7 +188,9 @@ impl PdfCraftApp { .title(tl!("Save over the changed file?").to_string()) .button(PromptChoice::Proceed, tl!("Save anyway").to_string()) .button(PromptChoice::Alternate, tl!("Save as…").to_string()) - .button(PromptChoice::Cancel, tl!("Cancel").to_string()); + .button(PromptChoice::Cancel, tl!("Cancel").to_string()) + // Production's order: Save as… between Cancel and Save anyway. + .alternate_role(craft::ui::sections::DialogRole::Alternative); let prompt = crate::dialogs::host::open(self, prompt); if let Some(pending) = self.pending_save.as_mut().filter(|p| p.key == key) { pending.prompt = Some(prompt); diff --git a/crates/ui-egui/src/home.rs b/crates/ui-egui/src/home.rs index 62180087ca..8a942f5145 100644 --- a/crates/ui-egui/src/home.rs +++ b/crates/ui-egui/src/home.rs @@ -148,6 +148,10 @@ pub fn show(app: &mut PdfCraftApp, ui: &mut egui::Ui) { let (mut view, mut sort) = (app.recent_view, app.recent_sort); let mut screen = StartScreen::new(craft::ui::contract::Bind::bound(&mut view), craft::ui::contract::Bind::bound(&mut sort), &files) .max_recent(app.recent_limit) + // Production's start screen: heading-strength section titles (Clear recent beside Recent) and the pinned + // folders above the recent files. + .heading_sections() + .pinned_first() .offers_new(false) // Open is in the title bar, as in production. .offers_open(false) diff --git a/crates/ui-egui/src/script_dialog.rs b/crates/ui-egui/src/script_dialog.rs index 1c4620e101..4ca9524cec 100644 --- a/crates/ui-egui/src/script_dialog.rs +++ b/crates/ui-egui/src/script_dialog.rs @@ -73,7 +73,8 @@ fn alert_prompt(run: DocId, document: &str, message: &Message) -> (StandardPromp } prompt = prompt.button(PromptChoice::Proceed, if yes_no { tl!("Yes").to_string() } else { tl!("OK").to_string() }); if yes_no { - prompt = prompt.button(PromptChoice::Alternate, tl!("No").to_string()); + // Production's order: No between Cancel and Yes. + prompt = prompt.button(PromptChoice::Alternate, tl!("No").to_string()).alternate_role(craft::ui::sections::DialogRole::Alternative); } // One script runs at a time and its prompt closes before the next opens, so the run names the instance. let prompt = prompt.button(PromptChoice::Cancel, tl!("Cancel").to_string()).instance(("script.prompt", run.0)); diff --git a/crates/ui-egui/src/tools/forms_ui/choice_list.rs b/crates/ui-egui/src/tools/forms_ui/choice_list.rs index ec58c260f2..e41189f286 100644 --- a/crates/ui-egui/src/tools/forms_ui/choice_list.rs +++ b/crates/ui-egui/src/tools/forms_ui/choice_list.rs @@ -2,7 +2,7 @@ use craft::behavior::{DisplayOrder, ItemSource}; // PLAN: assumed `craft::ui::contract::CollectionEvent` re-export of the collection event enum. -use craft::ui::contract::{Bind, CollectionEvent, LeadOnOpen, ShowCollection as _, ShowContainer as _, overlay::Anchor}; +use craft::ui::contract::{Bind, CollectionEvent, LeadOnOpen, Props as _, ShowCollection as _, ShowContainer as _, overlay::Anchor}; use craft::ui::fonts::FontRef; use craft::ui::list::{DocumentRows, List, ListRow}; use craft::ui::popover::{PopupList, PopupListKind}; @@ -52,14 +52,18 @@ pub(super) fn choice_list(ui: &mut egui::Ui, field: &FormField, rect: Rect, zoom }; let names: Vec<&str> = field.options.iter().map(|(_, shown)| shown.as_str()).collect(); let source = Names(&names); + // The popup names its list: the framework routes the field's list keys (arrows, End, Enter) to a named list only. + let list = ui.scope_id().with("pdfcraft.choice-list"); let shown = PopupList::new(tl!("Options"), Bind::bound(&mut *open)) .kind(PopupListKind::Document) .overlay(|overlay| { let dismiss = overlay.dismiss.focus_left(false); overlay.anchor(Anchor::Rect(rect)).dismiss(dismiss) }) + .list(list) .show(ui, |ui, _| { List::::options(tl!("Options")) + .id(list) .lead_on_open(LeadOnOpen::Selected) .document_rows(DocumentRows::new(FontRef::proportional(), size, align)) .show_items(ui, &source, &mut |key, _| ListRow::new(names.get(*key).copied().unwrap_or_default().to_owned()).option()) diff --git a/crates/ui-egui/src/tools/forms_ui/editor.rs b/crates/ui-egui/src/tools/forms_ui/editor.rs index 70791cb177..36dd3c01ce 100644 --- a/crates/ui-egui/src/tools/forms_ui/editor.rs +++ b/crates/ui-egui/src/tools/forms_ui/editor.rs @@ -391,7 +391,10 @@ pub(crate) fn show( let editor = TextEditor::new(f.name.clone(), &mut host, Bind::bound(selection)) .id_salt((f.obj, widget)) .mode(if multiline { EditorMode::FieldLines } else { EditorMode::FieldLine }) - .esc_commits(false); + .esc_commits(false) + // The field's part handed the editor the focus: going back there when the session ends would open the + // field again, so an ended session leaves the focus as production does. + .returns_focus(false); let editor = if f.has(field_flags::PASSWORD) { editor.masked() } else { editor }; let out = ui.push_id((&f.name, f.obj, widget), |ui| editor.show_at(ui, rect)).inner; ended = out.ended; diff --git a/crates/ui-egui/tests/it/forms.rs b/crates/ui-egui/tests/it/forms.rs index fa70697b94..366e0ff835 100644 --- a/crates/ui-egui/tests/it/forms.rs +++ b/crates/ui-egui/tests/it/forms.rs @@ -65,9 +65,9 @@ fn card_count(h: &Harness<'static, PdfCraftApp>) -> usize { toast::cards(&h.ctx, &WindowKey::main()).len() } -/// Whether the "Save changes?" prompt is on screen. +/// Whether the "Save changes?" prompt is on screen: an alert dialog, the framework's role for the question. fn asks_to_save(h: &Harness<'static, PdfCraftApp>) -> bool { - h.query_by(|n| n.role() == egui::accesskit::Role::Dialog && n.label().is_some_and(|l| l.starts_with("Save changes to “"))).is_some() + h.query_by(|n| n.role() == egui::accesskit::Role::AlertDialog && n.label().is_some_and(|l| l.starts_with("Save changes to “"))).is_some() } /// The unsaved-changes question's Save answer in the platform's words (production's wording, on every platform). diff --git a/crates/ui-egui/tests/it/view.rs b/crates/ui-egui/tests/it/view.rs index a09164d580..3ea3f19b37 100644 --- a/crates/ui-egui/tests/it/view.rs +++ b/crates/ui-egui/tests/it/view.rs @@ -2561,7 +2561,9 @@ fn full_screen_esc_from_a_field_closes_the_field_first() { h.key_press(Key::Escape); h.run_steps(4); assert!(h.state().full_screen(), "the first Esc closes the field only"); - assert!(!h.ctx.egui_wants_keyboard_input(), "the field is closed"); + // Full screen hands the keyboard to the page view once nothing holds it, so the closed field is read from the + // session rather than from egui's keyboard claim. + assert!(h.state().views[n].session.forms.focus.is_none(), "the field is closed"); h.key_press(Key::Escape); h.run_steps(4); assert!(!h.state().full_screen(), "the second Esc leaves full screen");