Use a registered navigation icon and split out the placement handler

This commit is contained in:
FredApps committed 2026-12-06 09:59:10 +01:00
1 parent 3a788845b3
commit f60f07a125
3 files changed
+16 -16

No files matched your search

+1 -1
View File
@@ -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);
}
}
+14 -14
View File
@@ -157,6 +157,19 @@ impl PdfCraftApp {
}
}
fn move_rail_controls(&mut self, ctx: &egui::Context, active: Option<usize>, 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": <group id> }` 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()) {
+1 -1
View File
@@ -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"),