fix(engine): To Stage in a group inside a symbol, an import's path through vfs, every setting a check item (M8)

This commit is contained in:
Tanish Manku committed 2026-11-24 15:22:45 -07:00
1 parent 9dccedc136
commit 3b2ec2c2bf
5 files changed
+34 -9

No files matched your search

+1 -1
View File
@@ -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() };
+6 -4
View File
@@ -725,11 +725,13 @@ fn selected_units(s: &Session, outlines: bool) -> Vec<Unit> {
/// 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)
}
}
+9
View File
@@ -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!({}));
+10
View File
@@ -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<PathBuf> {
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)?;
+8 -4
View File
@@ -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));
}