From 7341b8f6be35a69c42136e58d71fe88655340d67 Mon Sep 17 00:00:00 2001 From: PaddleStroke Date: Thu, 29 Oct 2026 09:20:11 +0000 Subject: [PATCH] Browser: Show/Hide context menu on origin axis rows (#8382) (#8724) * claim: #8382 * Browser: Show/Hide context menu on origin axis rows (#8382) Right-clicking an origin axis row (X, Y, Z) now opens its own menu with Show/Hide (V), through ui.originPart and browser.visibility like the origin planes' entry. An axis takes no sketch, so Create Sketch is not offered. Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 --- crates/ui-egui/src/browser.rs | 13 +++++++++---- crates/ui-egui/src/context_menu.rs | 11 +++++++++++ crates/ui-egui/src/menu_tests.rs | 25 +++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/browser.rs b/crates/ui-egui/src/browser.rs index 6e7d0fbf9..e5be74595 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.rs index efe9839d9..3dca67bb7 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 { 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 { ] } +/// An origin axis: Show/Hide, as on a plane (an axis takes no sketch) (#8382). +fn origin_axis_items(app: &SolveApp, name: &str) -> Vec { + 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 { 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.rs index 49c517d0b..2c541a80a 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 = 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() },