From 3b2ec2c2bf087260ac322ee2f4da6031752d384d Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Tue, 24 Nov 2026 15:22:45 -0700 Subject: [PATCH] fix(engine): To Stage in a group inside a symbol, an import's path through vfs, every setting a check item (M8) --- crates/engine/src/cmds_file.rs | 2 +- crates/engine/src/cmds_modify.rs | 10 ++++++---- crates/engine/src/tests.rs | 9 +++++++++ crates/engine/src/vfs.rs | 10 ++++++++++ src/menus.rs | 12 ++++++++---- 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/crates/engine/src/cmds_file.rs b/crates/engine/src/cmds_file.rs index 4e8a547f..1f2b2b22 100644 --- a/crates/engine/src/cmds_file.rs +++ b/crates/engine/src/cmds_file.rs @@ -208,7 +208,7 @@ impl Import { // inside the package as "animation.anicraft". let package = match package.file_name() { Some(_) => package, - None => std::fs::canonicalize(&package).unwrap_or(package), + None => crate::vfs::canonicalize(&package).unwrap_or(package), }; // A folder's whole name ("walk.v2" stays "walk.v2"); a file's without its extension. let name = if crate::vfs::is_dir(&package) { package.file_name() } else { package.file_stem() }; diff --git a/crates/engine/src/cmds_modify.rs b/crates/engine/src/cmds_modify.rs index 9ed44fe1..61bd7b17 100644 --- a/crates/engine/src/cmds_modify.rs +++ b/crates/engine/src/cmds_modify.rs @@ -725,11 +725,13 @@ fn selected_units(s: &Session, outlines: bool) -> Vec { /// What To Stage aligns to: the stage, or inside an open symbol its own space, where the /// symbol's registration point stands for the stage (#568): centring there centres the -/// artwork on that point, and Left and Top put its edge on it. +/// artwork on that point, and Left and Top put its edge on it. A group or drawing object opened +/// inside a symbol is still inside that symbol. fn stage_in_edit_space(s: &Session) -> Rect { - match s.editing.last().map(|l| l.open) { - Some(crate::editing::Opened::Symbol(_)) => Rect::new(0.0, 0.0, 0.0, 0.0), - _ => Rect::new(0.0, 0.0, s.doc.stage.width as f32, s.doc.stage.height as f32), + if s.editing.iter().any(|l| l.symbol().is_some()) { + Rect::new(0.0, 0.0, 0.0, 0.0) + } else { + Rect::new(0.0, 0.0, s.doc.stage.width as f32, s.doc.stage.height as f32) } } diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 15f4f982..5c4537ed 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -493,6 +493,15 @@ fn align_to_stage_inside_a_symbol_centres_on_its_registration_point() { run(&mut s, "align.vcenter", json!({"to_stage": true})); let c = s.selection_bounds().center(); assert!(c.x.abs() < 0.01 && c.y.abs() < 0.01, "centred on the registration point: {c:?}"); + // A group opened inside the symbol is still inside it. + run(&mut s, "element.translate", json!({"dx": 70, "dy": 30})); + run(&mut s, "modify.group", json!({})); + let group = s.selection.ids().next().unwrap(); + run(&mut s, "symbol.edit", json!({"id": group.0})); + run(&mut s, "edit.select_all", json!({})); + run(&mut s, "align.hcenter", json!({"to_stage": true})); + let c = s.selection_bounds().center(); + assert!(c.x.abs() < 0.01, "inside a group in the symbol, still its registration point: {c:?}"); // On the stage itself, To Stage is still the document's stage. run(&mut s, "symbol.exit", json!({"all": true})); run(&mut s, "edit.select_all", json!({})); diff --git a/crates/engine/src/vfs.rs b/crates/engine/src/vfs.rs index 1ee19b4d..c03b5c89 100644 --- a/crates/engine/src/vfs.rs +++ b/crates/engine/src/vfs.rs @@ -266,6 +266,16 @@ pub fn is_dir(path: &Path) -> bool { mem(|m| m.is_dir(path)).unwrap_or_else(|| path.is_dir()) } +/// `path` with its `.` and `..` parts and links resolved (`std::fs::canonicalize`), for a path +/// an agent may probe. In memory, and where it can't be resolved, `None`: the caller keeps the +/// path it has. +pub fn canonicalize(path: &Path) -> Option { + if check(path, Access::Probe).is_err() || in_memory() { + return None; + } + std::fs::canonicalize(path).ok() +} + /// Folders in memory exist through their files, so this only checks the name there. pub fn create_dir_all(path: &Path) -> io::Result<()> { check(path, Access::Write)?; diff --git a/src/menus.rs b/src/menus.rs index 04afceb4..365137d5 100644 --- a/src/menus.rs +++ b/src/menus.rs @@ -512,7 +512,9 @@ fn item(app: &mut App, ui: &mut egui::Ui, spec: &CommandSpec) { _ => crate::i18n::t_cmd(spec.id, spec.label).to_string(), }; // Settings show whether they are on, as check items do. - let label = match checked(app, spec.id) { + let on = checked(app, spec.id); + let name = label.clone(); + let label = match on { Some(true) => format!("✔ {label}"), Some(false) => format!(" {label}"), None => label, @@ -521,12 +523,14 @@ fn item(app: &mut App, ui: &mut egui::Ui, spec: &CommandSpec) { // What this build can't do stays in its usual place, dimmed, saying why (the web build). let missing = platform::unavailable(spec.id); let r = ui.add_enabled(enabled(app, spec.id) && missing.is_none(), button); - if spec.id == "view.hide_edges" { + // A setting is a check item to a screen reader too: its name without the tick drawn for + // the eye, and whether it is on (every toggling command, not one of them). + if let Some(on) = on { use egui::accesskit::{Role, Toggled}; ui.ctx().accesskit_node_builder(r.id, |node| { node.set_role(Role::MenuItemCheckBox); - node.set_label(crate::i18n::t_cmd(spec.id, spec.label).to_string()); - node.set_toggled(if app.s.aids.hide_edges { Toggled::True } else { Toggled::False }); + node.set_label(name); + node.set_toggled(if on { Toggled::True } else { Toggled::False }); if let Some(key) = app.keymap.primary(spec.id) { node.set_keyboard_shortcut(platform::shortcut_label(key)); }