From 5a8682e45dac8e96cebb6bcd79eba908cce0bdba Mon Sep 17 00:00:00 2001 From: "Ayberk A." <105879357+AyberkA0@users.noreply.github.com> Date: Mon, 12 Oct 2026 11:39:13 +0300 Subject: [PATCH] Toolbar: centre the tool buttons inside the panel's border The buttons were placed (WIDTH - 36) / 2 from the panel's content edge, but the docked panel's content is narrower than WIDTH: the 1.5 pt frame stroke on both sides and the 1 pt separator line egui reserves on the right leave 44 pt. So the single column sat 6.5 pt from the left border and 1.5 pt from the right (2.5 pt right of centre), and the double column's second button ran over the right border. Centre each row on the panel's inside instead, and widen the double column to 80 pt so its two buttons fit with 2 pt either side. --- crates/ui-egui/src/toolbar.rs | 43 ++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index 7c73ca98..7066a30f 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -95,7 +95,9 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { let t = Tokens::get(ui.ctx()); // The user's choice alone: a window too short for the tools scrolls them. let cols = if app.ui.toolbar_double { 2 } else { 1 }; - let w = if cols == 2 { 76.0 } else { WIDTH }; + // Two 36 pt buttons with 2 pt either side inside the border and separator line (at 76 they + // overran the right border). + let w = if cols == 2 { 80.0 } else { WIDTH }; // Where the panel docks: along the window's left edge, under the bars. let edge = ui.available_rect_before_wrap(); ui.ctx().data_mut(|d| d.insert_temp(crate::floating::tools_zone_id(), egui::Rect::from_min_size(edge.min, vec2(WIDTH, edge.height())))); @@ -199,11 +201,10 @@ fn body(app: &mut VectorcraftApp, ui: &mut Ui, cols: usize, floating: Option 40.0) + .map(|w| w.rect) + .next() + }); + let hdr = hdr.unwrap(); + let first = tools[0]; + let row_right = tools.iter().filter(|r| r.top() == first.top()).map(|r| r.right()).fold(first.right(), f32::max); + assert_eq!(row_right - hdr.center().x, hdr.center().x - first.left(), "double {double}, floating {floating:?}: {first:?} in {hdr:?}"); + assert!(first.left() >= hdr.left() && row_right <= hdr.right(), "double {double}, floating {floating:?}: {first:?} in {hdr:?}"); + } + } + /// #812: double-clicking the Artboard tool opens Artboard Options of the active artboard, a /// graph tool Graph Type for the selected graph, and the Magic Wand tool its panel. #[test]