A placement row's menu starts from its component's menu, which takes Turn Up Axis's enabled state from the component's first placement. Move/Copy was already set again for the placement right-clicked; Turn Up Axis and its two turns now are too, so a free second placement can turn while the first is grounded, and a grounded one can't. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
cf86f18c11
commit
93d0298d25
@@ -833,6 +833,8 @@ fn occurrence_items(app: &SolveApp, path: &[u64]) -> Vec<Item> {
|
||||
entries.insert(0, Item::heading("Shared child: edits affect all copies of its parent"));
|
||||
}
|
||||
let bodies = app.session.occurrence_bodies(path, true).unwrap_or_default();
|
||||
// The component's menu asks its first placement; this row may be another one.
|
||||
let movable = !placement.grounded && app.session.held_by_rigid_group(placement.occurrence).is_none();
|
||||
for item in &mut entries {
|
||||
match item.id.as_str() {
|
||||
"ui.activate" => {
|
||||
@@ -846,11 +848,13 @@ fn occurrence_items(app: &SolveApp, path: &[u64]) -> Vec<Item> {
|
||||
}
|
||||
"ui.moveOccurrence" => {
|
||||
item.params = Some(json!({"occurrence": placement.occurrence, "path": path}));
|
||||
item.enabled = !placement.grounded && app.session.held_by_rigid_group(placement.occurrence).is_none();
|
||||
item.enabled = movable;
|
||||
}
|
||||
"ui.properties" => item.params = Some(json!({"occurrence": placement.occurrence, "path": path})),
|
||||
"ui.turnUpAxis" => {
|
||||
item.enabled = movable;
|
||||
for child in &mut item.children {
|
||||
child.enabled = movable;
|
||||
if let Some(params) = child.params.as_mut() {
|
||||
params["occurrence"] = json!(placement.occurrence);
|
||||
}
|
||||
|
||||
@@ -128,6 +128,24 @@ fn occurrence_second_row_selects_exact_path_and_menu_actions() {
|
||||
assert_eq!(h.app.session.active_occurrence_path, Some(vec![second]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn turn_up_axis_follows_the_placement_right_clicked() {
|
||||
// Whichever placement comes first, a grounded one can't turn and a free one can.
|
||||
let (mut h, _, first, second) = fixture();
|
||||
let turns = |h: &Harness, occurrence: u64| {
|
||||
let items = context_menu::items(&h.app, &Target::Occurrence { path: vec![occurrence] });
|
||||
let turn = items.into_iter().find(|i| i.id == "ui.turnUpAxis").unwrap();
|
||||
let children: Vec<_> = turn.children.iter().map(|c| (c.enabled, c.params.as_ref().unwrap()["occurrence"].as_u64())).collect();
|
||||
(turn.enabled, children)
|
||||
};
|
||||
for (grounded, free) in [(first, second), (second, first)] {
|
||||
h.app.run("occurrence.ground", json!({"occurrence": grounded, "grounded": true})).unwrap();
|
||||
h.app.run("occurrence.ground", json!({"occurrence": free, "grounded": false})).unwrap();
|
||||
assert_eq!(turns(&h, free), (true, vec![(true, Some(free)); 2]), "free placement {free}");
|
||||
assert_eq!(turns(&h, grounded), (false, vec![(false, Some(grounded)); 2]), "grounded placement {grounded}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn occurrence_eye_and_fold_are_independent_and_survive_rename() {
|
||||
let (mut h, component, first, second) = fixture();
|
||||
|
||||
Reference in New Issue
Block a user