* claim: #9894 * Fix viewport recovery after component isolation
This commit is contained in:
1 parent
062a7b8288
commit
da586bc048
2 files changed
+36
-4
No files matched your search
@@ -734,11 +734,11 @@ fn viewport_items(app: &SolveApp) -> Vec<Item> {
|
||||
v.push(act("ui.fit", "Fit", "fit"));
|
||||
v.push(act("ui.home", "Home View", "home"));
|
||||
v.push(Item::sep());
|
||||
let anything_hidden = !app.session.visibility.hidden_bodies.is_empty()
|
||||
|| !app.session.visibility.hidden_sketches.is_empty()
|
||||
|| !app.session.visibility.hidden_folders.is_empty();
|
||||
let can_unisolate = !app.session.visibility.hidden_bodies.is_empty() || !app.session.visibility.hidden_occurrences.is_empty();
|
||||
let anything_hidden =
|
||||
can_unisolate || !app.session.visibility.hidden_sketches.is_empty() || !app.session.visibility.hidden_folders.is_empty();
|
||||
v.push(act("ui.showAll", "Show All", "eye").on(anything_hidden));
|
||||
v.push(act("ui.showAll", "Unisolate", "eye").on(!app.session.visibility.hidden_bodies.is_empty()));
|
||||
v.push(act("ui.showAll", "Unisolate", "eye").on(can_unisolate));
|
||||
v.push(Item::sep());
|
||||
v.push(cmd(app, "solid.extrude", "Extrude"));
|
||||
v.push(cmd(app, "solid.fillet", "Fillet"));
|
||||
|
||||
@@ -34,6 +34,38 @@ fn fixture() -> (Harness, u64, u64, u64) {
|
||||
(h, component, first, second)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn viewport_restores_isolated_occurrences_and_undo_restores_isolation() {
|
||||
for label in ["Show All", "Unisolate"] {
|
||||
let (mut h, _, first, second) = fixture();
|
||||
h.app.session.selection.clear();
|
||||
let menu_item =
|
||||
|h: &Harness, label: &str| context_menu::items(&h.app, &Target::Viewport).into_iter().find(|item| item.label == label).unwrap();
|
||||
assert!(!menu_item(&h, label).enabled, "nothing is hidden yet");
|
||||
let isolate =
|
||||
context_menu::items(&h.app, &Target::Occurrence { path: vec![first] }).into_iter().find(|item| item.label == "Isolate").unwrap();
|
||||
context_menu::run_item(&mut h.app, &isolate, egui::Pos2::ZERO);
|
||||
assert!(h.app.session.visibility.hidden_bodies.is_empty());
|
||||
assert_eq!(h.app.session.visibility.hidden_occurrences, vec![vec![second]]);
|
||||
let other_body = h.app.session.occurrence_bodies(&[second], false).unwrap()[0].clone();
|
||||
assert!(!h.app.session.body_visible(&other_body));
|
||||
|
||||
let restore = menu_item(&h, label);
|
||||
assert!(restore.enabled, "{label} must restore a hidden component instance");
|
||||
let undo = h.app.session.undo.len();
|
||||
context_menu::run_item(&mut h.app, &restore, egui::Pos2::ZERO);
|
||||
assert!(h.app.session.visibility.hidden_occurrences.is_empty());
|
||||
assert!(h.app.session.body_visible(&other_body));
|
||||
assert_eq!(h.app.session.undo.len(), undo + 1, "restoring visibility is one undo step");
|
||||
assert!(!menu_item(&h, label).enabled, "all component instances are visible again");
|
||||
|
||||
h.app.run("edit.undo", json!({})).unwrap();
|
||||
assert_eq!(h.app.session.visibility.hidden_occurrences, vec![vec![second]]);
|
||||
assert!(!h.app.session.body_visible(&other_body));
|
||||
assert!(menu_item(&h, label).enabled);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn folder_visibility_shortcut_targets_only_the_clicked_placement() {
|
||||
let (mut h, component, first, second) = fixture();
|
||||
|
||||
Reference in new issue
Block a user