From 6a48d5af401469f2bff3a8baee68ab2029df6d09 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 09:55:34 -0800 Subject: [PATCH] Tools: the rail shows one rule above the controls under the tools The tool rail's footer region draws its own rule and gap since craft-libs#4140, so the divider at the top of bottom_controls drew a second rule. Remove it, and have the rule test count exactly one. --- crates/ui-egui/src/toolbar.rs | 4 ++-- crates/ui-egui/src/toolbar/tests.rs | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index 6f2f72d06a..973e47ddf1 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -768,11 +768,11 @@ fn quad_bounds(quad: &[Point; 4]) -> vectorcraft_geom::Rect { /// The Fill/Stroke proxy, Color/Gradient/None, the drawing modes and screen mode under the rail's /// tools: in two columns the three drawing modes show, in one only the current one, which cycles /// them. A row the rail is too narrow for goes on in the next line. The All Tools drawer's Show -/// section hides any of them. A rule above them parts them from the tools, which scroll above it in a short rail. +/// section hides any of them. The rail's footer region draws the rule that parts them from the tools, which scroll +/// above it in a short rail. fn bottom_controls(app: &mut VectorcraftApp, ui: &mut Ui, footer: RailFooter) { let two = footer.columns > 1; let show = app.ui.toolbar_show; - Divider::horizontal().show(ui); if show.fill_stroke { crate::panels::proxy(app, ui); } diff --git a/crates/ui-egui/src/toolbar/tests.rs b/crates/ui-egui/src/toolbar/tests.rs index 9ce6cca2e6..66688bf9ed 100644 --- a/crates/ui-egui/src/toolbar/tests.rs +++ b/crates/ui-egui/src/toolbar/tests.rs @@ -306,9 +306,9 @@ fn the_paint_and_drawing_mode_buttons_fit_the_toolbar_width() { assert_eq!(app.session.draw_mode, vectorcraft_engine::DrawMode::Behind); } -/// In one column the Color, Gradient and None chips share one line, and a rule across the rail parts the controls under -/// the tools from the tools, which scroll above them in a short rail: it lies between the last tool and Fill and -/// Stroke. +/// In one column the Color, Gradient and None chips share one line, and one rule across the rail parts the controls +/// under the tools from the tools, which scroll above them in a short rail: it lies between the last tool and Fill and +/// Stroke, and no second rule doubles it. #[test] fn the_controls_under_the_tools_share_a_line_under_a_rule() { let mut app = app_with(200, 200); @@ -325,12 +325,15 @@ fn the_controls_under_the_tools_share_a_line_under_a_rule() { // A rule is a thin horizontal line or bar across most of the rail's width, between the tools and the controls. let between = |y: f32| y > last.bottom() && y < proxy.top(); let across = |left: f32, right: f32| right - left >= last.width() * 0.75 && left < last.right() && right > last.left(); - let ruled = flat.iter().any(|shape| match shape { - egui::Shape::LineSegment { points: [a, b], .. } => (a.y - b.y).abs() < 0.5 && between(a.y) && across(a.x.min(b.x), a.x.max(b.x)), - egui::Shape::Rect(r) => r.rect.height() <= 2.0 && between(r.rect.center().y) && across(r.rect.left(), r.rect.right()), - _ => false, - }); - assert!(ruled, "a rule lies between the last tool {last:?} and Fill and Stroke {proxy:?}"); + let rules = flat + .iter() + .filter(|shape| match shape { + egui::Shape::LineSegment { points: [a, b], .. } => (a.y - b.y).abs() < 0.5 && between(a.y) && across(a.x.min(b.x), a.x.max(b.x)), + egui::Shape::Rect(r) => r.rect.height() <= 2.0 && between(r.rect.center().y) && across(r.rect.left(), r.rect.right()), + _ => false, + }) + .count(); + assert_eq!(rules, 1, "one rule lies between the last tool {last:?} and Fill and Stroke {proxy:?}"); } /// A screen reader reads the drawing-mode buttons' state as the rail shows it, in every mode: in two columns the