Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Give the centerline tool a toolbar icon, and paint both line-type icons in construction orange (#427)

William Dunnbf2a9f554161
diff --git a/crates/engine/src/cmd/sketch_create.rs b/crates/engine/src/cmd/sketch_create.rs
index 0cf9478db7..fc486e34f9 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 0f7fa4e381..566b318d6c 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 0000000000..e3e345ca90
--- /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": []}}}
+]