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 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
PaddleStroke
2026-10-29 09:20:11 +00:00
committed by GitHub
parent 0f2ad19bdb
commit 7341b8f6be
3 changed files with 45 additions and 4 deletions
+9 -4
View File
@@ -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());
+11
View File
@@ -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() };
+25
View File
@@ -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() },