* claim: #2560 * fix(ui): route Browser body picks into active dialogs
This commit is contained in:
committed by
GitHub
parent
2e5924ed5e
commit
7dd5baac5c
@@ -1643,8 +1643,8 @@ 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.
|
||||
/// Browser picks go only into compatible active dialog inputs. Outside a dialog, planes and
|
||||
/// axes become the selection; body rows use the ordinary Ctrl/Shift-aware selection path.
|
||||
fn pick_from_browser(app: &mut SolveApp, x: Sel) {
|
||||
if let Sel::Body { .. } = &x
|
||||
&& dialog_takes_body(app)
|
||||
@@ -2045,12 +2045,10 @@ fn entry_row(
|
||||
app.edit_sketch(id);
|
||||
}
|
||||
} else if r.clicked {
|
||||
if folder == "construction" {
|
||||
if folder == "construction" || (folder == "bodies" && app.dialog.is_some()) {
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -2,6 +2,59 @@ use super::*;
|
||||
use crate::scenario::{Harness, handle_at, rect_of};
|
||||
use crate::shell::{LayoutMode, SHELL_GAP};
|
||||
|
||||
#[test]
|
||||
fn browser_body_clicks_fill_and_toggle_save_mesh_inputs() {
|
||||
for mode in [LayoutMode::Floating, LayoutMode::Docked] {
|
||||
let mut h = Harness::new();
|
||||
h.app.ui.layout = mode;
|
||||
for (name, x) in [("One", 0), ("Two", 20)] {
|
||||
h.app.run("solid.box", json!({"length":10,"width":10,"height":10,"corner":[x,0,0],"operation":"new_body","body_name":name})).unwrap();
|
||||
}
|
||||
h.app.start("file.save_mesh");
|
||||
h.settle();
|
||||
for (clicked, expected) in [("One", vec!["One"]), ("Two", vec!["One", "Two"]), ("One", vec!["Two"])] {
|
||||
h.step(&json!({"click":{"handle":format!("row:{clicked}")}})).unwrap();
|
||||
let d = h.app.dialog.as_ref().unwrap();
|
||||
let crate::dialogs::Kind::SaveMesh(k) = &d.kind else { panic!("Save as Mesh is open") };
|
||||
let commands = crate::dialogs_save_mesh::commands(k, &d.inputs).unwrap();
|
||||
assert_eq!(commands[0].1["bodies"], json!(expected), "{mode:?}: clicked {clicked}");
|
||||
assert!(crate::dialogs_save_mesh::ready(&d.inputs));
|
||||
assert!(h.app.session.selection.is_empty(), "dialog picks do not change the global selection");
|
||||
}
|
||||
h.step(&json!({"click":{"handle":"row:Two"}})).unwrap();
|
||||
assert!(!crate::dialogs_save_mesh::ready(&h.app.dialog.as_ref().unwrap().inputs));
|
||||
h.step(&json!({"key":"Escape"})).unwrap();
|
||||
h.step(&json!({"click":{"handle":"row:One"}})).unwrap();
|
||||
assert_eq!(h.app.session.selection, vec![Sel::Body { name: "One".into() }]);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn browser_body_clicks_respect_the_active_dialog_input() {
|
||||
let mut h = Harness::new();
|
||||
for (name, x) in [("One", 0), ("Two", 20)] {
|
||||
h.app.run("solid.box", json!({"length":10,"width":10,"height":10,"corner":[x,0,0],"operation":"new_body","body_name":name})).unwrap();
|
||||
}
|
||||
h.app.start("solid.combine");
|
||||
h.app.dialog.as_mut().unwrap().preview_enabled = false;
|
||||
h.settle();
|
||||
h.step(&json!({"click":{"handle":"row:One"}})).unwrap();
|
||||
assert_eq!(h.app.dialog.as_ref().unwrap().active, 1, "a target pick advances to Tool Bodies");
|
||||
h.step(&json!({"click":{"handle":"row:Two"}})).unwrap();
|
||||
let d = h.app.dialog.as_ref().unwrap();
|
||||
assert_eq!(d.inputs[0].items, vec![Sel::Body { name: "One".into() }]);
|
||||
assert_eq!(d.inputs[1].items, vec![Sel::Body { name: "Two".into() }]);
|
||||
h.call("ui.dialogInput", json!({"index":0}));
|
||||
h.step(&json!({"click":{"handle":"row:Two"}})).unwrap();
|
||||
assert_eq!(h.app.dialog.as_ref().unwrap().inputs[0].items, vec![Sel::Body { name: "Two".into() }], "a single input replaces its pick");
|
||||
h.step(&json!({"key":"Escape"})).unwrap();
|
||||
h.app.start("solid.fillet");
|
||||
h.settle();
|
||||
h.step(&json!({"click":{"handle":"row:One"}})).unwrap();
|
||||
assert!(h.app.dialog.as_ref().unwrap().inputs.iter().all(|i| i.items.is_empty()), "a body is not an edge");
|
||||
assert!(h.app.session.selection.is_empty(), "an incompatible pick does not leak into the global selection");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn browser_card_shrinks_and_scrolls_without_covering_history() {
|
||||
let mut h = Harness::new();
|
||||
|
||||
@@ -40,6 +40,21 @@ fn click(h: &mut Harness, path: &[u64], control: &str) {
|
||||
assert_eq!(result["ok"], true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn save_mesh_browser_pick_uses_the_body_of_the_clicked_placement() {
|
||||
let (mut h, _, first, second) = fixture();
|
||||
h.app.tree.collapsed.insert(super::occurrence_key(&[first]));
|
||||
let expected = h.app.session.occurrence_bodies(&[second], true).unwrap();
|
||||
h.app.start("file.save_mesh");
|
||||
h.settle();
|
||||
h.step(&json!({"click":{"handle":"row:Body1"}})).unwrap();
|
||||
let d = h.app.dialog.as_ref().unwrap();
|
||||
let crate::dialogs::Kind::SaveMesh(k) = &d.kind else { panic!("Save as Mesh is open") };
|
||||
let commands = crate::dialogs_save_mesh::commands(k, &d.inputs).unwrap();
|
||||
assert_eq!(commands[0].1["bodies"], json!(expected));
|
||||
assert_ne!(expected, h.app.session.occurrence_bodies(&[first], true).unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn occurrence_second_row_selects_exact_path_and_menu_actions() {
|
||||
let (mut h, component, first, second) = fixture();
|
||||
|
||||
Reference in New Issue
Block a user