From fd971559e7ea07349e88c77a72773f794c4edc1d Mon Sep 17 00:00:00 2001 From: alehel Date: Thu, 22 Oct 2026 17:29:03 +0200 Subject: [PATCH] M3: going Home puts the expanded All tools away with no document open With no document open the expanded view covers Home itself, so the control option `home` changed no tab and the view stayed up (CodeRabbit's remaining merge-risk note on 8a8bb92d). The option now puts the view away itself. `going_home_with_no_document_puts_the_expanded_all_tools_away` was seen to fail with the fix reverted. Also doc comments on the view's `show` and `tile` and the sidebar's `all_tools`, for CodeRabbit's docstring-coverage check. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/all_tools_ui.rs | 5 +++++ crates/ui-egui/src/lib.rs | 7 ++++++- crates/ui-egui/src/panels.rs | 2 ++ crates/ui-egui/tests/ui.rs | 10 ++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/all_tools_ui.rs b/crates/ui-egui/src/all_tools_ui.rs index 71b4c16845..53aa7ebbd7 100644 --- a/crates/ui-egui/src/all_tools_ui.rs +++ b/crates/ui-egui/src/all_tools_ui.rs @@ -36,6 +36,8 @@ fn matches(query: &str, group: &ToolGroup) -> Option> { (!items.is_empty()).then_some(items) } +/// Draw the view over the workspace: the title with Collapse, the search field, and each +/// category's tiles that match the search. Choosing a tile opens that tool's panel. pub fn show(app: &mut PdfCraftApp, ui: &mut egui::Ui) { let t = Tokens::get(ui.ctx()); // A dialog or prompt over the view owns Escape. @@ -103,6 +105,9 @@ pub fn show(app: &mut PdfCraftApp, ui: &mut egui::Ui) { } } +/// One tool's tile: its icon and name, then the `items` the search found it by or, when there are +/// none, its availability (a planned tool is greyed out with its milestone). A name or note cut +/// short shows in full on hover. fn tile(ui: &mut egui::Ui, t: &Tokens, g: &ToolGroup, items: &[&'static str]) -> egui::Response { let (rect, resp) = ui.allocate_exact_size(TILE, Sense::click()); resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, tl!(g.label))); diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 8272978545..0e8a5a58c6 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -2712,7 +2712,12 @@ impl PdfCraftApp { self.select_tool(g.id); } ("left", _) => self.left_open = value != "closed", - ("home", _) => self.active = None, + ("home", _) => { + self.active = None; + // With no document open the expanded All tools view covers Home itself, so no + // other tab comes forward to put it away. + self.all_tools_full = false; + } ("dialog", _) => { self.dialog = match value { "properties" => Some(Dialog::Properties(PropsTab::Description)), diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index ebddd320b5..c36b442410 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -62,6 +62,8 @@ pub(crate) fn panel_header(ui: &mut egui::Ui, t: &Tokens, title: &str, lead: Opt (go_back, close) } +/// The All tools sidebar: Expand (the full view) and Close, then the tool list, the first few +/// tools until View more shows them all. fn all_tools(app: &mut PdfCraftApp, ui: &mut egui::Ui, t: &Tokens) { // Labels distinct from the Combine grid's Expand and Collapse, which can show beside them. let (expand, close) = panel_header(ui, t, "All tools", Some(("maximize-2", tl!("Expand all tools")))); diff --git a/crates/ui-egui/tests/ui.rs b/crates/ui-egui/tests/ui.rs index ae32820fc8..4ee1f06582 100644 --- a/crates/ui-egui/tests/ui.rs +++ b/crates/ui-egui/tests/ui.rs @@ -240,6 +240,16 @@ fn another_tab_coming_forward_puts_the_expanded_all_tools_away() { assert!(!h.state().all_tools_full, "one.pdf shows, not the catalogue over it"); } +#[test] +fn going_home_with_no_document_puts_the_expanded_all_tools_away() { + // Home is already the tab in front, so only the option itself can put the view away. + let mut h = harness(|app| app.set_option("tools", "full").unwrap()); + h.state_mut().set_option("home", "").unwrap(); + h.run_steps(3); + assert!(!h.state().all_tools_full); + h.get_by_label_contains("Welcome to PdfCraft"); +} + #[test] fn expanding_all_tools_from_read_mode_restores_the_right_panel() { use pdfcraft_ui_egui::{Mode, RightPanel};