Tools pane: 330 in a wide window, production's 272 under 900 points

This commit is contained in:
Dylan M. Taylor
2026-11-22 15:20:44 -05:00
parent ac823fb949
commit ef0cf346ba
3 changed files with 35 additions and 0 deletions
+1
View File
@@ -275,6 +275,7 @@ impl PdfCraftApp {
last_right: RightPanel::Comments,
notice_inset: 0.0,
toolbar_tools_open: true,
window_narrow: false,
right_before_read: None,
comments_panel_closed: false,
right_panel_closed: false,
+3
View File
@@ -279,6 +279,9 @@ pub struct PdfCraftApp {
/// Whether the Tools pane was in the dock when the floating toolbar was last placed: the toolbar follows the page area's
/// left edge as the pane closes and opens.
pub(crate) toolbar_tools_open: bool,
/// Whether the window was narrow (under [`panels::side_panels::NARROW_WINDOW`]) when the Tools pane's width was last set: a
/// narrow window keeps the pane at production's width, a wide one gives it the width Format text needs.
pub(crate) window_narrow: bool,
/// The right panel that was open when the user switched to Read mode, which starts with the
/// panes closed; leaving Read mode brings it back unless the user opened or closed a pane in
/// Read mode meanwhile.
+31
View File
@@ -169,6 +169,10 @@ const PAGE_SHARE: f32 = 0.8;
/// 10-point gaps need about 55 more for Format text's size field to keep room for its value beside the colour well, the list
/// buttons and the alignment menu (the field takes what the row leaves).
const TOOLS_WIDTH: f32 = 330.0;
/// The Tools pane's width in a narrow window, as production opened it.
const TOOLS_WIDTH_NARROW: f32 = 272.0;
/// Windows narrower than this keep the Tools pane at [`TOOLS_WIDTH_NARROW`]: a wider pane would leave the page area too little.
pub(crate) const NARROW_WINDOW: f32 = 900.0;
/// The arrangement of a new install: Tools at the start edge, the side-panel rail at the window edge,
/// and the toolbar floating at the start of the page area. The side panels form one collapsed group.
@@ -203,6 +207,32 @@ fn keep_toolbar_in_the_margin(app: &mut PdfCraftApp) {
}
}
/// The Tools pane's width follows the window across [`NARROW_WINDOW`]: production's narrower pane in a small window, the
/// wider default in a large one. Only the crossing changes it, so a width the user dragged to is kept.
fn fit_tools_to_window(app: &mut PdfCraftApp, window_width: f32) {
let narrow = window_width.is_finite() && window_width < NARROW_WINDOW;
if narrow == app.window_narrow {
return;
}
app.window_narrow = narrow;
if !app.dock.layout.contains(&PanelId::Tools) {
return;
}
let width = if narrow { TOOLS_WIDTH_NARROW } else { TOOLS_WIDTH };
// A refused resize (a locked layout) leaves the width as it is.
if app.dock.apply(Action::resize_column(PanelId::Tools, width), false, permissions).is_err() {
return;
}
// The floating toolbar sits in the page area's margin, which moved with the pane's edge.
let shift = if narrow { TOOLS_WIDTH_NARROW - TOOLS_WIDTH } else { TOOLS_WIDTH - TOOLS_WIDTH_NARROW };
if app.toolbar_tools_open
&& let Some(window) = app.dock.layout.floating.iter_mut().find(|window| window.contains(&PanelId::Toolbar))
&& window.rect.min.x >= TOOLS_WIDTH_NARROW
{
window.rect = window.rect.translate(egui::vec2(shift, 0.0));
}
}
/// The window edge whose dock holds `panel`, `None` when it is closed or floating.
fn edge_of(workspace: &Workspace<PanelId>, panel: PanelId) -> Option<DockEdge> {
let mut pending: Vec<(&Node<PanelId>, usize)> = workspace.layout.root.iter().map(|node| (node, 0)).collect();
@@ -506,6 +536,7 @@ pub fn dock(app: &mut PdfCraftApp, ui: &mut Ui) {
let toolbar = active && !app.hotbar_hidden() && !organizing && !expanded;
let anchor = rail_anchor(app);
keep_toolbar_in_the_margin(app);
fit_tools_to_window(app, ui.ctx().content_rect().width());
let workspace = app.dock.clone();
// The rail lists the Accessibility Checker once the document has a report, and Search and Compare only while
// they show; their commands open them.