From f60f07a125b086dd2ba7bc3d683430a6728ccf80 Mon Sep 17 00:00:00 2001 From: FredApps Date: Sun, 6 Dec 2026 09:59:10 +0100 Subject: [PATCH] Use a registered navigation icon and split out the placement handler --- crates/ui-egui/src/chrome/view_rail.rs | 2 +- crates/ui-egui/src/commands.rs | 28 +++++++++++++------------- crates/ui-egui/src/commands/catalog.rs | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/crates/ui-egui/src/chrome/view_rail.rs b/crates/ui-egui/src/chrome/view_rail.rs index aa05b678ec..9b5009221e 100644 --- a/crates/ui-egui/src/chrome/view_rail.rs +++ b/crates/ui-egui/src/chrome/view_rail.rs @@ -145,6 +145,6 @@ fn controls(app: &mut PdfCraftApp, ui: &mut Ui, top: bool) { let left = egui::Rect::from_min_max(row.min, egui::pos2(row.center().x, row.bottom())); let right = egui::Rect::from_min_max(egui::pos2(row.center().x, row.top()), row.max); IconButton::command(IconId::new(icon), side_command).show_at(ui, left); - IconButton::command(IconId::new("panels_top_left"), "view.rail.top").show_at(ui, right); + IconButton::command(IconId::new("rows-3"), "view.rail.top").show_at(ui, right); } } diff --git a/crates/ui-egui/src/commands.rs b/crates/ui-egui/src/commands.rs index a177b44a10..bdf32ca6a7 100644 --- a/crates/ui-egui/src/commands.rs +++ b/crates/ui-egui/src/commands.rs @@ -157,6 +157,19 @@ impl PdfCraftApp { } } + fn move_rail_controls(&mut self, ctx: &egui::Context, active: Option, top: bool) { + if top != self.rail_controls_top { + self.set_live_rail_controls_top(top); + if let Some(view) = active.and_then(|i| self.views.get(i)) { + ctx.data_mut(|data| data.insert_temp(view.page_input_id().with("rail-placement-focus"), true)); + } + let message = if top { tl!("Page navigation controls moved to the top bar") } else { tl!("Page navigation controls moved to the rail") }; + use craft::ui::runtime::access::{Politeness, announce}; + announce(ctx, message.to_string(), Politeness::Polite); + ctx.request_repaint(); + } + } + /// The handlers of the catalog ids that are not registered engine commands. `false` when /// `fired` is not one of them. fn run_catalog_command(&mut self, ctx: &egui::Context, fired: &Fired) -> bool { @@ -214,20 +227,7 @@ impl PdfCraftApp { self.notify(e); } } - "view.rail.top" | "view.rail.in_rail" => { - let top = id == "view.rail.top"; - if top != self.rail_controls_top { - self.set_live_rail_controls_top(top); - if let Some(view) = active.and_then(|i| self.views.get(i)) { - ctx.data_mut(|data| data.insert_temp(view.page_input_id().with("rail-placement-focus"), true)); - } - let message = - if top { tl!("Page navigation controls moved to the top bar") } else { tl!("Page navigation controls moved to the rail") }; - use craft::ui::runtime::access::{Politeness, announce}; - announce(ctx, message.to_string(), Politeness::Polite); - ctx.request_repaint(); - } - } + "view.rail.top" | "view.rail.in_rail" => self.move_rail_controls(ctx, active, id == "view.rail.top"), "home.unpin_tool" => { // PLAN: assumed params `{ "tool": }` and `PdfCraftApp::unpin_tool(&mut self, &str)` (pdf-chrome-w9). if let Some(tool) = fired.command.params.get("tool").and_then(|t| t.as_str()) { diff --git a/crates/ui-egui/src/commands/catalog.rs b/crates/ui-egui/src/commands/catalog.rs index 6b2c6bc6cf..446375e948 100644 --- a/crates/ui-egui/src/commands/catalog.rs +++ b/crates/ui-egui/src/commands/catalog.rs @@ -30,7 +30,7 @@ pub(crate) const CATALOG_ONLY: &[(&str, &str, &str)] = &[ ("view.rail.left", "Dock navigation rail on Left", "panel-left"), ("view.rail.right", "Dock navigation rail on Right", "panel-right"), // The view controls (page number, page stepping, zoom, page display) in a bar above the document, or back in the rail. - ("view.rail.top", "Show navigation controls at the Top", "panels-top-left"), + ("view.rail.top", "Show navigation controls at the Top", "rows-3"), ("view.rail.in_rail", "Show navigation controls in the Rail", "panel-right"), ("view.fit_toggle", "Toggle fit", "scan"), ("bookmark.paste", "Paste bookmarks", "clipboard-paste"),