Skip to content

PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust

fix(ui): keep the All tools rows clear of the scrollbar (#5133)

RiceDee0c5119791db7
diff --git a/crates/ui-egui/src/panels/tools.rs b/crates/ui-egui/src/panels/tools.rs
index 4ff76a7c4..9d106e38b 100644
--- a/crates/ui-egui/src/panels/tools.rs
+++ b/crates/ui-egui/src/panels/tools.rs
@@ -58,6 +58,9 @@ pub(crate) fn panel_header(ui: &mut egui::Ui, t: &Tokens, title: &str, lead: Opt
(go_back, close)
}
+/// Width kept free at the right of the tool list for the floating scrollbar.
+const SCROLLBAR_GUTTER: f32 = 18.0;
+
/// 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) {
@@ -70,6 +73,8 @@ fn all_tools(app: &mut PdfCraftApp, ui: &mut egui::Ui, t: &Tokens) {
app.left_open = false;
}
egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| {
+ // The scrollbar floats over the right edge: keep the rows (and their rounded hover wash) clear of it.
+ ui.set_max_width((ui.available_width() - SCROLLBAR_GUTTER).max(0.0));
ui.add_space(2.0);
let shown = if app.all_tools_expanded { TOOL_GROUPS.len() } else { COLLAPSED_TOOLS.min(TOOL_GROUPS.len()) };
for g in &TOOL_GROUPS[..shown] {