M3.11: layer commands respect locks, keep children in place on delete, arrange step by step, keep depth and separated dimensions, keep links on duplicate/paste

- Locked layers can't be selected (Timeline click, Select All, Ctrl+Up/Down; shy layers while
  hidden too) and are left alone by Clear/Delete, Arrange, Layer ▸ Transform and Center Anchor
  Point, which fail when every target is locked (`commands::unlocked`, `commands::selectable`).
- Deleting a parent unparents its children where they are, in the same undo step: the
  pick-whip compensation moved out of `layer.setParent` into `layer::parent_fixes` /
  `ParentFix::apply`, which now also handles separated X/Y Position.
- Bring Forward / Send Backward move each selected layer one step (a non-contiguous selection
  was squeezed into one block).
- Center In View / Fit to Comp keep a 3D layer's Z (and Fit keeps Scale/Anchor Z); Reset /
  Center / Fit / Center Anchor Point work with separated dimensions (`layer::update_position`).
- Duplicate and paste keep parents and track mattes, following the copies when both were
  copied; paste dropped them always.
- Docs: agents, parity.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bflatastic
2026-10-04 23:33:54 +07:00
co-authored by Claude Opus 5.5
parent 753de070a0
commit 89653f37de
8 changed files with 381 additions and 88 deletions
+18 -9
View File
@@ -209,6 +209,7 @@ fn set_transform(s: &mut Session, p: &Value) -> Result<Value> {
fn center_anchor(s: &mut Session, p: &Value) -> Result<Value> {
let (cid, ids) = layers_p(s, p)?;
let ids = super::unlocked(s, cid, ids, "layer.centerAnchor")?;
let t = s.time();
let comp = s.project.comp(cid).ok_or(EngineError::NoComp)?;
let ctx = effectcraft_render::EvalCtx::new(&s.project, cid, comp, t);
@@ -234,17 +235,25 @@ fn center_anchor(s: &mut Session, p: &Value) -> Result<Value> {
if let Some(a) = tr.get_mut("anchor") {
a.set_value_at(lt, KV::Vec3([c[0], c[1], anchor[2]]));
}
if let Some(pos) = tr.get_mut("position") {
// Shift every key so the layer stays put over its whole animation.
if pos.keys.is_empty() {
let v = pos.value.as_vec3();
pos.value = KV::Vec3([v[0] + shift[0], v[1] + shift[1], v[2]]);
} else {
for k in &mut pos.keys {
let v = k.value.as_vec3();
k.value = KV::Vec3([v[0] + shift[0], v[1] + shift[1], v[2]]);
// Shift every key so the layer stays put over its whole animation (X and Y Position
// when the dimensions are separated).
let offset = |pr: &mut effectcraft_project::Property, f: &dyn Fn(&KV) -> KV| {
pr.value = f(&pr.value);
for k in &mut pr.keys {
k.value = f(&k.value);
}
};
if tr.get("positionX").is_some() {
for (m, d) in [("positionX", shift[0]), ("positionY", shift[1])] {
if let Some(pr) = tr.get_mut(m) {
offset(pr, &|v| KV::Scalar(v.as_f64() + d));
}
}
} else if let Some(pr) = tr.get_mut("position") {
offset(pr, &|v| {
let c = v.as_vec3();
KV::Vec3([c[0] + shift[0], c[1] + shift[1], c[2]])
});
}
}
Ok(())