Combine takes bodies clicked in the Browser (#4452) (#4766)

* claim: #4452

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Combine takes bodies clicked in the Browser (#4452)

A body row in the Browser only replaced the selection, so with Combine
open its target and tools stayed empty and overlapping bodies could only
be picked in the view. When the open dialog's active input takes bodies,
a body row now goes there, as plane and axis rows already do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Combine Browser picks: test both layouts and control-channel clicks (#4452)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DuBearte
2026-10-23 13:44:32 +00:00
committed by GitHub
parent 4106332738
commit 1a953736ff
2 changed files with 57 additions and 0 deletions
+17
View File
@@ -1580,9 +1580,24 @@ impl CanvasPanel {
}
}
/// Does the open dialog's active input take bodies (Combine's target and tools, #4452)? Then a
/// body clicked in the Browser goes there, as a click on it in the view does, rather than
/// replacing the selection: overlapping bodies are often only told apart in the Browser.
fn dialog_takes_body(app: &SolveApp) -> bool {
app.dialog.as_ref().and_then(|d| d.active_input()).is_some_and(|i| i.accept & crate::selection::BODIES != 0)
}
/// A browser click on a plane or axis: it goes to the open dialog's input if that takes it,
/// otherwise it becomes the selection.
fn pick_from_browser(app: &mut SolveApp, x: Sel) {
if let Sel::Body { .. } = &x
&& dialog_takes_body(app)
&& let Some(mut d) = app.dialog.take()
{
d.pick(&app.session, x);
app.dialog = Some(d);
return;
}
let hit = match &x {
Sel::Plane { name } => crate::viewport::Hit::Plane { name: name.clone(), point: solidcraft_engine::geom::Vec3::ZERO },
Sel::Axis { name } => crate::viewport::Hit::Axis { name: name.clone() },
@@ -1978,6 +1993,8 @@ fn entry_row(
if let Some(s) = e.sel.clone() {
pick_from_browser(app, s);
}
} else if let Some(s) = e.sel.clone().filter(|s| matches!(s, Sel::Body { .. }) && dialog_takes_body(app)) {
pick_from_browser(app, s);
} else {
click_select(app, ui, e.row_key.clone(), e.sel.clone());
}
+40
View File
@@ -2272,3 +2272,43 @@ fn hovering_a_large_body_does_not_wait_for_its_pick_index() {
assert!(matches!(h.app.viewport.hover, Some(crate::viewport::Hit::Face { .. })), "{:?}", h.app.viewport.hover);
assert!(hover_ms < index_ms / 3.0, "the first hover took {hover_ms:.1} ms; making the index takes {index_ms:.1} ms");
}
/// #4452: with Combine open, bodies clicked in the Browser fill its inputs, as clicks on them
/// in the view do: the first is the target, the next the tools. Overlapping bodies are often
/// only told apart in the Browser.
#[test]
fn combine_takes_bodies_clicked_in_the_browser() {
for layout in ["docked", "floating"] {
for control in [false, true] {
combine_takes_bodies_clicked_in_the_browser_in(layout, control);
}
}
}
/// `control`: click the rows as the control channel's `ui.click` does (move, press and release
/// in one frame), as an agent or a live screenshot run does.
fn combine_takes_bodies_clicked_in_the_browser_in(layout: &str, control: bool) {
let mut h = crate::scenario::Harness::new();
h.step(&json!({"call": "ui.set", "params": {"layout": layout}})).unwrap();
h.frames(2);
h.app.run("solid.box", json!({"corner": [0, 0, 0], "length": 20, "width": 20, "height": 20, "body_name": "Block"})).unwrap();
h.app.run("solid.box", json!({"corner": [10, 10, 10], "length": 20, "width": 20, "height": 20, "body_name": "Cutter"})).unwrap();
h.app.session.selection.clear();
h.app.start("solid.combine");
h.frames(2);
for label in ["Block", "Cutter"] {
if control {
let rows = h.call("ui.handles", json!({"prefix": "row:"}))["result"].clone();
let rows = rows.get("handles").cloned().unwrap_or(rows);
let row = rows.as_array().unwrap().iter().find(|r| r["name"] == format!("row:{label}")).cloned().unwrap();
h.call("ui.click", json!({"x": row["x"], "y": row["y"]}));
h.frames(2);
} else {
h.step(&json!({"click": {"browser": label}})).unwrap();
h.frames(1);
}
}
let d = h.app.dialog.as_ref().expect("Combine stays open");
assert_eq!(d.inputs[0].items, vec![Sel::Body { name: "Block".into() }], "{layout} control={control} target: {:?}", d.inputs);
assert_eq!(d.inputs[1].items, vec![Sel::Body { name: "Cutter".into() }], "{layout} control={control} tools: {:?}", d.inputs);
}