SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Browser: Show/Hide context menu on origin axis rows (#8382) (#8724)
PaddleStroke7341b8f6be35
diff --git a/crates/ui-egui/src/browser.rs b/crates/ui-egui/src/browser.rsindex 6e7d0fbf90..e5be74595f 100644--- a/crates/ui-egui/src/browser.rs+++ b/crates/ui-egui/src/browser.rs@@ -1690,10 +1690,15 @@ fn origin_rows(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize, acts: &mut A// Through the command, so the Origin row's eye is an undo step (#2219).let _ = app.run("browser.visibility", json!({ "items": [k], "visible": !visible }));}- if let Some(p) = r.secondary- && icon == "plane"- {- crate::context_menu::open_for(app, p, Target::OriginPlane { name: k.into() });+ if let Some(p) = r.secondary {+ let target = match icon {+ "plane" => Some(Target::OriginPlane { name: k.into() }),+ "axis" => Some(Target::OriginAxis { name: k.into() }),+ _ => None,+ };+ if let Some(target) = target {+ crate::context_menu::open_for(app, p, target);+ }}if r.hovered && icon == "plane" {acts.hover_plane = Some(k.into());diff --git a/crates/ui-egui/src/context_menu.rs b/crates/ui-egui/src/context_menu.rsindex efe9839d93..3dca67bb7d 100644--- a/crates/ui-egui/src/context_menu.rs+++ b/crates/ui-egui/src/context_menu.rs@@ -44,6 +44,10 @@ pub enum Target {OriginPlane {name: String,},+ /// An origin axis (X, Y or Z).+ OriginAxis {+ name: String,+ },Component {id: u64,},@@ -375,6 +379,7 @@ pub fn items(app: &SolveApp, target: &Target) -> Vec<Item> {Target::Feature { id } => feature_items(app, *id),Target::Plane { id } => plane_items(app, *id),Target::OriginPlane { name } => origin_plane_items(app, name),+ Target::OriginAxis { name } => origin_axis_items(app, name),Target::Component { id } => component_items(app, *id),Target::Occurrence { path } => occurrence_items(app, path),Target::Group { id, scope } => crate::browser::group_items(app, *id, scope),@@ -789,6 +794,12 @@ fn origin_plane_items(app: &SolveApp, name: &str) -> Vec<Item> {]}+/// An origin axis: Show/Hide, as on a plane (an axis takes no sketch) (#8382).+fn origin_axis_items(app: &SolveApp, name: &str) -> Vec<Item> {+ let visible = !app.session.visibility.hidden_origin.iter().any(|h| h == name);+ vec![act("ui.originPart", "Show/Hide", "eye").key("V").with(json!({ "keys": [name], "show": !visible }))]+}+/// An assembly joint: edit, drive, suppress, delete.fn joint_items(app: &SolveApp, id: u64) -> Vec<Item> {let Some(j) = app.session.doc.assembly.joints.iter().find(|j| j.id == id) else { return Vec::new() };diff --git a/crates/ui-egui/src/menu_tests.rs b/crates/ui-egui/src/menu_tests.rsindex 49c517d0bd..2c541a80a1 100644--- a/crates/ui-egui/src/menu_tests.rs+++ b/crates/ui-egui/src/menu_tests.rs@@ -952,6 +952,9 @@ fn v_with_a_menu_open_shows_or_hides_what_the_menu_is_for() {open(&mut h, Target::OriginPlane { name: "XY".into() });press_v(&mut h);assert!(h.app.session.visibility.hidden_origin.iter().any(|o| o == "XY"), "V on an origin plane's menu");+ open(&mut h, Target::OriginAxis { name: "Z".into() });+ press_v(&mut h);+ assert!(h.app.session.visibility.hidden_origin.iter().any(|o| o == "Z"), "V on an origin axis's menu (#8382)");assert!(!h.app.session.visibility.hidden_bodies.contains(&b));// With no menu open, V still flips the selection.press_v(&mut h);@@ -1235,6 +1238,27 @@ fn right_click_on_a_plane_offers_a_sketch_on_it() {assert_eq!(sketch, Some(25.0), "the sketch is on the construction plane");}+/// A right-click on an origin axis row opens its own menu, with the planes' Show/Hide (#8382).+#[test]+fn right_click_on_an_origin_axis_offers_show_hide() {+ let mut h = crate::scenario::Harness::new();+ h.app.home.open = false;+ crate::browser::toggle(&mut h.app, "origin", false);+ h.frames(3);+ let at = crate::scenario::handle_at("row:Y").expect("the Origin folder lists the Y axis");+ h.call("ui.click", json!({"x": at.x, "y": at.y, "button": "right"}));+ h.frames(2);+ let menu = h.call("ui.menu", json!({}))["result"].clone();+ assert_eq!(menu["target"], json!({"type": "origin_axis", "name": "Y"}), "{menu}");+ let t = Target::OriginAxis { name: "Y".into() };+ let labels: Vec<String> = context_menu::items(&h.app, &t).iter().map(|i| i.label.clone()).collect();+ assert_eq!(labels, ["Show/Hide"], "an axis offers no Create Sketch");+ act(&mut h.app, &t, "Show/Hide");+ assert!(h.app.session.visibility.hidden_origin.contains(&"Y".to_string()), "hidden through the menu");+ act(&mut h.app, &t, "Show/Hide");+ assert!(!h.app.session.visibility.hidden_origin.contains(&"Y".to_string()), "shown again");+}+/// A right-click on empty space leads with Create Sketch too (#3032), in the same place as on a/// plane: the toolbar's, which asks for the plane or face. Either way the menu offers it once.#[test]@@ -1436,6 +1460,7 @@ fn every_context_target_has_identified_icon_rows_including_submenus() {Target::Plane { id: plane },Target::Feature { id: feature },Target::OriginPlane { name: "XY".into() },+ Target::OriginAxis { name: "Z".into() },Target::Component { id: part },Target::Occurrence { path: vec![occurrence] },Target::Group { id: group_id, scope: "c0".into() },