mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-08 03:54:35 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
4 files changed
+23
-1
No files matched your search
@@ -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)));
|
||||
|
||||
@@ -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)),
|
||||
|
||||
@@ -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"))));
|
||||
|
||||
@@ -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};
|
||||
|
||||
Reference in new issue
Block a user