From 528ede465fe1bd7f55f6daf6c3d4f66c3e1cf051 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 22 Nov 2026 03:01:54 -0500 Subject: [PATCH] Chrome look: floating tools stay with hidden window UI, search layout, bookmarks empty state, mode bar order, Save pages primary, tool panel heading --- crates/ui-egui/src/canvas/organize.rs | 2 +- crates/ui-egui/src/chrome/mode_bar.rs | 7 ++++--- crates/ui-egui/src/panels/bookmarks.rs | 8 +++++++- crates/ui-egui/src/panels/search_ui.rs | 13 +++++++++---- crates/ui-egui/src/panels/side_panels.rs | 18 +++++++++++++----- crates/ui-egui/tests/it/editing.rs | 2 +- crates/ui-egui/tests/it/viewer.rs | 3 +++ crates/ui-egui/tests/it/viewer_prefs.rs | 20 ++++++++++++++++++-- 8 files changed, 56 insertions(+), 17 deletions(-) diff --git a/crates/ui-egui/src/canvas/organize.rs b/crates/ui-egui/src/canvas/organize.rs index 93ca72c29c..b445ea44d3 100644 --- a/crates/ui-egui/src/canvas/organize.rs +++ b/crates/ui-egui/src/canvas/organize.rs @@ -167,7 +167,7 @@ pub(super) fn organize_grid(view: &mut DocView, doc: &pdfcraft_engine::Document, // What the grid shows is what is saved. // PLAN: assumed `Props::tooltip(impl Into)` and `TooltipSpec -> Tooltip`. let hint = craft::ui::contract::TooltipSpec::new(tl!("Save these pages as one PDF")).disabled_text(tl!("No changes to save")); - save |= Button::new(tl!("Save pages")).enabled(dirty).tooltip(hint).show(ui).clicked(); + save |= Button::new(tl!("Save pages")).variant(Variant::PRIMARY).enabled(dirty).tooltip(hint).show(ui).clicked(); close |= Button::new(tl!("Close")).variant(Variant::GHOST).icon(IconId::new("x")).show(ui).clicked(); }) .show(cx.ui, |ui, _| { diff --git a/crates/ui-egui/src/chrome/mode_bar.rs b/crates/ui-egui/src/chrome/mode_bar.rs index 4550e09d2c..ed4f23f30e 100644 --- a/crates/ui-egui/src/chrome/mode_bar.rs +++ b/crates/ui-egui/src/chrome/mode_bar.rs @@ -60,14 +60,15 @@ pub(super) fn show(app: &mut PdfCraftApp, ui: &mut egui::Ui) { if hidden.toolbar { return; } - IconButton::command(IconId::new("printer"), "print.dialog").show(ui); - IconButton::command(IconId::new("save"), "file.save").show(ui); - IconButton::command(IconId::new("info"), "file.properties").show(ui); if compact_search { IconButton::command(IconId::new("search"), "view.palette").label(tl!("Find tools and commands")).show(ui); } else { CommandSearch::new("view.palette", tl!("Find tools and commands")).show(ui); } + // Production puts the search first and the document buttons at the right edge. + IconButton::command(IconId::new("info"), "file.properties").show(ui); + IconButton::command(IconId::new("save"), "file.save").show(ui); + IconButton::command(IconId::new("printer"), "print.dialog").show(ui); }) .show(ui, |ui, _| { if hidden.toolbar { diff --git a/crates/ui-egui/src/panels/bookmarks.rs b/crates/ui-egui/src/panels/bookmarks.rs index ec4595ad73..325c6c4cb7 100644 --- a/crates/ui-egui/src/panels/bookmarks.rs +++ b/crates/ui-egui/src/panels/bookmarks.rs @@ -224,7 +224,13 @@ pub(super) fn body(app: &mut PdfCraftApp, ui: &mut egui::Ui) -> PanelResult { let current = view.current(); if outline.is_empty() { - Notice::new(craft::theme::variant::Tone::Neutral, tl!("This document has no bookmarks.")).show(ui); + // Centred in the panel with a glyph above, as the old panel showed an empty list. + ui.add_space(40.0); + ui.vertical_centered(|ui| { + craft::ui::display::Icon::new(IconSpec::svg(IconId::new("bookmark-plus"))).show(ui); + ui.add_space(8.0); + craft::ui::display::Text::new(tl!("This document has no bookmarks.").to_string()).show(ui); + }); return result; } diff --git a/crates/ui-egui/src/panels/search_ui.rs b/crates/ui-egui/src/panels/search_ui.rs index a494f9c70e..04a0ba0537 100644 --- a/crates/ui-egui/src/panels/search_ui.rs +++ b/crates/ui-egui/src/panels/search_ui.rs @@ -6,8 +6,9 @@ use std::collections::HashMap; use craft::behavior::{DisplayOrder, ItemSource, Selection, SelectionChange}; use craft::ui::choice::Checkbox; -use craft::ui::contract::{Bind, CollectionEvent, Props as _, SelectMode, Show as _, ShowCollection as _}; +use craft::ui::contract::{Bind, CollectionEvent, Props as _, SelectMode, Show as _, ShowCollection as _, ShowContainer as _}; use craft::ui::display::Text; +use craft::ui::layout_components::Row; use craft::ui::list::{List, ListRow}; use craft::ui::runtime::env::Label; use craft::ui::runtime::focus::{self, FocusTarget}; @@ -60,7 +61,9 @@ pub(crate) fn show(app: &mut PdfCraftApp, ui: &mut egui::Ui) -> PanelResult { let searched = view.session.texts.len() + view.session.text_failed.len(); let Some(find) = view.find.as_mut() else { return result }; find.in_panel = true; - let field = TextField::search(tl!("What word or phrase would you like to search for?").to_string(), Bind::bound(&mut find.query)) + Text::new(tl!("What word or phrase would you like to search for?").to_string()).show(ui); + let field = TextField::search(tl!("Search").to_string(), Bind::bound(&mut find.query)) + .placeholder(tl!("Search")) .select_on_focus() .show(ui); // The bar was asked for (⇧⌘F, also with the panel open): the field takes the focus once. @@ -68,8 +71,10 @@ pub(crate) fn show(app: &mut PdfCraftApp, ui: &mut egui::Ui) -> PanelResult { focus::request(ui.ctx(), FocusTarget::Id(field.response.id)); } let before = (find.options.whole_word, find.options.match_case); - Checkbox::new(Bind::bound(&mut find.options.whole_word)).label(tl!("Whole words only").to_string()).show(ui); - Checkbox::new(Bind::bound(&mut find.options.match_case)).label(tl!("Case-sensitive").to_string()).show(ui); + Row::new().show(ui, |ui, _| { + Checkbox::new(Bind::bound(&mut find.options.whole_word)).label(tl!("Whole words only").to_string()).show(ui); + Checkbox::new(Bind::bound(&mut find.options.match_case)).label(tl!("Case-sensitive").to_string()).show(ui); + }); if before != (find.options.whole_word, find.options.match_case) { find.case_query.clear(); } diff --git a/crates/ui-egui/src/panels/side_panels.rs b/crates/ui-egui/src/panels/side_panels.rs index b1fd7c94af..701118d7db 100644 --- a/crates/ui-egui/src/panels/side_panels.rs +++ b/crates/ui-egui/src/panels/side_panels.rs @@ -315,8 +315,15 @@ impl DockPanels for Panels<'_> { spec } None if self.app.left == LeftPanel::CalculationOrder => PanelSpec::new(crate::i18n::t("Calculation order").to_owned()).command(command), - None if super::tools::has_footer(self.app) => PanelSpec::new(crate::i18n::t("Tools").to_owned()).command(command).footer(), - None => PanelSpec::new(crate::i18n::t("Tools").to_owned()).command(command), + None => { + // The panel is headed by what it shows: the tool's name, or All tools (production's heading). + let title = match self.app.left { + LeftPanel::Tool(id) => super::catalog::group(id).map_or_else(|| crate::i18n::t("All tools"), |g| crate::i18n::t(g.label)), + _ => crate::i18n::t("All tools"), + }; + let spec = PanelSpec::new(title.to_owned()).command(command); + if super::tools::has_footer(self.app) { spec.footer() } else { spec } + } } } @@ -477,7 +484,7 @@ pub fn dock(app: &mut PdfCraftApp, ui: &mut Ui) { // in its tab (ISO 32000-2 Table 147); the tab strip stays, and F8 brings the rest back (`viewer_prefs`). let bare = app.full_screen_document() || app.hidden_interface().window_ui; let organizing = app.active_ids().and_then(|(index, _)| app.views.get(index)).is_some_and(|view| view.organize); - let toolbar = active && !app.hotbar_hidden() && !organizing; + let toolbar = active && !app.hotbar_hidden() && !organizing && !expanded; let anchor = rail_anchor(app); let workspace = app.dock.clone(); // The rail lists the Accessibility Checker once the document has a report, and Search and Compare only while @@ -491,11 +498,12 @@ pub fn dock(app: &mut PdfCraftApp, ui: &mut Ui) { }; let mut panels = Panels { ctx: ui.ctx().clone(), app: &mut *app }; // Home and Combine have no side panel and no toolbar, and Read mode hides the tools and the quick toolbar, not the - // navigation panels. + // navigation panels. A document that hides the window controls keeps the quick toolbar on its pages; full screen + // hides it (`hotbar_hidden`), and so does the expanded All tools view, which takes the pages' place. let shown = |panel: &PanelId| match panel { PanelId::Document => true, - _ if bare => false, PanelId::Toolbar => toolbar, + _ if bare => false, PanelId::Tools => !read && !expanded, _ => active && !expanded && listed(panel), }; diff --git a/crates/ui-egui/tests/it/editing.rs b/crates/ui-egui/tests/it/editing.rs index 8169faea8c..a2ba9d01fb 100644 --- a/crates/ui-egui/tests/it/editing.rs +++ b/crates/ui-egui/tests/it/editing.rs @@ -200,7 +200,7 @@ fn row_number(h: &Harness<'static, PdfCraftApp>, label: &str) -> Option /// The page grid's own Close, in its Organize pages bar: the window's title bar has a Close too. fn close_grid(h: &mut Harness<'static, PdfCraftApp>) { - h.get_by_label("Organize pages").get_by_role_and_label(Role::Button, "Close").click(); + h.get_by_role_and_label(Role::Toolbar, "Organize pages").get_by_role_and_label(Role::Button, "Close").click(); } fn organize(pages: usize) -> Harness<'static, PdfCraftApp> { diff --git a/crates/ui-egui/tests/it/viewer.rs b/crates/ui-egui/tests/it/viewer.rs index b7e6fce7d7..defe47bf1c 100644 --- a/crates/ui-egui/tests/it/viewer.rs +++ b/crates/ui-egui/tests/it/viewer.rs @@ -1549,6 +1549,9 @@ fn advanced_search_lists_results_with_context() { assert!(h.execute("edit.advanced_search")); h.run_steps(2); h.get_by_label("What word or phrase would you like to search for?"); + let whole = h.get_by_label("Whole words only").rect(); + let case = h.get_by_label("Case-sensitive").rect(); + assert!((whole.center().y - case.center().y).abs() < whole.height() / 2.0, "search options share a row"); h.state_mut().views[i].find.as_mut().unwrap().query = "pages".into(); // Background rendering and text extraction can take seconds on a loaded CI runner (FreeBSD VM). for _ in 0..3000 { diff --git a/crates/ui-egui/tests/it/viewer_prefs.rs b/crates/ui-egui/tests/it/viewer_prefs.rs index 1423f18f43..d7e93ca5a5 100644 --- a/crates/ui-egui/tests/it/viewer_prefs.rs +++ b/crates/ui-egui/tests/it/viewer_prefs.rs @@ -78,8 +78,8 @@ fn a_document_that_hides_the_interface_opens_without_it_and_f8_brings_it_back() let mut h = harness(|_| {}, &["", HIDE_ALL]); assert_eq!(shown(&h), (false, false, false), "the toolbar, menu and rail are hidden"); assert_eq!(h.state().hidden_interface(), HiddenInterface::ALL); - // The tool rail is a toolbar too. - assert!(h.query_by_role_and_label(egui::accesskit::Role::Toolbar, "Toolbar").is_none()); + // The floating tool rail stays on the pages, as in production. + assert!(h.query_by_role_and_label(egui::accesskit::Role::Toolbar, "Toolbar").is_some()); // The tab strip stays: the tabs and Home are still there. h.get_by_label("Home"); @@ -167,6 +167,22 @@ fn hiding_the_window_controls_leaves_the_document_the_whole_width() { assert!(width(&h) < 1400.0 - 48.0 - 200.0, "{}", width(&h)); } +#[test] +fn document_hiding_window_ui_keeps_the_floating_quick_tools() { + let h = harness(|_| {}, &["/ViewerPreferences << /HideWindowUI true >>"]); + assert!(h.query_by_label("Select").is_some(), "the floating toolbar remains available"); +} + +#[test] +fn expanded_all_tools_does_not_cover_the_grid_with_the_quick_toolbar() { + let mut h = harness(|_| {}, &[""]); + assert!(h.query_by_label("Select").is_some(), "the quick toolbar starts visible"); + h.get_by_label("Expand all tools").click(); + h.run_steps(3); + assert!(h.state().all_tools_full); + assert!(h.query_by_label("Select").is_none(), "the expanded catalogue keeps the toolbar out of its way"); +} + #[test] fn the_preference_to_ignore_document_views_keeps_the_interface() { let h = harness(|app| app.always_default_view = true, &[HIDE_ALL]);