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.
This commit is contained in:
1 parent
d6af554c6d
commit
bf2a9f5541
3 files changed
+40
-2
No files matched your search
@@ -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!(
|
||||
|
||||
@@ -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" => {
|
||||
// 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)], pen.accent);
|
||||
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" => {
|
||||
|
||||
@@ -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": []}}}
|
||||
]
|
||||
Reference in new issue
Block a user