From bf2a9f554161c188f03fc63e63222eb7415bf4df Mon Sep 17 00:00:00 2001 From: William Dunn Date: Tue, 13 Oct 2026 01:26:47 -0400 Subject: [PATCH] Give the centerline tool a toolbar icon, and paint both line-type icons in construction orange (#427) Centerline gets a place in SKETCH > CREATE with its own long-short icon, and both line-type icons now draw in the construction orange. --- crates/engine/src/cmd/sketch_create.rs | 2 ++ crates/ui-egui/src/icons.rs | 24 +++++++++++++++---- .../sketch_centerline_toolbar_icon.json | 20 ++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 crates/ui-egui/tests/scenarios/sketch_centerline_toolbar_icon.json diff --git a/crates/engine/src/cmd/sketch_create.rs b/crates/engine/src/cmd/sketch_create.rs index 0cf9478d..fc486e34 100644 --- a/crates/engine/src/cmd/sketch_create.rs +++ b/crates/engine/src/cmd/sketch_create.rs @@ -75,6 +75,8 @@ pub static COMMANDS: &[CommandSpec] = &[ .enabled(in_sketch) .params(concat!("a, b: end points of two curves (\"l1.end\", \"a2.start\"): a smooth (tangent) spline joining them", created_doc!())), CommandSpec::new("sketch.centerline", "Centerline", centerline) + .at("SKETCH", "CREATE") + .icon("centerline") .enabled(in_sketch) .params("curves: [line ids], value?: bool (default toggles): centerline line type (not in profiles; an axis)"), CommandSpec::new("sketch.text", "Text", text).at("SKETCH", "CREATE").icon("text").enabled(in_sketch).params(concat!( diff --git a/crates/ui-egui/src/icons.rs b/crates/ui-egui/src/icons.rs index 0f7fa4e3..566b318d 100644 --- a/crates/ui-egui/src/icons.rs +++ b/crates/ui-egui/src/icons.rs @@ -345,10 +345,26 @@ pub fn paint(p: &Painter, r: Rect, name: &str, ink: Color32, fill: Color32, acce pen.arrow((12.0, 11.0), (19.5, 11.0), a); pen.line(&[(9.0, 15.0), (15.0, 15.0)], ink); } - "construction" => { - for i in 0..4 { - let t = i as f32 * 4.5; - pen.line(&[(3.0 + t, 19.0 - t), (5.5 + t, 16.5 - t)], pen.accent); + // Construction geometry has one fixed meaning everywhere in the app (the theme's + // construction orange), independent of the tab accent the caller passes in: a plain + // construction curve is an even dashed line, a centerline the ISO long-short rhythm. + "construction" | "centerline" => { + let orange = crate::theme::Tokens::get().construction_geom; + if name == "construction" { + for i in 0..4 { + let t = i as f32 * 4.5; + pen.line(&[(3.0 + t, 19.0 - t), (5.5 + t, 16.5 - t)], orange); + } + } else { + let (fx, fy) = (2.5, 20.5); + let (dx, dy) = (19.0, -18.0); + let seg = |t0: f32, t1: f32| { + pen.line(&[(fx + dx * t0, fy + dy * t0), (fx + dx * t1, fy + dy * t1)], orange); + }; + seg(0.03, 0.32); + seg(0.40, 0.48); + seg(0.56, 0.85); + seg(0.93, 1.0); } } "c_hv" => { diff --git a/crates/ui-egui/tests/scenarios/sketch_centerline_toolbar_icon.json b/crates/ui-egui/tests/scenarios/sketch_centerline_toolbar_icon.json new file mode 100644 index 00000000..e3e345ca --- /dev/null +++ b/crates/ui-egui/tests/scenarios/sketch_centerline_toolbar_icon.json @@ -0,0 +1,20 @@ +[ + { + "note": "Centerline needs the same CREATE panel placement and icon as its neighbours (sketch.ellipse, sketch.conic): without them it never appeared in the CREATE panel's drop-down at all, pinned or not. Both it and the construction toggle draw their icon in the app's fixed construction orange, not the tab or panel accent colour a caller happens to pass to icons::paint." + }, + {"start": "sketch.create"}, + {"click": {"plane": "XY"}}, + {"expect": {"dialog": null}}, + {"click": {"handle": "panel:SKETCH:CREATE"}}, + {"expect": {"shown_handles": ["toolbar:sketch.construction", "toolbar:sketch.centerline"]}}, + {"click": [1000, 500]}, + {"start": "sketch.rectangle.two_point"}, + {"click": {"sketch": [0, 0]}}, + {"click": {"sketch": [30, 20]}}, + {"key": "Escape"}, + {"expect": {"query": {"command": "sketch.inspect", "path": ["profiles", 0, "area_mm2"], "value": 600}}}, + {"start": "sketch.centerline"}, + {"click": {"sketch": [15, 0]}}, + {"key": "Escape"}, + {"expect": {"query": {"command": "sketch.inspect", "path": ["profiles"], "value": []}}} +]