diff --git a/crates/ui-egui/src/browser.rs b/crates/ui-egui/src/browser.rs index 3f35c88289b..0562e8f2b98 100644 --- a/crates/ui-egui/src/browser.rs +++ b/crates/ui-egui/src/browser.rs @@ -41,11 +41,12 @@ pub(crate) fn rows_start_open(app: &SolveApp) -> bool { !app.preferences.browser_rows_start_closed } -/// Whether the Browser follows the 3D view: a body picked there opens the Browser down to its row -/// (#3005), and the rows above what is selected or under the pointer are marked (#3009). It does -/// while the rows start open; while they start closed, only Find in Browser opens them. -fn follows_view(app: &SolveApp) -> bool { - rows_start_open(app) +/// Whether the Browser follows the 3D view: a body or placement picked there opens the Browser +/// down to its row (#3005), and the rows above what is selected or under the pointer are marked +/// (#3009). It always does: "Browser rows start closed" only decides how rows are first drawn, +/// and no longer stops picks from revealing their row (#25420). +fn follows_view(_app: &SolveApp) -> bool { + true } /// Whether the Browser tree panel is open now. The panel layout holds the effective state (a diff --git a/crates/ui-egui/src/browser/features.rs b/crates/ui-egui/src/browser/features.rs index 4a42b8fc5bf..6390005f80a 100644 --- a/crates/ui-egui/src/browser/features.rs +++ b/crates/ui-egui/src/browser/features.rs @@ -1775,9 +1775,8 @@ mod tests { } /// While the Browser's rows start closed (Preferences › Layout, #8768), Find in Browser - /// opens the rows down to the body it finds and no others, and lights them from the path it - /// found, without walking the placements again. The next find closes the rows the last one - /// opened, but not rows opened or closed by hand since. + /// opens the rows down to the body it finds and no others, and lights them. The next find + /// closes the rows the last one opened, but not rows opened or closed by hand since. #[test] fn browser_find_opens_only_the_found_bodys_rows_and_the_next_find_closes_them() { let mut h = Harness::new(); @@ -1813,7 +1812,6 @@ mod tests { ); h.app.viewport.hover = None; assert_eq!(Lit::of(&mut h.app).paths, std::slice::from_ref(&second), "the rows above the found body are marked"); - assert!(!h.app.tree.model.as_ref().unwrap().body_paths_walked(), "from the path found once"); // By hand: the first Assembly opens, and Part in the second is closed and opened again. crate::test_support::click(&mut h, &format!("fold:occurrence:{assembly}")); diff --git a/crates/ui-egui/src/browser_model.rs b/crates/ui-egui/src/browser_model.rs index 74ded8e0fbc..37ee0b296c1 100644 --- a/crates/ui-egui/src/browser_model.rs +++ b/crates/ui-egui/src/browser_model.rs @@ -371,10 +371,4 @@ impl Model { pub fn body_paths_ready(&self) -> bool { self.body_paths.is_some() } - - /// Whether [`Model::body_path`] has walked the placements for this model. - #[cfg(test)] - pub fn body_paths_walked(&self) -> bool { - self.body_paths.is_some() - } } diff --git a/crates/ui-egui/src/browser_model_tests.rs b/crates/ui-egui/src/browser_model_tests.rs index e011a104c3f..9979cbdc45e 100644 --- a/crates/ui-egui/src/browser_model_tests.rs +++ b/crates/ui-egui/src/browser_model_tests.rs @@ -237,42 +237,30 @@ fn browser_rows_start_closed_closes_placements_even_with_components_start_open() assert!(h.app.tree.content.owner(crate::semantic_content::ContentOwner::BROWSER).unwrap().order.contains(&row), "off again, it is open again"); } -/// #8768: while the Browser's rows start closed (Preferences › Layout), a pick in the 3D view -/// opens, closes and scrolls nothing, and neither the pick nor a body under the pointer has its -/// placement looked up to mark the rows above it: on a large assembly that lookup names every -/// placement again after each edit. With the preference off again, the rows above the hovered -/// body are marked (#3009); a picked face marks its feature's row, not its body's (#9848). +/// #25420: enabling "Browser rows start closed" keeps initial rows collapsed without disabling 3D +/// viewport selection reveal (`reveal_pick`) or ancestor highlighting (`Lit::of`). #[test] -fn a_pick_in_the_viewport_leaves_the_browser_alone_while_its_rows_start_closed() { +fn a_pick_in_the_viewport_reveals_its_body_even_while_rows_start_closed() { let (mut h, _, occurrence) = fixture(); assert_eq!(h.call("ui.prefs", json!({"browser_rows_start_closed": true}))["ok"], true); let copy = h.app.run("occurrence.copy", json!({"occurrence":occurrence,"translate":[50,0,0]})).unwrap()["occurrence"].as_u64().unwrap(); + let first = super::model_placement(&mut h.app, &[occurrence]).unwrap().bodies[0].world.clone(); let second = super::model_placement(&mut h.app, &[copy]).unwrap().bodies[0].world.clone(); h.app.ui.show_browser = true; - // Both placements open by hand, their Bodies folders closed as they start. - h.app.tree.expanded.extend([super::occurrence_key(&[occurrence]), super::occurrence_key(&[copy])]); h.frames(2); - let (collapsed, expanded, order) = ( - h.app.tree.collapsed.clone(), - h.app.tree.expanded.clone(), - h.app.tree.content.owner(crate::semantic_content::ContentOwner::BROWSER).unwrap().order.clone(), - ); - let point = solidcore_record::Vec3::new(55.0, 5.0, 10.0); + assert!(!super::is_open(&h.app, &super::occurrence_key(&[occurrence]), false), "first placement starts closed"); + assert!(!super::is_open(&h.app, &super::occurrence_key(&[copy]), false), "second placement starts closed"); + + let point = solidcraft_kernel::api::record::Vec3::new(55.0, 5.0, 10.0); crate::viewport::select(&mut h.app, Some(Sel::Face { body: second.clone(), index: 0, point }), false, false); - assert!(h.app.tree.reveal.is_none(), "nothing to scroll to"); + assert_eq!(h.app.tree.reveal.as_deref(), Some(second.as_str()), "3D pick schedules reveal"); h.frames(3); - assert!(!h.app.session.selection.is_empty(), "the face is picked"); - assert_eq!((&h.app.tree.collapsed, &h.app.tree.expanded), (&collapsed, &expanded), "every row stays open or closed as it was"); - assert_eq!(h.app.tree.content.owner(crate::semantic_content::ContentOwner::BROWSER).unwrap().order, order, "the same rows are drawn"); - h.app.viewport.hover = Some(crate::viewport::Hit::Face { body: second.clone(), index: 0, point }); - let lit = super::Lit::of(&mut h.app); - assert!(lit.paths.is_empty(), "no row above the picked or hovered body is marked: {:?}", lit.paths); - assert!(!h.app.tree.model.as_ref().unwrap().body_paths_walked(), "the placements were not walked for the pick or the pointer"); - assert_eq!(h.call("ui.prefs", json!({"browser_rows_start_closed": false}))["ok"], true); - // The call's frames took the hover from the pointer, which is elsewhere. - h.app.viewport.hover = Some(crate::viewport::Hit::Face { body: second.clone(), index: 0, point }); - let lit = super::Lit::of(&mut h.app); - assert_eq!(lit.paths, [vec![copy]], "the placement above the hovered body, which also holds the picked face, once"); + assert!(h.app.tree.reveal.is_none(), "the revealed body row was drawn and scrolled to"); + let order = &h.app.tree.content.owner(crate::semantic_content::ContentOwner::BROWSER).unwrap().order; + assert!(order.contains(&format!("b:{second}")), "picked body is revealed in the Browser"); + assert!(!order.contains(&format!("b:{first}")), "other placements remain closed"); + h.app.viewport.hover = None; + assert_eq!(super::Lit::of(&mut h.app).paths, [vec![copy]], "ancestor placement is marked"); } /// #8768: while the Browser's rows start closed, a new design's Bodies and Sketches folders list @@ -424,7 +412,7 @@ fn render_browser_swatch_resolves_face_body_component_then_physical_material() { assert_eq!(swatch(&h).name, "ABS - Red"); h.app.run("appearance.assign", json!({"bodies":["Body1"],"appearance":"ABS - Blue"})).unwrap(); assert_eq!(swatch(&h).name, "ABS - Blue"); - let point = solidcore_record::Vec3::new(0.0, 5.0, 5.0); + let point = solidcraft_kernel::api::record::Vec3::new(0.0, 5.0, 5.0); h.app.run("appearance.assign", json!({"body":"Body1","faces":[point],"appearance":"ABS - Red"})).unwrap(); let state = crate::open_meshing::session_world(&h.app.session); let body = state.body("Body1").unwrap(); @@ -847,7 +835,7 @@ fn find_in_browser_opens_placements_that_start_closed() { fn a_body_keeps_a_faint_bar_while_one_of_its_faces_is_selected() { let (mut h, component, occurrence) = fixture(); let body = super::model_placement(&mut h.app, &[occurrence]).unwrap().bodies[0].world.clone(); - let point = solidcore_record::Vec3::new(0.0, 5.0, 5.0); + let point = solidcraft_kernel::api::record::Vec3::new(0.0, 5.0, 5.0); let state = crate::open_meshing::session_world(&h.app.session); let face = solidcraft_engine::doc::appearance::face_index_at(state.body(&body).unwrap(), point).unwrap(); let row = |app: &mut crate::SolveApp| { @@ -1173,7 +1161,7 @@ fn reveal_pick_follows_shared_panel_open_state_over_show_browser_flag() { } #[test] -fn clicking_an_occurrence_leaves_the_browser_alone_while_rows_start_closed() { +fn clicking_an_occurrence_reveals_its_ancestors_even_while_rows_start_closed() { let mut h = crate::scenario::Harness::new(); assert_eq!(h.call("ui.prefs", json!({"browser_rows_start_closed": true}))["ok"], true); let outer = h.app.run("component.create", json!({"name": "Outer"})).unwrap()["occurrence"].as_u64().unwrap(); @@ -1182,21 +1170,15 @@ fn clicking_an_occurrence_leaves_the_browser_alone_while_rows_start_closed() { h.app.run("component.activate", json!({"component": 0})).unwrap(); let path = vec![outer, inner]; let outer_key = super::occurrence_key(&[outer]); - let body = h.app.session.occurrence_bodies(&path, false).unwrap()[0].clone(); h.app.ui.show_browser = true; h.frames(2); - let (collapsed, expanded) = (h.app.tree.collapsed.clone(), h.app.tree.expanded.clone()); + assert!(!super::is_open(&h.app, &outer_key, false)); crate::viewport::select(&mut h.app, Some(Sel::Occurrence { path: path.clone() }), false, false); - assert!(h.app.tree.reveal_occurrence.is_none()); - assert!(!super::is_open(&h.app, &outer_key, true)); - assert_eq!((&h.app.tree.collapsed, &h.app.tree.expanded), (&collapsed, &expanded)); - assert!(super::Lit::of(&mut h.app).paths.is_empty()); - - // Explicit Find in Browser still opens the path to the body and acknowledges it. - super::reveal_body(&mut h.app, &body); + assert_eq!(h.app.tree.reveal_occurrence.as_ref(), Some(&path)); + assert!(super::is_open(&h.app, &outer_key, false)); + assert!(!super::is_open(&h.app, &super::occurrence_key(&path), false)); + assert_eq!(super::Lit::of(&mut h.app).paths, std::slice::from_ref(&path)); h.frames(2); - assert!(h.app.tree.reveal.is_none()); - assert!(super::is_open(&h.app, &outer_key, true)); - assert!(super::is_open(&h.app, &super::occurrence_key(&path), true)); + assert!(h.app.tree.reveal_occurrence.is_none()); } diff --git a/crates/ui-egui/src/prefs/fields/layout.rs b/crates/ui-egui/src/prefs/fields/layout.rs index f8a7009c684..2a9ccef8e51 100644 --- a/crates/ui-egui/src/prefs/fields/layout.rs +++ b/crates/ui-egui/src/prefs/fields/layout.rs @@ -35,10 +35,9 @@ macro_rules! layout_preferences { /// Folders in the Browser start closed, and placements too whatever "Components start open" /// says, and they open only on request (#8768): with their arrow, Expand All or Find in /// Browser, which opens just the rows down to its body and closes again the ones the last find - /// opened. A body picked in the 3D view leaves the Browser as it is, and only the body Find in - /// Browser found has the rows above it marked, so a large assembly's placements are not named - /// again after each edit. Off by default: folders start open, placements as "Components start - /// open" says, and a pick in the 3D view opens the Browser down to its body (#3005), as before. + /// opened. A pick in the 3D view still opens the Browser down to what it picked (#3005, #25420): + /// this only decides how rows are first drawn. Off by default: folders start open and + /// placements as "Components start open" says. browser_rows_start_closed: bool = false, PAGE_LAYOUT; /// Use distinct tab treatments for the focused view, cards, hidden views, and pop-outs. clear_view_tabs: bool = true, PAGE_LAYOUT; diff --git a/crates/ui-text/locales/en.json b/crates/ui-text/locales/en.json index c6ce745688d..8eb7647b73c 100644 --- a/crates/ui-text/locales/en.json +++ b/crates/ui-text/locales/en.json @@ -25,7 +25,7 @@ "prefs.browser_eye_left": "Eye beside the fold arrow", "prefs.browser_eye_left_note": "Browser rows show their show/hide eye next to the fold arrow, as before, instead of in a column at the right end of the rows.", "prefs.browser_rows_start_closed": "Browser rows start closed", - "prefs.browser_rows_start_closed_note": "Placements and folders in the Browser start closed, so a design with many components shows its top-level rows. Each opens with its arrow, Expand All or Find in Browser, which opens just the rows down to its body and closes again the ones the last find opened. A body picked in the 3D view leaves the Browser as it is. When off, folders start open, placements start as Components start open says, and a pick in the 3D view opens the Browser down to its body, as before.", + "prefs.browser_rows_start_closed_note": "Placements and folders in the Browser start closed, so a design with many components shows its top-level rows. Each opens with its arrow, Expand All, Find in Browser or a pick in the 3D view, which opens just the rows down to what it picked. When off, folders start open and placements start as Components start open says.", "prefs.built_in": "Built in", "prefs.button_left": "Left drag", "prefs.button_middle": "Middle drag",