PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust
M3: going Home puts the expanded All tools away with no document open
alehelfd971559e7ea
diff --git a/crates/ui-egui/src/all_tools_ui.rs b/crates/ui-egui/src/all_tools_ui.rsindex 71b4c1684..53aa7ebbd 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<Vec<&'static str>> {(!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.rsindex 827297854..0e8a5a58c 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.rsindex ebddd320b..c36b44241 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.rsindex ae32820fc..4ee1f0658 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};