From b4b2950c5df426a8a39bc4c506238892a88fb860 Mon Sep 17 00:00:00 2001
From: Brandon Thomas
Date: Thu, 1 Oct 2026 22:36:31 -0400
Subject: [PATCH 1/4] M3.4: After Effects menu-bar parity (engine menu tree,
~190 new commands, menu dialogs)
- engine::menus: the AE 2026 menu bar as an indented tree (same menus, order,
submenus, separators, "..." labels, AE default macOS shortcuts; [mac]/[!mac]
app menu vs Edit > Preferences / File > Exit), entries bind command params,
check-mark state, Effect categories from the registry.
- New engine commands: Layer (quality/sampling, frame blending, switch ops,
numeric Transform values, Center Anchor Point, Auto-Orient, mask ops on
existing masks, layer markers + lock, track-matte menu, open/reveal source,
expression errors), Edit (keyframe clipboard + Paste Reversed, Copy with
(Relative) Property Links, Copy Expression Only, Lift/Extract Work Area,
Select Label Group, Purge, Edit Original), Animation (JSON animation
presets, Add Keyframe, Exponential Scale, Time-Reverse Keyframes, Sequence
Layers, text selectors, Remove All Text Animators, Reveal Properties),
File (New Folder, Close/Close Project, Save a Copy, placeholders/solids,
New Comp from Selection, Dependencies, Run Script File, Interpret/Remember/
Apply Interpretation, Replace/Reload Footage, Reveal in Finder),
Composition (crop to ROI / layer bounds, Save Frame As PNG, Responsive
Design - Time), View (guides add/clear/import/export, region of interest),
Help docs links.
- Frontend commands (viewer, panels, workspaces, dialogs) are registered
engine commands that emit Event::Frontend; owned-elsewhere items (3D,
render queue, time remap, pen, tracking, layer styles) are disabled stubs.
- UI renders the engine tree (check gutter, scrolling long submenus, dynamic
Undo/Redo labels), bindings include param'd entries, generic parameter
forms, Settings, Keyboard Shortcuts, View Options, guides/ROI/pasteboard in
the viewer, timeline reveal of engine-picked properties; snapshot example
gains a `pointer` step for opening menus headlessly.
- Tests: menu order, every entry resolves, spec/tree consistency, shortcut
uniqueness, per-family command tests with undo.
- Workspace clippy -D warnings clean (rust 1.96 lints).
Co-Authored-By: Claude Opus 5.5
---
Cargo.lock | 1 +
apps/effectcraft-cli/src/main.rs | 3 +-
apps/effectcraft/src/main.rs | 8 +-
crates/engine/Cargo.toml | 1 +
crates/engine/src/commands/anim.rs | 428 +++++++++++
crates/engine/src/commands/comp.rs | 6 +-
crates/engine/src/commands/comp_more.rs | 130 ++++
crates/engine/src/commands/edit.rs | 371 ++++++++-
crates/engine/src/commands/file.rs | 10 +-
crates/engine/src/commands/file_more.rs | 681 +++++++++++++++++
crates/engine/src/commands/frontend.rs | 77 ++
crates/engine/src/commands/help.rs | 17 +-
crates/engine/src/commands/layer.rs | 14 +-
crates/engine/src/commands/layer_menu.rs | 834 ++++++++++++++++++++
crates/engine/src/commands/mod.rs | 70 +-
crates/engine/src/commands/prop.rs | 4 +-
crates/engine/src/commands/stubs.rs | 112 +++
crates/engine/src/commands/time.rs | 2 +-
crates/engine/src/commands/view.rs | 86 +++
crates/engine/src/lib.rs | 49 +-
crates/engine/src/menus.rs | 925 +++++++++++++++++++++++
crates/engine/src/menus/tests.rs | 148 ++++
crates/engine/src/tests_menu_cmds.rs | 491 ++++++++++++
crates/host/src/lib.rs | 11 +-
crates/project/src/build.rs | 1 +
crates/project/src/lib.rs | 14 +
crates/ui-egui/examples/snapshot.rs | 19 +
crates/ui-egui/src/lib.rs | 16 +
crates/ui-egui/src/menus.rs | 714 +++++++++++------
crates/ui-egui/src/panels/dialogs.rs | 16 +-
crates/ui-egui/src/panels/forms.rs | 547 ++++++++++++++
crates/ui-egui/src/panels/mod.rs | 1 +
crates/ui-egui/src/panels/project.rs | 6 +-
crates/ui-egui/src/panels/timeline.rs | 41 +-
crates/ui-egui/src/panels/viewer.rs | 80 +-
crates/ui-egui/src/state.rs | 22 +
36 files changed, 5673 insertions(+), 283 deletions(-)
create mode 100644 crates/engine/src/commands/anim.rs
create mode 100644 crates/engine/src/commands/comp_more.rs
create mode 100644 crates/engine/src/commands/file_more.rs
create mode 100644 crates/engine/src/commands/frontend.rs
create mode 100644 crates/engine/src/commands/layer_menu.rs
create mode 100644 crates/engine/src/commands/stubs.rs
create mode 100644 crates/engine/src/commands/view.rs
create mode 100644 crates/engine/src/menus.rs
create mode 100644 crates/engine/src/menus/tests.rs
create mode 100644 crates/engine/src/tests_menu_cmds.rs
create mode 100644 crates/ui-egui/src/panels/forms.rs
diff --git a/Cargo.lock b/Cargo.lock
index e0e234725..eba12ce11 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1099,6 +1099,7 @@ dependencies = [
"effectcraft-render",
"effectcraft-text",
"effectcraft-time",
+ "image",
"log",
"serde",
"serde_json",
diff --git a/apps/effectcraft-cli/src/main.rs b/apps/effectcraft-cli/src/main.rs
index dc010d58f..819d952ad 100644
--- a/apps/effectcraft-cli/src/main.rs
+++ b/apps/effectcraft-cli/src/main.rs
@@ -22,7 +22,8 @@ fn open(s: &mut Session, args: &[String]) {
eprintln!("effectcraft: {e}");
std::process::exit(1);
}
- } else if args.iter().any(|a| a == "--demo") || true {
+ } else {
+ // No project given (with or without --demo): open the demo project.
let _ = s.execute("file.openDemoProject", json!({}));
}
}
diff --git a/apps/effectcraft/src/main.rs b/apps/effectcraft/src/main.rs
index a2b3fedd5..9e8bcd6fd 100644
--- a/apps/effectcraft/src/main.rs
+++ b/apps/effectcraft/src/main.rs
@@ -54,10 +54,10 @@ fn main() -> eframe::Result {
let _ = session.execute("file.openDemoProject", json!({}));
}
let media: Vec = files.iter().filter(|f| !f.ends_with(".ecproj")).cloned().collect();
- if !media.is_empty() {
- if let Err(e) = session.execute("file.import", json!({"paths": media})) {
- eprintln!("effectcraft: {e}");
- }
+ if !media.is_empty()
+ && let Err(e) = session.execute("file.import", json!({"paths": media}))
+ {
+ eprintln!("effectcraft: {e}");
}
let mut app = EffectcraftApp::new(session);
app.ui.start_screen = home;
diff --git a/crates/engine/Cargo.toml b/crates/engine/Cargo.toml
index ecc392430..331503793 100644
--- a/crates/engine/Cargo.toml
+++ b/crates/engine/Cargo.toml
@@ -24,3 +24,4 @@ serde = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }
log = { workspace = true }
+image = { workspace = true }
diff --git a/crates/engine/src/commands/anim.rs b/crates/engine/src/commands/anim.rs
new file mode 100644
index 000000000..62ac01835
--- /dev/null
+++ b/crates/engine/src/commands/anim.rs
@@ -0,0 +1,428 @@
+//! Animation menu: animation presets (EffectCraft's own JSON format), Add Keyframe, Keyframe
+//! Assistant (Exponential Scale, Time-Reverse Keyframes), text animators/selectors, and the
+//! Reveal Properties commands.
+
+use std::collections::BTreeMap;
+
+use effectcraft_keyframe::{Interp, Keyframe, Value as KV};
+use effectcraft_project::build::{self, Ids};
+use effectcraft_project::{GroupKind, LayerId, Node, PropGroup, Property, Uid};
+use effectcraft_time::Tick;
+use serde_json::{Value, json};
+
+use super::{CommandSpec, bad, frontend, has_comp, has_keys, has_layers, layer_mut, layer_p, layers_p, match_path_of, selected_leaf_props, str_p};
+use crate::{EngineError, KeyRef, Result, Session, cmd};
+
+/// Preset file format version tag (`*.ecpreset`, JSON).
+pub const PRESET_TAG: &str = "effectcraftAnimationPreset";
+
+fn has_selected_props(s: &Session) -> std::result::Result<(), String> {
+ has_comp(s)?;
+ if selected_leaf_props(s).is_empty() && selected_effects(s).is_empty() { Err("select properties or effects first".into()) } else { Ok(()) }
+}
+
+fn has_text_layer(s: &Session) -> std::result::Result<(), String> {
+ has_layers(s)?;
+ let c = s.active_comp().ok_or("no composition")?;
+ if s.state.selected_layers.iter().filter_map(|l| c.layer(*l)).any(|l| l.props.group("text/animators").is_some()) {
+ Ok(())
+ } else {
+ Err("select a text layer".into())
+ }
+}
+
+/// Selected effect groups (layer, effect group).
+fn selected_effects(s: &Session) -> Vec<(LayerId, PropGroup)> {
+ let Some(c) = s.active_comp() else { return vec![] };
+ s.state
+ .selected_props
+ .iter()
+ .filter_map(|(l, u)| {
+ let layer = c.layer(*l)?;
+ let fx = layer.effects()?;
+ fx.groups().find(|g| g.uid == *u).map(|g| (*l, g.clone()))
+ })
+ .collect()
+}
+
+// ---------------------------------------------------------------- presets
+
+fn save_preset(s: &mut Session, p: &Value) -> Result {
+ let path = str_p(p, "path").ok_or_else(|| bad("anim.savePreset", "missing `path`"))?.to_string();
+ let comp = s.active_comp().ok_or(EngineError::NoComp)?;
+ let t = s.time();
+ let effects: Vec<(LayerId, PropGroup)> = selected_effects(s);
+ let effect_uids: Vec = effects.iter().map(|(_, g)| g.uid).collect();
+ let mut props = vec![];
+ for (lid, uid) in selected_leaf_props(s) {
+ let Some(l) = comp.layer(lid) else { continue };
+ // Properties inside a saved effect travel with the effect.
+ if l.effects().is_some_and(|fx| fx.groups().any(|g| effect_uids.contains(&g.uid) && g.find(uid).is_some())) {
+ continue;
+ }
+ let (Some(pr), Some(mp)) = (l.props.find(uid), match_path_of(&l.props, uid)) else { continue };
+ props.push((l.layer_time(t), mp, pr.clone()));
+ }
+ if props.is_empty() && effects.is_empty() {
+ return Err(bad("anim.savePreset", "select properties or effects to save"));
+ }
+ // Key times are stored relative to the earliest key so the preset applies at the CTI.
+ let first = props.iter().flat_map(|(_, _, pr)| pr.keys.iter().map(|k| k.time)).min().unwrap_or(Tick::ZERO);
+ let props_json: Vec = props
+ .iter()
+ .map(|(_, mp, pr)| {
+ let mut pr = pr.clone();
+ for k in &mut pr.keys {
+ k.time -= first;
+ }
+ json!({"path": mp, "value": pr.value, "keys": pr.keys, "expression": pr.expr})
+ })
+ .collect();
+ let fx_json: Vec = effects.iter().map(|(_, g)| serde_json::to_value(g).unwrap_or_default()).collect();
+ let name = str_p(p, "name")
+ .map(str::to_string)
+ .unwrap_or_else(|| std::path::Path::new(&path).file_stem().map(|s| s.to_string_lossy().to_string()).unwrap_or_default());
+ let doc = json!({PRESET_TAG: 1, "name": name, "properties": props_json, "effects": fx_json});
+ let text = serde_json::to_string_pretty(&doc).unwrap_or_default();
+ s.services.write_file(&path, text.as_bytes()).map_err(|e| EngineError::Other(format!("cannot write {path}: {e}")))?;
+ Ok(json!({"path": path, "properties": props.len(), "effects": effects.len()}))
+}
+
+fn apply_preset(s: &mut Session, p: &Value) -> Result {
+ let doc: Value = match (p.get("preset"), str_p(p, "path")) {
+ (Some(v), _) => v.clone(),
+ (None, Some(path)) => {
+ let bytes = s.services.read_file(path).map_err(|e| EngineError::Other(format!("cannot read {path}: {e}")))?;
+ serde_json::from_slice(&bytes).map_err(|e| bad("anim.applyPreset", format!("not a preset: {e}")))?
+ }
+ _ => return Err(bad("anim.applyPreset", "missing `path` (or inline `preset`)")),
+ };
+ if doc.get(PRESET_TAG).is_none() {
+ return Err(bad("anim.applyPreset", "not an EffectCraft animation preset"));
+ }
+ let (cid, ids) = layers_p(s, p)?;
+ if ids.is_empty() {
+ return Err(bad("anim.applyPreset", "select a layer"));
+ }
+ let effects: Vec =
+ doc["effects"].as_array().map(|a| a.iter().filter_map(|v| serde_json::from_value(v.clone()).ok()).collect()).unwrap_or_default();
+ let props: Vec<(String, Property)> = doc["properties"]
+ .as_array()
+ .map(|a| {
+ a.iter()
+ .filter_map(|v| {
+ let path = v["path"].as_str()?.to_string();
+ let value: KV = serde_json::from_value(v["value"].clone()).ok()?;
+ let keys: Vec = serde_json::from_value(v["keys"].clone()).unwrap_or_default();
+ let expr = serde_json::from_value(v["expression"].clone()).ok().flatten();
+ let mut pr = Property::new(0, "", "", value);
+ pr.keys = keys;
+ pr.expr = expr;
+ Some((path, pr))
+ })
+ .collect()
+ })
+ .unwrap_or_default();
+ let t = s.time();
+ let mut applied = 0;
+ let mut skipped = vec![];
+ s.edit("Apply Animation Preset", None, |proj, _| {
+ let mut next = proj.next_id;
+ for lid in &ids {
+ let l = layer_mut(proj, cid, *lid)?;
+ let lt = l.layer_time(t);
+ if let Some(fx) = l.props.sub_mut("effects") {
+ for g in &effects {
+ let mut g = g.clone();
+ g.reassign_uids(&mut next);
+ next += 1;
+ fx.children.push(Node::Group(g));
+ applied += 1;
+ }
+ }
+ for (path, src) in &props {
+ match l.props.prop_mut(path) {
+ Some(pr) if std::mem::discriminant(&pr.value) == std::mem::discriminant(&src.value) => {
+ pr.value = src.value.clone();
+ pr.keys = src
+ .keys
+ .iter()
+ .cloned()
+ .map(|mut k| {
+ k.time += lt;
+ k
+ })
+ .collect();
+ if src.expr.is_some() {
+ pr.expr = src.expr.clone();
+ }
+ applied += 1;
+ }
+ _ => skipped.push(path.clone()),
+ }
+ }
+ }
+ proj.next_id = next;
+ Ok(())
+ })?;
+ Ok(json!({"applied": applied, "skipped": skipped}))
+}
+
+// ---------------------------------------------------------------- keyframes
+
+fn add_keyframe(s: &mut Session, _: &Value) -> Result {
+ let targets = selected_leaf_props(s);
+ if targets.is_empty() {
+ return Err(bad("anim.addKeyframe", "select properties first"));
+ }
+ let cid = s.active_comp_id().ok_or(EngineError::NoComp)?;
+ let t = s.time();
+ let n = s.edit("Add Keyframe", None, |proj, _| {
+ let mut n = 0;
+ for (lid, uid) in &targets {
+ let l = layer_mut(proj, cid, *lid)?;
+ let lt = l.layer_time(t);
+ let Some(pr) = l.props.find_mut(*uid) else { continue };
+ if pr.static_only {
+ continue;
+ }
+ if pr.keys.is_empty() {
+ pr.set_animated(true, lt);
+ } else {
+ let v = pr.value_at(lt);
+ pr.set_value_at(lt, v);
+ }
+ n += 1;
+ }
+ Ok(n)
+ })?;
+ Ok(json!({"keys": n}))
+}
+
+/// Selected keys grouped by (layer, property).
+fn keys_by_prop(s: &Session) -> BTreeMap<(LayerId, Uid), Vec> {
+ let mut m: BTreeMap<(LayerId, Uid), Vec> = BTreeMap::new();
+ for k in &s.state.selected_keys {
+ m.entry((k.layer, k.prop)).or_default().push(k.time);
+ }
+ m
+}
+
+fn exponential_scale(s: &mut Session, _: &Value) -> Result {
+ let cid = s.active_comp_id().ok_or(EngineError::NoComp)?;
+ let comp = s.project.comp(cid).ok_or(EngineError::NoComp)?;
+ let fd = comp.frame_duration();
+ let groups = keys_by_prop(s);
+ let mut done = 0;
+ let mut work = vec![];
+ for ((lid, uid), mut times) in groups {
+ let Some(l) = comp.layer(lid) else { continue };
+ if l.transform().and_then(|tr| tr.get("scale")).map(|p| p.uid) != Some(uid) {
+ continue;
+ }
+ times.sort();
+ if times.len() >= 2 {
+ work.push((lid, uid, times[0], *times.last().unwrap_or(×[0])));
+ }
+ }
+ if work.is_empty() {
+ return Err(bad("keys.exponentialScale", "select two Scale keyframes"));
+ }
+ s.edit("Exponential Scale", None, |proj, st| {
+ for (lid, uid, a, b) in &work {
+ let l = layer_mut(proj, cid, *lid)?;
+ let Some(pr) = l.props.find_mut(*uid) else { continue };
+ let (va, vb) = (pr.value_at(*a).as_vec3(), pr.value_at(*b).as_vec3());
+ pr.keys.retain(|k| k.time <= *a || k.time >= *b);
+ let n = ((*b - *a).0 / fd.0.max(1)).max(1);
+ for i in 0..=n {
+ let u = i as f64 / n as f64;
+ let t = if i == n { *b } else { *a + Tick(fd.0 * i) };
+ let f = |x: f64, y: f64| if x.abs() < 1e-9 || y.abs() < 1e-9 || x.signum() != y.signum() { x + (y - x) * u } else { x * (y / x).powf(u) };
+ let v = [f(va[0], vb[0]), f(va[1], vb[1]), f(va[2], vb[2])];
+ let mut k = Keyframe::new(t, KV::Vec3(v));
+ k.in_interp = Interp::Linear;
+ k.out_interp = Interp::Linear;
+ effectcraft_keyframe::set_key(&mut pr.keys, k);
+ st.selected_keys.push(KeyRef { layer: *lid, prop: *uid, time: t });
+ }
+ done += 1;
+ }
+ st.selected_keys.sort_by_key(|k| (k.layer.0, k.prop, k.time));
+ st.selected_keys.dedup();
+ Ok(())
+ })?;
+ Ok(json!({"properties": done}))
+}
+
+fn time_reverse_keys(s: &mut Session, _: &Value) -> Result {
+ let cid = s.active_comp_id().ok_or(EngineError::NoComp)?;
+ let groups = keys_by_prop(s);
+ let n = groups.len();
+ s.edit("Time-Reverse Keyframes", None, |proj, st| {
+ st.selected_keys.clear();
+ for ((lid, uid), times) in &groups {
+ let (Some(lo), Some(hi)) = (times.iter().min().copied(), times.iter().max().copied()) else { continue };
+ let l = layer_mut(proj, cid, *lid)?;
+ let Some(pr) = l.props.find_mut(*uid) else { continue };
+ let (mut moved, rest): (Vec, Vec) = pr.keys.drain(..).partition(|k| times.contains(&k.time));
+ for k in &mut moved {
+ k.time = lo + hi - k.time;
+ std::mem::swap(&mut k.in_interp, &mut k.out_interp);
+ std::mem::swap(&mut k.in_ease, &mut k.out_ease);
+ std::mem::swap(&mut k.spatial_in, &mut k.spatial_out);
+ st.selected_keys.push(KeyRef { layer: *lid, prop: *uid, time: k.time });
+ }
+ pr.keys = rest;
+ for k in moved {
+ effectcraft_keyframe::set_key(&mut pr.keys, k);
+ }
+ }
+ Ok(())
+ })?;
+ Ok(json!({"properties": n}))
+}
+
+// ---------------------------------------------------------------- text animators
+
+fn add_selector(s: &mut Session, p: &Value) -> Result {
+ let kind = str_p(p, "kind").unwrap_or("range");
+ if kind != "range" {
+ return Err(bad("text.addSelector", "only Range selectors are available"));
+ }
+ let (cid, lid) = layer_p(s, p, "text.addSelector")?;
+ // Target: a selected animator (or anything inside one), else the last animator.
+ let sel: Vec = s.state.selected_props.iter().filter(|(l, _)| *l == lid).map(|(_, u)| *u).collect();
+ let uid = s.edit("Add Text Selector", None, |proj, _| {
+ let mut next = proj.next_id;
+ let l = layer_mut(proj, cid, lid)?;
+ let anims = l.props.group_mut("text/animators").ok_or_else(|| bad("text.addSelector", "not a text layer"))?;
+ if anims.children.is_empty() {
+ return Err(bad("text.addSelector", "the layer has no text animators (use Animate Text first)"));
+ }
+ let idx = anims
+ .children
+ .iter()
+ .position(|c| c.as_group().is_some_and(|g| sel.contains(&g.uid) || sel.iter().any(|u| g.find(*u).is_some() || g.find_group(*u).is_some())))
+ .unwrap_or(anims.children.len() - 1);
+ let Some(Node::Group(anim)) = anims.children.get_mut(idx) else { return Err(bad("text.addSelector", "no animator")) };
+ let sels = anim.sub_mut("selectors").ok_or_else(|| bad("text.addSelector", "animator has no selectors group"))?;
+ let mut ids = Ids(&mut next);
+ let g = build::range_selector(&mut ids, &format!("Range Selector {}", sels.children.len() + 1));
+ let uid = g.uid;
+ sels.children.push(g.into());
+ proj.next_id = next;
+ Ok(uid)
+ })?;
+ Ok(json!({"selector": uid}))
+}
+
+fn remove_all_animators(s: &mut Session, p: &Value) -> Result {
+ let (cid, ids) = layers_p(s, p)?;
+ s.edit("Remove All Text Animators", None, |proj, _| {
+ for lid in &ids {
+ if let Some(a) = layer_mut(proj, cid, *lid)?.props.group_mut("text/animators") {
+ a.children.clear();
+ }
+ }
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+// ---------------------------------------------------------------- reveal
+
+/// Whether a static property differs from the value a fresh layer would have. Transform
+/// defaults depend on the source size and comp size.
+fn modified(pr: &Property, group: &str, default_anchor: [f64; 2], comp_center: [f64; 2]) -> bool {
+ if pr.is_animated() || pr.expr.is_some() {
+ return true;
+ }
+ let v = &pr.value;
+ let near = |a: &[f64], b: &[f64]| a.iter().zip(b).all(|(x, y)| (x - y).abs() < 1e-6);
+ match (group, pr.match_id.as_str()) {
+ ("transform", "anchor") => !near(&v.as_vec2(), &default_anchor),
+ ("transform", "position") => !near(&v.as_vec2(), &comp_center) || v.as_vec3()[2].abs() > 1e-6,
+ ("transform", "scale") => !near(&v.as_vec3(), &[100.0; 3]),
+ ("transform", "opacity") => (v.as_f64() - 100.0).abs() > 1e-6,
+ ("transform", "orientation") => !near(&v.as_vec3(), &[0.0; 3]),
+ ("transform", _) => v.as_f64().abs() > 1e-6,
+ _ => false,
+ }
+}
+
+fn reveal(s: &mut Session, p: &Value) -> Result {
+ let kind = str_p(p, "kind").unwrap_or("keyframes").to_string();
+ let cid = super::comp_id(s, p)?;
+ let comp = s.project.comp(cid).ok_or(EngineError::NoComp)?;
+ let layers: Vec = if s.state.selected_layers.is_empty() { comp.layers.iter().map(|l| l.id).collect() } else { s.state.selected_layers.clone() };
+ let mut out = vec![];
+ for lid in &layers {
+ let Some(l) = comp.layer(*lid) else { continue };
+ let (w, h) = effectcraft_render::source_size(&s.project, l);
+ let anchor = [w as f64 / 2.0, h as f64 / 2.0];
+ let center = [comp.width as f64 / 2.0, comp.height as f64 / 2.0];
+ for top in l.props.groups() {
+ let hit = |pr: &Property| match kind.as_str() {
+ "keyframes" => pr.is_animated(),
+ "animation" => pr.is_animated() || pr.has_expression(),
+ _ => modified(pr, &top.match_id, anchor, center),
+ };
+ let mut found = vec![];
+ top.walk("", &mut |_, pr| {
+ if hit(pr) {
+ found.push(pr.uid);
+ }
+ });
+ // Modified: effects and masks count as modifications in full (AE reveals them).
+ if kind == "modified" && matches!(top.match_id.as_str(), "effects" | "masks") {
+ for g in top.groups() {
+ found.push(g.uid);
+ }
+ }
+ if kind == "modified" && top.match_id == "text" {
+ for g in top.group("animators").into_iter().flat_map(|a| a.groups()) {
+ found.push(g.uid);
+ }
+ }
+ out.extend(found.into_iter().map(|u| json!({"layer": lid.0, "prop": u})));
+ }
+ }
+ frontend(s, "timeline.revealProps", &json!({"props": out, "kind": kind}))?;
+ Ok(json!({"props": out}))
+}
+
+/// Is `g` an effect/mask group kind (used by tests).
+#[allow(dead_code)]
+pub(crate) fn is_indexed(g: &PropGroup) -> bool {
+ matches!(g.kind, GroupKind::Indexed | GroupKind::Mask { .. } | GroupKind::Effect { .. })
+}
+
+pub fn specs() -> Vec {
+ vec![
+ cmd!(
+ "anim.savePreset",
+ "Save Animation Preset...",
+ ["Animation"],
+ None,
+ "{path (.ecpreset), name?} — saves the selected properties/effects",
+ has_selected_props,
+ save_preset
+ ),
+ cmd!("anim.applyPreset", "Apply Animation Preset...", ["Animation"], None, "{path | preset, layers?}", has_layers, apply_preset),
+ cmd!("anim.addKeyframe", "Add Keyframe", ["Animation"], None, "{} — keys the selected properties at the CTI", has_selected_props, add_keyframe),
+ cmd!(
+ "keys.exponentialScale",
+ "Exponential Scale",
+ ["Animation", "Keyframe Assistant"],
+ None,
+ "{} — two selected Scale keys",
+ has_keys,
+ exponential_scale
+ ),
+ cmd!("keys.timeReverse", "Time-Reverse Keyframes", ["Animation", "Keyframe Assistant"], None, "{}", has_keys, time_reverse_keys),
+ cmd!("text.addSelector", "Add Text Selector", [], None, "{layer?, kind: range}", has_text_layer, add_selector),
+ cmd!("text.removeAllAnimators", "Remove All Text Animators", ["Animation"], None, "{layers?}", has_text_layer, remove_all_animators),
+ cmd!("anim.reveal", "Reveal Properties", [], None, "{kind: keyframes|animation|modified}", has_comp, reveal),
+ ]
+}
diff --git a/crates/engine/src/commands/comp.rs b/crates/engine/src/commands/comp.rs
index 07d341340..c066536d5 100644
--- a/crates/engine/src/commands/comp.rs
+++ b/crates/engine/src/commands/comp.rs
@@ -202,7 +202,7 @@ pub fn specs() -> Vec {
vec![
cmd!(
"comp.new",
- "New Composition…",
+ "New Composition...",
["Composition"],
Some("Cmd+N"),
"{name?, width?, height?, frameRate?, duration? (s), background? [r,g,b]|#hex, open?}",
@@ -211,7 +211,7 @@ pub fn specs() -> Vec {
),
cmd!(
"comp.settings",
- "Composition Settings…",
+ "Composition Settings...",
["Composition"],
Some("Cmd+K"),
"{comp?, name?, width?, height?, frameRate?, duration?, background?, shutterAngle?, shutterPhase?, motionBlurSamples?}",
@@ -221,7 +221,7 @@ pub fn specs() -> Vec {
cmd!("comp.setPosterTime", "Set Poster Time", ["Composition"], None, "{}", has_comp, poster),
cmd!("comp.trimToWorkArea", "Trim Comp to Work Area", ["Composition"], Some("Cmd+Shift+X"), "{comp?}", has_comp, trim_to_wa),
cmd!("comp.open", "Open Composition", [], None, "{comp: id|name}", always, open),
- cmd!("comp.close", "Close Composition", [], Some("Cmd+W"), "{comp?}", has_comp, close),
+ cmd!("comp.close", "Close Composition", [], None, "{comp?}", has_comp, close),
cmd!("comp.workArea", "Set Work Area", [], None, "{start?, end?, set?: begin|end (at CTI)}", has_comp, work_area),
cmd!("comp.setSwitch", "Composition Switch", [], None, "{switch: hideShy|motionBlur|frameBlending|draft3d, value?}", has_comp, comp_switch),
cmd!("comp.addMarker", "Add Marker", [], Some("Num*"), "{time?, comment?}", has_comp, add_marker),
diff --git a/crates/engine/src/commands/comp_more.rs b/crates/engine/src/commands/comp_more.rs
new file mode 100644
index 000000000..6a066b5ac
--- /dev/null
+++ b/crates/engine/src/commands/comp_more.rs
@@ -0,0 +1,130 @@
+//! Composition menu, part two: crop to region of interest / layer bounds, Save Frame As ▸ File,
+//! Responsive Design — Time.
+
+use effectcraft_keyframe::Value as KV;
+use effectcraft_project::Marker;
+use effectcraft_time::Tick;
+use serde_json::{Value, json};
+
+use super::{CommandSpec, bad, comp_id, f_p, has_comp, has_layers, layers_p, str_p};
+use crate::{EngineError, Result, Session, cmd};
+
+fn has_roi(s: &Session) -> std::result::Result<(), String> {
+ has_comp(s)?;
+ if s.state.region_of_interest.is_some() { Ok(()) } else { Err("draw a region of interest in the viewer first".into()) }
+}
+
+/// Crop the comp to `[x, y, w, h]`: the comp shrinks and every unparented layer moves by -x, -y
+/// (all position keys too) so nothing moves on screen.
+fn crop(s: &mut Session, cid: effectcraft_project::ItemId, r: [f64; 4], label: &str) -> Result {
+ let (x, y) = (r[0].round(), r[1].round());
+ let (w, h) = (r[2].round().max(1.0) as u32, r[3].round().max(1.0) as u32);
+ s.edit(label, None, |proj, st| {
+ let c = proj.comp_mut(cid).ok_or(EngineError::NoComp)?;
+ c.width = w;
+ c.height = h;
+ for l in c.layers.iter_mut().filter(|l| l.parent.is_none()) {
+ let Some(pos) = l.transform_mut().and_then(|tr| tr.get_mut("position")) else { continue };
+ let mv = |v: &KV| {
+ let a = v.as_vec3();
+ KV::Vec3([a[0] - x, a[1] - y, a[2]])
+ };
+ pos.value = mv(&pos.value);
+ for k in &mut pos.keys {
+ k.value = mv(&k.value);
+ }
+ }
+ for g in &mut c.guides {
+ g.position -= if g.vertical { x } else { y };
+ }
+ st.region_of_interest = None;
+ Ok(())
+ })?;
+ Ok(json!({"width": w, "height": h, "offset": [x, y]}))
+}
+
+fn crop_to_roi(s: &mut Session, p: &Value) -> Result {
+ let cid = comp_id(s, p)?;
+ let r = s.state.region_of_interest.ok_or_else(|| bad("comp.cropToRegionOfInterest", "no region of interest"))?;
+ crop(s, cid, r, "Crop Comp to Region of Interest")
+}
+
+fn crop_to_layers(s: &mut Session, p: &Value) -> Result {
+ let (cid, ids) = layers_p(s, p)?;
+ 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);
+ let mut b = [f64::MAX, f64::MAX, f64::MIN, f64::MIN];
+ for l in comp.layers.iter().filter(|l| ids.contains(&l.id)) {
+ let Some([x0, y0, x1, y1]) = effectcraft_render::content_bounds(&ctx, l) else { continue };
+ let (m, _) = ctx.layer_to_comp(l);
+ for (px, py) in [(x0, y0), (x1, y0), (x1, y1), (x0, y1)] {
+ let v = m.0;
+ let wz = v[2][0] * px + v[2][1] * py + v[2][2];
+ let wz = if wz.abs() < 1e-9 { 1.0 } else { wz };
+ let cx = (v[0][0] * px + v[0][1] * py + v[0][2]) / wz;
+ let cy = (v[1][0] * px + v[1][1] * py + v[1][2]) / wz;
+ b = [b[0].min(cx), b[1].min(cy), b[2].max(cx), b[3].max(cy)];
+ }
+ }
+ if b[0] > b[2] {
+ return Err(bad("comp.cropToLayerBounds", "the selected layers have no visible bounds"));
+ }
+ let (x0, y0) = (b[0].floor(), b[1].floor());
+ crop(s, cid, [x0, y0, b[2].ceil() - x0, b[3].ceil() - y0], "Crop Comp to Selected Layer(s) Bounds")
+}
+
+/// Encode straight 8-bit RGBA as PNG.
+pub(crate) fn encode_png(rgba: &[u8], w: u32, h: u32) -> std::result::Result, String> {
+ use image::ImageEncoder;
+ let mut out = vec![];
+ image::codecs::png::PngEncoder::new(&mut out).write_image(rgba, w, h, image::ExtendedColorType::Rgba8).map_err(|e| e.to_string())?;
+ Ok(out)
+}
+
+fn save_frame(s: &mut Session, p: &Value) -> Result {
+ let path = str_p(p, "path").ok_or_else(|| bad("comp.saveFrameAs", "missing `path` (.png)"))?.to_string();
+ let cid = comp_id(s, p)?;
+ let comp = s.project.comp(cid).ok_or(EngineError::NoComp)?;
+ let t = f_p(p, "time").map(Tick::from_seconds_f64).unwrap_or(s.time());
+ let scale = f_p(p, "scale").unwrap_or(1.0).clamp(0.01, 4.0);
+ let bg = comp.background;
+ let img = s.render(cid, t, effectcraft_render::RenderOpts { scale, ..Default::default() });
+ let rgba = img.to_rgba8_over(bg);
+ let png = encode_png(&rgba, img.width, img.height).map_err(|e| EngineError::Other(format!("PNG encoding failed: {e}")))?;
+ s.services.write_file(&path, &png).map_err(|e| EngineError::Other(format!("cannot write {path}: {e}")))?;
+ s.toast(format!("Saved frame to {path}"));
+ Ok(json!({"path": path, "width": img.width, "height": img.height, "time": t.seconds()}))
+}
+
+/// Responsive Design — Time: protected comp markers for an intro, an outro or the work area.
+fn responsive_time(s: &mut Session, p: &Value) -> Result {
+ let cid = comp_id(s, p)?;
+ let comp = s.project.comp(cid).ok_or(EngineError::NoComp)?;
+ let t = s.time();
+ let (start, end, comment) = match str_p(p, "op").unwrap_or("workArea") {
+ "intro" => (Tick::ZERO, t, "Intro"),
+ "outro" => (t, comp.duration, "Outro"),
+ "workArea" => (comp.work_area.0, comp.work_area.1, "Protected Region"),
+ o => return Err(bad("comp.responsiveTime", format!("op: intro|outro|workArea, not `{o}`"))),
+ };
+ if end <= start {
+ return Err(bad("comp.responsiveTime", "move the current time first (the region would be empty)"));
+ }
+ s.edit("Create Protected Region", None, |proj, _| {
+ let c = proj.comp_mut(cid).ok_or(EngineError::NoComp)?;
+ c.markers.push(Marker { time: start, duration: end - start, comment: comment.into(), protected: true, ..Default::default() });
+ c.markers.sort_by_key(|m| m.time);
+ Ok(())
+ })?;
+ Ok(json!({"start": start.seconds(), "end": end.seconds()}))
+}
+
+pub fn specs() -> Vec {
+ vec![
+ cmd!("comp.cropToRegionOfInterest", "Crop Comp to Region of Interest", ["Composition"], None, "{comp?}", has_roi, crop_to_roi),
+ cmd!("comp.cropToLayerBounds", "Crop Comp to Selected Layer(s) Bounds", ["Composition"], None, "{layers?}", has_layers, crop_to_layers),
+ cmd!("comp.saveFrameAs", "File...", ["Composition", "Save Frame As"], Some("Cmd+Alt+S"), "{path (.png), time?, scale?}", has_comp, save_frame),
+ cmd!("comp.responsiveTime", "Responsive Design — Time", [], None, "{op: intro|outro|workArea}", has_comp, responsive_time),
+ ]
+}
diff --git a/crates/engine/src/commands/edit.rs b/crates/engine/src/commands/edit.rs
index b68df62de..4e48c8456 100644
--- a/crates/engine/src/commands/edit.rs
+++ b/crates/engine/src/commands/edit.rs
@@ -1,11 +1,12 @@
//! Edit menu.
use effectcraft_color::Label;
-use effectcraft_project::{Layer, LayerId};
+use effectcraft_project::{Expression, ItemKind, Layer, LayerId, LayerSource};
+use effectcraft_time::Tick;
use serde_json::{Value, json};
-use super::{CommandSpec, has_comp, has_layers, layers_p, str_p};
-use crate::{Result, Session, cmd};
+use super::{CommandSpec, has_comp, has_layers, layers_p, match_path_of, selected_leaf_props, str_p};
+use crate::{EngineError, KeyClip, LinkClip, Result, Session, cmd};
fn can_undo(s: &Session) -> std::result::Result<(), String> {
if s.history.undo.is_empty() { Err("nothing to undo".into()) } else { Ok(()) }
@@ -15,7 +16,25 @@ fn can_redo(s: &Session) -> std::result::Result<(), String> {
}
fn has_clip(s: &Session) -> std::result::Result<(), String> {
has_comp(s)?;
- if s.state.clipboard.is_empty() { Err("the clipboard is empty".into()) } else { Ok(()) }
+ if s.state.clipboard.is_empty() && s.state.key_clipboard.is_empty() && s.state.link_clipboard.is_none() {
+ Err("the clipboard is empty".into())
+ } else {
+ Ok(())
+ }
+}
+fn has_key_clip(s: &Session) -> std::result::Result<(), String> {
+ has_layers(s)?;
+ if s.state.key_clipboard.is_empty() { Err("no keyframes on the clipboard".into()) } else { Ok(()) }
+}
+fn has_props_or_layers(s: &Session) -> std::result::Result<(), String> {
+ has_comp(s)?;
+ if s.state.selected_layers.is_empty() && s.state.selected_props.is_empty() { Err("select layers or properties first".into()) } else { Ok(()) }
+}
+fn has_props_or_layers_or_items(s: &Session) -> std::result::Result<(), String> {
+ if has_props_or_layers(s).is_ok() || !s.state.project_selection.is_empty() { Ok(()) } else { Err("select layers or project items first".into()) }
+}
+fn has_selected_footage(s: &Session) -> std::result::Result<(), String> {
+ if original_path(s).is_some() { Ok(()) } else { Err("select a footage item or layer".into()) }
}
fn undo(s: &mut Session, _: &Value) -> Result {
@@ -96,19 +115,215 @@ fn delete(s: &mut Session, p: &Value) -> Result {
Ok(json!(ids.len()))
}
+fn clear_clipboards(s: &mut Session) {
+ s.state.clipboard.clear();
+ s.state.key_clipboard.clear();
+ s.state.link_clipboard = None;
+}
+
+/// Edit ▸ Copy: selected keyframes (when any) go to the keyframe clipboard, else layers.
fn copy(s: &mut Session, p: &Value) -> Result {
+ if !s.state.selected_keys.is_empty() && p.get("layers").is_none() && p.get("layer").is_none() {
+ let comp = s.active_comp().ok_or(EngineError::NoComp)?;
+ let mut clips: Vec = vec![];
+ let earliest = s.state.selected_keys.iter().map(|k| k.time).min().unwrap_or(Tick::ZERO);
+ for k in &s.state.selected_keys {
+ let Some(l) = comp.layer(k.layer) else { continue };
+ let (Some(pr), Some(path)) = (l.props.find(k.prop), match_path_of(&l.props, k.prop)) else { continue };
+ let Some(key) = pr.keys.iter().find(|x| x.time == k.time) else { continue };
+ let mut key = key.clone();
+ key.time -= earliest;
+ match clips.iter_mut().find(|c| c.path == path) {
+ Some(c) => c.keys.push(key),
+ None => clips.push(KeyClip { path, keys: vec![key] }),
+ }
+ }
+ for c in &mut clips {
+ c.keys.sort_by_key(|k| k.time);
+ }
+ let n: usize = clips.iter().map(|c| c.keys.len()).sum();
+ clear_clipboards(s);
+ s.state.key_clipboard = clips;
+ return Ok(json!({"keys": n}));
+ }
let (cid, ids) = layers_p(s, p)?;
let comp = s.project.comp(cid).ok_or(crate::EngineError::NoComp)?;
- s.state.clipboard = comp.layers.iter().filter(|l| ids.contains(&l.id)).cloned().collect();
+ let layers: Vec = comp.layers.iter().filter(|l| ids.contains(&l.id)).cloned().collect();
+ clear_clipboards(s);
+ s.state.clipboard = layers;
Ok(json!(s.state.clipboard.len()))
}
+/// The expression accessor for a property, e.g. `comp("Main").layer("Solid").transform("Position")`.
+pub(crate) fn link_expression(s: &Session, lid: LayerId, uid: effectcraft_project::Uid, relative: bool) -> Option {
+ let cid = s.active_comp_id()?;
+ let comp = s.project.comp(cid)?;
+ let l = comp.layer(lid)?;
+ let names = l.props.name_path_of(uid)?;
+ let matches = match_path_of(&l.props, uid)?;
+ let names: Vec<&str> = names.split('/').collect();
+ let first = matches.split('/').next()?.to_string();
+ let q = |x: &str| serde_json::to_string(x).unwrap_or_default();
+ let base = if relative { format!("thisComp.layer({})", q(&l.name)) } else { format!("comp({}).layer({})", q(&s.project.item(cid)?.name), q(&l.name)) };
+ let mut out = match first.as_str() {
+ "transform" => format!("{base}.transform"),
+ "effects" => format!("{base}.effect({})", q(names.get(1)?)),
+ "masks" => format!("{base}.mask({})", q(names.get(1)?)),
+ "text" => format!("{base}.text"),
+ "contents" => format!("{base}.content({})", q(names.get(1)?)),
+ _ => return None,
+ };
+ let skip = if matches!(first.as_str(), "effects" | "masks" | "contents") { 2 } else { 1 };
+ for n in names.iter().skip(skip) {
+ out.push_str(&format!("({})", q(n)));
+ }
+ Some(out)
+}
+
+fn copy_links(s: &mut Session, p: &Value, relative: bool) -> Result {
+ let props = selected_leaf_props(s);
+ if props.is_empty() {
+ // Layers: copy them with every animatable transform/effect property linked to the source.
+ let (cid, ids) = layers_p(s, p)?;
+ let comp = s.project.comp(cid).ok_or(EngineError::NoComp)?;
+ let mut layers = vec![];
+ for l in comp.layers.iter().filter(|l| ids.contains(&l.id)) {
+ let mut copy = l.clone();
+ let mut uids = vec![];
+ for g in ["transform", "effects"] {
+ if let Some(grp) = l.props.sub(g) {
+ grp.walk("", &mut |_, pr| {
+ if !pr.static_only && !pr.hold_only {
+ uids.push(pr.uid);
+ }
+ });
+ }
+ }
+ for uid in uids {
+ if let (Some(e), Some(pr)) = (link_expression(s, l.id, uid, relative), copy.props.find_mut(uid)) {
+ pr.expr = Some(Expression { text: e, enabled: true });
+ }
+ }
+ layers.push(copy);
+ }
+ let n = layers.len();
+ clear_clipboards(s);
+ s.state.clipboard = layers;
+ return Ok(json!({"layers": n}));
+ }
+ let comp = s.active_comp().ok_or(EngineError::NoComp)?;
+ let mut links = vec![];
+ for (lid, uid) in &props {
+ let Some(path) = comp.layer(*lid).and_then(|l| match_path_of(&l.props, *uid)) else { continue };
+ if let Some(e) = link_expression(s, *lid, *uid, relative) {
+ links.push((path, e));
+ }
+ }
+ let n = links.len();
+ clear_clipboards(s);
+ s.state.link_clipboard = Some(LinkClip::Links { relative, links });
+ Ok(json!({"links": n}))
+}
+
+fn copy_expression_only(s: &mut Session, _: &Value) -> Result {
+ let comp = s.active_comp().ok_or(EngineError::NoComp)?;
+ let mut out = vec![];
+ for (lid, uid) in selected_leaf_props(s) {
+ let Some(l) = comp.layer(lid) else { continue };
+ if let (Some(pr), Some(path)) = (l.props.find(uid), match_path_of(&l.props, uid))
+ && let Some(e) = &pr.expr
+ {
+ out.push((path, e.clone()));
+ }
+ }
+ if out.is_empty() {
+ return Err(EngineError::Other("the selected properties have no expressions".into()));
+ }
+ let n = out.len();
+ clear_clipboards(s);
+ s.state.link_clipboard = Some(LinkClip::Expressions(out));
+ Ok(json!({"expressions": n}))
+}
+
+/// Paste the keyframe clipboard at the CTI onto the selected layers (same property paths).
+fn paste_keys(s: &mut Session, reversed: bool) -> Result {
+ let cid = s.active_comp_id().ok_or(EngineError::NoComp)?;
+ let ids = s.state.selected_layers.clone();
+ if ids.is_empty() {
+ return Err(EngineError::Other("select a layer to paste keyframes into".into()));
+ }
+ let clip = s.state.key_clipboard.clone();
+ let t = s.time();
+ let n = s.edit(if reversed { "Paste Reversed Keyframes" } else { "Paste Keyframes" }, None, |proj, st| {
+ let mut n = 0;
+ st.selected_keys.clear();
+ for lid in &ids {
+ let l = super::layer_mut(proj, cid, *lid)?;
+ let lt = l.layer_time(t);
+ for c in &clip {
+ let Some(pr) = l.props.prop_mut(&c.path) else { continue };
+ let span = c.keys.last().map(|k| k.time).unwrap_or(Tick::ZERO);
+ for k in &c.keys {
+ let mut k = k.clone();
+ if std::mem::discriminant(&k.value) != std::mem::discriminant(&pr.value) {
+ continue;
+ }
+ if reversed {
+ k.time = span - k.time;
+ std::mem::swap(&mut k.in_interp, &mut k.out_interp);
+ std::mem::swap(&mut k.in_ease, &mut k.out_ease);
+ std::mem::swap(&mut k.spatial_in, &mut k.spatial_out);
+ }
+ k.time += lt;
+ st.selected_keys.push(crate::KeyRef { layer: *lid, prop: pr.uid, time: k.time });
+ effectcraft_keyframe::set_key(&mut pr.keys, k);
+ n += 1;
+ }
+ }
+ }
+ Ok(n)
+ })?;
+ Ok(json!({"keys": n}))
+}
+
+fn paste_links(s: &mut Session, clip: LinkClip) -> Result {
+ let cid = s.active_comp_id().ok_or(EngineError::NoComp)?;
+ let ids = s.state.selected_layers.clone();
+ if ids.is_empty() {
+ return Err(EngineError::Other("select a layer to paste into".into()));
+ }
+ let pairs: Vec<(String, Expression)> = match clip {
+ LinkClip::Links { links, .. } => links.into_iter().map(|(p, e)| (p, Expression { text: e, enabled: true })).collect(),
+ LinkClip::Expressions(v) => v,
+ };
+ let n = s.edit("Paste", None, |proj, _| {
+ let mut n = 0;
+ for lid in &ids {
+ let l = super::layer_mut(proj, cid, *lid)?;
+ for (path, e) in &pairs {
+ if let Some(pr) = l.props.prop_mut(path) {
+ pr.expr = Some(e.clone());
+ n += 1;
+ }
+ }
+ }
+ Ok(n)
+ })?;
+ Ok(json!({"expressions": n}))
+}
+
fn cut(s: &mut Session, p: &Value) -> Result {
copy(s, p)?;
delete(s, p)
}
fn paste(s: &mut Session, p: &Value) -> Result {
+ if let Some(clip) = s.state.link_clipboard.clone() {
+ return paste_links(s, clip);
+ }
+ if !s.state.key_clipboard.is_empty() {
+ return paste_keys(s, false);
+ }
let cid = super::comp_id(s, p)?;
let clip = s.state.clipboard.clone();
let new = s.edit("Paste", None, |proj, st| {
@@ -180,6 +395,123 @@ fn label(s: &mut Session, p: &Value) -> Result {
Ok(Value::Null)
}
+fn paste_reversed(s: &mut Session, _: &Value) -> Result {
+ paste_keys(s, true)
+}
+
+/// Lift (leave a gap) or extract (close the gap) the work area from the selected layers (all
+/// unlocked layers when none are selected).
+fn work_area_cut(s: &mut Session, p: &Value, extract: bool) -> Result {
+ let cid = super::comp_id(s, p)?;
+ let comp = s.project.comp(cid).ok_or(EngineError::NoComp)?;
+ let (a, b) = comp.work_area;
+ let ids: Vec = match layers_p(s, p)?.1 {
+ v if v.is_empty() => comp.layers.iter().map(|l| l.id).collect(),
+ v => v,
+ };
+ let gap = b - a;
+ s.edit(if extract { "Extract Work Area" } else { "Lift Work Area" }, None, |proj, st| {
+ let mut next = proj.next_id;
+ let c = proj.comp_mut(cid).ok_or(EngineError::NoComp)?;
+ let shift = |l: &mut Layer, d: Tick| {
+ l.start_time += d;
+ l.in_point += d;
+ l.out_point += d;
+ };
+ let mut i = 0;
+ while i < c.layers.len() {
+ if !ids.contains(&c.layers[i].id) || c.layers[i].switches.locked {
+ i += 1;
+ continue;
+ }
+ let (lin, lout) = (c.layers[i].in_point, c.layers[i].out_point);
+ if lout <= a {
+ i += 1;
+ } else if lin >= b {
+ if extract {
+ shift(&mut c.layers[i], Tick::ZERO - gap);
+ }
+ i += 1;
+ } else if lin >= a && lout <= b {
+ c.layers.remove(i);
+ } else if lin < a && lout > b {
+ // Split around the work area: the layer keeps the head, a copy takes the tail.
+ let mut tail = c.layers[i].clone();
+ reid(&mut tail, &mut next);
+ tail.in_point = b;
+ if extract {
+ shift(&mut tail, Tick::ZERO - gap);
+ }
+ c.layers[i].out_point = a;
+ c.layers.insert(i, tail);
+ i += 2;
+ } else if lin < a {
+ c.layers[i].out_point = a;
+ i += 1;
+ } else {
+ c.layers[i].in_point = b;
+ if extract {
+ shift(&mut c.layers[i], Tick::ZERO - gap);
+ }
+ i += 1;
+ }
+ }
+ let alive: Vec = c.layers.iter().map(|l| l.id).collect();
+ st.selected_layers.retain(|l| alive.contains(l));
+ proj.next_id = next;
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+fn lift(s: &mut Session, p: &Value) -> Result {
+ work_area_cut(s, p, false)
+}
+fn extract(s: &mut Session, p: &Value) -> Result {
+ work_area_cut(s, p, true)
+}
+
+fn select_label_group(s: &mut Session, _: &Value) -> Result {
+ let comp = s.active_comp().ok_or(EngineError::NoComp)?;
+ let labels: Vec = s.state.selected_layers.iter().filter_map(|l| comp.layer(*l)).map(|l| l.label).collect();
+ if labels.is_empty() {
+ // Project panel: items with the same labels.
+ let items: Vec = s.state.project_selection.iter().filter_map(|i| s.project.item(*i)).map(|i| i.label).collect();
+ s.state.project_selection = s.project.items.values().filter(|i| items.contains(&i.label)).map(|i| i.id).collect();
+ return Ok(json!({"items": s.state.project_selection.len()}));
+ }
+ s.state.selected_layers = comp.layers.iter().filter(|l| labels.contains(&l.label)).map(|l| l.id).collect();
+ Ok(json!({"layers": s.state.selected_layers.len()}))
+}
+
+fn purge_caches(s: &mut Session, p: &Value) -> Result {
+ let what = str_p(p, "what").unwrap_or("all").to_string();
+ s.events.push(crate::Event::PurgeCaches);
+ s.toast(format!("Purged {what} cache"));
+ Ok(json!({"purged": what}))
+}
+
+/// Path of the footage behind the selected layer or project item.
+fn original_path(s: &Session) -> Option {
+ let comp = s.active_comp();
+ let from_layer = s.state.selected_layers.first().and_then(|l| comp?.layer(*l)).and_then(|l| match l.source {
+ LayerSource::Footage { item } => Some(item),
+ _ => None,
+ });
+ let item = from_layer.or_else(|| s.state.project_selection.first().copied())?;
+ match &s.project.item(item)?.kind {
+ ItemKind::Footage(f) if !f.path.is_empty() => Some(f.path.clone()),
+ _ => None,
+ }
+}
+
+fn edit_original(s: &mut Session, _: &Value) -> Result {
+ let path = original_path(s).ok_or_else(|| super::bad("edit.editOriginal", "select a footage item or layer"))?;
+ let url = format!("file://{path}");
+ s.events.push(crate::Event::OpenUrl(url.clone()));
+ Ok(json!({"url": url}))
+}
+
fn purge(s: &mut Session, _: &Value) -> Result {
s.history.undo.clear();
s.history.redo.clear();
@@ -192,15 +524,40 @@ pub fn specs() -> Vec {
cmd!("edit.undo", "Undo", ["Edit"], Some("Cmd+Z"), "{}", can_undo, undo),
cmd!("edit.redo", "Redo", ["Edit"], Some("Cmd+Shift+Z"), "{}", can_redo, redo),
cmd!("edit.cut", "Cut", ["Edit"], Some("Cmd+X"), "{layers?}", has_layers, cut),
- cmd!("edit.copy", "Copy", ["Edit"], Some("Cmd+C"), "{layers?}", has_layers, copy),
- cmd!("edit.paste", "Paste", ["Edit"], Some("Cmd+V"), "{}", has_clip, paste),
+ cmd!("edit.copy", "Copy", ["Edit"], Some("Cmd+C"), "{layers?} (copies the selected keyframes when any, else layers)", has_props_or_layers, copy),
+ cmd!(
+ "edit.copyWithPropertyLinks",
+ "Copy with Property Links",
+ ["Edit"],
+ Some("Cmd+Alt+C"),
+ "{layers?} (selected properties, or layers, as expressions linking to the originals)",
+ has_props_or_layers,
+ |s, p| copy_links(s, p, false)
+ ),
+ cmd!(
+ "edit.copyWithRelativePropertyLinks",
+ "Copy with Relative Property Links",
+ ["Edit"],
+ None,
+ "{layers?} (like Copy with Property Links, using thisComp)",
+ has_props_or_layers,
+ |s, p| copy_links(s, p, true)
+ ),
+ cmd!("edit.copyExpressionOnly", "Copy Expression Only", ["Edit"], None, "{}", has_props_or_layers, copy_expression_only),
+ cmd!("edit.paste", "Paste", ["Edit"], Some("Cmd+V"), "{} (layers, keyframes at the CTI, or property links / expressions)", has_clip, paste),
+ cmd!("edit.pasteReversedKeyframes", "Paste Reversed Keyframes", ["Edit"], None, "{}", has_key_clip, paste_reversed),
cmd!("edit.clear", "Clear", ["Edit"], Some("Delete"), "{layers?}", has_layers, delete),
cmd!("edit.duplicate", "Duplicate", ["Edit"], Some("Cmd+D"), "{layers?}", has_layers, duplicate),
cmd!("edit.splitLayer", "Split Layer", ["Edit"], Some("Cmd+Shift+D"), "{layers?}", has_layers, split),
+ cmd!("edit.liftWorkArea", "Lift Work Area", ["Edit"], None, "{layers?}", has_comp, lift),
+ cmd!("edit.extractWorkArea", "Extract Work Area", ["Edit"], None, "{layers?}", has_comp, extract),
cmd!("edit.selectAll", "Select All", ["Edit"], Some("Cmd+A"), "{}", has_comp, select_all),
cmd!("edit.deselectAll", "Deselect All", ["Edit"], Some("Cmd+Shift+A"), "{}", always_ok, deselect_all),
cmd!("edit.label", "Label", ["Edit", "Label"], None, "{label: Red|Yellow|Aqua|…, layers?}", always_ok, label),
+ cmd!("edit.selectLabelGroup", "Select Label Group", ["Edit", "Label"], None, "{}", has_props_or_layers_or_items, select_label_group),
cmd!("edit.purgeUndo", "Undo", ["Edit", "Purge"], None, "{}", always_ok, purge),
+ cmd!("edit.purge", "Purge", [], None, "{what?: all|memoryAndDisk|memory|disk|3d|image|snapshot}", always_ok, purge_caches),
+ cmd!("edit.editOriginal", "Edit Original...", ["Edit"], Some("Cmd+E"), "{}", has_selected_footage, edit_original),
]
}
diff --git a/crates/engine/src/commands/file.rs b/crates/engine/src/commands/file.rs
index aa9b8fb26..343ca6113 100644
--- a/crates/engine/src/commands/file.rs
+++ b/crates/engine/src/commands/file.rs
@@ -141,16 +141,16 @@ fn cycle_depth(s: &mut Session, _: &Value) -> Result {
pub fn specs() -> Vec {
vec![
cmd!("file.newProject", "New Project", ["File", "New"], Some("Cmd+Alt+N"), "{}", always, new_project),
- cmd!("file.openDemoProject", "Open Demo Project", ["File"], None, "{}", always, demo),
- cmd!("file.open", "Open Project…", ["File"], Some("Cmd+O"), "{path}", always, open),
+ cmd!("file.openDemoProject", "Open Demo Project", ["Help"], None, "{}", always, demo),
+ cmd!("file.open", "Open Project...", ["File"], Some("Cmd+O"), "{path}", always, open),
cmd!("file.save", "Save", ["File"], Some("Cmd+S"), "{path?}", always, save),
- cmd!("file.saveAs", "Save As…", ["File", "Save As"], Some("Cmd+Shift+S"), "{path}", always, save_as),
+ cmd!("file.saveAs", "Save As...", ["File", "Save As"], Some("Cmd+Shift+S"), "{path}", always, save_as),
cmd!("file.incrementAndSave", "Increment and Save", ["File"], Some("Cmd+Alt+Shift+S"), "{}", has_path, increment_save),
cmd!("file.revert", "Revert", ["File"], None, "{}", has_path, revert),
- cmd!("file.import", "File…", ["File", "Import"], Some("Cmd+I"), "{paths: [string]}", always, import),
+ cmd!("file.import", "File...", ["File", "Import"], Some("Cmd+I"), "{paths: [string]}", always, import),
cmd!(
"file.projectSettings",
- "Project Settings…",
+ "Project Settings...",
["File"],
Some("Cmd+Alt+Shift+K"),
"{bitDepth?: 8|16|32, linearize?, timeDisplay?: timecode|frames}",
diff --git a/crates/engine/src/commands/file_more.rs b/crates/engine/src/commands/file_more.rs
new file mode 100644
index 000000000..0180d2798
--- /dev/null
+++ b/crates/engine/src/commands/file_more.rs
@@ -0,0 +1,681 @@
+//! File menu, part two: folders, close, save a copy, import placeholders/solids, New Comp from
+//! Selection, Dependencies (collect / consolidate / remove unused / reduce / find missing),
+//! scripts, footage interpretation, replace/reload footage, reveal in Finder.
+
+use std::collections::{BTreeMap, BTreeSet};
+
+use effectcraft_color::Label;
+use effectcraft_project::{AlphaMode, Comp, Footage, FootageKind, ItemId, ItemKind, LayerSource, Project, Solid};
+use effectcraft_time::{FrameRate, Tick};
+use serde_json::{Value, json};
+
+use super::{CommandSpec, always, bad, f_p, has_comp, has_project_selection, str_p};
+use crate::{EngineError, Result, Session, cmd};
+
+fn has_footage_selection(s: &Session) -> std::result::Result<(), String> {
+ if selected_footage(s).is_empty() { Err("select footage in the Project panel".into()) } else { Ok(()) }
+}
+
+fn has_interpretation(s: &Session) -> std::result::Result<(), String> {
+ has_footage_selection(s)?;
+ if s.state.interpretation.is_none() { Err("no interpretation remembered".into()) } else { Ok(()) }
+}
+
+fn has_items(s: &Session) -> std::result::Result<(), String> {
+ if s.project.items.is_empty() { Err("the project is empty".into()) } else { Ok(()) }
+}
+
+fn has_comp_selection(s: &Session) -> std::result::Result<(), String> {
+ if s.state.project_selection.iter().any(|i| s.project.comp(*i).is_some()) { Ok(()) } else { Err("select compositions in the Project panel".into()) }
+}
+
+/// Selected project items that are footage (or the source of the selected layer).
+fn selected_footage(s: &Session) -> Vec {
+ let mut v: Vec =
+ s.state.project_selection.iter().copied().filter(|i| matches!(s.project.item(*i).map(|x| &x.kind), Some(ItemKind::Footage(_)))).collect();
+ if v.is_empty()
+ && let Some(c) = s.active_comp()
+ {
+ v = s
+ .state
+ .selected_layers
+ .iter()
+ .filter_map(|l| c.layer(*l))
+ .filter_map(|l| if let LayerSource::Footage { item } = l.source { Some(item) } else { None })
+ .collect();
+ }
+ v
+}
+
+fn items_p(s: &Session, p: &Value) -> Vec {
+ match p.get("items").or(p.get("item")) {
+ Some(Value::Array(a)) => a.iter().filter_map(Value::as_u64).map(ItemId).collect(),
+ Some(Value::Number(n)) => n.as_u64().map(ItemId).into_iter().collect(),
+ _ => selected_footage(s),
+ }
+}
+
+fn new_folder(s: &mut Session, p: &Value) -> Result {
+ let name = str_p(p, "name").unwrap_or("Untitled Folder").to_string();
+ let parent = p.get("parent").and_then(Value::as_u64).map(ItemId).filter(|i| s.project.item(*i).is_some_and(|x| x.is_folder()));
+ let id = s.edit("New Folder", None, |proj, st| {
+ let id = proj.add_item(&name, Label::Yellow, parent, ItemKind::Folder);
+ st.project_selection = vec![id];
+ Ok(id)
+ })?;
+ Ok(json!({"item": id.0}))
+}
+
+fn close(s: &mut Session, p: &Value) -> Result {
+ s.execute("comp.close", p.clone())
+}
+
+fn close_project(s: &mut Session, _: &Value) -> Result {
+ s.replace_project(Project::default(), None);
+ Ok(Value::Null)
+}
+
+fn save_copy(s: &mut Session, p: &Value) -> Result {
+ let path = str_p(p, "path").ok_or_else(|| bad("file.saveCopy", "missing `path`"))?;
+ let json = s.project.to_json();
+ s.services.write_file(path, json.as_bytes()).map_err(|e| EngineError::Other(format!("cannot write {path}: {e}")))?;
+ Ok(json!({"path": path, "bytes": json.len()}))
+}
+
+fn rate_of(p: &Value) -> FrameRate {
+ f_p(p, "frameRate").map(FrameRate::from_f64).unwrap_or(FrameRate::FPS_29_97)
+}
+
+fn placeholder_footage(p: &Value) -> Footage {
+ let w = p.get("width").and_then(Value::as_u64).unwrap_or(1920) as u32;
+ let h = p.get("height").and_then(Value::as_u64).unwrap_or(1080) as u32;
+ Footage {
+ path: String::new(),
+ kind: FootageKind::Video,
+ width: w,
+ height: h,
+ pixel_aspect: 1.0,
+ frame_rate: rate_of(p),
+ native_rate: None,
+ duration: Tick::from_seconds_f64(f_p(p, "duration").unwrap_or(30.0)),
+ has_video: true,
+ has_audio: false,
+ alpha: AlphaMode::Straight,
+ premul_color: [0.0; 3],
+ loop_count: 1,
+ codec: "Placeholder".into(),
+ missing: true,
+ sequence: vec![],
+ }
+}
+
+fn import_placeholder(s: &mut Session, p: &Value) -> Result {
+ let name = str_p(p, "name").unwrap_or("Placeholder").to_string();
+ let f = placeholder_footage(p);
+ let id = s.edit("Import Placeholder", None, |proj, st| {
+ let id = proj.add_item(&name, Label::Aqua, None, ItemKind::Footage(f));
+ st.project_selection = vec![id];
+ Ok(id)
+ })?;
+ Ok(json!({"item": id.0}))
+}
+
+fn solid_from(p: &Value, s: &Session) -> Solid {
+ let (cw, ch) = s.active_comp().map(|c| (c.width, c.height)).unwrap_or((1920, 1080));
+ let color = match p.get("color") {
+ Some(Value::String(h)) => effectcraft_color::Rgba::from_hex(h).map(|c| [c.r, c.g, c.b]),
+ Some(Value::Array(a)) => Some([0, 1, 2].map(|i| a.get(i).and_then(Value::as_f64).unwrap_or(0.0) as f32)),
+ _ => None,
+ }
+ .unwrap_or([0.5, 0.5, 0.5]);
+ Solid {
+ color,
+ width: p.get("width").and_then(Value::as_u64).map(|v| v as u32).unwrap_or(cw).max(1),
+ height: p.get("height").and_then(Value::as_u64).map(|v| v as u32).unwrap_or(ch).max(1),
+ pixel_aspect: 1.0,
+ }
+}
+
+fn import_solid(s: &mut Session, p: &Value) -> Result {
+ let so = solid_from(p, s);
+ let name = str_p(p, "name").unwrap_or("Solid").to_string();
+ let id = s.edit("Import Solid", None, |proj, st| {
+ let folder = proj.folder_named("Solids").unwrap_or_else(|| proj.add_item("Solids", Label::Yellow, None, ItemKind::Folder));
+ let id = proj.add_item(&name, Label::Red, Some(folder), ItemKind::Solid(so));
+ st.project_selection = vec![id];
+ Ok(id)
+ })?;
+ Ok(json!({"item": id.0}))
+}
+
+fn new_comp_from_selection(s: &mut Session, p: &Value) -> Result {
+ let items: Vec = s.state.project_selection.iter().copied().filter(|i| s.project.item(*i).is_some_and(|x| !x.is_folder())).collect();
+ if items.is_empty() {
+ return Err(bad("file.newCompFromSelection", "select footage in the Project panel"));
+ }
+ let mut made = vec![];
+ for item in items {
+ let it = s.project.item(item).ok_or(EngineError::NoComp)?.clone();
+ let (w, h) = it.dimensions().unwrap_or((1920, 1080));
+ let rate = it.frame_rate().unwrap_or(FrameRate::FPS_29_97);
+ let dur = it.duration().filter(|d| *d > Tick::ZERO).unwrap_or(Tick::from_seconds_f64(f_p(p, "duration").unwrap_or(10.0)));
+ let name = it.name.rsplit_once('.').map(|(a, _)| a.to_string()).unwrap_or(it.name.clone());
+ let c = Comp::new(w.max(1), h.max(1), rate, dur);
+ let cid = s.edit("New Comp from Selection", None, |proj, st| {
+ let cid = proj.add_item(&name, Label::Sandstone, None, ItemKind::Comp(c.into()));
+ st.project_selection = vec![cid];
+ Ok(cid)
+ })?;
+ s.open_comp(cid);
+ s.execute("layer.addItem", json!({"comp": cid.0, "item": item.0}))?;
+ made.push(cid.0);
+ }
+ Ok(json!({"comps": made}))
+}
+
+// ---------------------------------------------------------------- dependencies
+
+/// Items used (transitively) by `roots`.
+fn used_items(proj: &Project, roots: &[ItemId]) -> BTreeSet {
+ let mut seen = BTreeSet::new();
+ let mut stack: Vec = roots.to_vec();
+ while let Some(i) = stack.pop() {
+ if !seen.insert(i) {
+ continue;
+ }
+ if let Some(c) = proj.comp(i) {
+ stack.extend(c.layers.iter().filter_map(|l| l.source.item()));
+ }
+ // Parent folders stay so the structure is kept.
+ if let Some(parent) = proj.item(i).and_then(|x| x.parent) {
+ stack.push(parent);
+ }
+ }
+ seen
+}
+
+fn referenced_sources(proj: &Project) -> BTreeSet {
+ proj.comps().flat_map(|(_, c)| c.layers.iter().filter_map(|l| l.source.item())).collect()
+}
+
+fn remove_unused(s: &mut Session, _: &Value) -> Result {
+ let used = referenced_sources(&s.project);
+ let n = s.edit("Remove Unused Footage", None, |proj, _| {
+ let before = proj.items.len();
+ proj.items.retain(|id, it| !matches!(it.kind, ItemKind::Footage(_) | ItemKind::Solid(_)) || used.contains(id));
+ Ok(before - proj.items.len())
+ })?;
+ s.sanitize_state();
+ s.toast(format!("Removed {n} unused footage item(s)"));
+ Ok(json!({"removed": n}))
+}
+
+fn consolidate(s: &mut Session, _: &Value) -> Result {
+ // Footage with the same file and interpretation collapses into the first such item.
+ let mut first: BTreeMap = BTreeMap::new();
+ let mut remap: BTreeMap = BTreeMap::new();
+ for (id, it) in &s.project.items {
+ if let ItemKind::Footage(f) = &it.kind
+ && !f.path.is_empty()
+ {
+ let key = serde_json::to_string(f).unwrap_or_default();
+ match first.get(&key) {
+ Some(keep) => {
+ remap.insert(*id, *keep);
+ }
+ None => {
+ first.insert(key, *id);
+ }
+ }
+ }
+ }
+ let n = remap.len();
+ s.edit("Consolidate All Footage", None, |proj, _| {
+ let ids: Vec = proj.comps().map(|(id, _)| *id).collect();
+ for cid in ids {
+ if let Some(c) = proj.comp_mut(cid) {
+ for l in &mut c.layers {
+ if let LayerSource::Footage { item } = &mut l.source
+ && let Some(k) = remap.get(item)
+ {
+ *item = *k;
+ }
+ }
+ }
+ }
+ proj.items.retain(|id, _| !remap.contains_key(id));
+ Ok(())
+ })?;
+ s.sanitize_state();
+ s.toast(format!("Consolidated {n} duplicate footage item(s)"));
+ Ok(json!({"removed": n}))
+}
+
+fn reduce(s: &mut Session, _: &Value) -> Result {
+ let roots: Vec = s.state.project_selection.iter().copied().filter(|i| s.project.comp(*i).is_some()).collect();
+ let keep = used_items(&s.project, &roots);
+ let n = s.edit("Reduce Project", None, |proj, _| {
+ let before = proj.items.len();
+ proj.items.retain(|id, _| keep.contains(id));
+ Ok(before - proj.items.len())
+ })?;
+ s.sanitize_state();
+ s.toast(format!("Removed {n} item(s)"));
+ Ok(json!({"removed": n}))
+}
+
+fn find_missing(s: &mut Session, p: &Value) -> Result {
+ let what = str_p(p, "what").unwrap_or("footage");
+ match what {
+ "footage" => {
+ let ids: Vec = s.project.items.values().filter(|i| matches!(&i.kind, ItemKind::Footage(f) if f.missing)).map(|i| i.id).collect();
+ s.state.project_selection = ids.clone();
+ s.toast(format!("{} missing footage item(s)", ids.len()));
+ Ok(json!({"items": ids.iter().map(|i| i.0).collect::>()}))
+ }
+ "effects" => {
+ let mut found = vec![];
+ for (cid, c) in s.project.comps() {
+ for l in &c.layers {
+ for g in l.effects().into_iter().flat_map(|fx| fx.groups()) {
+ if let effectcraft_project::GroupKind::Effect { effect } = &g.kind
+ && crate::effects::find(effect).is_none()
+ {
+ found.push(json!({"comp": cid.0, "layer": l.id.0, "effect": effect}));
+ }
+ }
+ }
+ }
+ s.toast(format!("{} missing effect(s)", found.len()));
+ Ok(json!({"effects": found}))
+ }
+ "fonts" => {
+ let families = crate::text_families();
+ let mut found = vec![];
+ for (cid, c) in s.project.comps() {
+ for l in &c.layers {
+ if let Some(pr) = l.props.prop("text/sourceText")
+ && let Some(doc) = pr.value.as_text()
+ && !families.iter().any(|f| f.eq_ignore_ascii_case(&doc.font))
+ {
+ found.push(json!({"comp": cid.0, "layer": l.id.0, "font": doc.font}));
+ }
+ }
+ }
+ s.toast(format!("{} layer(s) with missing fonts", found.len()));
+ Ok(json!({"fonts": found}))
+ }
+ w => Err(bad("file.findMissing", format!("what: footage|effects|fonts, not `{w}`"))),
+ }
+}
+
+fn collect_files(s: &mut Session, p: &Value) -> Result {
+ let folder = str_p(p, "folder").ok_or_else(|| bad("file.collectFiles", "missing `folder`"))?.trim_end_matches('/').to_string();
+ let mut proj = (*s.project).clone();
+ let mut copied = 0;
+ let mut errors = vec![];
+ let mut used_names = BTreeSet::new();
+ for it in proj.items.values_mut() {
+ let ItemKind::Footage(f) = &mut it.kind else { continue };
+ if f.path.is_empty() {
+ continue;
+ }
+ let files: Vec = if f.sequence.is_empty() { vec![f.path.clone()] } else { f.sequence.clone() };
+ let mut new_paths = vec![];
+ for src in &files {
+ let mut name = std::path::Path::new(src).file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_else(|| "footage".into());
+ let mut k = 2;
+ while !used_names.insert(name.clone()) {
+ name = format!("{k}_{name}");
+ k += 1;
+ }
+ let dst = format!("{folder}/(Footage)/{name}");
+ match s.services.read_file(src).and_then(|bytes| s.services.write_file(&dst, &bytes)) {
+ Ok(()) => copied += 1,
+ Err(e) => errors.push(format!("{src}: {e}")),
+ }
+ new_paths.push(dst);
+ }
+ if f.sequence.is_empty() {
+ f.path = new_paths.remove(0);
+ } else {
+ f.path = new_paths.first().cloned().unwrap_or_default();
+ f.sequence = new_paths;
+ }
+ }
+ let stem = s
+ .path
+ .as_deref()
+ .and_then(|p| std::path::Path::new(p).file_stem())
+ .map(|n| n.to_string_lossy().to_string())
+ .unwrap_or_else(|| "Untitled Project".into());
+ let out = format!("{folder}/{stem}.ecproj");
+ s.services.write_file(&out, proj.to_json().as_bytes()).map_err(|e| EngineError::Other(format!("cannot write {out}: {e}")))?;
+ s.toast(format!("Collected {copied} file(s) into {folder}"));
+ Ok(json!({"project": out, "copied": copied, "errors": errors}))
+}
+
+// ---------------------------------------------------------------- scripts
+
+/// Run a command script: a JSON array or JSON lines of `{"command": id, "params": {…}}` (also
+/// accepts the control channel's `{"method": "engine.execute", "params": {"id", "params"}}`).
+fn run_script(s: &mut Session, p: &Value) -> Result {
+ let steps: Vec = match (p.get("steps"), str_p(p, "path")) {
+ (Some(Value::Array(a)), _) => a.clone(),
+ (_, Some(path)) => {
+ let bytes = s.services.read_file(path).map_err(|e| EngineError::Other(format!("cannot read {path}: {e}")))?;
+ let text = String::from_utf8_lossy(&bytes).to_string();
+ match serde_json::from_str::(&text) {
+ Ok(Value::Array(a)) => a,
+ _ => text
+ .lines()
+ .map(str::trim)
+ .filter(|l| !l.is_empty() && !l.starts_with("//") && !l.starts_with('#'))
+ .map(|l| serde_json::from_str(l).map_err(|e| bad("file.runScript", format!("{e}: {l}"))))
+ .collect::>>()?,
+ }
+ }
+ _ => return Err(bad("file.runScript", "missing `path` (or inline `steps`)")),
+ };
+ let mut results = vec![];
+ for (i, step) in steps.iter().enumerate() {
+ let (id, params) = match (step.get("command").or(step.get("id")).and_then(Value::as_str), step.get("method").and_then(Value::as_str)) {
+ (Some(id), _) => (id.to_string(), step.get("params").cloned().unwrap_or(json!({}))),
+ (None, Some("engine.execute")) => {
+ let pp = step.get("params").cloned().unwrap_or(json!({}));
+ (pp.get("id").and_then(Value::as_str).unwrap_or_default().to_string(), pp.get("params").cloned().unwrap_or(json!({})))
+ }
+ _ => return Err(bad("file.runScript", format!("step {}: needs `command`", i + 1))),
+ };
+ if id == "file.runScript" {
+ return Err(bad("file.runScript", "scripts can't run scripts"));
+ }
+ let r = s.execute(&id, params).map_err(|e| EngineError::Other(format!("step {} ({id}): {e}", i + 1)))?;
+ results.push(r);
+ }
+ Ok(json!({"steps": results.len(), "results": results}))
+}
+
+// ---------------------------------------------------------------- footage
+
+fn interpret(s: &mut Session, p: &Value) -> Result {
+ let items = items_p(s, p);
+ if items.is_empty() {
+ return Err(bad("file.interpretFootage", "select footage"));
+ }
+ let rate = f_p(p, "frameRate").map(FrameRate::from_f64);
+ let alpha = match str_p(p, "alpha") {
+ Some("straight") => Some(AlphaMode::Straight),
+ Some("premultiplied") => Some(AlphaMode::Premultiplied),
+ Some("ignore") => Some(AlphaMode::Ignore),
+ Some(a) => return Err(bad("file.interpretFootage", format!("alpha: straight|premultiplied|ignore, not `{a}`"))),
+ None => None,
+ };
+ let loops = p.get("loop").and_then(Value::as_u64).map(|v| v.max(1) as u32);
+ let par = f_p(p, "pixelAspect");
+ s.edit("Interpret Footage", None, |proj, _| {
+ for i in &items {
+ if let Some(ItemKind::Footage(f)) = proj.item_mut(*i).map(|x| &mut x.kind) {
+ if let Some(r) = rate {
+ if f.native_rate.is_none() {
+ f.native_rate = Some(f.frame_rate);
+ }
+ f.frame_rate = r;
+ }
+ if let Some(a) = alpha {
+ f.alpha = a;
+ }
+ if let Some(l) = loops {
+ f.loop_count = l;
+ }
+ if let Some(x) = par {
+ f.pixel_aspect = x;
+ }
+ }
+ }
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+fn remember_interpretation(s: &mut Session, p: &Value) -> Result {
+ let item = *items_p(s, p).first().ok_or_else(|| bad("file.rememberInterpretation", "select footage"))?;
+ if let Some(ItemKind::Footage(f)) = s.project.item(item).map(|x| &x.kind) {
+ s.state.interpretation = Some(f.clone());
+ }
+ Ok(Value::Null)
+}
+
+fn apply_interpretation(s: &mut Session, p: &Value) -> Result {
+ let src = s.state.interpretation.clone().ok_or_else(|| bad("file.applyInterpretation", "no interpretation remembered"))?;
+ let items = items_p(s, p);
+ s.edit("Apply Interpretation", None, |proj, _| {
+ for i in &items {
+ if let Some(ItemKind::Footage(f)) = proj.item_mut(*i).map(|x| &mut x.kind) {
+ f.alpha = src.alpha;
+ f.premul_color = src.premul_color;
+ f.pixel_aspect = src.pixel_aspect;
+ f.loop_count = src.loop_count;
+ if src.native_rate.is_some() {
+ if f.native_rate.is_none() {
+ f.native_rate = Some(f.frame_rate);
+ }
+ f.frame_rate = src.frame_rate;
+ }
+ }
+ }
+ Ok(())
+ })?;
+ Ok(json!({"items": items.len()}))
+}
+
+fn replace_footage(s: &mut Session, p: &Value) -> Result {
+ let path = str_p(p, "path").ok_or_else(|| bad("file.replaceFootage", "missing `path`"))?.to_string();
+ let item = *items_p(s, p).first().ok_or_else(|| bad("file.replaceFootage", "select footage"))?;
+ let importer = s.importer.clone().ok_or_else(|| EngineError::Other("media import is not available in this build".into()))?;
+ let f = importer.probe(&path).map_err(|e| EngineError::Other(format!("{path}: {e}")))?;
+ let name = std::path::Path::new(&path).file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or(path.clone());
+ s.edit("Replace Footage", None, |proj, _| {
+ let it = proj.item_mut(item).ok_or_else(|| bad("file.replaceFootage", "no such item"))?;
+ it.name = name;
+ it.kind = ItemKind::Footage(f);
+ retarget_layers(proj, item, |_| LayerSource::Footage { item });
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+/// Point every layer using `item` at a new source kind.
+fn retarget_layers(proj: &mut Project, item: ItemId, src: impl Fn(&LayerSource) -> LayerSource) {
+ let ids: Vec = proj.comps().map(|(id, _)| *id).collect();
+ for cid in ids {
+ if let Some(c) = proj.comp_mut(cid) {
+ for l in &mut c.layers {
+ if l.source.item() == Some(item) {
+ l.source = src(&l.source);
+ }
+ }
+ }
+ }
+}
+
+fn replace_with_placeholder(s: &mut Session, p: &Value) -> Result {
+ let item = *items_p(s, p).first().ok_or_else(|| bad("file.replaceWithPlaceholder", "select footage"))?;
+ let base = match s.project.item(item).map(|x| &x.kind) {
+ Some(ItemKind::Footage(f)) => json!({"width": f.width, "height": f.height, "frameRate": f.frame_rate.as_f64(), "duration": f.duration.seconds()}),
+ _ => json!({}),
+ };
+ let mut merged = base;
+ if let (Some(m), Some(pm)) = (merged.as_object_mut(), p.as_object()) {
+ for (k, v) in pm {
+ m.insert(k.clone(), v.clone());
+ }
+ }
+ let f = placeholder_footage(&merged);
+ s.edit("Replace Footage", None, |proj, _| {
+ let it = proj.item_mut(item).ok_or_else(|| bad("file.replaceWithPlaceholder", "no such item"))?;
+ it.kind = ItemKind::Footage(f);
+ retarget_layers(proj, item, |_| LayerSource::Footage { item });
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+fn replace_with_solid(s: &mut Session, p: &Value) -> Result {
+ let item = *items_p(s, p).first().ok_or_else(|| bad("file.replaceWithSolid", "select footage"))?;
+ let mut so = solid_from(p, s);
+ if let Some((w, h)) = s.project.item(item).and_then(|x| x.dimensions())
+ && p.get("width").is_none()
+ {
+ so.width = w.max(1);
+ so.height = h.max(1);
+ }
+ s.edit("Replace Footage", None, |proj, _| {
+ let it = proj.item_mut(item).ok_or_else(|| bad("file.replaceWithSolid", "no such item"))?;
+ it.kind = ItemKind::Solid(so);
+ retarget_layers(proj, item, |_| LayerSource::Solid { item });
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+fn reload(s: &mut Session, p: &Value) -> Result {
+ let items = items_p(s, p);
+ let Some(importer) = s.importer.clone() else { return Err(EngineError::Other("media import is not available in this build".into())) };
+ let mut updates = vec![];
+ for i in &items {
+ if let Some(ItemKind::Footage(f)) = s.project.item(*i).map(|x| &x.kind) {
+ let mut nf = match importer.probe(&f.path) {
+ Ok(n) => n,
+ Err(_) => Footage { missing: true, ..f.clone() },
+ };
+ // Keep the interpretation.
+ nf.alpha = f.alpha;
+ nf.loop_count = f.loop_count;
+ nf.pixel_aspect = f.pixel_aspect;
+ updates.push((*i, nf));
+ }
+ }
+ let n = updates.len();
+ s.edit("Reload Footage", None, |proj, _| {
+ for (i, f) in updates {
+ if let Some(it) = proj.item_mut(i) {
+ it.kind = ItemKind::Footage(f);
+ }
+ }
+ Ok(())
+ })?;
+ s.events.push(crate::Event::PurgeCaches);
+ Ok(json!({"reloaded": n}))
+}
+
+fn reveal_in_finder(s: &mut Session, p: &Value) -> Result {
+ let item = *items_p(s, p).first().ok_or_else(|| bad("file.revealInFinder", "select footage"))?;
+ let path = match s.project.item(item).map(|x| &x.kind) {
+ Some(ItemKind::Footage(f)) if !f.path.is_empty() => f.path.clone(),
+ _ => return Err(bad("file.revealInFinder", "the item is not a file")),
+ };
+ let url = super::layer_menu::folder_url(&path);
+ s.events.push(crate::Event::OpenUrl(url.clone()));
+ Ok(json!({"url": url}))
+}
+
+pub fn specs() -> Vec {
+ vec![
+ cmd!("project.newFolder", "New Folder", ["File", "New"], Some("Cmd+Alt+Shift+N"), "{name?, parent?}", always, new_folder),
+ cmd!("file.close", "Close", ["File"], Some("Cmd+W"), "{comp?}", has_comp, close),
+ cmd!("file.closeProject", "Close Project", ["File"], None, "{}", always, close_project),
+ cmd!("file.saveCopy", "Save a Copy...", ["File", "Save As"], None, "{path}", always, save_copy),
+ cmd!("file.importMultiple", "Multiple Files...", ["File", "Import"], Some("Cmd+Alt+I"), "{paths: [string]}", always, |s, p| s
+ .execute("file.import", p.clone())),
+ cmd!(
+ "file.importPlaceholder",
+ "Placeholder...",
+ ["File", "Import"],
+ None,
+ "{name?, width?, height?, frameRate?, duration? (s)}",
+ always,
+ import_placeholder
+ ),
+ cmd!("file.importSolid", "Solid...", ["File", "Import"], None, "{name?, color?, width?, height?}", always, import_solid),
+ cmd!(
+ "file.newCompFromSelection",
+ "New Comp from Selection...",
+ ["File"],
+ Some("Cmd+Alt+\\"),
+ "{duration? (s, for stills)}",
+ has_project_selection,
+ new_comp_from_selection
+ ),
+ cmd!("file.collectFiles", "Collect Files...", ["File", "Dependencies"], None, "{folder}", has_items, collect_files),
+ cmd!("file.consolidateFootage", "Consolidate All Footage", ["File", "Dependencies"], None, "{}", has_items, consolidate),
+ cmd!("file.removeUnusedFootage", "Remove Unused Footage", ["File", "Dependencies"], None, "{}", has_items, remove_unused),
+ cmd!(
+ "file.reduceProject",
+ "Reduce Project",
+ ["File", "Dependencies"],
+ None,
+ "{} (keeps the selected comps and what they use)",
+ has_comp_selection,
+ reduce
+ ),
+ cmd!("file.findMissing", "Find Missing", [], None, "{what: footage|effects|fonts}", has_items, find_missing),
+ cmd!(
+ "file.runScript",
+ "Run Script File...",
+ ["File", "Scripts"],
+ None,
+ "{path (.jsonl/.json command script) | steps: [{command, params}]}",
+ always,
+ run_script
+ ),
+ cmd!(
+ "file.interpretFootage",
+ "Main...",
+ ["File", "Interpret Footage"],
+ Some("Cmd+Alt+G"),
+ "{items?, frameRate?, alpha?: straight|premultiplied|ignore, loop?, pixelAspect?}",
+ has_footage_selection,
+ interpret
+ ),
+ cmd!(
+ "file.rememberInterpretation",
+ "Remember Interpretation",
+ ["File", "Interpret Footage"],
+ None,
+ "{item?}",
+ has_footage_selection,
+ remember_interpretation
+ ),
+ cmd!(
+ "file.applyInterpretation",
+ "Apply Interpretation",
+ ["File", "Interpret Footage"],
+ Some("Cmd+Alt+V"),
+ "{items?}",
+ has_interpretation,
+ apply_interpretation
+ ),
+ cmd!("file.replaceFootage", "File...", ["File", "Replace Footage"], Some("Cmd+H"), "{path, item?}", has_footage_selection, replace_footage),
+ cmd!(
+ "file.replaceWithPlaceholder",
+ "Placeholder...",
+ ["File", "Replace Footage"],
+ None,
+ "{item?, width?, height?, frameRate?, duration?}",
+ has_footage_selection,
+ replace_with_placeholder
+ ),
+ cmd!(
+ "file.replaceWithSolid",
+ "Solid...",
+ ["File", "Replace Footage"],
+ None,
+ "{item?, color?, width?, height?}",
+ has_footage_selection,
+ replace_with_solid
+ ),
+ cmd!("file.reloadFootage", "Reload Footage", ["File"], Some("Cmd+Alt+L"), "{items?}", has_footage_selection, reload),
+ cmd!("file.revealInFinder", "Reveal in Finder", ["File"], None, "{item?}", has_footage_selection, reveal_in_finder),
+ ]
+}
diff --git a/crates/engine/src/commands/frontend.rs b/crates/engine/src/commands/frontend.rs
new file mode 100644
index 000000000..f83af9219
--- /dev/null
+++ b/crates/engine/src/commands/frontend.rs
@@ -0,0 +1,77 @@
+//! Frontend-only commands: viewer zoom/resolution/overlays, panels, workspaces, dialogs and app
+//! chrome. They live in the registry so every menu entry is a command (menus, shortcuts, the
+//! control channel and MCP all see them); running one emits [`crate::Event::Frontend`] and the UI
+//! performs it. Headless sessions accept and ignore them.
+
+use super::{CommandSpec, always, frontend, has_comp, has_layers};
+use crate::cmd;
+
+macro_rules! fe {
+ ($id:literal, $label:literal, [$($m:literal),*], $sc:expr, $params:literal, $en:expr) => {
+ cmd!($id, $label, [$($m),*], $sc, $params, $en, |s, p| frontend(s, $id, p))
+ };
+}
+
+pub fn specs() -> Vec {
+ vec![
+ // Application.
+ fe!("app.about", "About EffectCraft...", [], None, "{}", always),
+ fe!(
+ "app.settings",
+ "Settings...",
+ [],
+ None,
+ "{page?: general|startup|project|composition|previews|appearance|grids|labels|type|import|export|audio|disk|memory|video|3d|scripting}",
+ always
+ ),
+ fe!("app.hide", "Hide EffectCraft", [], None, "{}", always),
+ fe!("app.quit", "Quit EffectCraft", [], Some("Cmd+Q"), "{}", always),
+ fe!("app.commandPalette", "Quick Apply...", ["Edit"], Some("Cmd+Shift+Space"), "{query?}", always),
+ fe!("app.keyboardShortcuts", "Keyboard Shortcuts", ["Edit"], Some("Cmd+Alt+'"), "{}", always),
+ fe!("app.templates", "Templates", [], None, "{kind: renderSettings|outputModule}", always),
+ fe!("app.find", "Find", ["File"], Some("Cmd+F"), "{query?}", always),
+ // Preview.
+ fe!("playback.toggle", "Play Current Preview", ["Composition", "Preview"], Some("Space"), "{}", has_comp),
+ fe!("playback.cacheWhenIdle", "Cache Frames When Idle", ["Composition", "Preview"], None, "{value?}", always),
+ // Viewer.
+ fe!("view.zoomIn", "Zoom In", ["View"], Some("."), "{}", has_comp),
+ fe!("view.zoomOut", "Zoom Out", ["View"], Some(","), "{}", has_comp),
+ fe!("view.res.full", "Full", ["View", "Resolution"], Some("Cmd+J"), "{}", has_comp),
+ fe!("view.res.half", "Half", ["View", "Resolution"], Some("Cmd+Shift+J"), "{}", has_comp),
+ fe!("view.res.third", "Third", ["View", "Resolution"], None, "{}", has_comp),
+ fe!("view.res.quarter", "Quarter", ["View", "Resolution"], Some("Cmd+Alt+Shift+J"), "{}", has_comp),
+ fe!("view.rulers", "Show Rulers", ["View"], Some("Cmd+R"), "{value?}", always),
+ fe!("view.panelBackground", "Panel Background Color", [], None, "{color?: black|darkGray|mediumGray|lightGray|white|custom|#hex, pick?: true}", always),
+ fe!("view.guides", "Show Guides", ["View"], Some("Cmd+;"), "{value?}", always),
+ fe!("view.snapToGuides", "Snap to Guides", ["View"], Some("Cmd+Shift+;"), "{value?}", always),
+ fe!("view.lockGuides", "Lock Guides", ["View"], Some("Cmd+Alt+Shift+;"), "{value?}", always),
+ fe!("view.grid", "Show Grid", ["View"], Some("Cmd+'"), "{value?}", always),
+ fe!("view.snapToGrid", "Snap to Grid", ["View"], Some("Cmd+Shift+'"), "{value?}", always),
+ fe!("view.options", "View Options...", ["View"], Some("Cmd+Alt+U"), "{}", has_comp),
+ fe!("view.layerControls", "Show Layer Controls", ["View"], Some("Cmd+Shift+H"), "{value?}", always),
+ fe!("view.fullScreen", "Enter Full Screen", ["View"], Some("Ctrl+Cmd+F"), "{}", always),
+ // Panels and workspaces.
+ fe!(
+ "window.panel",
+ "Show Panel",
+ [],
+ None,
+ "{panel: project|effectControls|composition|layer|timeline|info|audio|preview|effectsPresets|properties|character|paragraph|align|tracker|wiggler|smoother|motionSketch|paint|brushes|renderQueue|flowchart|history|markers|tools}",
+ always
+ ),
+ fe!(
+ "window.workspace",
+ "Workspace",
+ [],
+ None,
+ "{name: Default|Standard|Small Screen|Animation|Effects|Motion Tracking|Paint|Text|Minimal|All Panels}",
+ always
+ ),
+ fe!("window.resetWorkspace", "Reset to Saved Layout", ["Window", "Workspace"], None, "{}", always),
+ fe!("comp.flowchart", "Composition Flowchart", ["Composition"], Some("Cmd+F11"), "{}", always),
+ fe!("comp.miniFlowchart", "Composition Mini-Flowchart", ["Composition"], None, "{}", has_comp),
+ fe!("layer.openLayer", "Open Layer", ["Layer"], None, "{layer?}", has_layers),
+ fe!("effect.manage", "Manage Effects...", ["Effect"], None, "{}", always),
+ fe!("anim.browsePresets", "Browse Presets...", ["Animation"], None, "{}", always),
+ ]
+}
diff --git a/crates/engine/src/commands/help.rs b/crates/engine/src/commands/help.rs
index 4cd9a799a..2ed358b54 100644
--- a/crates/engine/src/commands/help.rs
+++ b/crates/engine/src/commands/help.rs
@@ -16,13 +16,26 @@ fn sibling(s: &mut Session, p: &Value) -> Result {
if str_p(p, "kind") == Some("github") { open(s, links::github_of(&slug)) } else { open(s, links::page_of(&slug)) }
}
+/// Help ▸ EffectCraft Help / Scripting Help / Expression Reference / Effect Reference.
+fn docs(s: &mut Session, p: &Value) -> Result {
+ let page = match str_p(p, "page").unwrap_or("help") {
+ "scripting" => "docs/control-protocol.md",
+ "expressions" => "docs/expressions.md",
+ "effects" => "docs/effects.md",
+ "agents" => "docs/agents.md",
+ _ => "README.md",
+ };
+ open(s, format!("{}/blob/main/{page}", links::GITHUB))
+}
+
pub fn specs() -> Vec {
vec![
- cmd!("help.discord", "Join the ArtCraft Discord…", ["Help"], None, "{}", always, |s, _| open(s, links::DISCORD.into())),
+ cmd!("help.docs", "EffectCraft Help...", [], Some("F1"), "{page?: help|scripting|expressions|effects|agents}", always, docs),
+ cmd!("help.discord", "Join the ArtCraft Discord...", ["Help"], None, "{}", always, |s, _| open(s, links::DISCORD.into())),
cmd!("help.website", "ArtCraft Website", ["Help"], None, "{}", always, |s, _| open(s, links::WEBSITE.into())),
cmd!("help.appPage", "EffectCraft Home Page", ["Help"], None, "{}", always, |s, _| open(s, links::APP_PAGE.into())),
cmd!("help.github", "EffectCraft on GitHub", ["Help"], None, "{}", always, |s, _| open(s, links::GITHUB.into())),
- cmd!("help.reportIssue", "Report an Issue…", ["Help"], None, "{}", always, |s, _| open(s, links::ISSUES.into())),
+ cmd!("help.reportIssue", "Provide Feedback...", ["Help"], None, "{}", always, |s, _| open(s, links::ISSUES.into())),
cmd!(
"help.sibling",
"Other ArtCraft Apps",
diff --git a/crates/engine/src/commands/layer.rs b/crates/engine/src/commands/layer.rs
index 6adad1015..b20b9c824 100644
--- a/crates/engine/src/commands/layer.rs
+++ b/crates/engine/src/commands/layer.rs
@@ -865,9 +865,9 @@ fn layer_settings(s: &mut Session, p: &Value) -> Result {
pub fn specs() -> Vec {
vec![
cmd!("layer.newText", "Text", ["Layer", "New"], Some("Cmd+Alt+Shift+T"), "{text?, size?, font?, fill?, position? [x,y], justify?}", has_comp, new_text),
- cmd!("layer.newSolid", "Solid…", ["Layer", "New"], Some("Cmd+Y"), "{name?, color? #hex|[r,g,b], width?, height?}", has_comp, new_solid),
- cmd!("layer.newLight", "Light…", ["Layer", "New"], Some("Cmd+Alt+Shift+L"), "{kind?: Parallel|Spot|Point|Ambient}", has_comp, new_light),
- cmd!("layer.newCamera", "Camera…", ["Layer", "New"], Some("Cmd+Alt+Shift+C"), "{name?}", has_comp, new_camera),
+ cmd!("layer.newSolid", "Solid...", ["Layer", "New"], Some("Cmd+Y"), "{name?, color? #hex|[r,g,b], width?, height?}", has_comp, new_solid),
+ cmd!("layer.newLight", "Light...", ["Layer", "New"], Some("Cmd+Alt+Shift+L"), "{kind?: Parallel|Spot|Point|Ambient}", has_comp, new_light),
+ cmd!("layer.newCamera", "Camera...", ["Layer", "New"], Some("Cmd+Alt+Shift+C"), "{name?}", has_comp, new_camera),
cmd!("layer.newNull", "Null Object", ["Layer", "New"], Some("Cmd+Alt+Shift+Y"), "{name?}", has_comp, new_null),
cmd!(
"layer.newShape",
@@ -879,7 +879,7 @@ pub fn specs() -> Vec {
new_shape
),
cmd!("layer.newAdjustment", "Adjustment Layer", ["Layer", "New"], Some("Cmd+Alt+Y"), "{name?}", has_comp, new_adjustment),
- cmd!("layer.settings", "Layer Settings…", ["Layer"], Some("Cmd+Shift+Y"), "{layer?, name?, color?, width?, height?}", has_layers, layer_settings),
+ cmd!("layer.settings", "Layer Settings...", ["Layer"], Some("Cmd+Shift+Y"), "{layer?, name?, color?, width?, height?}", has_layers, layer_settings),
cmd!("layer.addItem", "Add Footage to Comp", ["File"], Some("Cmd+/"), "{item: id|name, time?}", has_comp, add_item),
cmd!("layer.select", "Select Layers", [], None, "{layers: [id|name|#n], add?, toggle?}", has_comp, select),
cmd!("layer.selectNext", "Select Next Layer", [], Some("Cmd+ArrowDown"), "{add?}", has_comp, select_next),
@@ -915,7 +915,7 @@ pub fn specs() -> Vec {
timing
),
cmd!("layer.arrange", "Arrange", ["Layer", "Arrange"], None, "{layers?, to: front|forward|backward|back, index?}", has_layers, arrange),
- cmd!("layer.precompose", "Pre-compose…", ["Layer"], Some("Cmd+Shift+C"), "{layers?, name?}", has_layers, precompose),
+ cmd!("layer.precompose", "Pre-compose...", ["Layer"], Some("Cmd+Shift+C"), "{layers?, name?}", has_layers, precompose),
cmd!(
"layer.addMask",
"New Mask",
@@ -947,7 +947,7 @@ pub fn specs() -> Vec {
cmd!(
"layer.addTextAnimator",
"Animate Text",
- ["Animation"],
+ [],
None,
"{layer?, properties: [position|scale|rotation|opacity|fillColor|tracking|…]}",
has_layers,
@@ -962,7 +962,7 @@ pub fn specs() -> Vec {
has_layers,
transform_op
),
- cmd!("layer.timeStretch", "Time Stretch…", ["Layer", "Time"], None, "{layers?, percent?, op?: reverse}", has_layers, time_stretch),
+ cmd!("layer.timeStretch", "Time Stretch...", ["Layer", "Time"], None, "{layers?, percent?, op?: reverse}", has_layers, time_stretch),
]
}
diff --git a/crates/engine/src/commands/layer_menu.rs b/crates/engine/src/commands/layer_menu.rs
new file mode 100644
index 000000000..117240b1e
--- /dev/null
+++ b/crates/engine/src/commands/layer_menu.rs
@@ -0,0 +1,834 @@
+//! Layer menu: quality / sampling / frame blending, switches, transform dialogs, masks on existing
+//! layers, markers, track matte shortcuts, open/reveal, and Keyframe Assistant ▸ Sequence Layers.
+
+use effectcraft_keyframe::{Keyframe, ShapePath, Value as KV};
+use effectcraft_project::{
+ AutoOrient, FrameBlend, GroupKind, ItemId, LayerId, LayerSource, Marker, MaskMode, MatteKind, Node, Quality, Sampling, TrackMatte, Uid,
+};
+use effectcraft_time::Tick;
+use serde_json::{Value, json};
+
+use super::{CommandSpec, b_p, bad, comp_id, f_p, frontend, has_comp, has_layers, layer_mut, layer_p, layers_p, merge_p, str_p};
+use crate::{EngineError, Result, Session, cmd};
+
+// ---------------------------------------------------------------- enablement
+
+fn has_masks(s: &Session) -> std::result::Result<(), String> {
+ has_layers(s)?;
+ let c = s.active_comp().ok_or("no composition")?;
+ let any = s.state.selected_layers.iter().filter_map(|l| c.layer(*l)).any(|l| l.masks().is_some_and(|m| !m.children.is_empty()));
+ if any { Ok(()) } else { Err("the selected layers have no masks".into()) }
+}
+
+fn has_markers(s: &Session) -> std::result::Result<(), String> {
+ has_layers(s)?;
+ let c = s.active_comp().ok_or("no composition")?;
+ if s.state.selected_layers.iter().filter_map(|l| c.layer(*l)).any(|l| !l.markers.is_empty()) {
+ Ok(())
+ } else {
+ Err("the selected layers have no markers".into())
+ }
+}
+
+fn has_source_item(s: &Session) -> std::result::Result<(), String> {
+ has_layers(s)?;
+ let c = s.active_comp().ok_or("no composition")?;
+ if s.state.selected_layers.iter().filter_map(|l| c.layer(*l)).any(|l| l.source.item().is_some()) {
+ Ok(())
+ } else {
+ Err("the selected layer has no source item".into())
+ }
+}
+
+fn has_footage_layer(s: &Session) -> std::result::Result<(), String> {
+ has_layers(s)?;
+ let c = s.active_comp().ok_or("no composition")?;
+ let any = s.state.selected_layers.iter().filter_map(|l| c.layer(*l)).any(|l| matches!(l.source, LayerSource::Footage { .. }));
+ if any { Ok(()) } else { Err("select a footage layer".into()) }
+}
+
+fn has_multiple_layers(s: &Session) -> std::result::Result<(), String> {
+ has_comp(s)?;
+ if s.state.selected_layers.len() >= 2 { Ok(()) } else { Err("select two or more layers".into()) }
+}
+
+// ---------------------------------------------------------------- quality / sampling / blending
+
+fn quality(s: &mut Session, p: &Value) -> Result {
+ let (cid, ids) = layers_p(s, p)?;
+ let q = match str_p(p, "quality").unwrap_or("best").to_ascii_lowercase().as_str() {
+ "best" => Quality::Best,
+ "draft" => Quality::Draft,
+ "wireframe" => Quality::Wireframe,
+ q => return Err(bad("layer.quality", format!("quality must be best|draft|wireframe, not `{q}`"))),
+ };
+ s.edit("Layer Quality", None, |proj, _| {
+ for l in proj.comp_mut(cid).ok_or(EngineError::NoComp)?.layers.iter_mut().filter(|l| ids.contains(&l.id)) {
+ l.switches.quality = q;
+ }
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+fn sampling(s: &mut Session, p: &Value) -> Result {
+ let (cid, ids) = layers_p(s, p)?;
+ let q = match str_p(p, "sampling").unwrap_or("bilinear").to_ascii_lowercase().as_str() {
+ "bilinear" => Sampling::Bilinear,
+ "bicubic" => Sampling::Bicubic,
+ q => return Err(bad("layer.sampling", format!("sampling must be bilinear|bicubic, not `{q}`"))),
+ };
+ s.edit("Layer Sampling", None, |proj, _| {
+ for l in proj.comp_mut(cid).ok_or(EngineError::NoComp)?.layers.iter_mut().filter(|l| ids.contains(&l.id)) {
+ l.switches.sampling = q;
+ }
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+fn frame_blending(s: &mut Session, p: &Value) -> Result {
+ let (cid, ids) = layers_p(s, p)?;
+ let m = match str_p(p, "mode").unwrap_or("off") {
+ "off" => FrameBlend::Off,
+ "frameMix" => FrameBlend::FrameMix,
+ "pixelMotion" => FrameBlend::PixelMotion,
+ m => return Err(bad("layer.frameBlending", format!("mode must be off|frameMix|pixelMotion, not `{m}`"))),
+ };
+ s.edit("Frame Blending", None, |proj, _| {
+ for l in proj.comp_mut(cid).ok_or(EngineError::NoComp)?.layers.iter_mut().filter(|l| ids.contains(&l.id)) {
+ l.switches.frame_blend = m;
+ }
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+// ---------------------------------------------------------------- switches
+
+fn hide_other_video(s: &mut Session, p: &Value) -> Result {
+ let (cid, ids) = layers_p(s, p)?;
+ s.edit("Hide Other Video", None, |proj, _| {
+ for l in proj.comp_mut(cid).ok_or(EngineError::NoComp)?.layers.iter_mut() {
+ if !ids.contains(&l.id) && l.source.is_av() {
+ l.switches.video = false;
+ }
+ }
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+fn show_all_video(s: &mut Session, p: &Value) -> Result {
+ let cid = comp_id(s, p)?;
+ s.edit("Show All Video", None, |proj, _| {
+ let c = proj.comp_mut(cid).ok_or(EngineError::NoComp)?;
+ // Track mattes stay hidden (their video switch is off by design).
+ let mattes: Vec = c.layers.iter().filter_map(|l| l.track_matte.map(|m| m.layer)).collect();
+ for l in c.layers.iter_mut().filter(|l| !mattes.contains(&l.id)) {
+ l.switches.video = true;
+ }
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+fn unlock_all(s: &mut Session, p: &Value) -> Result {
+ let cid = comp_id(s, p)?;
+ s.edit("Unlock All Layers", None, |proj, _| {
+ for l in proj.comp_mut(cid).ok_or(EngineError::NoComp)?.layers.iter_mut() {
+ l.switches.locked = false;
+ }
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+fn expressions(s: &mut Session, p: &Value) -> Result {
+ let (cid, ids) = layers_p(s, p)?;
+ let on = b_p(p, "enabled").unwrap_or(true);
+ let n = s.edit(if on { "Enable Expressions" } else { "Disable Expressions" }, None, |proj, _| {
+ let mut n = 0;
+ for l in proj.comp_mut(cid).ok_or(EngineError::NoComp)?.layers.iter_mut().filter(|l| ids.contains(&l.id)) {
+ l.props.walk_mut(&mut |pr| {
+ if let Some(e) = &mut pr.expr {
+ e.enabled = on;
+ n += 1;
+ }
+ });
+ }
+ Ok(n)
+ })?;
+ Ok(json!({"expressions": n}))
+}
+
+// ---------------------------------------------------------------- transform
+
+fn transform_member(prop: &str) -> Option<&'static str> {
+ Some(match prop {
+ "anchor" | "anchorPoint" => "anchor",
+ "position" => "position",
+ "scale" => "scale",
+ "orientation" => "orientation",
+ "rotation" => "rotation",
+ "opacity" => "opacity",
+ _ => return None,
+ })
+}
+
+fn set_transform(s: &mut Session, p: &Value) -> Result {
+ let (cid, ids) = layers_p(s, p)?;
+ let prop = str_p(p, "prop").ok_or_else(|| bad("layer.setTransform", "missing `prop`"))?;
+ let m = transform_member(prop).ok_or_else(|| bad("layer.setTransform", "prop: anchor|position|scale|orientation|rotation|opacity"))?;
+ let v = p.get("value").ok_or_else(|| bad("layer.setTransform", "missing `value`"))?.clone();
+ let t = s.time();
+ let label = match m {
+ "anchor" => "Anchor Point",
+ "position" => "Position",
+ "scale" => "Scale",
+ "orientation" => "Orientation",
+ "rotation" => "Rotation",
+ _ => "Opacity",
+ };
+ s.edit(label, merge_p(p), |proj, _| {
+ for lid in &ids {
+ let l = layer_mut(proj, cid, *lid)?;
+ let lt = l.layer_time(t);
+ let Some(pr) = l.transform_mut().and_then(|tr| tr.get_mut(m)) else { continue };
+ let cur = pr.value_at(lt);
+ // Two numbers for a 3D value keep the current z.
+ let j = match (&cur, &v) {
+ (KV::Vec3(c), Value::Array(a)) if a.len() == 2 => json!([a[0], a[1], c[2]]),
+ _ => v.clone(),
+ };
+ let nv = cur.coerce_json(&j).ok_or_else(|| bad("layer.setTransform", format!("can't use {v} for {label}")))?;
+ pr.set_value_at(lt, nv);
+ }
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+fn center_anchor(s: &mut Session, p: &Value) -> Result {
+ let (cid, ids) = layers_p(s, p)?;
+ 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);
+ let mut centers = vec![];
+ for lid in &ids {
+ let Some(l) = comp.layer(*lid) else { continue };
+ if let Some([x0, y0, x1, y1]) = effectcraft_render::content_bounds(&ctx, l) {
+ centers.push((*lid, [(x0 + x1) / 2.0, (y0 + y1) / 2.0]));
+ }
+ }
+ s.edit("Center Anchor Point", None, |proj, _| {
+ for (lid, c) in ¢ers {
+ let l = layer_mut(proj, cid, *lid)?;
+ let lt = l.layer_time(t);
+ let Some(tr) = l.transform_mut() else { continue };
+ let get = |tr: &effectcraft_project::PropGroup, m: &str, d: [f64; 3]| tr.get(m).map(|p| p.value_at(lt).as_vec3()).unwrap_or(d);
+ let anchor = get(tr, "anchor", [0.0; 3]);
+ let scale = get(tr, "scale", [100.0; 3]);
+ let rot = tr.get("rotation").map(|p| p.value_at(lt).as_f64()).unwrap_or(0.0).to_radians();
+ let (dx, dy) = ((c[0] - anchor[0]) * scale[0] / 100.0, (c[1] - anchor[1]) * scale[1] / 100.0);
+ let (sn, cs) = rot.sin_cos();
+ let shift = [dx * cs - dy * sn, dx * sn + dy * cs];
+ 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]]);
+ }
+ }
+ }
+ }
+ Ok(())
+ })?;
+ Ok(json!({"layers": centers.len()}))
+}
+
+fn auto_orient(s: &mut Session, p: &Value) -> Result {
+ let (cid, ids) = layers_p(s, p)?;
+ let mode = match str_p(p, "mode").ok_or_else(|| bad("layer.autoOrient", "missing `mode`"))? {
+ "off" => AutoOrient::Off,
+ "alongPath" => AutoOrient::AlongPath,
+ "towardsCamera" => AutoOrient::TowardsCamera,
+ "towardsPointOfInterest" => AutoOrient::TowardsPointOfInterest,
+ m => return Err(bad("layer.autoOrient", format!("mode: off|alongPath|towardsCamera|towardsPointOfInterest, not `{m}`"))),
+ };
+ s.edit("Auto-Orient", None, |proj, _| {
+ for l in proj.comp_mut(cid).ok_or(EngineError::NoComp)?.layers.iter_mut().filter(|l| ids.contains(&l.id)) {
+ l.auto_orient = mode;
+ }
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+// ---------------------------------------------------------------- masks
+
+/// Masks the command applies to: `mask` (index / uid / name) on `layer`, else selected masks,
+/// else every mask of the selected layers.
+fn target_masks(s: &Session, p: &Value) -> Result<(ItemId, Vec<(LayerId, Uid)>)> {
+ let (cid, ids) = layers_p(s, p)?;
+ let comp = s.project.comp(cid).ok_or(EngineError::NoComp)?;
+ let mut out = vec![];
+ if let Some(m) = p.get("mask") {
+ for lid in &ids {
+ let Some(masks) = comp.layer(*lid).and_then(|l| l.masks()) else { continue };
+ let g = match m {
+ Value::Number(n) => {
+ let n = n.as_u64().unwrap_or(1);
+ masks.children.iter().find(|c| c.uid() == n).or_else(|| masks.children.get(n.saturating_sub(1) as usize))
+ }
+ Value::String(name) => masks.children.iter().find(|c| c.name() == name),
+ _ => None,
+ };
+ if let Some(g) = g {
+ out.push((*lid, g.uid()));
+ }
+ }
+ return Ok((cid, out));
+ }
+ for (lid, uid) in &s.state.selected_props {
+ let Some(masks) = comp.layer(*lid).and_then(|l| l.masks()) else { continue };
+ for g in masks.groups() {
+ if g.uid == *uid || g.find(*uid).is_some() {
+ out.push((*lid, g.uid));
+ }
+ }
+ }
+ if out.is_empty() {
+ for lid in &ids {
+ if let Some(masks) = comp.layer(*lid).and_then(|l| l.masks()) {
+ out.extend(masks.groups().map(|g| (*lid, g.uid)));
+ }
+ }
+ }
+ out.dedup();
+ Ok((cid, out))
+}
+
+fn edit_masks(
+ s: &mut Session,
+ p: &Value,
+ label: &str,
+ mut f: impl FnMut(&mut effectcraft_project::PropGroup, (f64, f64), Tick) -> Result<()>,
+) -> Result {
+ let (cid, targets) = target_masks(s, p)?;
+ if targets.is_empty() {
+ return Err(EngineError::Other("no masks".into()));
+ }
+ let t = s.time();
+ let sizes: Vec<(LayerId, (f64, f64))> = targets
+ .iter()
+ .filter_map(|(lid, _)| s.project.comp(cid)?.layer(*lid).map(|l| (*lid, effectcraft_render::source_size(&s.project, l))))
+ .map(|(l, (w, h))| (l, (w as f64, h as f64)))
+ .collect();
+ let n = targets.len();
+ s.edit(label, merge_p(p), |proj, _| {
+ for (lid, uid) in &targets {
+ let size = sizes.iter().find(|(l, _)| l == lid).map(|x| x.1).unwrap_or((0.0, 0.0));
+ let l = layer_mut(proj, cid, *lid)?;
+ let lt = l.layer_time(t);
+ let Some(g) = l.props.sub_mut("masks").and_then(|m| m.find_group_mut(*uid)) else { continue };
+ f(g, size, lt)?;
+ }
+ Ok(())
+ })?;
+ Ok(json!({"masks": n}))
+}
+
+fn mask_kind(g: &mut effectcraft_project::PropGroup) -> Option<(&mut MaskMode, &mut bool, &mut bool)> {
+ match &mut g.kind {
+ GroupKind::Mask { mode, inverted, locked, .. } => Some((mode, inverted, locked)),
+ _ => None,
+ }
+}
+
+fn mask_set(s: &mut Session, p: &Value) -> Result {
+ let field = str_p(p, "field").ok_or_else(|| bad("layer.mask.set", "missing `field` (feather|opacity|expansion)"))?.to_string();
+ if !matches!(field.as_str(), "feather" | "opacity" | "expansion") {
+ return Err(bad("layer.mask.set", "field: feather|opacity|expansion"));
+ }
+ let v = p.get("value").ok_or_else(|| bad("layer.mask.set", "missing `value`"))?.clone();
+ let label = match field.as_str() {
+ "feather" => "Mask Feather",
+ "opacity" => "Mask Opacity",
+ _ => "Mask Expansion",
+ };
+ edit_masks(s, p, label, |g, _, lt| {
+ let pr = g.get_mut(&field).ok_or_else(|| bad("layer.mask.set", "mask has no such property"))?;
+ let cur = pr.value_at(lt);
+ let j = match (&cur, &v) {
+ (KV::Vec2(_), Value::Number(n)) => json!([n, n]),
+ _ => v.clone(),
+ };
+ let nv = cur.coerce_json(&j).ok_or_else(|| bad("layer.mask.set", format!("can't use {v} for {label}")))?;
+ pr.set_value_at(lt, nv);
+ Ok(())
+ })
+}
+
+fn mask_shape(s: &mut Session, p: &Value) -> Result {
+ let r = p.get("rect").and_then(Value::as_array).filter(|a| a.len() == 4).map(|a| [0, 1, 2, 3].map(|i| a[i].as_f64().unwrap_or(0.0)));
+ let r = r.ok_or_else(|| bad("layer.mask.shape", "missing `rect` [left, top, width, height] (layer px)"))?;
+ let ellipse = str_p(p, "shape") == Some("ellipse");
+ edit_masks(s, p, "Mask Shape", |g, _, lt| {
+ let (cx, cy) = (r[0] + r[2] / 2.0, r[1] + r[3] / 2.0);
+ let path = if ellipse { ShapePath::ellipse([cx, cy], r[2], r[3]) } else { ShapePath::rect([cx, cy], r[2], r[3]) };
+ if let Some(pr) = g.get_mut("path") {
+ pr.set_value_at(lt, KV::Path(path));
+ }
+ Ok(())
+ })
+}
+
+fn mask_reset(s: &mut Session, p: &Value) -> Result {
+ edit_masks(s, p, "Reset Mask", |g, (w, h), _| {
+ let (w, h) = if w > 0.0 { (w, h) } else { (400.0, 300.0) };
+ let reset = |g: &mut effectcraft_project::PropGroup, m: &str, v: KV| {
+ if let Some(pr) = g.get_mut(m) {
+ pr.keys.clear();
+ pr.expr = None;
+ pr.value = v;
+ }
+ };
+ reset(g, "path", KV::Path(ShapePath::rect([w / 2.0, h / 2.0], w, h)));
+ reset(g, "feather", KV::Vec2([0.0, 0.0]));
+ reset(g, "opacity", KV::Scalar(100.0));
+ reset(g, "expansion", KV::Scalar(0.0));
+ if let Some((mode, inv, _)) = mask_kind(g) {
+ *mode = MaskMode::Add;
+ *inv = false;
+ }
+ Ok(())
+ })
+}
+
+fn mask_remove(s: &mut Session, p: &Value) -> Result {
+ let (cid, targets) = target_masks(s, p)?;
+ // Without an explicit `mask`, Remove Mask only removes selected masks (AE), else the first.
+ let selected: Vec<(LayerId, Uid)> = targets
+ .iter()
+ .copied()
+ .filter(|(l, u)| {
+ p.get("mask").is_some()
+ || s.state.selected_props.iter().any(|(sl, su)| {
+ sl == l
+ && (su == u || s.active_comp().and_then(|c| c.layer(*l)).and_then(|ly| ly.props.find_group(*u)).is_some_and(|g| g.find(*su).is_some()))
+ })
+ })
+ .collect();
+ let remove = if selected.is_empty() { targets.into_iter().take(1).collect() } else { selected };
+ remove_masks(s, cid, remove, "Remove Mask")
+}
+
+fn remove_masks(s: &mut Session, cid: ItemId, remove: Vec<(LayerId, Uid)>, label: &str) -> Result {
+ let n = remove.len();
+ s.edit(label, None, |proj, st| {
+ for (lid, uid) in &remove {
+ if let Some(m) = layer_mut(proj, cid, *lid)?.props.sub_mut("masks") {
+ m.children.retain(|c| c.uid() != *uid);
+ }
+ }
+ st.selected_props.retain(|(l, u)| !remove.iter().any(|(rl, ru)| rl == l && ru == u));
+ Ok(())
+ })?;
+ Ok(json!({"removed": n}))
+}
+
+fn mask_remove_all(s: &mut Session, p: &Value) -> Result {
+ let (cid, ids) = layers_p(s, p)?;
+ let comp = s.project.comp(cid).ok_or(EngineError::NoComp)?;
+ let all: Vec<(LayerId, Uid)> =
+ ids.iter().filter_map(|l| comp.layer(*l)).flat_map(|l| l.masks().into_iter().flat_map(|m| m.groups().map(|g| (l.id, g.uid)))).collect();
+ remove_masks(s, cid, all, "Remove All Masks")
+}
+
+fn mask_mode(s: &mut Session, p: &Value) -> Result {
+ let m =
+ str_p(p, "mode").and_then(MaskMode::from_name).ok_or_else(|| bad("layer.mask.mode", "mode: None|Add|Subtract|Intersect|Lighten|Darken|Difference"))?;
+ edit_masks(s, p, "Mask Mode", |g, _, _| {
+ if let Some((mode, ..)) = mask_kind(g) {
+ *mode = m;
+ }
+ Ok(())
+ })
+}
+
+fn mask_invert(s: &mut Session, p: &Value) -> Result {
+ let v = b_p(p, "value");
+ edit_masks(s, p, "Mask Inverted", |g, _, _| {
+ if let Some((_, inv, _)) = mask_kind(g) {
+ *inv = v.unwrap_or(!*inv);
+ }
+ Ok(())
+ })
+}
+
+fn mask_lock(s: &mut Session, p: &Value) -> Result {
+ let v = b_p(p, "value");
+ edit_masks(s, p, "Mask Locked", |g, _, _| {
+ if let Some((_, _, locked)) = mask_kind(g) {
+ *locked = v.unwrap_or(!*locked);
+ }
+ Ok(())
+ })
+}
+
+fn mask_unlock_all(s: &mut Session, p: &Value) -> Result {
+ let (cid, ids) = layers_p(s, p)?;
+ s.edit("Unlock All Masks", None, |proj, _| {
+ for lid in &ids {
+ if let Some(m) = layer_mut(proj, cid, *lid)?.props.sub_mut("masks") {
+ for c in &mut m.children {
+ if let Node::Group(g) = c
+ && let Some((_, _, locked)) = mask_kind(g)
+ {
+ *locked = false;
+ }
+ }
+ }
+ }
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+fn mask_lock_others(s: &mut Session, p: &Value) -> Result {
+ let (cid, keep) = target_masks(s, p)?;
+ let layers: Vec = keep.iter().map(|(l, _)| *l).collect();
+ s.edit("Lock Other Masks", None, |proj, _| {
+ for lid in &layers {
+ if let Some(m) = layer_mut(proj, cid, *lid)?.props.sub_mut("masks") {
+ for c in &mut m.children {
+ let uid = c.uid();
+ if let Node::Group(g) = c
+ && let Some((_, _, locked)) = mask_kind(g)
+ {
+ *locked = !keep.contains(&(*lid, uid));
+ }
+ }
+ }
+ }
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+// ---------------------------------------------------------------- markers
+
+fn add_marker(s: &mut Session, p: &Value) -> Result {
+ let (cid, ids) = layers_p(s, p)?;
+ if ids.is_empty() {
+ return Err(bad("layer.addMarker", "no layer"));
+ }
+ let t = f_p(p, "time").map(Tick::from_seconds_f64).unwrap_or(s.time());
+ let comment = str_p(p, "comment").unwrap_or_default().to_string();
+ s.edit("Add Marker", None, |proj, _| {
+ for lid in &ids {
+ let l = layer_mut(proj, cid, *lid)?;
+ if l.markers_locked {
+ continue;
+ }
+ // Layer markers are stored in layer time.
+ let lt = l.layer_time(t);
+ l.markers.retain(|m| m.time != lt);
+ l.markers.push(Marker { time: lt, comment: comment.clone(), ..Default::default() });
+ l.markers.sort_by_key(|m| m.time);
+ }
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+fn markers_lock(s: &mut Session, p: &Value) -> Result {
+ let (cid, ids) = layers_p(s, p)?;
+ let v = b_p(p, "value");
+ let r = s.edit("Lock Markers", None, |proj, _| {
+ let c = proj.comp_mut(cid).ok_or(EngineError::NoComp)?;
+ let target = v.unwrap_or_else(|| !c.layers.iter().find(|l| ids.contains(&l.id)).is_some_and(|l| l.markers_locked));
+ for l in c.layers.iter_mut().filter(|l| ids.contains(&l.id)) {
+ l.markers_locked = target;
+ }
+ Ok(target)
+ })?;
+ Ok(json!(r))
+}
+
+fn delete_all_markers(s: &mut Session, p: &Value) -> Result {
+ let (cid, ids) = layers_p(s, p)?;
+ s.edit("Delete All Markers", None, |proj, _| {
+ for l in proj.comp_mut(cid).ok_or(EngineError::NoComp)?.layers.iter_mut().filter(|l| ids.contains(&l.id) && !l.markers_locked) {
+ l.markers.clear();
+ }
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+// ---------------------------------------------------------------- track matte
+
+fn track_matte_op(s: &mut Session, p: &Value) -> Result {
+ let (cid, ids) = layers_p(s, p)?;
+ let op = str_p(p, "op").ok_or_else(|| bad("layer.trackMatte", "missing `op`"))?.to_string();
+ let kind = match op.as_str() {
+ "alpha" => Some(MatteKind::Alpha),
+ "alphaInverted" => Some(MatteKind::AlphaInverted),
+ "luma" => Some(MatteKind::Luma),
+ "lumaInverted" => Some(MatteKind::LumaInverted),
+ "none" | "above" | "below" => None,
+ o => return Err(bad("layer.trackMatte", format!("op: none|alpha|alphaInverted|luma|lumaInverted|above|below, not `{o}`"))),
+ };
+ s.edit("Track Matte", None, |proj, _| {
+ let c = proj.comp_mut(cid).ok_or(EngineError::NoComp)?;
+ let order: Vec = c.layers.iter().map(|l| l.id).collect();
+ let mut hide = vec![];
+ for lid in &ids {
+ let i = order.iter().position(|x| x == lid).unwrap_or(0);
+ let l = c.layer_mut(*lid).ok_or(EngineError::NoComp)?;
+ let cur_kind = l.track_matte.map(|m| m.kind).unwrap_or_default();
+ l.track_matte = match op.as_str() {
+ "none" => None,
+ "above" | "below" => {
+ let j = if op == "above" { i.checked_sub(1) } else { Some(i + 1) };
+ match j.and_then(|j| order.get(j)) {
+ Some(m) => Some(TrackMatte { layer: *m, kind: cur_kind }),
+ None => return Err(bad("layer.trackMatte", format!("there is no layer {op}"))),
+ }
+ }
+ _ => match (l.track_matte, i.checked_sub(1).and_then(|j| order.get(j))) {
+ (Some(m), _) => Some(TrackMatte { layer: m.layer, kind: kind.unwrap_or_default() }),
+ (None, Some(above)) => Some(TrackMatte { layer: *above, kind: kind.unwrap_or_default() }),
+ (None, None) => return Err(bad("layer.trackMatte", "the top layer has no layer above to use as a matte")),
+ },
+ };
+ if let Some(m) = l.track_matte {
+ hide.push(m.layer);
+ }
+ }
+ for m in hide {
+ if let Some(ml) = c.layer_mut(m) {
+ ml.switches.video = false;
+ }
+ }
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+// ---------------------------------------------------------------- open / reveal
+
+fn source_item(s: &Session, p: &Value, cmd: &str) -> Result {
+ let (cid, lid) = layer_p(s, p, cmd)?;
+ s.project.comp(cid).and_then(|c| c.layer(lid)).and_then(|l| l.source.item()).ok_or_else(|| bad(cmd, "the layer has no source item"))
+}
+
+fn open_source(s: &mut Session, p: &Value) -> Result {
+ let item = source_item(s, p, "layer.openSource")?;
+ if s.project.comp(item).is_some() {
+ s.open_comp(item);
+ return Ok(json!({"comp": item.0}));
+ }
+ frontend(s, "window.panel", &json!({"panel": "layer"}))
+}
+
+/// Folder containing a file as a `file://` URL.
+pub(crate) fn folder_url(path: &str) -> String {
+ let dir = std::path::Path::new(path).parent().map(|d| d.to_string_lossy().to_string()).unwrap_or_default();
+ format!("file://{dir}")
+}
+
+fn reveal_in_finder(s: &mut Session, p: &Value) -> Result {
+ let item = source_item(s, p, "layer.revealInFinder")?;
+ let path = match s.project.item(item).map(|i| &i.kind) {
+ Some(effectcraft_project::ItemKind::Footage(f)) if !f.path.is_empty() => f.path.clone(),
+ _ => return Err(bad("layer.revealInFinder", "the layer's source is not a file")),
+ };
+ let url = folder_url(&path);
+ s.events.push(crate::Event::OpenUrl(url.clone()));
+ Ok(json!({"url": url}))
+}
+
+fn reveal_source(s: &mut Session, p: &Value) -> Result {
+ let item = source_item(s, p, "layer.revealSource")?;
+ s.state.project_selection = vec![item];
+ frontend(s, "window.panel", &json!({"panel": "project"}))?;
+ Ok(json!({"item": item.0}))
+}
+
+fn reveal_comp(s: &mut Session, p: &Value) -> Result {
+ let cid = comp_id(s, p)?;
+ s.state.project_selection = vec![cid];
+ frontend(s, "window.panel", &json!({"panel": "project"}))?;
+ Ok(json!({"item": cid.0}))
+}
+
+fn reveal_expression_errors(s: &mut Session, p: &Value) -> Result {
+ let cid = comp_id(s, p)?;
+ let t = s.time();
+ let comp = s.project.comp(cid).ok_or(EngineError::NoComp)?;
+ let mut errors = vec![];
+ for l in &comp.layers {
+ let mut has = vec![];
+ l.props.walk("", &mut |_, pr| {
+ if pr.has_expression() {
+ has.push(pr);
+ }
+ });
+ for pr in has {
+ let text = pr.expr.as_ref().map(|e| e.text.clone()).unwrap_or_default();
+ let err = match &s.expr {
+ Some(host) => {
+ let mut ctx = effectcraft_render::EvalCtx::new(&s.project, cid, comp, t);
+ ctx.expr = Some(host.as_ref());
+ host.eval(&ctx, l, pr, &pr.value_at(l.layer_time(t))).err()
+ }
+ None => None,
+ };
+ if let Some(e) = err {
+ errors.push(json!({"layer": l.id.0, "prop": pr.uid, "name": pr.name, "expression": text, "error": e}));
+ }
+ }
+ }
+ let props: Vec = errors.iter().map(|e| json!({"layer": e["layer"], "prop": e["prop"]})).collect();
+ frontend(s, "timeline.revealProps", &json!({"props": props}))?;
+ if errors.is_empty() {
+ s.toast("No expression errors");
+ }
+ Ok(json!({"errors": errors}))
+}
+
+// ---------------------------------------------------------------- sequence layers
+
+fn sequence(s: &mut Session, p: &Value) -> Result {
+ let cid = comp_id(s, p)?;
+ // Selection order (AE sequences in the order layers were selected).
+ let ids: Vec = match p.get("layers") {
+ Some(_) => layers_p(s, p)?.1,
+ None => s.state.selected_layers.clone(),
+ };
+ if ids.len() < 2 {
+ return Err(bad("layer.sequence", "select two or more layers"));
+ }
+ let overlap = b_p(p, "overlap").unwrap_or(false);
+ let dur = if overlap { Tick::from_seconds_f64(f_p(p, "duration").unwrap_or(1.0)) } else { Tick::ZERO };
+ let transition = str_p(p, "transition").unwrap_or("off").to_string();
+ s.edit("Sequence Layers", None, |proj, _| {
+ let c = proj.comp_mut(cid).ok_or(EngineError::NoComp)?;
+ let mut next: Option = None;
+ for (k, lid) in ids.iter().enumerate() {
+ let l = c.layer_mut(*lid).ok_or(EngineError::NoComp)?;
+ if let Some(at) = next {
+ let d = at - l.in_point;
+ l.start_time += d;
+ l.in_point += d;
+ l.out_point += d;
+ }
+ if overlap && transition != "off" {
+ let (a, b) = (l.layer_time(l.in_point), l.layer_time(l.in_point + dur));
+ let (oa, ob) = (l.layer_time(l.out_point - dur), l.layer_time(l.out_point));
+ let last = k + 1 == ids.len();
+ if let Some(op) = l.transform_mut().and_then(|tr| tr.get_mut("opacity")) {
+ op.keys.clear();
+ if k > 0 {
+ op.keys.push(Keyframe::new(a, KV::Scalar(0.0)));
+ op.keys.push(Keyframe::new(b, KV::Scalar(100.0)));
+ }
+ if transition == "crossDissolve" && !last {
+ op.keys.push(Keyframe::new(oa, KV::Scalar(100.0)));
+ op.keys.push(Keyframe::new(ob, KV::Scalar(0.0)));
+ }
+ op.keys.sort_by_key(|k| k.time);
+ op.keys.dedup_by_key(|k| k.time);
+ }
+ }
+ next = Some(l.out_point - dur);
+ }
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+pub fn specs() -> Vec {
+ vec![
+ cmd!("layer.quality", "Quality", [], None, "{layers?, quality: best|draft|wireframe}", has_layers, quality),
+ cmd!("layer.sampling", "Sampling", [], None, "{layers?, sampling: bilinear|bicubic}", has_layers, sampling),
+ cmd!("layer.frameBlending", "Frame Blending", [], None, "{layers?, mode: off|frameMix|pixelMotion}", has_layers, frame_blending),
+ cmd!("layer.hideOtherVideo", "Hide Other Video", ["Layer", "Switches"], Some("Cmd+Alt+Shift+V"), "{layers?}", has_layers, hide_other_video),
+ cmd!("layer.showAllVideo", "Show All Video", ["Layer", "Switches"], None, "{comp?}", has_comp, show_all_video),
+ cmd!("layer.unlockAll", "Unlock All Layers", ["Layer", "Switches"], Some("Cmd+Shift+L"), "{comp?}", has_comp, unlock_all),
+ cmd!("layer.expressions", "Enable/Disable Expressions", [], None, "{layers?, enabled: bool}", has_layers, expressions),
+ cmd!(
+ "layer.setTransform",
+ "Transform Value",
+ [],
+ None,
+ "{layers?, prop: anchor|position|scale|orientation|rotation|opacity, value}",
+ has_layers,
+ set_transform
+ ),
+ cmd!(
+ "layer.centerAnchor",
+ "Center Anchor Point in Layer Content",
+ ["Layer", "Transform"],
+ Some("Cmd+Alt+Home"),
+ "{layers?}",
+ has_layers,
+ center_anchor
+ ),
+ cmd!(
+ "layer.autoOrient",
+ "Auto-Orient...",
+ ["Layer", "Transform"],
+ Some("Cmd+Alt+O"),
+ "{layers?, mode: off|alongPath|towardsCamera|towardsPointOfInterest}",
+ has_layers,
+ auto_orient
+ ),
+ cmd!(
+ "layer.mask.shape",
+ "Mask Shape...",
+ ["Layer", "Mask"],
+ Some("Cmd+Shift+M"),
+ "{layer?, mask?, rect: [x, y, w, h], shape?: rect|ellipse}",
+ has_masks,
+ mask_shape
+ ),
+ cmd!("layer.mask.set", "Mask Settings", [], None, "{layer?, mask?, field: feather|opacity|expansion, value}", has_masks, mask_set),
+ cmd!("layer.mask.reset", "Reset Mask", ["Layer", "Mask"], None, "{layer?, mask?}", has_masks, mask_reset),
+ cmd!("layer.mask.remove", "Remove Mask", ["Layer", "Mask"], None, "{layer?, mask?}", has_masks, mask_remove),
+ cmd!("layer.mask.removeAll", "Remove All Masks", ["Layer", "Mask"], None, "{layers?}", has_masks, mask_remove_all),
+ cmd!("layer.mask.mode", "Mask Mode", [], None, "{layer?, mask?, mode: None|Add|Subtract|Intersect|Lighten|Darken|Difference}", has_masks, mask_mode),
+ cmd!("layer.mask.invert", "Inverted", ["Layer", "Mask"], Some("Cmd+Shift+I"), "{layer?, mask?, value?}", has_masks, mask_invert),
+ cmd!("layer.mask.lock", "Locked", ["Layer", "Mask"], None, "{layer?, mask?, value?}", has_masks, mask_lock),
+ cmd!("layer.mask.unlockAll", "Unlock All Masks", ["Layer", "Mask"], None, "{layers?}", has_masks, mask_unlock_all),
+ cmd!("layer.mask.lockOthers", "Lock Other Masks", ["Layer", "Mask"], None, "{layer?, mask?}", has_masks, mask_lock_others),
+ cmd!("layer.addMarker", "Add Marker", ["Layer", "Markers"], None, "{layers?, time?, comment?}", has_layers, add_marker),
+ cmd!("layer.markersLock", "Lock Markers", ["Layer", "Markers"], None, "{layers?, value?}", has_layers, markers_lock),
+ cmd!("layer.deleteAllMarkers", "Delete All Markers", ["Layer", "Markers"], None, "{layers?}", has_markers, delete_all_markers),
+ cmd!("layer.trackMatte", "Track Matte", [], None, "{layers?, op: none|alpha|alphaInverted|luma|lumaInverted|above|below}", has_layers, track_matte_op),
+ cmd!("layer.openSource", "Open Layer Source", ["Layer"], None, "{layer?}", has_source_item, open_source),
+ cmd!("layer.revealInFinder", "Reveal in Finder", ["Layer"], None, "{layer?}", has_footage_layer, reveal_in_finder),
+ cmd!("layer.revealSource", "Reveal Layer Source in Project", ["Layer", "Reveal"], None, "{layer?}", has_source_item, reveal_source),
+ cmd!("comp.revealInProject", "Reveal Composition in Project", ["Layer", "Reveal"], None, "{comp?}", has_comp, reveal_comp),
+ cmd!("layer.revealExpressionErrors", "Reveal Expression Errors", ["Layer", "Reveal"], None, "{comp?}", has_comp, reveal_expression_errors),
+ cmd!(
+ "layer.sequence",
+ "Sequence Layers...",
+ ["Animation", "Keyframe Assistant"],
+ None,
+ "{layers? (in order), overlap?: bool, duration? (s), transition?: off|dissolveFront|crossDissolve}",
+ has_multiple_layers,
+ sequence
+ ),
+ ]
+}
diff --git a/crates/engine/src/commands/mod.rs b/crates/engine/src/commands/mod.rs
index 1a7b41a86..2553ef53a 100644
--- a/crates/engine/src/commands/mod.rs
+++ b/crates/engine/src/commands/mod.rs
@@ -1,15 +1,22 @@
//! The command registry. Ids follow After Effects' menu structure; every menu item, panel button,
//! shortcut and viewer/timeline gesture maps to one of these.
+mod anim;
mod comp;
+mod comp_more;
mod edit;
mod effect;
mod file;
+mod file_more;
+mod frontend;
mod help;
mod layer;
+mod layer_menu;
mod prop;
mod query;
+mod stubs;
mod time;
+mod view;
use std::sync::OnceLock;
@@ -73,6 +80,13 @@ pub fn command_specs() -> &'static [CommandSpec] {
v.extend(time::specs());
v.extend(help::specs());
v.extend(query::specs());
+ v.extend(layer_menu::specs());
+ v.extend(anim::specs());
+ v.extend(view::specs());
+ v.extend(file_more::specs());
+ v.extend(comp_more::specs());
+ v.extend(frontend::specs());
+ v.extend(stubs::specs());
v
})
}
@@ -98,6 +112,60 @@ pub(crate) fn has_keys(s: &Session) -> std::result::Result<(), String> {
if s.state.selected_keys.is_empty() { Err("select keyframes first".into()) } else { Ok(()) }
}
+pub(crate) fn has_project_selection(s: &Session) -> std::result::Result<(), String> {
+ if s.state.project_selection.is_empty() { Err("select an item in the Project panel first".into()) } else { Ok(()) }
+}
+
+/// Disabled-command enablement (menu entries whose implementation lands with another milestone).
+pub(crate) fn not_yet(_: &Session) -> std::result::Result<(), String> {
+ Err("not available yet in EffectCraft".into())
+}
+
+/// `run` of a not-yet-available command.
+pub(crate) fn not_yet_run(_: &mut Session, _: &Value) -> Result {
+ Err(EngineError::Other("not available yet in EffectCraft".into()))
+}
+
+/// Hand a frontend-only command to the UI ([`crate::Event::Frontend`]).
+pub(crate) fn frontend(s: &mut Session, id: &str, p: &Value) -> Result {
+ s.events.push(crate::Event::Frontend { command: id.to_string(), params: p.clone() });
+ Ok(serde_json::json!({"frontend": id}))
+}
+
+/// Match path of a node (`transform/position`, `effects/#2/blurriness` style with `match#n`
+/// occurrences) so it can be found again on another layer.
+pub fn match_path_of(g: &effectcraft_project::PropGroup, uid: effectcraft_project::Uid) -> Option {
+ for c in &g.children {
+ let nth = g.children.iter().take_while(|x| !std::ptr::eq(*x, c)).filter(|x| x.match_id() == c.match_id()).count() + 1;
+ let seg = if nth == 1 { c.match_id().to_string() } else { format!("{}#{nth}", c.match_id()) };
+ if c.uid() == uid {
+ return Some(seg);
+ }
+ if let effectcraft_project::Node::Group(sub) = c
+ && let Some(rest) = match_path_of(sub, uid)
+ {
+ return Some(format!("{seg}/{rest}"));
+ }
+ }
+ None
+}
+
+/// Selected properties (leaves) of the active comp as (layer, uid); selected groups expand to
+/// their properties.
+pub(crate) fn selected_leaf_props(s: &Session) -> Vec<(LayerId, effectcraft_project::Uid)> {
+ let Some(comp) = s.active_comp() else { return vec![] };
+ let mut out = vec![];
+ for (lid, uid) in &s.state.selected_props {
+ let Some(l) = comp.layer(*lid) else { continue };
+ if l.props.find(*uid).is_some() {
+ out.push((*lid, *uid));
+ } else if let Some(g) = l.props.find_group(*uid) {
+ g.walk("", &mut |_, p| out.push((*lid, p.uid)));
+ }
+ }
+ out
+}
+
// ---------- params ----------
pub(crate) fn bad(cmd: &str, msg: impl Into) -> EngineError {
@@ -182,6 +250,6 @@ pub(crate) fn time_p(s: &Session, p: &Value, comp: Option<&Comp>) -> Tick {
s.time()
}
-pub(crate) fn layer_mut<'a>(p: &'a mut effectcraft_project::Project, cid: ItemId, lid: LayerId) -> Result<&'a mut Layer> {
+pub(crate) fn layer_mut(p: &mut effectcraft_project::Project, cid: ItemId, lid: LayerId) -> Result<&mut Layer> {
p.comp_mut(cid).ok_or(EngineError::NoComp)?.layer_mut(lid).ok_or(EngineError::Project(effectcraft_project::ProjectError::NoLayer(lid)))
}
diff --git a/crates/engine/src/commands/prop.rs b/crates/engine/src/commands/prop.rs
index 43bd88e6d..df415537e 100644
--- a/crates/engine/src/commands/prop.rs
+++ b/crates/engine/src/commands/prop.rs
@@ -432,7 +432,7 @@ pub fn specs() -> Vec {
cmd!("keys.toggleHold", "Toggle Hold Keyframe", ["Animation"], Some("Cmd+Alt+H"), "{}", has_keys, toggle_hold),
cmd!(
"keys.interpolation",
- "Keyframe Interpolation…",
+ "Keyframe Interpolation...",
["Animation"],
Some("Cmd+Alt+K"),
"{interpolation?|in?|out?: linear|bezier|hold, autoBezier?}",
@@ -441,7 +441,7 @@ pub fn specs() -> Vec {
),
cmd!(
"keys.velocity",
- "Keyframe Velocity…",
+ "Keyframe Velocity...",
["Animation"],
Some("Cmd+Shift+K"),
"{inSpeed?, inInfluence? %, outSpeed?, outInfluence? %}",
diff --git a/crates/engine/src/commands/stubs.rs b/crates/engine/src/commands/stubs.rs
new file mode 100644
index 000000000..7a0cccc4d
--- /dev/null
+++ b/crates/engine/src/commands/stubs.rs
@@ -0,0 +1,112 @@
+//! Menu entries whose implementation is owned by another milestone (3D, render queue/export,
+//! time remapping, pen/mask-vertex editing, motion tracking, layer styles…) or that have no
+//! EffectCraft equivalent yet. They are registered so the menu bar matches After Effects, and are
+//! always disabled. When a feature lands, delete its line here and register the real command
+//! with the same id (the menu tree in `menus.rs` already points at it).
+
+use super::{CommandSpec, not_yet, not_yet_run};
+
+macro_rules! stub {
+ ($id:literal, $label:literal, [$($m:literal),*], $params:literal) => {
+ CommandSpec { id: $id, label: $label, menu: &[$($m),*], shortcut: None, params: $params, enabled: not_yet, run: not_yet_run, journal: true }
+ };
+ ($id:literal, $label:literal, [$($m:literal),*], $sc:literal, $params:literal) => {
+ CommandSpec { id: $id, label: $label, menu: &[$($m),*], shortcut: Some($sc), params: $params, enabled: not_yet, run: not_yet_run, journal: true }
+ };
+}
+
+pub fn specs() -> Vec {
+ vec![
+ // macOS application menu items handled by the OS.
+ stub!("app.hideOthers", "Hide Others", [], "{}"),
+ stub!("app.showAll", "Show All", [], "{}"),
+ // Render queue / export (export milestone).
+ stub!("render.addToQueue", "Add to Render Queue", ["Composition"], "Cmd+M", "{comp?}"),
+ stub!("render.addOutputModule", "Add Output Module", ["Composition"], "{}"),
+ stub!("render.preRender", "Pre-render...", ["Composition"], "{}"),
+ stub!("render.saveCurrentPreview", "Save Current Preview...", ["Composition"], "{path}"),
+ stub!("file.createProxy", "Create Proxy", [], "{kind: still|movie}"),
+ // Proxies (no proxy model yet).
+ stub!("file.setProxy", "File...", ["File", "Set Proxy"], "{path}"),
+ stub!("file.setProxyNone", "None", ["File", "Set Proxy"], "{}"),
+ stub!("file.interpretProxy", "Proxy...", ["File", "Interpret Footage"], "{}"),
+ // Text editing in the viewer.
+ stub!("edit.pasteTextMatchFormatting", "Paste Text and Match Formatting", ["Edit"], "{}"),
+ stub!("edit.pasteTextFormattingOnly", "Paste Text Formatting Only", ["Edit"], "{}"),
+ stub!("keys.selectLabelGroup", "Select Keyframe Label Group", [], "{scope}"),
+ // Preview audio.
+ stub!("playback.audio", "Audio", ["Composition", "Preview"], "{}"),
+ // Layer ▸ New (3D / content-aware fill).
+ stub!("layer.newContentAwareFill", "Content-Aware Fill Layer...", ["Layer", "New"], "{}"),
+ stub!("layer.new3dPrimitive", "3D Primitive", [], "{kind: cube|sphere|plane|torus|cone|cylinder}"),
+ // Mask options not in the mask model yet; pen / vertex editing (timeline milestone).
+ stub!("layer.mask.motionBlur", "Motion Blur", [], "{mode: sameAsLayer|on|off}"),
+ stub!("layer.mask.featherFalloff", "Feather Falloff", [], "{mode: smooth|linear}"),
+ stub!("layer.mask.hideLocked", "Hide Locked Masks", ["Layer", "Mask"], "{}"),
+ stub!("path.rotoBezier", "RotoBezier", ["Layer", "Mask and Shape Path"], "{}"),
+ stub!("path.closed", "Closed", ["Layer", "Mask and Shape Path"], "{}"),
+ stub!("path.convertToBezier", "Convert To Bezier Path", ["Layer", "Mask and Shape Path"], "{}"),
+ stub!("path.groupShapes", "Group Shapes", ["Layer", "Mask and Shape Path"], "Cmd+G", "{}"),
+ stub!("path.ungroupShapes", "Ungroup Shapes", ["Layer", "Mask and Shape Path"], "Cmd+Shift+G", "{}"),
+ stub!("path.setFirstVertex", "Set First Vertex", ["Layer", "Mask and Shape Path"], "{}"),
+ stub!("path.freeTransform", "Free Transform Points", ["Layer", "Mask and Shape Path"], "{}"),
+ // Time (timeline milestone).
+ stub!("layer.timeRemap", "Enable Time Remapping", ["Layer", "Time"], "Cmd+Alt+T", "{layers?}"),
+ stub!("layer.freezeFrame", "Freeze Frame", ["Layer", "Time"], "{layers?}"),
+ stub!("layer.freezeOnLastFrame", "Freeze On Last Frame", ["Layer", "Time"], "{layers?}"),
+ stub!("layer.alignVideoToData", "Align Video to Data", ["Layer", "Time"], "{}"),
+ stub!("layer.environment", "Environment Layer", ["Layer"], "{}"),
+ stub!("layer.updateMarkersFromSource", "Update Markers From Source", ["Layer", "Markers"], "{}"),
+ stub!("layer.styles", "Layer Styles", [], "{op?|style?}"),
+ stub!("layer.create", "Create", [], "{op}"),
+ stub!("layer.autoTrace", "Auto-trace...", ["Layer"], "{}"),
+ stub!("layer.sceneEditDetection", "Scene Edit Detection...", ["Layer"], "{}"),
+ // Cameras / lights / materials / 3D views (3D milestone).
+ stub!("camera.fromView", "Create Camera from 3D View", ["Layer", "Camera"], "{}"),
+ stub!("camera.stereoRig", "Create Stereo 3D Rig", ["Layer", "Camera"], "{}"),
+ stub!("camera.orbitNull", "Create Orbit Null", ["Layer", "Camera"], "{}"),
+ stub!("camera.fromModel", "Create Cameras from 3D Model", ["Layer", "Camera"], "{}"),
+ stub!("camera.linkFocusToPoi", "Link Focus Distance to Point of Interest", ["Layer", "Camera"], "{}"),
+ stub!("camera.linkFocusToLayer", "Link Focus Distance to Layer", ["Layer", "Camera"], "{}"),
+ stub!("camera.setFocusToLayer", "Set Focus Distance to Layer", ["Layer", "Camera"], "{}"),
+ stub!("camera.settings", "Camera Settings...", ["Layer", "Camera"], "{}"),
+ stub!("view.reset3dView", "Reset 3D View", ["Layer", "Camera"], "{}"),
+ stub!("light.fromModel", "Create Lights from 3D Model", ["Layer", "Light"], "{}"),
+ stub!("light.controlWithCamera", "Control Light with Camera", ["Layer", "Light"], "{}"),
+ stub!("light.environmentBackground", "Create Environment Light Background Layer", ["Layer", "Light"], "{}"),
+ stub!("material.revealSource", "Reveal Material Source in Project", ["Layer", "Material"], "{}"),
+ stub!("material.reset", "Reset Material", ["Layer", "Material"], "{}"),
+ stub!("material.duplicateAssign", "Duplicate and Assign Material", ["Layer", "Material"], "{}"),
+ stub!("view.layout", "Switch View Layout", [], "{views: 1|2|4}"),
+ stub!("view.shareViewOptions", "Share View Options", ["View", "Switch View Layout"], "{}"),
+ stub!("view.3d", "Switch 3D View", [], "{view}"),
+ stub!("view.last3dView", "Switch to Last 3D View", ["View"], "Escape", "{}"),
+ stub!("view.lookAtSelected", "Look at Selected Layers", ["View"], "Cmd+Alt+Shift+\\", "{}"),
+ stub!("view.lookAtAll", "Look at All Layers", ["View"], "{}"),
+ stub!("view.splitLockedViewer", "Split with New Locked Viewer", ["View"], "{}"),
+ stub!("view.res.custom", "Custom...", ["View", "Resolution"], "{}"),
+ // Color management.
+ stub!("view.displayColorManagement", "Use Display Color Management", ["View"], "{}"),
+ stub!("view.simulateOutput", "Simulate Output", [], "{profile}"),
+ // Keyframes / text / tracking.
+ stub!("keys.audioToKeyframes", "Convert Audio to Keyframes", ["Animation", "Keyframe Assistant"], "{}"),
+ stub!("keys.rpfCameraImport", "RPF Camera Import", ["Animation", "Keyframe Assistant"], "{}"),
+ stub!("text.perCharacter3d", "Enable Per-character 3D", ["Animation", "Animate Text"], "{}"),
+ stub!("text.animatorLineAnchor", "Line Anchor", ["Animation", "Animate Text"], "{}"),
+ stub!("text.animatorCharacterValue", "Character Value", ["Animation", "Animate Text"], "{}"),
+ stub!("text.animatorFontAxes", "Variable Font Axes", ["Animation", "Animate Text"], "{}"),
+ stub!("text.addWigglySelector", "Wiggly", ["Animation", "Add Text Selector"], "{}"),
+ stub!("text.addExpressionSelector", "Expression", ["Animation", "Add Text Selector"], "{}"),
+ stub!("prop.separateDimensions", "Separate Dimensions", ["Animation"], "{}"),
+ stub!("track.camera", "Track Camera", ["Animation"], "{}"),
+ stub!("track.warpStabilizer", "Warp Stabilizer VFX", ["Animation"], "{}"),
+ stub!("track.motion", "Track Motion", ["Animation"], "{}"),
+ stub!("track.mask", "Track Mask", ["Animation"], "{}"),
+ stub!("track.property", "Track this Property", ["Animation"], "{}"),
+ // Workspaces and panels that don't exist yet.
+ stub!("window.saveWorkspace", "Save Changes to this Workspace", ["Window", "Workspace"], "{}"),
+ stub!("window.saveWorkspaceAs", "Save as New Workspace...", ["Window", "Workspace"], "{name}"),
+ stub!("window.editWorkspaces", "Edit Workspaces...", ["Window", "Workspace"], "{}"),
+ stub!("window.unavailablePanel", "Panel", [], "{panel}"),
+ ]
+}
diff --git a/crates/engine/src/commands/time.rs b/crates/engine/src/commands/time.rs
index df2b7af92..d2971b716 100644
--- a/crates/engine/src/commands/time.rs
+++ b/crates/engine/src/commands/time.rs
@@ -91,7 +91,7 @@ fn go(s: &mut Session, p: &Value) -> Result {
pub fn specs() -> Vec {
vec![
- cmd!("time.set", "Go to Time…", ["View"], Some("Alt+Shift+J"), "{time? (s) | frame? | timecode?}", has_comp, set),
+ cmd!("time.set", "Go to Time...", ["View"], Some("Alt+Shift+J"), "{time? (s) | frame? | timecode?}", has_comp, set),
cmd!("time.nextFrame", "Next Frame", [], Some("PageDown"), "{}", has_comp, |s, _| step(s, &json!({"frames": 1}))),
cmd!("time.previousFrame", "Previous Frame", [], Some("PageUp"), "{}", has_comp, |s, _| step(s, &json!({"frames": -1}))),
cmd!("time.forward10", "Forward 10 Frames", [], Some("Shift+PageDown"), "{}", has_comp, |s, _| step(s, &json!({"frames": 10}))),
diff --git a/crates/engine/src/commands/view.rs b/crates/engine/src/commands/view.rs
new file mode 100644
index 000000000..83b23cd39
--- /dev/null
+++ b/crates/engine/src/commands/view.rs
@@ -0,0 +1,86 @@
+//! View menu commands that change the project (guides) or headless-relevant editor state (the
+//! region of interest).
+
+use effectcraft_project::Guide;
+use serde_json::{Value, json};
+
+use super::{CommandSpec, always, bad, comp_id, f_p, has_comp, str_p};
+use crate::{EngineError, Result, Session, cmd};
+
+fn has_guides(s: &Session) -> std::result::Result<(), String> {
+ has_comp(s)?;
+ if s.active_comp().is_some_and(|c| !c.guides.is_empty()) { Ok(()) } else { Err("the composition has no guides".into()) }
+}
+
+fn add_guide(s: &mut Session, p: &Value) -> Result {
+ let cid = comp_id(s, p)?;
+ let vertical = match str_p(p, "orientation").unwrap_or("vertical") {
+ "vertical" | "v" => true,
+ "horizontal" | "h" => false,
+ o => return Err(bad("view.addGuide", format!("orientation must be vertical or horizontal, not `{o}`"))),
+ };
+ let comp = s.project.comp(cid).ok_or(EngineError::NoComp)?;
+ let position = f_p(p, "position").unwrap_or(if vertical { comp.width as f64 / 2.0 } else { comp.height as f64 / 2.0 });
+ let n = s.edit("Add Guide", None, |proj, _| {
+ let c = proj.comp_mut(cid).ok_or(EngineError::NoComp)?;
+ c.guides.push(Guide { vertical, position });
+ Ok(c.guides.len())
+ })?;
+ Ok(json!({"guides": n}))
+}
+
+fn clear_guides(s: &mut Session, p: &Value) -> Result {
+ let cid = comp_id(s, p)?;
+ s.edit("Clear Guides", None, |proj, _| {
+ proj.comp_mut(cid).ok_or(EngineError::NoComp)?.guides.clear();
+ Ok(())
+ })?;
+ Ok(Value::Null)
+}
+
+fn export_guides(s: &mut Session, p: &Value) -> Result {
+ let path = str_p(p, "path").ok_or_else(|| bad("view.exportGuides", "missing `path`"))?;
+ let comp = s.project.comp(comp_id(s, p)?).ok_or(EngineError::NoComp)?;
+ let doc = json!({"effectcraftGuides": 1, "width": comp.width, "height": comp.height, "guides": comp.guides});
+ let text = serde_json::to_string_pretty(&doc).unwrap_or_default();
+ s.services.write_file(path, text.as_bytes()).map_err(|e| EngineError::Other(format!("cannot write {path}: {e}")))?;
+ Ok(json!({"path": path, "guides": comp.guides.len()}))
+}
+
+fn import_guides(s: &mut Session, p: &Value) -> Result {
+ let path = str_p(p, "path").ok_or_else(|| bad("view.importGuides", "missing `path`"))?;
+ let cid = comp_id(s, p)?;
+ let bytes = s.services.read_file(path).map_err(|e| EngineError::Other(format!("cannot read {path}: {e}")))?;
+ let doc: Value = serde_json::from_slice(&bytes).map_err(|e| bad("view.importGuides", format!("not a guides file: {e}")))?;
+ let guides: Vec = serde_json::from_value(doc.get("guides").cloned().unwrap_or(json!([]))).map_err(|e| bad("view.importGuides", e.to_string()))?;
+ let n = guides.len();
+ s.edit("Import Guides", None, |proj, _| {
+ proj.comp_mut(cid).ok_or(EngineError::NoComp)?.guides.extend(guides);
+ Ok(())
+ })?;
+ Ok(json!({"imported": n}))
+}
+
+fn region_of_interest(s: &mut Session, p: &Value) -> Result {
+ s.state.region_of_interest = match p.get("rect") {
+ Some(Value::Array(a)) if a.len() == 4 => {
+ let r = [0, 1, 2, 3].map(|i| a[i].as_f64().unwrap_or(0.0));
+ if r[2] <= 0.0 || r[3] <= 0.0 {
+ return Err(bad("view.setRegionOfInterest", "width and height must be positive"));
+ }
+ Some(r)
+ }
+ _ => None,
+ };
+ Ok(json!(s.state.region_of_interest))
+}
+
+pub fn specs() -> Vec {
+ vec![
+ cmd!("view.addGuide", "Add Guide...", ["View"], None, "{orientation?: vertical|horizontal, position? (comp px)}", has_comp, add_guide),
+ cmd!("view.clearGuides", "Clear Guides", ["View"], None, "{comp?}", has_guides, clear_guides),
+ cmd!("view.importGuides", "Import Guides...", ["View"], None, "{path}", has_comp, import_guides),
+ cmd!("view.exportGuides", "Export Guides...", ["View"], None, "{path}", has_guides, export_guides),
+ cmd!("view.setRegionOfInterest", "Region of Interest", [], None, "{rect?: [x, y, w, h] | null}", always, region_of_interest),
+ ]
+}
diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs
index f93caa18f..5506e675f 100644
--- a/crates/engine/src/lib.rs
+++ b/crates/engine/src/lib.rs
@@ -11,6 +11,7 @@
pub mod commands;
pub mod demo;
pub mod links;
+pub mod menus;
use std::sync::Arc;
@@ -110,15 +111,57 @@ pub struct EditorState {
pub snapping: bool,
/// Last applied effect id (Effect ▸ last effect).
pub last_effect: Option,
+ /// Viewer region of interest `[x, y, w, h]` in comp pixels (Composition ▸ Crop Comp to Region
+ /// of Interest).
+ #[serde(default)]
+ pub region_of_interest: Option<[f64; 4]>,
+ /// Keyframe clipboard (Edit ▸ Copy with keys selected; Paste / Paste Reversed Keyframes).
+ #[serde(skip)]
+ pub key_clipboard: Vec,
+ /// Property-link clipboard (Edit ▸ Copy with Property Links / Copy Expression Only).
+ #[serde(skip)]
+ pub link_clipboard: Option,
+ /// File ▸ Interpret Footage ▸ Remember Interpretation.
+ #[serde(skip)]
+ pub interpretation: Option,
+}
+
+/// Copied keyframes of one property, addressed by its match path (`transform/position`).
+#[derive(Clone, Debug, PartialEq)]
+pub struct KeyClip {
+ pub path: String,
+ pub keys: Vec,
+}
+
+/// What Copy with Property Links / Copy Expression Only put on the clipboard.
+#[derive(Clone, Debug, PartialEq)]
+pub enum LinkClip {
+ /// Expressions that link back to the source properties: (match path, expression text).
+ Links { relative: bool, links: Vec<(String, String)> },
+ /// Expressions only: (match path, expression).
+ Expressions(Vec<(String, effectcraft_project::Expression)>),
}
/// Events for frontends (drained each frame).
#[derive(Clone, Debug, PartialEq, Serialize)]
pub enum Event {
- ProjectChanged { revision: u64 },
- Toast { message: String, error: bool },
+ ProjectChanged {
+ revision: u64,
+ },
+ Toast {
+ message: String,
+ error: bool,
+ },
OpenComp(ItemId),
OpenUrl(String),
+ /// A frontend-only command (viewer zoom, panels, dialogs…) ran: the UI performs it. Headless
+ /// sessions ignore these.
+ Frontend {
+ command: String,
+ params: Value,
+ },
+ /// Drop cached frames / renders (Edit ▸ Purge).
+ PurgeCaches,
}
pub struct Session {
@@ -324,6 +367,8 @@ impl Session {
#[cfg(test)]
mod tests;
+#[cfg(test)]
+mod tests_menu_cmds;
/// Font families available to text layers (bundled + scanned system fonts).
pub fn text_families() -> Vec {
diff --git a/crates/engine/src/menus.rs b/crates/engine/src/menus.rs
new file mode 100644
index 000000000..25059484c
--- /dev/null
+++ b/crates/engine/src/menus.rs
@@ -0,0 +1,925 @@
+//! The menu bar, laid out like After Effects' (same menus, order, submenus, separators and
+//! labels). Every entry runs a registered command (`commands::find`), optionally with bound
+//! parameters (e.g. `layer.setBlendMode {"mode":"Multiply"}`). Frontends render this tree; agents
+//! read it through `ui.menu.list` / the command registry.
+//!
+//! The tree is written in a small indented text format (two spaces per level):
+//!
+//! ```text
+//! Layer top-level menu
+//! Blending Mode submenu (has deeper lines below it)
+//! Multiply | layer.setBlendMode {"mode":"Multiply"}
+//! Next Blending Mode | layer.setBlendMode {"step":1} | Shift+=
+//! --- separator
+//! @effects the effect categories (Effect menu)
+//! [mac] Quit EffectCraft | app.quit only on macOS ([!mac] = everywhere else)
+//! ```
+//!
+//! An entry's shortcut is the command's default shortcut unless the line gives one (needed for
+//! entries with bound parameters). Adobe-service entries (Team Projects, Libraries, Bridge, Media
+//! Encoder, Essential Graphics, Behance, Creative Cloud…) are intentionally absent.
+
+use std::sync::OnceLock;
+
+use serde::Serialize;
+use serde_json::Value;
+
+use crate::Session;
+use crate::commands::{self, CommandSpec};
+
+/// One node of the menu tree.
+#[derive(Clone, Debug, Serialize)]
+#[serde(tag = "type", rename_all = "camelCase")]
+pub enum MenuNode {
+ Item(MenuEntry),
+ Separator,
+ Submenu { label: String, children: Vec },
+}
+
+/// A clickable menu entry.
+#[derive(Clone, Debug, Serialize)]
+pub struct MenuEntry {
+ pub label: String,
+ pub command: String,
+ /// Parameters bound to the entry (`null` = none).
+ #[serde(skip_serializing_if = "Value::is_null")]
+ pub params: Value,
+ pub shortcut: Option,
+}
+
+impl MenuEntry {
+ pub fn spec(&self) -> Option<&'static CommandSpec> {
+ commands::find(&self.command)
+ }
+ pub fn params_or_empty(&self) -> Value {
+ if self.params.is_null() { Value::Object(Default::default()) } else { self.params.clone() }
+ }
+}
+
+/// Top-level menus in order (macOS has the application menu first).
+pub fn top_level() -> Vec<&'static str> {
+ menu_bar()
+ .iter()
+ .filter_map(|n| match n {
+ MenuNode::Submenu { label, .. } => Some(label.as_str()),
+ _ => None,
+ })
+ .collect()
+}
+
+/// The menu bar for this platform.
+pub fn menu_bar() -> &'static [MenuNode] {
+ static BAR: OnceLock> = OnceLock::new();
+ BAR.get_or_init(|| parse(TREE, cfg!(target_os = "macos")).expect("menu tree parses"))
+}
+
+/// Every entry with its submenu path (`["Layer", "Blending Mode"]`), depth first.
+pub fn entries() -> Vec<(Vec, &'static MenuEntry)> {
+ fn rec(nodes: &'static [MenuNode], path: &mut Vec, out: &mut Vec<(Vec, &'static MenuEntry)>) {
+ for n in nodes {
+ match n {
+ MenuNode::Item(e) => out.push((path.clone(), e)),
+ MenuNode::Separator => {}
+ MenuNode::Submenu { label, children } => {
+ path.push(label.clone());
+ rec(children, path, out);
+ path.pop();
+ }
+ }
+ }
+ }
+ let mut out = vec![];
+ rec(menu_bar(), &mut vec![], &mut out);
+ out
+}
+
+/// Check-mark state of an entry (`None` = not a toggle / radio entry). Frontend-only toggles
+/// (rulers, grid…) are answered by the frontend.
+pub fn checked(s: &Session, command: &str, params: &Value) -> Option {
+ let comp = s.active_comp()?;
+ let layer = s.state.selected_layers.first().and_then(|l| comp.layer(*l));
+ let pstr = |k: &str| params.get(k).and_then(Value::as_str);
+ match command {
+ "layer.setBlendMode" => {
+ let want = effectcraft_color::BlendMode::from_name(pstr("mode")?)?;
+ Some(layer?.blend_mode == want)
+ }
+ "layer.setSwitch" => {
+ let l = layer?;
+ let sw = &l.switches;
+ Some(match pstr("switch")? {
+ "shy" => sw.shy,
+ "lock" => sw.locked,
+ "audio" => sw.audio,
+ "video" => sw.video,
+ "solo" => sw.solo,
+ "fx" => sw.effects,
+ "collapse" => sw.collapse,
+ "motionBlur" => sw.motion_blur,
+ "adjustment" => sw.adjustment,
+ "threeD" => sw.three_d,
+ "guide" => sw.guide,
+ "preserveTransparency" => l.preserve_transparency,
+ _ => return None,
+ })
+ }
+ "layer.quality" => {
+ use effectcraft_project::Quality::*;
+ let q = layer?.switches.quality;
+ Some(matches!((pstr("quality")?, q), ("best", Best) | ("draft", Draft) | ("wireframe", Wireframe)))
+ }
+ "layer.sampling" => {
+ use effectcraft_project::Sampling::*;
+ let q = layer?.switches.sampling;
+ Some(matches!((pstr("sampling")?, q), ("bilinear", Bilinear) | ("bicubic", Bicubic)))
+ }
+ "layer.frameBlending" => {
+ use effectcraft_project::FrameBlend::*;
+ let q = layer?.switches.frame_blend;
+ Some(matches!((pstr("mode")?, q), ("off", Off) | ("frameMix", FrameMix) | ("pixelMotion", PixelMotion)))
+ }
+ "layer.trackMatte" => {
+ use effectcraft_project::MatteKind::*;
+ let m = layer?.track_matte;
+ Some(match (pstr("op")?, m) {
+ ("none", None) => true,
+ ("alpha", Some(m)) => m.kind == Alpha,
+ ("alphaInverted", Some(m)) => m.kind == AlphaInverted,
+ ("luma", Some(m)) => m.kind == Luma,
+ ("lumaInverted", Some(m)) => m.kind == LumaInverted,
+ _ => false,
+ })
+ }
+ "layer.markersLock" => Some(layer?.markers_locked),
+ _ => None,
+ }
+}
+
+/// Parse the tree text. `mac` selects `[mac]` / `[!mac]` lines.
+pub fn parse(text: &str, mac: bool) -> Result, String> {
+ struct Line<'a> {
+ depth: usize,
+ body: &'a str,
+ }
+ let mut lines = vec![];
+ // Depth of a skipped (other-platform) line: its whole subtree is skipped too.
+ let mut skip_below: Option = None;
+ for (n, raw) in text.lines().enumerate() {
+ if raw.trim().is_empty() || raw.trim_start().starts_with("//") {
+ continue;
+ }
+ let indent = raw.len() - raw.trim_start().len();
+ if indent % 2 != 0 {
+ return Err(format!("line {}: odd indentation", n + 1));
+ }
+ let depth = indent / 2;
+ match skip_below {
+ Some(d) if depth > d => continue,
+ _ => skip_below = None,
+ }
+ let mut body = raw.trim();
+ let tagged = |tag: &str, keep: bool, body: &mut &str| -> Option {
+ let rest = body.strip_prefix(tag)?;
+ *body = rest;
+ Some(keep)
+ };
+ if let Some(false) = tagged("[mac] ", mac, &mut body).or_else(|| tagged("[!mac] ", !mac, &mut body)) {
+ skip_below = Some(depth);
+ continue;
+ }
+ lines.push(Line { depth, body });
+ }
+ fn build(lines: &[Line], i: &mut usize, depth: usize) -> Result, String> {
+ let mut out = vec![];
+ while *i < lines.len() {
+ let l = &lines[*i];
+ if l.depth < depth {
+ break;
+ }
+ if l.depth > depth {
+ return Err(format!("unexpected indentation at `{}`", l.body));
+ }
+ *i += 1;
+ if l.body == "---" {
+ out.push(MenuNode::Separator);
+ continue;
+ }
+ if l.body == "@effects" {
+ out.extend(effect_categories());
+ continue;
+ }
+ let mut parts = l.body.split(" | ");
+ let label = parts.next().unwrap_or_default().trim().to_string();
+ match parts.next() {
+ Some(cmd) => {
+ let cmd = cmd.trim();
+ let (command, params) = match cmd.split_once(' ') {
+ Some((c, json)) => (c.to_string(), serde_json::from_str(json.trim()).map_err(|e| format!("`{}`: {e}", l.body))?),
+ None => (cmd.to_string(), Value::Null),
+ };
+ // Entries with bound params state their own shortcut; plain entries use the command's.
+ let inherited = if params.is_null() { commands::find(&command).and_then(|c| c.shortcut).map(str::to_string) } else { None };
+ let shortcut = parts.next().map(|s| s.trim().to_string()).or(inherited);
+ out.push(MenuNode::Item(MenuEntry { label, command, params, shortcut }));
+ }
+ None => {
+ let children = build(lines, i, depth + 1)?;
+ if children.is_empty() {
+ return Err(format!("`{label}` has neither a command nor children"));
+ }
+ out.push(MenuNode::Submenu { label, children });
+ }
+ }
+ }
+ Ok(out)
+ }
+ let mut i = 0;
+ build(&lines, &mut i, 0)
+}
+
+/// Effect ▸ category submenus from the effect registry.
+fn effect_categories() -> Vec {
+ let mut cats: Vec<(&str, Vec)> = vec![];
+ for e in crate::effects::registry() {
+ let entry =
+ MenuNode::Item(MenuEntry { label: e.name.into(), command: "effect.apply".into(), params: serde_json::json!({"effect": e.id}), shortcut: None });
+ match cats.iter_mut().find(|(c, _)| *c == e.category) {
+ Some((_, v)) => v.push(entry),
+ None => cats.push((e.category, vec![entry])),
+ }
+ }
+ cats.sort_by_key(|c| c.0.to_ascii_lowercase());
+ for (_, v) in &mut cats {
+ v.sort_by_key(|n| match n {
+ MenuNode::Item(e) => e.label.to_ascii_lowercase(),
+ _ => String::new(),
+ });
+ }
+ cats.into_iter().map(|(c, children)| MenuNode::Submenu { label: c.to_string(), children }).collect()
+}
+
+/// The After Effects menu layout. Labels use "..." like AE's macOS menus.
+pub const TREE: &str = r#"
+[mac] EffectCraft
+ About EffectCraft... | app.about
+ ---
+ Settings...
+ General... | app.settings {"page":"general"} | Cmd+Alt+;
+ Startup & Repair... | app.settings {"page":"startup"}
+ Project... | app.settings {"page":"project"}
+ Composition... | app.settings {"page":"composition"}
+ Previews... | app.settings {"page":"previews"}
+ Appearance... | app.settings {"page":"appearance"}
+ Grids & Guides... | app.settings {"page":"grids"}
+ Labels... | app.settings {"page":"labels"}
+ Type... | app.settings {"page":"type"}
+ Import... | app.settings {"page":"import"}
+ Export... | app.settings {"page":"export"}
+ Audio... | app.settings {"page":"audio"}
+ Disk... | app.settings {"page":"disk"}
+ Memory & CPU... | app.settings {"page":"memory"}
+ Video... | app.settings {"page":"video"}
+ 3D... | app.settings {"page":"3d"}
+ Scripting & Expressions... | app.settings {"page":"scripting"}
+ ---
+ Hide EffectCraft | app.hide
+ Hide Others | app.hideOthers
+ Show All | app.showAll
+ ---
+ Quit EffectCraft | app.quit
+File
+ New
+ New Project | file.newProject
+ New Folder | project.newFolder
+ Open Project... | file.open
+ ---
+ Close | file.close
+ Close Project | file.closeProject
+ Save | file.save
+ Save As
+ Save As... | file.saveAs
+ Save a Copy... | file.saveCopy
+ Increment and Save | file.incrementAndSave
+ Revert | file.revert
+ ---
+ Import
+ File... | file.import
+ Multiple Files... | file.importMultiple
+ Placeholder... | file.importPlaceholder
+ Solid... | file.importSolid
+ Export
+ Add to Render Queue | render.addToQueue
+ ---
+ Find | app.find
+ ---
+ Add Footage to Comp | layer.addItem
+ New Comp from Selection... | file.newCompFromSelection
+ ---
+ Dependencies
+ Collect Files... | file.collectFiles
+ Consolidate All Footage | file.consolidateFootage
+ Remove Unused Footage | file.removeUnusedFootage
+ Reduce Project | file.reduceProject
+ Find Missing Effects | file.findMissing {"what":"effects"}
+ Find Missing Fonts | file.findMissing {"what":"fonts"}
+ Find Missing Footage | file.findMissing {"what":"footage"}
+ ---
+ Scripts
+ Run Script File... | file.runScript
+ ---
+ Create Proxy
+ Still... | file.createProxy {"kind":"still"}
+ Movie... | file.createProxy {"kind":"movie"}
+ Set Proxy
+ File... | file.setProxy
+ None | file.setProxyNone
+ Interpret Footage
+ Main... | file.interpretFootage
+ Proxy... | file.interpretProxy
+ Remember Interpretation | file.rememberInterpretation
+ Apply Interpretation | file.applyInterpretation
+ Replace Footage
+ File... | file.replaceFootage
+ Placeholder... | file.replaceWithPlaceholder
+ Solid... | file.replaceWithSolid
+ Reload Footage | file.reloadFootage
+ Reveal in Finder | file.revealInFinder
+ ---
+ Project Settings... | file.projectSettings
+ [!mac] ---
+ [!mac] Exit | app.quit
+Edit
+ Undo | edit.undo
+ Redo | edit.redo
+ ---
+ Quick Apply... | app.commandPalette
+ ---
+ Cut | edit.cut
+ Copy | edit.copy
+ Copy with Property Links | edit.copyWithPropertyLinks
+ Copy with Relative Property Links | edit.copyWithRelativePropertyLinks
+ Copy Expression Only | edit.copyExpressionOnly
+ Paste | edit.paste
+ Paste Reversed Keyframes | edit.pasteReversedKeyframes
+ Paste Text and Match Formatting | edit.pasteTextMatchFormatting
+ Paste Text Formatting Only | edit.pasteTextFormattingOnly
+ Clear | edit.clear
+ ---
+ Duplicate | edit.duplicate
+ Split Layer | edit.splitLayer
+ Lift Work Area | edit.liftWorkArea
+ Extract Work Area | edit.extractWorkArea
+ Select All | edit.selectAll
+ Deselect All | edit.deselectAll
+ ---
+ Label
+ Select Label Group | edit.selectLabelGroup
+ ---
+ None | edit.label {"label":"None"}
+ Red | edit.label {"label":"Red"}
+ Yellow | edit.label {"label":"Yellow"}
+ Aqua | edit.label {"label":"Aqua"}
+ Pink | edit.label {"label":"Pink"}
+ Lavender | edit.label {"label":"Lavender"}
+ Peach | edit.label {"label":"Peach"}
+ Sea Foam | edit.label {"label":"Sea Foam"}
+ Blue | edit.label {"label":"Blue"}
+ Green | edit.label {"label":"Green"}
+ Purple | edit.label {"label":"Purple"}
+ Orange | edit.label {"label":"Orange"}
+ Brown | edit.label {"label":"Brown"}
+ Fuchsia | edit.label {"label":"Fuchsia"}
+ Cyan | edit.label {"label":"Cyan"}
+ Sandstone | edit.label {"label":"Sandstone"}
+ Dark Green | edit.label {"label":"Dark Green"}
+ ---
+ Edit Label Colors... | app.settings {"page":"labels"}
+ Select Keyframe Label Group
+ On Selected Layers | keys.selectLabelGroup {"scope":"selected"}
+ On All Layers | keys.selectLabelGroup {"scope":"all"}
+ Visible Keyframes on Selected Layers | keys.selectLabelGroup {"scope":"visibleSelected"}
+ Visible Keyframes on All Layers | keys.selectLabelGroup {"scope":"visibleAll"}
+ ---
+ Purge
+ All Cache... | edit.purge {"what":"all"}
+ All Memory & Disk Cache... | edit.purge {"what":"memoryAndDisk"}
+ All Memory | edit.purge {"what":"memory"}
+ All Disk Cache... | edit.purge {"what":"disk"}
+ All 3D Cache... | edit.purge {"what":"3d"}
+ Undo | edit.purgeUndo
+ Image Cache Memory | edit.purge {"what":"image"}
+ Snapshot | edit.purge {"what":"snapshot"}
+ ---
+ Edit Original... | edit.editOriginal
+ ---
+ Templates
+ Render Settings... | app.templates {"kind":"renderSettings"}
+ Output Module... | app.templates {"kind":"outputModule"}
+ Keyboard Shortcuts | app.keyboardShortcuts
+ [!mac] Preferences
+ [!mac] General... | app.settings {"page":"general"} | Cmd+Alt+;
+ [!mac] Startup & Repair... | app.settings {"page":"startup"}
+ [!mac] Project... | app.settings {"page":"project"}
+ [!mac] Composition... | app.settings {"page":"composition"}
+ [!mac] Previews... | app.settings {"page":"previews"}
+ [!mac] Appearance... | app.settings {"page":"appearance"}
+ [!mac] Grids & Guides... | app.settings {"page":"grids"}
+ [!mac] Labels... | app.settings {"page":"labels"}
+ [!mac] Type... | app.settings {"page":"type"}
+ [!mac] Import... | app.settings {"page":"import"}
+ [!mac] Export... | app.settings {"page":"export"}
+ [!mac] Audio... | app.settings {"page":"audio"}
+ [!mac] Disk... | app.settings {"page":"disk"}
+ [!mac] Memory & CPU... | app.settings {"page":"memory"}
+ [!mac] Video... | app.settings {"page":"video"}
+ [!mac] 3D... | app.settings {"page":"3d"}
+ [!mac] Scripting & Expressions... | app.settings {"page":"scripting"}
+Composition
+ New Composition... | comp.new
+ ---
+ Composition Settings... | comp.settings
+ Set Poster Time | comp.setPosterTime
+ Trim Comp to Work Area | comp.trimToWorkArea
+ Crop Comp to Region of Interest | comp.cropToRegionOfInterest
+ Crop Comp to Selected Layer(s) Bounds | comp.cropToLayerBounds
+ ---
+ Add to Render Queue | render.addToQueue
+ Add Output Module | render.addOutputModule
+ ---
+ Preview
+ Play Current Preview | playback.toggle
+ Cache Frames When Idle | playback.cacheWhenIdle
+ Audio | playback.audio
+ Save Frame As
+ File... | comp.saveFrameAs
+ Pre-render... | render.preRender
+ Save Current Preview... | render.saveCurrentPreview
+ ---
+ Responsive Design — Time
+ Create Intro | comp.responsiveTime {"op":"intro"}
+ Create Outro | comp.responsiveTime {"op":"outro"}
+ Create Protected Region from Work Area | comp.responsiveTime {"op":"workArea"}
+ ---
+ Composition Flowchart | comp.flowchart
+ Composition Mini-Flowchart | comp.miniFlowchart
+Layer
+ New
+ Text | layer.newText
+ Solid... | layer.newSolid
+ Light... | layer.newLight
+ Camera... | layer.newCamera
+ Null Object | layer.newNull
+ Shape Layer | layer.newShape
+ Adjustment Layer | layer.newAdjustment
+ Content-Aware Fill Layer... | layer.newContentAwareFill
+ Cube | layer.new3dPrimitive {"kind":"cube"}
+ Sphere | layer.new3dPrimitive {"kind":"sphere"}
+ Plane | layer.new3dPrimitive {"kind":"plane"}
+ Torus | layer.new3dPrimitive {"kind":"torus"}
+ Cone | layer.new3dPrimitive {"kind":"cone"}
+ Cylinder | layer.new3dPrimitive {"kind":"cylinder"}
+ Layer Settings... | layer.settings
+ ---
+ Open Layer | layer.openLayer
+ Open Layer Source | layer.openSource
+ Reveal in Finder | layer.revealInFinder
+ ---
+ Mask
+ New Mask | layer.addMask
+ Mask Shape... | layer.mask.shape
+ Mask Feather... | layer.mask.set {"field":"feather"} | Cmd+Shift+F
+ Mask Opacity... | layer.mask.set {"field":"opacity"}
+ Mask Expansion... | layer.mask.set {"field":"expansion"}
+ Reset Mask | layer.mask.reset
+ Remove Mask | layer.mask.remove
+ Remove All Masks | layer.mask.removeAll
+ Mode
+ None | layer.mask.mode {"mode":"None"}
+ Add | layer.mask.mode {"mode":"Add"}
+ Subtract | layer.mask.mode {"mode":"Subtract"}
+ Intersect | layer.mask.mode {"mode":"Intersect"}
+ Lighten | layer.mask.mode {"mode":"Lighten"}
+ Darken | layer.mask.mode {"mode":"Darken"}
+ Difference | layer.mask.mode {"mode":"Difference"}
+ Inverted | layer.mask.invert
+ Locked | layer.mask.lock
+ Motion Blur
+ Same As Layer | layer.mask.motionBlur {"mode":"sameAsLayer"}
+ On | layer.mask.motionBlur {"mode":"on"}
+ Off | layer.mask.motionBlur {"mode":"off"}
+ Feather Falloff
+ Smooth | layer.mask.featherFalloff {"mode":"smooth"}
+ Linear | layer.mask.featherFalloff {"mode":"linear"}
+ Unlock All Masks | layer.mask.unlockAll
+ Lock Other Masks | layer.mask.lockOthers
+ Hide Locked Masks | layer.mask.hideLocked
+ Mask and Shape Path
+ RotoBezier | path.rotoBezier
+ Closed | path.closed
+ Convert To Bezier Path | path.convertToBezier
+ Group Shapes | path.groupShapes
+ Ungroup Shapes | path.ungroupShapes
+ Set First Vertex | path.setFirstVertex
+ Free Transform Points | path.freeTransform
+ Quality
+ Best | layer.quality {"quality":"best"} | Cmd+U
+ Draft | layer.quality {"quality":"draft"} | Cmd+Shift+U
+ Wireframe | layer.quality {"quality":"wireframe"} | Cmd+Alt+Shift+U
+ ---
+ Bilinear | layer.sampling {"sampling":"bilinear"}
+ Bicubic | layer.sampling {"sampling":"bicubic"}
+ Switches
+ Hide Other Video | layer.hideOtherVideo
+ Show All Video | layer.showAllVideo
+ Unlock All Layers | layer.unlockAll
+ Enable Expressions | layer.expressions {"enabled":true}
+ Disable Expressions | layer.expressions {"enabled":false}
+ ---
+ Shy | layer.setSwitch {"switch":"shy"}
+ Lock | layer.setSwitch {"switch":"lock"} | Cmd+L
+ Audio | layer.setSwitch {"switch":"audio"}
+ Video | layer.setSwitch {"switch":"video"}
+ Solo | layer.setSwitch {"switch":"solo"}
+ Effect | layer.setSwitch {"switch":"fx"}
+ Collapse | layer.setSwitch {"switch":"collapse"}
+ Motion Blur | layer.setSwitch {"switch":"motionBlur"}
+ Adjustment Layer | layer.setSwitch {"switch":"adjustment"}
+ Transform
+ Reset | layer.transform {"op":"reset"}
+ Anchor Point... | layer.setTransform {"prop":"anchor"}
+ Position... | layer.setTransform {"prop":"position"} | Cmd+Shift+P
+ Scale... | layer.setTransform {"prop":"scale"}
+ Orientation... | layer.setTransform {"prop":"orientation"} | Cmd+Alt+Shift+R
+ Rotation... | layer.setTransform {"prop":"rotation"} | Cmd+Shift+R
+ Opacity... | layer.setTransform {"prop":"opacity"} | Cmd+Shift+O
+ ---
+ Flip Horizontal | layer.transform {"op":"flipH"}
+ Flip Vertical | layer.transform {"op":"flipV"}
+ Center In View | layer.transform {"op":"center"}
+ Center Anchor Point in Layer Content | layer.centerAnchor
+ Fit to Comp | layer.transform {"op":"fit"} | Cmd+Alt+F
+ Fit to Comp Width | layer.transform {"op":"fitWidth"} | Cmd+Alt+Shift+H
+ Fit to Comp Height | layer.transform {"op":"fitHeight"} | Cmd+Alt+Shift+G
+ ---
+ Auto-Orient... | layer.autoOrient
+ Time
+ Enable Time Remapping | layer.timeRemap
+ Time-Reverse Layer | layer.timeStretch {"op":"reverse"} | Cmd+Alt+R
+ Time Stretch... | layer.timeStretch
+ Freeze Frame | layer.freezeFrame
+ Freeze On Last Frame | layer.freezeOnLastFrame
+ Align Video to Data | layer.alignVideoToData
+ Frame Blending
+ Off | layer.frameBlending {"mode":"off"}
+ Frame Mix | layer.frameBlending {"mode":"frameMix"}
+ Pixel Motion | layer.frameBlending {"mode":"pixelMotion"}
+ 3D Layer | layer.setSwitch {"switch":"threeD"}
+ Guide Layer | layer.setSwitch {"switch":"guide"}
+ Environment Layer | layer.environment
+ Markers
+ Add Marker | layer.addMarker
+ Update Markers From Source | layer.updateMarkersFromSource
+ Lock Markers | layer.markersLock
+ Delete All Markers | layer.deleteAllMarkers
+ ---
+ Preserve Transparency | layer.setSwitch {"switch":"preserveTransparency"}
+ Blending Mode
+ Normal | layer.setBlendMode {"mode":"Normal"}
+ Dissolve | layer.setBlendMode {"mode":"Dissolve"}
+ Dancing Dissolve | layer.setBlendMode {"mode":"Dancing Dissolve"}
+ ---
+ Darken | layer.setBlendMode {"mode":"Darken"}
+ Multiply | layer.setBlendMode {"mode":"Multiply"}
+ Color Burn | layer.setBlendMode {"mode":"Color Burn"}
+ Classic Color Burn | layer.setBlendMode {"mode":"Classic Color Burn"}
+ Linear Burn | layer.setBlendMode {"mode":"Linear Burn"}
+ Darker Color | layer.setBlendMode {"mode":"Darker Color"}
+ ---
+ Add | layer.setBlendMode {"mode":"Add"}
+ Lighten | layer.setBlendMode {"mode":"Lighten"}
+ Screen | layer.setBlendMode {"mode":"Screen"}
+ Color Dodge | layer.setBlendMode {"mode":"Color Dodge"}
+ Classic Color Dodge | layer.setBlendMode {"mode":"Classic Color Dodge"}
+ Linear Dodge | layer.setBlendMode {"mode":"Linear Dodge"}
+ Lighter Color | layer.setBlendMode {"mode":"Lighter Color"}
+ ---
+ Overlay | layer.setBlendMode {"mode":"Overlay"}
+ Soft Light | layer.setBlendMode {"mode":"Soft Light"}
+ Hard Light | layer.setBlendMode {"mode":"Hard Light"}
+ Linear Light | layer.setBlendMode {"mode":"Linear Light"}
+ Vivid Light | layer.setBlendMode {"mode":"Vivid Light"}
+ Pin Light | layer.setBlendMode {"mode":"Pin Light"}
+ Hard Mix | layer.setBlendMode {"mode":"Hard Mix"}
+ ---
+ Difference | layer.setBlendMode {"mode":"Difference"}
+ Classic Difference | layer.setBlendMode {"mode":"Classic Difference"}
+ Exclusion | layer.setBlendMode {"mode":"Exclusion"}
+ Subtract | layer.setBlendMode {"mode":"Subtract"}
+ Divide | layer.setBlendMode {"mode":"Divide"}
+ ---
+ Hue | layer.setBlendMode {"mode":"Hue"}
+ Saturation | layer.setBlendMode {"mode":"Saturation"}
+ Color | layer.setBlendMode {"mode":"Color"}
+ Luminosity | layer.setBlendMode {"mode":"Luminosity"}
+ ---
+ Stencil Alpha | layer.setBlendMode {"mode":"Stencil Alpha"}
+ Stencil Luma | layer.setBlendMode {"mode":"Stencil Luma"}
+ Silhouette Alpha | layer.setBlendMode {"mode":"Silhouette Alpha"}
+ Silhouette Luma | layer.setBlendMode {"mode":"Silhouette Luma"}
+ ---
+ Alpha Add | layer.setBlendMode {"mode":"Alpha Add"}
+ Luminescent Premul | layer.setBlendMode {"mode":"Luminescent Premul"}
+ Next Blending Mode | layer.setBlendMode {"step":1} | Shift+=
+ Previous Blending Mode | layer.setBlendMode {"step":-1} | Shift+-
+ Track Matte
+ No Track Matte | layer.trackMatte {"op":"none"}
+ Alpha Matte | layer.trackMatte {"op":"alpha"}
+ Alpha Inverted Matte | layer.trackMatte {"op":"alphaInverted"}
+ Luma Matte | layer.trackMatte {"op":"luma"}
+ Luma Inverted Matte | layer.trackMatte {"op":"lumaInverted"}
+ ---
+ Matte with Layer Above | layer.trackMatte {"op":"above"}
+ Matte with Layer Below | layer.trackMatte {"op":"below"}
+ Layer Styles
+ Convert to Editable Styles | layer.styles {"op":"convert"}
+ Show All | layer.styles {"op":"showAll"}
+ Remove All | layer.styles {"op":"removeAll"}
+ ---
+ Drop Shadow | layer.styles {"style":"dropShadow"}
+ Inner Shadow | layer.styles {"style":"innerShadow"}
+ Outer Glow | layer.styles {"style":"outerGlow"}
+ Inner Glow | layer.styles {"style":"innerGlow"}
+ Bevel and Emboss | layer.styles {"style":"bevelEmboss"}
+ Satin | layer.styles {"style":"satin"}
+ Color Overlay | layer.styles {"style":"colorOverlay"}
+ Gradient Overlay | layer.styles {"style":"gradientOverlay"}
+ Stroke | layer.styles {"style":"stroke"}
+ ---
+ Arrange
+ Bring Layer to Front | layer.arrange {"to":"front"} | Cmd+Shift+]
+ Bring Layer Forward | layer.arrange {"to":"forward"} | Cmd+]
+ Send Layer Backward | layer.arrange {"to":"backward"} | Cmd+[
+ Send Layer to Back | layer.arrange {"to":"back"} | Cmd+Shift+[
+ ---
+ Reveal
+ Reveal in Finder | layer.revealInFinder
+ Reveal Layer Source in Project | layer.revealSource
+ Reveal Layer in Project Flowchart | comp.flowchart
+ Reveal Composition in Project | comp.revealInProject
+ Reveal Expression Errors | layer.revealExpressionErrors
+ Create
+ Convert to Editable Text | layer.create {"op":"editableText"}
+ Create Shapes from Text | layer.create {"op":"shapesFromText"}
+ Create Masks from Text | layer.create {"op":"masksFromText"}
+ Create Shapes from Vector Layer | layer.create {"op":"shapesFromVector"}
+ Create Keyframes from Data | layer.create {"op":"keyframesFromData"}
+ Null Controllers for Positional Points | layer.create {"op":"nullsPositional"}
+ Null Controllers for Path Points | layer.create {"op":"nullsPathPoints"}
+ Nulls Following Path Points | layer.create {"op":"nullsFollowing"}
+ Null Tracing Along Path | layer.create {"op":"nullTracing"}
+ Create 3D Layer Instance | layer.create {"op":"instance3d"}
+ ---
+ Camera
+ Create Camera from 3D View | camera.fromView
+ Create Stereo 3D Rig | camera.stereoRig
+ Create Orbit Null | camera.orbitNull
+ Create Cameras from 3D Model | camera.fromModel
+ Link Focus Distance to Point of Interest | camera.linkFocusToPoi
+ Link Focus Distance to Layer | camera.linkFocusToLayer
+ Set Focus Distance to Layer | camera.setFocusToLayer
+ Camera Settings... | camera.settings
+ Reset 3D View | view.reset3dView
+ Light
+ Create Lights from 3D Model | light.fromModel
+ Control Light with Camera | light.controlWithCamera
+ Create Environment Light Background Layer | light.environmentBackground
+ Material
+ Reveal Material Source in Project | material.revealSource
+ Reset Material | material.reset
+ Duplicate and Assign Material | material.duplicateAssign
+ Auto-trace... | layer.autoTrace
+ Pre-compose... | layer.precompose
+ Scene Edit Detection... | layer.sceneEditDetection
+Effect
+ Effect Controls | window.panel {"panel":"effectControls"} | F3
+ Last Effect | effect.applyLast
+ Remove All | effect.removeAll
+ ---
+ Manage Effects... | effect.manage
+ ---
+ @effects
+Animation
+ Save Animation Preset... | anim.savePreset
+ Apply Animation Preset... | anim.applyPreset
+ Browse Presets... | anim.browsePresets
+ ---
+ Add Keyframe | anim.addKeyframe
+ Toggle Hold Keyframe | keys.toggleHold
+ Keyframe Interpolation... | keys.interpolation
+ Keyframe Velocity... | keys.velocity
+ Keyframe Assistant
+ Convert Audio to Keyframes | keys.audioToKeyframes
+ Convert Expression to Keyframes | prop.convertExpressionToKeyframes
+ Create Keyframes from Data | layer.create {"op":"keyframesFromData"}
+ Easy Ease | keys.easyEase
+ Easy Ease In | keys.easyEaseIn
+ Easy Ease Out | keys.easyEaseOut
+ Exponential Scale | keys.exponentialScale
+ Null Controllers for Path Points | layer.create {"op":"nullsPathPoints"}
+ Null Controllers for Positional Points | layer.create {"op":"nullsPositional"}
+ Null Tracing Along Path | layer.create {"op":"nullTracing"}
+ Nulls Following Path Points | layer.create {"op":"nullsFollowing"}
+ RPF Camera Import | keys.rpfCameraImport
+ Sequence Layers... | layer.sequence
+ Time-Reverse Keyframes | keys.timeReverse
+ ---
+ Animate Text
+ Enable Per-character 3D | text.perCharacter3d
+ ---
+ Anchor Point | layer.addTextAnimator {"properties":["anchor"]}
+ Position | layer.addTextAnimator {"properties":["position"]}
+ Scale | layer.addTextAnimator {"properties":["scale"]}
+ Skew | layer.addTextAnimator {"properties":["skew"]}
+ Rotation | layer.addTextAnimator {"properties":["rotation"]}
+ Opacity | layer.addTextAnimator {"properties":["opacity"]}
+ ---
+ All Transform Properties | layer.addTextAnimator {"properties":["anchor","position","scale","skew","rotation","opacity"]}
+ ---
+ Fill Color | layer.addTextAnimator {"properties":["fillColor"]}
+ Stroke Color | layer.addTextAnimator {"properties":["strokeColor"]}
+ Stroke Width | layer.addTextAnimator {"properties":["strokeWidth"]}
+ ---
+ Tracking | layer.addTextAnimator {"properties":["tracking"]}
+ Line Anchor | text.animatorLineAnchor
+ Line Spacing | layer.addTextAnimator {"properties":["lineSpacing"]}
+ ---
+ Character Offset | layer.addTextAnimator {"properties":["characterOffset"]}
+ Character Value | text.animatorCharacterValue
+ ---
+ Blur | layer.addTextAnimator {"properties":["blur"]}
+ Variable Font Axes | text.animatorFontAxes
+ Add Text Selector
+ Range | text.addSelector {"kind":"range"}
+ Wiggly | text.addWigglySelector
+ Expression | text.addExpressionSelector
+ Remove All Text Animators | text.removeAllAnimators
+ ---
+ Add Expression | prop.setExpression
+ Separate Dimensions | prop.separateDimensions
+ Track Camera | track.camera
+ Warp Stabilizer VFX | track.warpStabilizer
+ Track Motion | track.motion
+ Track Mask | track.mask
+ Track this Property | track.property
+ ---
+ Reveal Properties with Keyframes | anim.reveal {"kind":"keyframes"} | U
+ Reveal Properties with Animation | anim.reveal {"kind":"animation"}
+ Reveal All Modified Properties | anim.reveal {"kind":"modified"}
+View
+ Split with New Locked Viewer | view.splitLockedViewer
+ ---
+ Zoom In | view.zoomIn
+ Zoom Out | view.zoomOut
+ ---
+ Resolution
+ Full | view.res.full
+ Half | view.res.half
+ Third | view.res.third
+ Quarter | view.res.quarter
+ Custom... | view.res.custom
+ ---
+ Use Display Color Management | view.displayColorManagement
+ Simulate Output
+ No Output Simulation | view.simulateOutput {"profile":"none"}
+ HDTV (Rec. 709) | view.simulateOutput {"profile":"rec709"}
+ SDTV NTSC | view.simulateOutput {"profile":"ntsc"}
+ SDTV PAL | view.simulateOutput {"profile":"pal"}
+ Legacy Macintosh RGB (Gamma 1.8) | view.simulateOutput {"profile":"mac18"}
+ Internet Standard RGB (sRGB) | view.simulateOutput {"profile":"srgb"}
+ Custom... | view.simulateOutput {"profile":"custom"}
+ ---
+ Show Rulers | view.rulers
+ Panel Background Color
+ Black | view.panelBackground {"color":"black"}
+ Dark Gray | view.panelBackground {"color":"darkGray"}
+ Medium Gray (Default) | view.panelBackground {"color":"mediumGray"}
+ Light Gray | view.panelBackground {"color":"lightGray"}
+ White | view.panelBackground {"color":"white"}
+ ---
+ Custom | view.panelBackground {"color":"custom"}
+ Select Custom Background Color... | view.panelBackground {"pick":true}
+ ---
+ Show Guides | view.guides
+ Snap to Guides | view.snapToGuides
+ Lock Guides | view.lockGuides
+ Add Guide... | view.addGuide
+ Clear Guides | view.clearGuides
+ Import Guides... | view.importGuides
+ Export Guides... | view.exportGuides
+ ---
+ Show Grid | view.grid
+ Snap to Grid | view.snapToGrid
+ ---
+ View Options... | view.options
+ Show Layer Controls | view.layerControls
+ ---
+ Camera Settings... | camera.settings
+ Reset 3D View | view.reset3dView
+ Create Camera from 3D View | camera.fromView
+ Switch View Layout
+ 1 View | view.layout {"views":1}
+ 2 Views | view.layout {"views":2}
+ 4 Views | view.layout {"views":4}
+ ---
+ Share View Options | view.shareViewOptions
+ Switch 3D View
+ Active Camera | view.3d {"view":"activeCamera"} | F12
+ Default | view.3d {"view":"default"}
+ ---
+ Front | view.3d {"view":"front"} | F10
+ Left | view.3d {"view":"left"}
+ Top | view.3d {"view":"top"}
+ Back | view.3d {"view":"back"}
+ Right | view.3d {"view":"right"}
+ Bottom | view.3d {"view":"bottom"}
+ ---
+ Custom View 1 | view.3d {"view":"custom1"} | F11
+ Custom View 2 | view.3d {"view":"custom2"}
+ Custom View 3 | view.3d {"view":"custom3"}
+ ---
+ Reset 3D View | view.reset3dView
+ Switch to Last 3D View | view.last3dView
+ Look at Selected Layers | view.lookAtSelected
+ Look at All Layers | view.lookAtAll
+ ---
+ Go to Time... | time.set
+ Enter Full Screen | view.fullScreen
+Window
+ Workspace
+ All Panels | window.workspace {"name":"All Panels"}
+ Animation | window.workspace {"name":"Animation"}
+ Default | window.workspace {"name":"Default"} | Shift+F10
+ Effects | window.workspace {"name":"Effects"}
+ Minimal | window.workspace {"name":"Minimal"}
+ Motion Tracking | window.workspace {"name":"Motion Tracking"}
+ Paint | window.workspace {"name":"Paint"}
+ Small Screen | window.workspace {"name":"Small Screen"} | Shift+F12
+ Standard | window.workspace {"name":"Standard"} | Shift+F11
+ Text | window.workspace {"name":"Text"}
+ ---
+ Reset to Saved Layout | window.resetWorkspace
+ Save Changes to this Workspace | window.saveWorkspace
+ Save as New Workspace... | window.saveWorkspaceAs
+ Edit Workspaces... | window.editWorkspaces
+ ---
+ Align | window.panel {"panel":"align"}
+ Audio | window.panel {"panel":"audio"} | Cmd+4
+ Brushes | window.panel {"panel":"brushes"} | Cmd+9
+ Character | window.panel {"panel":"character"} | Cmd+6
+ Content-Aware Fill | window.unavailablePanel {"panel":"contentAwareFill"}
+ Effects & Presets | window.panel {"panel":"effectsPresets"} | Cmd+5
+ Info | window.panel {"panel":"info"} | Cmd+2
+ Lumetri Scopes | window.unavailablePanel {"panel":"lumetriScopes"}
+ Mask Interpolation | window.unavailablePanel {"panel":"maskInterpolation"}
+ Media Browser | window.unavailablePanel {"panel":"mediaBrowser"}
+ Metadata | window.unavailablePanel {"panel":"metadata"}
+ Motion Sketch | window.panel {"panel":"motionSketch"}
+ Paint | window.panel {"panel":"paint"} | Cmd+8
+ Paragraph | window.panel {"panel":"paragraph"} | Cmd+7
+ Preview | window.panel {"panel":"preview"} | Cmd+3
+ Progress | window.unavailablePanel {"panel":"progress"}
+ Properties | window.panel {"panel":"properties"}
+ Smoother | window.panel {"panel":"smoother"}
+ Tools | window.panel {"panel":"tools"} | Cmd+1
+ Tracker | window.panel {"panel":"tracker"}
+ Wiggler | window.panel {"panel":"wiggler"}
+ ---
+ Composition | window.panel {"panel":"composition"}
+ Effect Controls | window.panel {"panel":"effectControls"} | F3
+ Flowchart | window.panel {"panel":"flowchart"}
+ Footage | window.unavailablePanel {"panel":"footage"}
+ Layer | window.panel {"panel":"layer"}
+ Project | window.panel {"panel":"project"} | Cmd+0
+ Render Queue | window.panel {"panel":"renderQueue"} | Cmd+Alt+0
+ Timeline | window.panel {"panel":"timeline"}
+Help
+ EffectCraft Help... | help.docs {"page":"help"} | F1
+ Scripting Help... | help.docs {"page":"scripting"}
+ Expression Reference... | help.docs {"page":"expressions"}
+ Effect Reference... | help.docs {"page":"effects"}
+ Animation Presets... | anim.browsePresets
+ Keyboard Shortcuts... | app.keyboardShortcuts
+ ---
+ Join the ArtCraft Discord... | help.discord
+ Provide Feedback... | help.reportIssue
+ ---
+ ArtCraft Website | help.website
+ EffectCraft Home Page | help.appPage
+ EffectCraft on GitHub | help.github
+ Open Demo Project | file.openDemoProject
+ [!mac] ---
+ [!mac] About EffectCraft... | app.about
+"#;
+
+#[cfg(test)]
+mod tests;
diff --git a/crates/engine/src/menus/tests.rs b/crates/engine/src/menus/tests.rs
new file mode 100644
index 000000000..672734bf6
--- /dev/null
+++ b/crates/engine/src/menus/tests.rs
@@ -0,0 +1,148 @@
+use std::collections::BTreeMap;
+
+use super::*;
+
+fn all_entries(nodes: &[MenuNode], path: &mut Vec, out: &mut Vec<(Vec, MenuEntry)>) {
+ for n in nodes {
+ match n {
+ MenuNode::Item(e) => out.push((path.clone(), e.clone())),
+ MenuNode::Separator => {}
+ MenuNode::Submenu { label, children } => {
+ path.push(label.clone());
+ all_entries(children, path, out);
+ path.pop();
+ }
+ }
+ }
+}
+
+fn platform_entries(mac: bool) -> Vec<(Vec, MenuEntry)> {
+ let tree = parse(TREE, mac).unwrap();
+ let mut out = vec![];
+ all_entries(&tree, &mut vec![], &mut out);
+ out
+}
+
+#[test]
+fn top_level_order_matches_after_effects() {
+ let mac: Vec =
+ parse(TREE, true).unwrap().iter().filter_map(|n| if let MenuNode::Submenu { label, .. } = n { Some(label.clone()) } else { None }).collect();
+ assert_eq!(mac, ["EffectCraft", "File", "Edit", "Composition", "Layer", "Effect", "Animation", "View", "Window", "Help"]);
+ let other: Vec =
+ parse(TREE, false).unwrap().iter().filter_map(|n| if let MenuNode::Submenu { label, .. } = n { Some(label.clone()) } else { None }).collect();
+ assert_eq!(other, ["File", "Edit", "Composition", "Layer", "Effect", "Animation", "View", "Window", "Help"]);
+ // The live bar is one of the two.
+ assert!(top_level().len() == mac.len() || top_level().len() == other.len());
+}
+
+#[test]
+fn every_menu_entry_resolves_to_a_registered_command() {
+ for mac in [true, false] {
+ for (path, e) in platform_entries(mac) {
+ assert!(crate::commands::find(&e.command).is_some(), "{} ▸ {}: unknown command `{}`", path.join(" ▸ "), e.label, e.command);
+ assert!(e.params.is_null() || e.params.is_object(), "{}: params must be an object", e.label);
+ }
+ }
+}
+
+#[test]
+fn command_menu_paths_and_labels_agree_with_the_tree() {
+ let entries = platform_entries(true);
+ let mut by_cmd: BTreeMap<&str, Vec<&(Vec, MenuEntry)>> = BTreeMap::new();
+ for e in &entries {
+ by_cmd.entry(e.1.command.as_str()).or_default().push(e);
+ }
+ for spec in crate::command_specs() {
+ if spec.menu.is_empty() {
+ continue;
+ }
+ let places = by_cmd.get(spec.id).unwrap_or_else(|| panic!("`{}` declares menu {:?} but is not in the menu tree", spec.id, spec.menu));
+ assert!(
+ places.iter().any(|(p, _)| p.iter().map(String::as_str).eq(spec.menu.iter().copied())),
+ "`{}` declares menu {:?}; the tree has it at {:?}",
+ spec.id,
+ spec.menu,
+ places.iter().map(|(p, _)| p.join(" ▸ ")).collect::>()
+ );
+ for (p, e) in places {
+ if e.params.is_null() && p.iter().map(String::as_str).eq(spec.menu.iter().copied()) {
+ assert_eq!(e.label, spec.label, "label of `{}`", spec.id);
+ }
+ }
+ }
+}
+
+#[test]
+fn dialog_labels_use_ascii_ellipsis() {
+ for (_, e) in platform_entries(true) {
+ assert!(!e.label.contains('…'), "`{}` uses a Unicode ellipsis; AE's menus use \"...\"", e.label);
+ }
+}
+
+#[test]
+fn shortcuts_are_unambiguous() {
+ // shortcut → (command, params) from command defaults and menu entries.
+ let mut seen: BTreeMap = BTreeMap::new();
+ let mut add = |sc: &str, id: &str, params: String| {
+ if sc == "Num*" {
+ return;
+ }
+ if let Some(prev) = seen.get(sc) {
+ assert_eq!(prev, &(id.to_string(), params.clone()), "shortcut {sc} is bound twice");
+ } else {
+ seen.insert(sc.to_string(), (id.to_string(), params));
+ }
+ };
+ for (_, e) in platform_entries(true) {
+ if let Some(sc) = &e.shortcut {
+ add(sc, &e.command, e.params.to_string());
+ }
+ }
+ for c in crate::command_specs() {
+ // Defaults of commands whose menu entries bind params are carried by the entries.
+ if let Some(sc) = c.shortcut
+ && !platform_entries(true).iter().any(|(_, e)| e.command == c.id && !e.params.is_null())
+ {
+ add(sc, c.id, "null".into());
+ }
+ }
+}
+
+#[test]
+fn menus_cover_after_effects_structure() {
+ let entries = platform_entries(true);
+ let count = |m: &str| entries.iter().filter(|(p, _)| p[0] == m).count();
+ // Floors (AE 2026 minus Adobe-service, history and user-specific entries).
+ assert!(count("File") >= 40, "File {}", count("File"));
+ assert!(count("Edit") >= 54, "Edit {}", count("Edit"));
+ assert!(count("Composition") >= 19, "Composition {}", count("Composition"));
+ assert!(count("Layer") >= 197, "Layer {}", count("Layer"));
+ assert!(count("Animation") >= 53, "Animation {}", count("Animation"));
+ assert!(count("View") >= 59, "View {}", count("View"));
+ assert!(count("Window") >= 43, "Window {}", count("Window"));
+ // 38 blending modes + next/previous.
+ let modes = entries.iter().filter(|(p, e)| p.last().map(String::as_str) == Some("Blending Mode") && e.command == "layer.setBlendMode").count();
+ assert_eq!(modes, 38);
+ // 16 label colours + None.
+ let labels = entries.iter().filter(|(_, e)| e.command == "edit.label").count();
+ assert_eq!(labels, 17);
+}
+
+#[test]
+fn checked_reflects_layer_state() {
+ let mut s = crate::Session::default();
+ s.execute("comp.new", serde_json::json!({"width": 320, "height": 180})).unwrap();
+ s.execute("layer.newSolid", serde_json::json!({})).unwrap();
+ s.execute("layer.setBlendMode", serde_json::json!({"mode": "Screen"})).unwrap();
+ assert_eq!(checked(&s, "layer.setBlendMode", &serde_json::json!({"mode": "Screen"})), Some(true));
+ assert_eq!(checked(&s, "layer.setBlendMode", &serde_json::json!({"mode": "Normal"})), Some(false));
+ assert_eq!(checked(&s, "layer.quality", &serde_json::json!({"quality": "best"})), Some(true));
+ assert_eq!(checked(&s, "file.save", &serde_json::json!({})), None);
+}
+
+#[test]
+fn parse_rejects_bad_trees() {
+ assert!(parse("File\n Empty\n", true).is_err());
+ assert!(parse("File\n Odd | file.save\n", true).is_err());
+ assert!(parse("File\n Bad | file.save {nope}\n", true).is_err());
+}
diff --git a/crates/engine/src/tests_menu_cmds.rs b/crates/engine/src/tests_menu_cmds.rs
new file mode 100644
index 000000000..de6ce1ea3
--- /dev/null
+++ b/crates/engine/src/tests_menu_cmds.rs
@@ -0,0 +1,491 @@
+//! Tests for the menu-parity command families (Layer / Edit / Animation / File / Composition /
+//! View menus), including undo.
+
+use effectcraft_keyframe::Value as KV;
+use effectcraft_project::{FrameBlend, ItemKind, MatteKind, Quality, Sampling};
+use serde_json::{Value, json};
+
+use crate::{EngineError, Event, Session};
+
+fn comp() -> Session {
+ let mut s = Session::default();
+ s.execute("comp.new", json!({"name": "Main", "width": 640, "height": 360, "frameRate": 30, "duration": 10})).unwrap();
+ s
+}
+
+fn solid(s: &mut Session, color: &str) -> u64 {
+ s.execute("layer.newSolid", json!({"color": color, "width": 200, "height": 100})).unwrap()["layer"].as_u64().unwrap()
+}
+
+fn layer(s: &Session, id: u64) -> effectcraft_project::Layer {
+ s.active_comp().unwrap().layer(effectcraft_project::LayerId(id)).unwrap().clone()
+}
+
+fn tmp(name: &str) -> String {
+ let d = std::env::temp_dir().join(format!("effectcraft-menu-tests-{}", std::process::id()));
+ std::fs::create_dir_all(&d).unwrap();
+ d.join(name).to_string_lossy().to_string()
+}
+
+fn frontend_events(s: &mut Session) -> Vec<(String, Value)> {
+ s.drain_events()
+ .into_iter()
+ .filter_map(|e| match e {
+ Event::Frontend { command, params } => Some((command, params)),
+ _ => None,
+ })
+ .collect()
+}
+
+#[test]
+fn layer_quality_sampling_frame_blending_and_undo() {
+ let mut s = comp();
+ let a = solid(&mut s, "#ff0000");
+ s.execute("layer.quality", json!({"quality": "wireframe"})).unwrap();
+ s.execute("layer.sampling", json!({"sampling": "bicubic"})).unwrap();
+ s.execute("layer.frameBlending", json!({"mode": "pixelMotion"})).unwrap();
+ let l = layer(&s, a);
+ assert_eq!((l.switches.quality, l.switches.sampling, l.switches.frame_blend), (Quality::Wireframe, Sampling::Bicubic, FrameBlend::PixelMotion));
+ s.execute("edit.undo", json!({})).unwrap();
+ assert_eq!(layer(&s, a).switches.frame_blend, FrameBlend::Off);
+ assert!(s.execute("layer.quality", json!({"quality": "fancy"})).is_err());
+}
+
+#[test]
+fn layer_switches_menu() {
+ let mut s = comp();
+ let a = solid(&mut s, "#ff0000");
+ let b = solid(&mut s, "#00ff00");
+ s.execute("layer.select", json!({"layers": [b]})).unwrap();
+ s.execute("layer.hideOtherVideo", json!({})).unwrap();
+ assert!(!layer(&s, a).switches.video && layer(&s, b).switches.video);
+ s.execute("layer.showAllVideo", json!({})).unwrap();
+ assert!(layer(&s, a).switches.video);
+ s.execute("layer.setSwitch", json!({"layers": [a, b], "switch": "lock"})).unwrap();
+ assert!(layer(&s, a).switches.locked);
+ s.execute("layer.unlockAll", json!({})).unwrap();
+ assert!(!layer(&s, a).switches.locked && !layer(&s, b).switches.locked);
+ s.execute("edit.undo", json!({})).unwrap();
+ assert!(layer(&s, a).switches.locked);
+ // Expressions on / off.
+ s.execute("prop.setExpression", json!({"layer": a, "path": "transform/opacity", "expression": "50"})).unwrap();
+ s.execute("layer.expressions", json!({"layers": [a], "enabled": false})).unwrap();
+ assert!(!layer(&s, a).props.prop("transform/opacity").unwrap().expr.as_ref().unwrap().enabled);
+ s.execute("layer.expressions", json!({"layers": [a], "enabled": true})).unwrap();
+ assert!(layer(&s, a).props.prop("transform/opacity").unwrap().has_expression());
+}
+
+#[test]
+fn transform_dialog_values_and_center_anchor() {
+ let mut s = comp();
+ let a = solid(&mut s, "#ff0000");
+ s.execute("layer.setTransform", json!({"prop": "position", "value": [100, 50]})).unwrap();
+ s.execute("layer.setTransform", json!({"prop": "rotation", "value": 90})).unwrap();
+ s.execute("layer.setTransform", json!({"prop": "opacity", "value": 25})).unwrap();
+ let l = layer(&s, a);
+ assert_eq!(l.props.prop("transform/position").unwrap().value, KV::Vec3([100.0, 50.0, 0.0]));
+ assert_eq!(l.props.prop("transform/opacity").unwrap().value.as_f64(), 25.0);
+ s.execute("edit.undo", json!({})).unwrap();
+ assert_eq!(layer(&s, a).props.prop("transform/opacity").unwrap().value.as_f64(), 100.0);
+ assert!(s.execute("layer.setTransform", json!({"prop": "skew", "value": 1})).is_err());
+
+ // Move the anchor off-centre, then Center Anchor Point keeps the layer in place.
+ s.execute("layer.setTransform", json!({"prop": "anchor", "value": [0, 0]})).unwrap();
+ s.execute("layer.setTransform", json!({"prop": "rotation", "value": 0})).unwrap();
+ let before = layer(&s, a).props.prop("transform/position").unwrap().value.as_vec3();
+ s.execute("layer.centerAnchor", json!({})).unwrap();
+ let l = layer(&s, a);
+ assert_eq!(l.props.prop("transform/anchor").unwrap().value.as_vec2(), [100.0, 50.0]);
+ let after = l.props.prop("transform/position").unwrap().value.as_vec3();
+ assert!((after[0] - before[0] - 100.0).abs() < 1e-6 && (after[1] - before[1] - 50.0).abs() < 1e-6, "{before:?} → {after:?}");
+
+ s.execute("layer.autoOrient", json!({"mode": "alongPath"})).unwrap();
+ assert_eq!(layer(&s, a).auto_orient, effectcraft_project::AutoOrient::AlongPath);
+}
+
+#[test]
+fn mask_menu_on_existing_masks() {
+ let mut s = comp();
+ let a = solid(&mut s, "#ff0000");
+ assert!(!s.is_enabled("layer.mask.reset"));
+ s.execute("layer.addMask", json!({})).unwrap();
+ s.execute("layer.addMask", json!({"shape": "ellipse"})).unwrap();
+ assert!(s.is_enabled("layer.mask.reset"));
+ let masks = |s: &Session| layer(s, a).masks().unwrap().groups().cloned().collect::>();
+ s.execute("layer.mask.set", json!({"field": "feather", "value": 12, "mask": 1})).unwrap();
+ assert_eq!(masks(&s)[0].get("feather").unwrap().value, KV::Vec2([12.0, 12.0]));
+ s.execute("layer.mask.set", json!({"field": "opacity", "value": 40})).unwrap();
+ assert!(masks(&s).iter().all(|m| m.get("opacity").unwrap().value.as_f64() == 40.0));
+ s.execute("layer.mask.invert", json!({"mask": 2})).unwrap();
+ s.execute("layer.mask.mode", json!({"mode": "Subtract", "mask": 2})).unwrap();
+ s.execute("layer.mask.lock", json!({"mask": 1})).unwrap();
+ let kinds: Vec<_> = masks(&s).iter().map(|m| m.kind.clone()).collect();
+ assert!(matches!(kinds[1], effectcraft_project::GroupKind::Mask { inverted: true, mode: effectcraft_project::MaskMode::Subtract, .. }));
+ assert!(matches!(kinds[0], effectcraft_project::GroupKind::Mask { locked: true, .. }));
+ s.execute("layer.mask.unlockAll", json!({})).unwrap();
+ assert!(matches!(masks(&s)[0].kind, effectcraft_project::GroupKind::Mask { locked: false, .. }));
+ s.execute("layer.mask.lockOthers", json!({"mask": 1})).unwrap();
+ assert!(matches!(masks(&s)[1].kind, effectcraft_project::GroupKind::Mask { locked: true, .. }));
+ s.execute("layer.mask.reset", json!({"mask": 1})).unwrap();
+ assert_eq!(masks(&s)[0].get("opacity").unwrap().value.as_f64(), 100.0);
+ s.execute("layer.mask.shape", json!({"mask": 1, "rect": [10, 10, 50, 40], "shape": "ellipse"})).unwrap();
+ s.execute("layer.mask.remove", json!({"mask": 2})).unwrap();
+ assert_eq!(masks(&s).len(), 1);
+ s.execute("layer.mask.removeAll", json!({})).unwrap();
+ assert!(masks(&s).is_empty());
+ s.execute("edit.undo", json!({})).unwrap();
+ assert_eq!(masks(&s).len(), 1);
+}
+
+#[test]
+fn layer_markers_lock_and_delete() {
+ let mut s = comp();
+ let a = solid(&mut s, "#ff0000");
+ s.execute("time.set", json!({"time": 1.0})).unwrap();
+ s.execute("layer.addMarker", json!({"comment": "hit"})).unwrap();
+ s.execute("layer.addMarker", json!({"time": 2.0})).unwrap();
+ assert_eq!(layer(&s, a).markers.len(), 2);
+ s.execute("layer.markersLock", json!({})).unwrap();
+ assert!(layer(&s, a).markers_locked);
+ s.execute("layer.deleteAllMarkers", json!({})).unwrap();
+ assert_eq!(layer(&s, a).markers.len(), 2, "locked markers survive");
+ s.execute("layer.markersLock", json!({"value": false})).unwrap();
+ s.execute("layer.deleteAllMarkers", json!({})).unwrap();
+ assert!(layer(&s, a).markers.is_empty());
+ s.execute("edit.undo", json!({})).unwrap();
+ assert_eq!(layer(&s, a).markers.len(), 2);
+}
+
+#[test]
+fn track_matte_menu() {
+ let mut s = comp();
+ let below = solid(&mut s, "#ff0000");
+ let top = solid(&mut s, "#00ff00");
+ s.execute("layer.select", json!({"layers": [below]})).unwrap();
+ s.execute("layer.trackMatte", json!({"op": "luma"})).unwrap();
+ let m = layer(&s, below).track_matte.unwrap();
+ assert_eq!((m.layer.0, m.kind), (top, MatteKind::Luma));
+ assert!(!layer(&s, top).switches.video);
+ s.execute("layer.trackMatte", json!({"op": "alphaInverted"})).unwrap();
+ assert_eq!(layer(&s, below).track_matte.unwrap().kind, MatteKind::AlphaInverted);
+ s.execute("layer.trackMatte", json!({"op": "none"})).unwrap();
+ assert!(layer(&s, below).track_matte.is_none());
+ s.execute("layer.select", json!({"layers": [top]})).unwrap();
+ assert!(s.execute("layer.trackMatte", json!({"op": "above"})).is_err());
+ s.execute("layer.trackMatte", json!({"op": "below"})).unwrap();
+ assert_eq!(layer(&s, top).track_matte.unwrap().layer.0, below);
+}
+
+#[test]
+fn keyframe_clipboard_paste_and_paste_reversed() {
+ let mut s = comp();
+ let a = solid(&mut s, "#ff0000");
+ let b = solid(&mut s, "#00ff00");
+ s.execute("prop.toggleAnimation", json!({"layer": a, "path": "transform/opacity"})).unwrap();
+ s.execute("time.set", json!({"time": 1.0})).unwrap();
+ s.execute("prop.set", json!({"layer": a, "path": "transform/opacity", "value": 0})).unwrap();
+ s.execute("prop.select", json!({"layer": a, "path": "transform/opacity"})).unwrap();
+ assert_eq!(s.execute("edit.copy", json!({})).unwrap()["keys"], 2);
+ s.execute("layer.select", json!({"layers": [b]})).unwrap();
+ s.execute("time.set", json!({"time": 2.0})).unwrap();
+ s.execute("edit.paste", json!({})).unwrap();
+ let keys = layer(&s, b).props.prop("transform/opacity").unwrap().keys.clone();
+ assert_eq!(keys.len(), 2);
+ assert!((keys[0].time.seconds() - 2.0).abs() < 1e-6 && keys[0].value.as_f64() == 100.0);
+ s.execute("edit.undo", json!({})).unwrap();
+ s.execute("edit.pasteReversedKeyframes", json!({})).unwrap();
+ let keys = layer(&s, b).props.prop("transform/opacity").unwrap().keys.clone();
+ assert_eq!((keys[0].value.as_f64(), keys[1].value.as_f64()), (0.0, 100.0));
+}
+
+#[test]
+fn property_links_and_expression_only() {
+ let mut s = comp();
+ let a = solid(&mut s, "#ff0000");
+ let b = solid(&mut s, "#00ff00");
+ s.execute("prop.select", json!({"layer": a, "path": "transform/position"})).unwrap();
+ s.execute("edit.copyWithPropertyLinks", json!({})).unwrap();
+ s.execute("layer.select", json!({"layers": [b]})).unwrap();
+ s.execute("edit.paste", json!({})).unwrap();
+ let e = layer(&s, b).props.prop("transform/position").unwrap().expr.clone().unwrap();
+ let name = layer(&s, a).name;
+ assert_eq!(e.text, format!("comp(\"Main\").layer({}).transform(\"Position\")", serde_json::to_string(&name).unwrap()));
+ // Relative links use thisComp.
+ s.execute("prop.select", json!({"layer": a, "path": "transform/opacity"})).unwrap();
+ s.execute("edit.copyWithRelativePropertyLinks", json!({})).unwrap();
+ s.execute("layer.select", json!({"layers": [b]})).unwrap();
+ s.execute("edit.paste", json!({})).unwrap();
+ assert!(layer(&s, b).props.prop("transform/opacity").unwrap().expr.as_ref().unwrap().text.starts_with("thisComp.layer("));
+ // Copy Expression Only.
+ s.execute("prop.setExpression", json!({"layer": a, "path": "transform/rotation", "expression": "time * 90"})).unwrap();
+ s.execute("prop.select", json!({"layer": a, "path": "transform/rotation"})).unwrap();
+ s.execute("edit.copyExpressionOnly", json!({})).unwrap();
+ s.execute("layer.select", json!({"layers": [b]})).unwrap();
+ s.execute("edit.paste", json!({})).unwrap();
+ assert_eq!(layer(&s, b).props.prop("transform/rotation").unwrap().expr.as_ref().unwrap().text, "time * 90");
+ // Layers with property links: the pasted copy follows the original.
+ s.state.selected_props.clear();
+ s.execute("layer.select", json!({"layers": [a]})).unwrap();
+ s.execute("edit.copyWithPropertyLinks", json!({})).unwrap();
+ let new = s.execute("edit.paste", json!({})).unwrap();
+ let nid = new[0].as_u64().unwrap();
+ assert!(layer(&s, nid).props.prop("transform/scale").unwrap().has_expression());
+}
+
+#[test]
+fn lift_and_extract_work_area() {
+ let mut s = comp();
+ let a = solid(&mut s, "#ff0000");
+ s.execute("comp.workArea", json!({"start": 2.0, "end": 4.0})).unwrap();
+ s.execute("edit.liftWorkArea", json!({})).unwrap();
+ let c = s.active_comp().unwrap();
+ assert_eq!(c.layers.len(), 2, "split around the gap");
+ let mut spans: Vec<(f64, f64)> = c.layers.iter().map(|l| (l.in_point.seconds(), l.out_point.seconds())).collect();
+ spans.sort_by(|x, y| x.0.total_cmp(&y.0));
+ assert!((spans[0].1 - 2.0).abs() < 1e-6 && (spans[1].0 - 4.0).abs() < 1e-6);
+ s.execute("edit.undo", json!({})).unwrap();
+ s.execute("layer.select", json!({"layers": [a]})).unwrap();
+ s.execute("edit.extractWorkArea", json!({})).unwrap();
+ let c = s.active_comp().unwrap();
+ let mut spans: Vec<(f64, f64)> = c.layers.iter().map(|l| (l.in_point.seconds(), l.out_point.seconds())).collect();
+ spans.sort_by(|x, y| x.0.total_cmp(&y.0));
+ assert!((spans[1].0 - 2.0).abs() < 1e-6 && (spans[1].1 - 8.0).abs() < 1e-6, "{spans:?}");
+}
+
+#[test]
+fn label_group_purge_and_edit_original() {
+ let mut s = comp();
+ let a = solid(&mut s, "#ff0000");
+ let b = solid(&mut s, "#00ff00");
+ let _c = solid(&mut s, "#0000ff");
+ s.execute("edit.label", json!({"layers": [a, b], "label": "Cyan"})).unwrap();
+ s.execute("layer.select", json!({"layers": [a]})).unwrap();
+ s.execute("edit.selectLabelGroup", json!({})).unwrap();
+ assert_eq!(s.state.selected_layers.len(), 2);
+ s.drain_events();
+ s.execute("edit.purge", json!({"what": "memory"})).unwrap();
+ assert!(s.drain_events().contains(&Event::PurgeCaches));
+ assert!(!s.is_enabled("edit.editOriginal"));
+}
+
+#[test]
+fn animation_menu_keys_presets_text() {
+ let mut s = comp();
+ let a = solid(&mut s, "#ff0000");
+ // Add Keyframe on selected properties.
+ s.execute("prop.select", json!({"layer": a, "path": "transform/scale"})).unwrap();
+ s.execute("anim.addKeyframe", json!({})).unwrap();
+ s.execute("time.set", json!({"time": 1.0})).unwrap();
+ s.execute("prop.set", json!({"layer": a, "path": "transform/scale", "value": [400, 400]})).unwrap();
+ assert_eq!(layer(&s, a).props.prop("transform/scale").unwrap().keys.len(), 2);
+ // Exponential Scale: a key per frame, geometric in between.
+ s.execute("prop.select", json!({"layer": a, "path": "transform/scale"})).unwrap();
+ s.execute("keys.exponentialScale", json!({})).unwrap();
+ let keys = layer(&s, a).props.prop("transform/scale").unwrap().keys.clone();
+ assert_eq!(keys.len(), 31);
+ assert!((keys[15].value.as_vec3()[0] - 200.0).abs() < 1e-6, "{:?}", keys[15].value);
+ s.execute("edit.undo", json!({})).unwrap();
+ // Time-Reverse Keyframes.
+ s.execute("prop.select", json!({"layer": a, "path": "transform/scale"})).unwrap();
+ s.execute("keys.timeReverse", json!({})).unwrap();
+ let keys = layer(&s, a).props.prop("transform/scale").unwrap().keys.clone();
+ assert_eq!((keys[0].value.as_vec3()[0], keys[1].value.as_vec3()[0]), (400.0, 100.0));
+
+ // Presets round-trip through a file onto another layer at the CTI.
+ let path = tmp("scale.ecpreset");
+ s.execute("prop.select", json!({"layer": a, "path": "transform/scale"})).unwrap();
+ s.execute("anim.savePreset", json!({"path": path})).unwrap();
+ let b = solid(&mut s, "#00ff00");
+ s.execute("time.set", json!({"time": 3.0})).unwrap();
+ let r = s.execute("anim.applyPreset", json!({"path": path, "layers": [b]})).unwrap();
+ assert_eq!(r["applied"], 1);
+ let keys = layer(&s, b).props.prop("transform/scale").unwrap().keys.clone();
+ assert_eq!(keys.len(), 2);
+ assert!((keys[0].time.seconds() - 3.0).abs() < 1e-6);
+
+ // Text: animate, add selector, reveal, remove all.
+ let t = s.execute("layer.newText", json!({"text": "Hi"})).unwrap()["layer"].as_u64().unwrap();
+ s.execute("layer.addTextAnimator", json!({"properties": ["anchor", "position", "scale", "skew", "rotation", "opacity"]})).unwrap();
+ s.execute("text.addSelector", json!({"kind": "range"})).unwrap();
+ let anim = layer(&s, t).props.group("text/animators").unwrap().groups().next().unwrap().clone();
+ assert_eq!(anim.sub("selectors").unwrap().children.len(), 2);
+ assert_eq!(anim.sub("properties").unwrap().children.len(), 6);
+ assert!(s.execute("text.addSelector", json!({"kind": "wiggly"})).is_err());
+ s.execute("text.removeAllAnimators", json!({})).unwrap();
+ assert!(layer(&s, t).props.group("text/animators").unwrap().children.is_empty());
+ s.execute("edit.undo", json!({})).unwrap();
+ assert_eq!(layer(&s, t).props.group("text/animators").unwrap().children.len(), 1);
+}
+
+#[test]
+fn reveal_properties() {
+ let mut s = comp();
+ let a = solid(&mut s, "#ff0000");
+ s.execute("prop.toggleAnimation", json!({"layer": a, "path": "transform/rotation"})).unwrap();
+ s.execute("prop.setExpression", json!({"layer": a, "path": "transform/opacity", "expression": "50"})).unwrap();
+ s.execute("prop.set", json!({"layer": a, "path": "transform/scale", "value": [50, 50]})).unwrap();
+ s.drain_events();
+ let n = |v: &Value| v["props"].as_array().unwrap().len();
+ assert_eq!(n(&s.execute("anim.reveal", json!({"kind": "keyframes"})).unwrap()), 1);
+ assert_eq!(n(&s.execute("anim.reveal", json!({"kind": "animation"})).unwrap()), 2);
+ assert_eq!(n(&s.execute("anim.reveal", json!({"kind": "modified"})).unwrap()), 3);
+ assert!(frontend_events(&mut s).iter().all(|(c, _)| c == "timeline.revealProps"));
+}
+
+#[test]
+fn sequence_layers() {
+ let mut s = comp();
+ let a = solid(&mut s, "#ff0000");
+ let b = solid(&mut s, "#00ff00");
+ let c = solid(&mut s, "#0000ff");
+ for (id, out) in [(a, 2.0), (b, 3.0), (c, 1.0)] {
+ s.execute("layer.timing", json!({"layers": [id], "out": out})).unwrap();
+ }
+ s.execute("layer.sequence", json!({"layers": [a, b, c], "overlap": true, "duration": 0.5, "transition": "dissolveFront"})).unwrap();
+ assert!((layer(&s, b).in_point.seconds() - 1.5).abs() < 1e-6);
+ assert!((layer(&s, c).in_point.seconds() - 4.0).abs() < 1e-6);
+ assert_eq!(layer(&s, c).props.prop("transform/opacity").unwrap().keys.len(), 2);
+}
+
+#[test]
+fn file_menu_project_ops() {
+ let mut s = comp();
+ let f = s.execute("project.newFolder", json!({"name": "Stuff"})).unwrap()["item"].as_u64().unwrap();
+ assert!(s.project.item(effectcraft_project::ItemId(f)).unwrap().is_folder());
+ let p1 = s.execute("file.importPlaceholder", json!({"name": "Shot 1", "width": 320, "height": 240})).unwrap()["item"].as_u64().unwrap();
+ let p2 = s.execute("file.importPlaceholder", json!({"name": "Unused"})).unwrap()["item"].as_u64().unwrap();
+ s.execute("file.importSolid", json!({"name": "Grey"})).unwrap();
+ s.state.project_selection = vec![effectcraft_project::ItemId(p1)];
+ let r = s.execute("file.newCompFromSelection", json!({})).unwrap();
+ let nc = effectcraft_project::ItemId(r["comps"][0].as_u64().unwrap());
+ assert_eq!((s.project.comp(nc).unwrap().width, s.project.comp(nc).unwrap().layers.len()), (320, 1));
+ // Missing footage = the placeholders.
+ let miss = s.execute("file.findMissing", json!({"what": "footage"})).unwrap();
+ assert_eq!(miss["items"].as_array().unwrap().len(), 2);
+ assert!(s.execute("file.findMissing", json!({"what": "fonts"})).is_ok());
+ // Interpretation.
+ s.state.project_selection = vec![effectcraft_project::ItemId(p1)];
+ s.execute("file.interpretFootage", json!({"frameRate": 24, "alpha": "premultiplied", "loop": 3})).unwrap();
+ s.execute("file.rememberInterpretation", json!({})).unwrap();
+ s.state.project_selection = vec![effectcraft_project::ItemId(p2)];
+ s.execute("file.applyInterpretation", json!({})).unwrap();
+ match &s.project.item(effectcraft_project::ItemId(p2)).unwrap().kind {
+ ItemKind::Footage(f) => assert_eq!((f.alpha, f.loop_count, f.frame_rate.as_f64().round()), (effectcraft_project::AlphaMode::Premultiplied, 3, 24.0)),
+ _ => panic!(),
+ }
+ // Remove Unused Footage drops the unused placeholder and the unused solid.
+ let before = s.project.items.len();
+ s.execute("file.removeUnusedFootage", json!({})).unwrap();
+ assert_eq!(s.project.items.len(), before - 2);
+ s.execute("edit.undo", json!({})).unwrap();
+ assert_eq!(s.project.items.len(), before);
+ // Replace with a solid retargets the layer.
+ s.state.project_selection = vec![effectcraft_project::ItemId(p1)];
+ s.execute("file.replaceWithSolid", json!({"color": "#336699"})).unwrap();
+ assert!(matches!(s.project.comp(nc).unwrap().layers[0].source, effectcraft_project::LayerSource::Solid { .. }));
+ // Reduce Project keeps only the selected comp and what it uses (+ folders of kept items).
+ s.state.project_selection = vec![nc];
+ s.execute("file.reduceProject", json!({})).unwrap();
+ assert!(s.project.items.len() <= 2, "{:?}", s.project.items.values().map(|i| &i.name).collect::>());
+ // Save a copy leaves the session path alone.
+ let path = tmp("copy.ecproj");
+ s.execute("file.saveCopy", json!({"path": path})).unwrap();
+ assert!(s.path.is_none() && std::fs::metadata(&path).is_ok());
+ s.execute("file.closeProject", json!({})).unwrap();
+ assert!(s.project.items.is_empty());
+}
+
+#[test]
+fn consolidate_duplicate_footage() {
+ let mut s = comp();
+ let f = |s: &mut Session| s.execute("file.importPlaceholder", json!({})).unwrap()["item"].as_u64().unwrap();
+ let a = f(&mut s);
+ let b = f(&mut s);
+ // Give both the same file path.
+ let mut p = (*s.project).clone();
+ for id in [a, b] {
+ if let Some(ItemKind::Footage(ft)) = p.item_mut(effectcraft_project::ItemId(id)).map(|i| &mut i.kind) {
+ ft.path = "/media/shot.mov".into();
+ }
+ }
+ s.project = std::sync::Arc::new(p);
+ s.execute("layer.addItem", json!({"item": b})).unwrap();
+ assert_eq!(s.execute("file.consolidateFootage", json!({})).unwrap()["removed"], 1);
+ let c = s.active_comp().unwrap();
+ assert_eq!(c.layers[0].source.item().unwrap().0, a);
+}
+
+#[test]
+fn run_script_steps() {
+ let mut s = comp();
+ let path = tmp("script.jsonl");
+ std::fs::write(&path, "// make two solids\n{\"command\":\"layer.newSolid\",\"params\":{\"color\":\"#ff0000\"}}\n{\"method\":\"engine.execute\",\"params\":{\"id\":\"layer.newNull\",\"params\":{}}}\n").unwrap();
+ let r = s.execute("file.runScript", json!({"path": path})).unwrap();
+ assert_eq!(r["steps"], 2);
+ assert_eq!(s.active_comp().unwrap().layers.len(), 2);
+ assert!(s.execute("file.runScript", json!({"steps": [{"command": "nope.nope"}]})).is_err());
+}
+
+#[test]
+fn crop_comp_and_save_frame() {
+ let mut s = comp();
+ let a = solid(&mut s, "#ff0000");
+ // ROI crop moves layers so nothing shifts on screen.
+ assert!(!s.is_enabled("comp.cropToRegionOfInterest"));
+ s.execute("view.setRegionOfInterest", json!({"rect": [100, 50, 200, 100]})).unwrap();
+ s.execute("comp.cropToRegionOfInterest", json!({})).unwrap();
+ let c = s.active_comp().unwrap();
+ assert_eq!((c.width, c.height), (200, 100));
+ assert_eq!(layer(&s, a).props.prop("transform/position").unwrap().value.as_vec2(), [220.0, 130.0]);
+ s.execute("edit.undo", json!({})).unwrap();
+ assert_eq!(s.active_comp().unwrap().width, 640);
+ // Crop to the selected layer's bounds (a 200×100 solid centred in 640×360).
+ s.execute("layer.select", json!({"layers": [a]})).unwrap();
+ let r = s.execute("comp.cropToLayerBounds", json!({})).unwrap();
+ assert_eq!((r["width"].as_u64(), r["height"].as_u64()), (Some(200), Some(100)));
+ assert_eq!(layer(&s, a).props.prop("transform/position").unwrap().value.as_vec2(), [100.0, 50.0]);
+ // Save Frame As ▸ File… writes a PNG.
+ let path = tmp("frame.png");
+ let r = s.execute("comp.saveFrameAs", json!({"path": path, "scale": 0.5})).unwrap();
+ assert_eq!(r["width"], 100);
+ let bytes = std::fs::read(&path).unwrap();
+ assert_eq!(&bytes[..8], b"\x89PNG\r\n\x1a\n");
+ // Responsive Design — Time.
+ s.execute("time.set", json!({"time": 2.0})).unwrap();
+ s.execute("comp.responsiveTime", json!({"op": "intro"})).unwrap();
+ let m = &s.active_comp().unwrap().markers[0];
+ assert!(m.protected && (m.duration.seconds() - 2.0).abs() < 1e-6);
+}
+
+#[test]
+fn guides_add_clear_import_export() {
+ let mut s = comp();
+ s.execute("view.addGuide", json!({"orientation": "horizontal", "position": 40})).unwrap();
+ s.execute("view.addGuide", json!({})).unwrap();
+ assert_eq!(s.active_comp().unwrap().guides.len(), 2);
+ assert_eq!(s.active_comp().unwrap().guides[1].position, 320.0);
+ let path = tmp("guides.json");
+ s.execute("view.exportGuides", json!({"path": path})).unwrap();
+ s.execute("view.clearGuides", json!({})).unwrap();
+ assert!(s.active_comp().unwrap().guides.is_empty());
+ s.execute("edit.undo", json!({})).unwrap();
+ assert_eq!(s.active_comp().unwrap().guides.len(), 2);
+ s.execute("view.clearGuides", json!({})).unwrap();
+ s.execute("view.importGuides", json!({"path": path})).unwrap();
+ assert_eq!(s.active_comp().unwrap().guides.len(), 2);
+}
+
+#[test]
+fn frontend_commands_emit_events_and_stubs_are_disabled() {
+ let mut s = comp();
+ s.drain_events();
+ s.execute("view.zoomIn", json!({})).unwrap();
+ s.execute("window.panel", json!({"panel": "align"})).unwrap();
+ let ev = frontend_events(&mut s);
+ assert_eq!(ev[0].0, "view.zoomIn");
+ assert_eq!(ev[1], ("window.panel".to_string(), json!({"panel": "align"})));
+ for id in ["render.addToQueue", "layer.timeRemap", "camera.fromView", "view.3d", "layer.styles", "prop.separateDimensions"] {
+ assert!(!s.is_enabled(id), "{id}");
+ assert!(matches!(s.execute(id, json!({})), Err(EngineError::Disabled(..))), "{id}");
+ }
+}
diff --git a/crates/host/src/lib.rs b/crates/host/src/lib.rs
index 15ef3f542..9eb8ee7eb 100644
--- a/crates/host/src/lib.rs
+++ b/crates/host/src/lib.rs
@@ -16,11 +16,12 @@ impl Importer for MediaImporter {
/// A new session with media, import and expressions enabled.
pub fn session() -> Session {
- let mut s = Session::default();
- s.footage = Arc::new(effectcraft_media::MediaPool::new());
- s.importer = Some(Arc::new(MediaImporter));
- s.expr = Some(Arc::new(effectcraft_expr::Expressions));
- s
+ Session {
+ footage: Arc::new(effectcraft_media::MediaPool::new()),
+ importer: Some(Arc::new(MediaImporter)),
+ expr: Some(Arc::new(effectcraft_expr::Expressions)),
+ ..Default::default()
+ }
}
#[cfg(test)]
diff --git a/crates/project/src/build.rs b/crates/project/src/build.rs
index a6fcdf1f3..ece3d2574 100644
--- a/crates/project/src/build.rs
+++ b/crates/project/src/build.rs
@@ -501,6 +501,7 @@ pub fn layer(project: &mut Project, comp: &Comp, name: &str, source: LayerSource
track_matte: None,
parent: None,
markers: vec![],
+ markers_locked: false,
auto_orient: Default::default(),
props: root,
}
diff --git a/crates/project/src/lib.rs b/crates/project/src/lib.rs
index 0575e7b41..f1da2c106 100644
--- a/crates/project/src/lib.rs
+++ b/crates/project/src/lib.rs
@@ -149,6 +149,16 @@ pub struct Comp {
pub draft_3d: bool,
#[serde(default)]
pub poster_time: Tick,
+ /// Viewer guides (View ▸ Add Guide…), in comp pixels.
+ #[serde(default, skip_serializing_if = "Vec::is_empty")]
+ pub guides: Vec,
+}
+
+/// A viewer guide line: vertical guides sit at an x position, horizontal ones at a y position.
+#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
+pub struct Guide {
+ pub vertical: bool,
+ pub position: f64,
}
fn yes() -> bool {
@@ -177,6 +187,7 @@ impl Comp {
enable_frame_blending: true,
draft_3d: false,
poster_time: Tick::ZERO,
+ guides: vec![],
}
}
pub fn layer(&self, id: LayerId) -> Option<&Layer> {
@@ -410,6 +421,9 @@ pub struct Layer {
pub parent: Option,
#[serde(default)]
pub markers: Vec,
+ /// Layer ▸ Markers ▸ Lock Markers.
+ #[serde(default, skip_serializing_if = "std::ops::Not::not")]
+ pub markers_locked: bool,
#[serde(default)]
pub auto_orient: AutoOrient,
/// The property tree (Masks, Effects, Transform, Text, Contents, Camera/Light options…).
diff --git a/crates/ui-egui/examples/snapshot.rs b/crates/ui-egui/examples/snapshot.rs
index 6cc9b175e..aa2aa5679 100644
--- a/crates/ui-egui/examples/snapshot.rs
+++ b/crates/ui-egui/examples/snapshot.rs
@@ -105,6 +105,25 @@ fn main() {
}
continue;
}
+ // Pointer input straight into the harness (menus and popups need real input events):
+ // {"method":"pointer","params":{"x":237,"y":12,"click":true}}
+ if method == "pointer" {
+ let pos = egui::pos2(params["x"].as_f64().unwrap_or(0.0) as f32, params["y"].as_f64().unwrap_or(0.0) as f32);
+ harness.input_mut().events.push(egui::Event::PointerMoved(pos));
+ if params["click"].as_bool() == Some(true) {
+ for pressed in [true, false] {
+ harness.input_mut().events.push(egui::Event::PointerButton {
+ pos,
+ button: egui::PointerButton::Primary,
+ pressed,
+ modifiers: Default::default(),
+ });
+ }
+ }
+ settle(&mut harness, 0.3);
+ println!("{}", json!({"method": method, "reply": {"ok": true}}));
+ continue;
+ }
let (reply_tx, reply_rx) = mpsc::channel();
let _ = tx.send(ControlRequest { method: method.clone(), params, reply: reply_tx });
// Requests are answered on a later frame (some wait for input to be processed).
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index 821a946d0..898c51142 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -41,6 +41,16 @@ pub enum Dialog {
CompSettings,
SolidSettings,
CommandPalette,
+ /// Settings (Preferences) on `dialog_state.settings_page`.
+ Settings,
+ /// Edit ▸ Keyboard Shortcuts.
+ Shortcuts,
+ /// A generic parameter form for a command (`dialog_state.form`).
+ Form,
+ /// A message (`dialog_state.info`).
+ Info,
+ /// View ▸ View Options.
+ ViewOptions,
}
/// Host hooks provided by the native app (file pickers etc.).
@@ -398,6 +408,12 @@ impl EffectcraftApp {
effectcraft_engine::Event::Toast { message, .. } => self.toast = Some((message, ctx.input(|i| i.time))),
effectcraft_engine::Event::OpenUrl(url) => ctx.open_url(egui::OpenUrl::new_tab(url)),
effectcraft_engine::Event::ProjectChanged { .. } => {}
+ effectcraft_engine::Event::Frontend { command, params } => {
+ if let Err(e) = crate::menus::frontend(self, ctx, &command, params) {
+ self.ui.status = e;
+ }
+ }
+ effectcraft_engine::Event::PurgeCaches => self.frames.clear(),
}
}
}
diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs
index 321cee162..3a5e014b0 100644
--- a/crates/ui-egui/src/menus.rs
+++ b/crates/ui-egui/src/menus.rs
@@ -1,13 +1,16 @@
-//! Menus, keyboard shortcuts and UI-level commands. The menu bar is generated from the engine
-//! registry plus the UI command table (commands that only affect the frontend: tools, playback,
-//! viewer zoom, panels, reveal shortcuts). `invoke` is the single entry point used by menus,
-//! shortcuts and the control channel.
+//! Menus, keyboard shortcuts and UI-level commands. The menu bar is the engine's After Effects
+//! menu tree (`effectcraft_engine::menus`): every entry is an engine command, and frontend-only
+//! commands (viewer zoom, panels, dialogs…) come back as `Event::Frontend` and are performed by
+//! [`frontend`]. [`UI_COMMANDS`] holds the remaining UI-only shortcuts (tools, timeline
+//! navigation, reveal keys). `invoke` is the single entry point used by menus, shortcuts and the
+//! control channel.
use serde_json::{Value, json};
use crate::EffectcraftApp;
use crate::dock::PanelKind;
use crate::state::{Resolution, Tool};
+use effectcraft_engine::menus::{MenuEntry, MenuNode};
pub struct UiCommand {
pub id: &'static str,
@@ -22,32 +25,23 @@ macro_rules! uic {
};
}
+/// UI-only commands (not in the AE menus; shortcuts and the command palette).
pub const UI_COMMANDS: &[UiCommand] = &[
- uic!("playback.toggle", "Play/Stop", ["Composition", "Preview"], Some("Space")),
- uic!("playback.ramPreview", "Play Current Preview", ["Composition", "Preview"], Some("Num0")),
+ uic!("playback.ramPreview", "Play Current Preview", [], Some("Num0")),
uic!("playback.stop", "Stop", [], None),
- uic!("view.zoomIn", "Zoom In", ["View"], Some(".")),
- uic!("view.zoomOut", "Zoom Out", ["View"], Some(",")),
- uic!("view.fit", "Fit", ["View"], Some("Shift+/")),
- uic!("view.actualSize", "100%", ["View"], Some("/")),
- uic!("view.res.full", "Full", ["View", "Resolution"], Some("Cmd+J")),
- uic!("view.res.half", "Half", ["View", "Resolution"], Some("Cmd+Shift+J")),
- uic!("view.res.third", "Third", ["View", "Resolution"], None),
- uic!("view.res.quarter", "Quarter", ["View", "Resolution"], Some("Cmd+Alt+Shift+J")),
- uic!("view.res.auto", "Auto", ["View", "Resolution"], None),
- uic!("view.rulers", "Show Rulers", ["View"], Some("Cmd+R")),
- uic!("view.grid", "Show Grid", ["View"], Some("Cmd+'")),
- uic!("view.safeMargins", "Title/Action Safe", ["View"], None),
- uic!("view.transparencyGrid", "Transparency Grid", ["View"], None),
- uic!("view.layerControls", "Show Layer Controls", ["View"], Some("Cmd+Shift+H")),
- uic!("view.fastPreviews", "Fast Previews", ["View"], None),
- uic!("view.theme.dark", "Dark", ["View", "Appearance"], None),
- uic!("view.theme.darker", "Darker", ["View", "Appearance"], None),
- uic!("view.theme.light", "Light", ["View", "Appearance"], None),
+ uic!("view.fit", "Fit", [], Some("Shift+/")),
+ uic!("view.actualSize", "100%", [], Some("/")),
+ uic!("view.res.auto", "Resolution: Auto", [], None),
+ uic!("view.safeMargins", "Title/Action Safe", [], None),
+ uic!("view.transparencyGrid", "Transparency Grid", [], None),
+ uic!("view.fastPreviews", "Fast Previews", [], None),
+ uic!("view.theme.dark", "Theme: Dark", [], None),
+ uic!("view.theme.darker", "Theme: Darker", [], None),
+ uic!("view.theme.light", "Theme: Light", [], None),
uic!("timeline.zoomIn", "Zoom In Time", [], Some("=")),
uic!("timeline.zoomOut", "Zoom Out Time", [], Some("-")),
uic!("timeline.zoomFit", "Zoom to Fit Comp", [], Some(";")),
- uic!("timeline.graphEditor", "Graph Editor", ["Window"], Some("Shift+F3")),
+ uic!("timeline.graphEditor", "Graph Editor", [], Some("Shift+F3")),
uic!("timeline.switchesModes", "Toggle Switches / Modes", [], Some("F4")),
uic!("timeline.workAreaBegin", "Set Work Area Begin", [], Some("B")),
uic!("timeline.workAreaEnd", "Set Work Area End", [], Some("N")),
@@ -60,22 +54,10 @@ pub const UI_COMMANDS: &[UiCommand] = &[
uic!("timeline.reveal.rotation", "Reveal Rotation", [], Some("R")),
uic!("timeline.reveal.opacity", "Reveal Opacity", [], Some("T")),
uic!("timeline.reveal.anchor", "Reveal Anchor Point", [], Some("A")),
- uic!("timeline.reveal.animated", "Reveal Animated Properties", ["Animation"], Some("U")),
uic!("timeline.reveal.effects", "Reveal Effects", [], Some("E")),
uic!("timeline.reveal.masks", "Reveal Masks", [], Some("M")),
uic!("timeline.reveal.feather", "Reveal Mask Feather", [], Some("F")),
uic!("timeline.collapseAll", "Collapse All", [], Some("Cmd+`")),
- uic!("window.workspace.default", "Default", ["Window", "Workspace"], Some("Shift+F10")),
- uic!("window.workspace.standard", "Standard", ["Window", "Workspace"], Some("Shift+F11")),
- uic!("window.workspace.smallscreen", "Small Screen", ["Window", "Workspace"], Some("Shift+F12")),
- uic!("window.workspace.animation", "Animation", ["Window", "Workspace"], None),
- uic!("window.workspace.effects", "Effects", ["Window", "Workspace"], None),
- uic!("window.workspace.motiontracking", "Motion Tracking", ["Window", "Workspace"], None),
- uic!("window.workspace.paint", "Paint", ["Window", "Workspace"], None),
- uic!("window.workspace.text", "Text", ["Window", "Workspace"], None),
- uic!("window.workspace.minimal", "Minimal", ["Window", "Workspace"], None),
- uic!("window.workspace.allpanels", "All Panels", ["Window", "Workspace"], None),
- uic!("window.workspace.reset", "Reset to Saved Layout", ["Window", "Workspace"], None),
uic!("tool.selection", "Selection Tool", [], Some("V")),
uic!("tool.hand", "Hand Tool", [], Some("H")),
uic!("tool.zoom", "Zoom Tool", [], Some("Z")),
@@ -90,12 +72,10 @@ pub const UI_COMMANDS: &[UiCommand] = &[
uic!("tool.brush", "Brush Tools", [], Some("Cmd+B")),
uic!("tool.rotoBrush", "Roto Brush Tool", [], Some("Alt+W")),
uic!("tool.puppet", "Puppet Tools", [], Some("Cmd+P")),
- uic!("app.newComp", "New Composition…", [], None),
- uic!("app.compSettings", "Composition Settings…", [], None),
- uic!("app.solidSettings", "New Solid…", [], None),
- uic!("app.commandPalette", "Command Palette…", ["Window"], Some("Cmd+Shift+P")),
- uic!("app.about", "About EffectCraft", ["Help"], None),
- uic!("app.home", "Home", ["Window"], None),
+ uic!("app.newComp", "New Composition...", [], None),
+ uic!("app.compSettings", "Composition Settings...", [], None),
+ uic!("app.solidSettings", "New Solid...", [], None),
+ uic!("app.home", "Home", [], None),
];
pub fn panel_command_id(p: PanelKind) -> String {
@@ -118,23 +98,22 @@ fn reveal(app: &mut EffectcraftApp, kind: &str) {
app.ui.timeline.open_layers = sel.iter().map(|l| l.0).collect();
}
+fn no_params(p: &Value) -> bool {
+ p.as_object().is_none_or(|m| m.is_empty())
+}
+
/// Execute a UI or engine command by id.
pub fn invoke(app: &mut EffectcraftApp, ctx: &egui::Context, id: &str, params: Value) -> Result {
let now = ctx.input(|i| i.time);
+ // Legacy per-panel / per-workspace ids (`window.panel.Project`, `window.workspace.default`).
if let Some(rest) = id.strip_prefix("window.panel.") {
- let p = PanelKind::from_name(rest).ok_or_else(|| format!("unknown panel `{rest}`"))?;
- app.show_panel(p);
- return Ok(Value::Null);
+ return frontend(app, ctx, "window.panel", json!({"panel": rest}));
}
if let Some(ws) = id.strip_prefix("window.workspace.") {
if ws == "reset" {
- let name = app.ui.workspace.clone();
- app.set_workspace(&name);
- return Ok(Value::Null);
+ return frontend(app, ctx, "window.resetWorkspace", json!({}));
}
- let name = crate::dock::WORKSPACES.iter().find(|w| w.to_ascii_lowercase().replace(' ', "") == ws).ok_or_else(|| format!("unknown workspace `{ws}`"))?;
- app.set_workspace(name);
- return Ok(json!({"workspace": name}));
+ return frontend(app, ctx, "window.workspace", json!({"name": ws}));
}
if let Some(t) = id.strip_prefix("tool.") {
// Slot shortcuts cycle through the slot's tools.
@@ -165,11 +144,14 @@ pub fn invoke(app: &mut EffectcraftApp, ctx: &egui::Context, id: &str, params: V
return Ok(json!({"tool": tool}));
}
if let Some(k) = id.strip_prefix("timeline.reveal.") {
+ if k == "animated" {
+ return run_engine(app, ctx, "anim.reveal", json!({"kind": "keyframes"}));
+ }
reveal(app, k);
return Ok(Value::Null);
}
- if let Some(r) = id.strip_prefix("view.res.") {
- app.ui.viewer.res = Resolution::ALL.into_iter().find(|x| x.label().eq_ignore_ascii_case(r)).ok_or("unknown resolution")?;
+ if id == "view.res.auto" {
+ app.ui.viewer.res = Resolution::Auto;
return Ok(Value::Null);
}
if let Some(th) = id.strip_prefix("view.theme.") {
@@ -179,7 +161,7 @@ pub fn invoke(app: &mut EffectcraftApp, ctx: &egui::Context, id: &str, params: V
}
let timing = |app: &mut EffectcraftApp, op: &str| app.session.execute("layer.timing", json!({"op": op})).map_err(|e| e.to_string());
match id {
- "playback.toggle" | "playback.ramPreview" => {
+ "playback.ramPreview" => {
app.toggle_play(now);
return Ok(json!({"playing": app.playback.playing}));
}
@@ -187,17 +169,6 @@ pub fn invoke(app: &mut EffectcraftApp, ctx: &egui::Context, id: &str, params: V
app.stop();
return Ok(Value::Null);
}
- "view.zoomIn" | "view.zoomOut" => {
- let cur = app.ui.viewer.zoom.unwrap_or_else(|| crate::panels::viewer::last_fit(ctx));
- const STEPS: [f32; 16] = [0.015, 0.03, 0.0625, 0.125, 0.25, 0.333, 0.5, 0.66, 1.0, 1.5, 2.0, 3.0, 4.0, 8.0, 16.0, 32.0];
- let next = if id == "view.zoomIn" {
- STEPS.iter().copied().find(|s| *s > cur + 1e-3).unwrap_or(32.0)
- } else {
- STEPS.iter().rev().copied().find(|s| *s < cur - 1e-3).unwrap_or(0.015)
- };
- app.ui.viewer.zoom = Some(next);
- return Ok(json!({"zoom": next}));
- }
"view.fit" => {
app.ui.viewer.zoom = None;
app.ui.viewer.pan = [0.0, 0.0];
@@ -208,11 +179,8 @@ pub fn invoke(app: &mut EffectcraftApp, ctx: &egui::Context, id: &str, params: V
app.ui.viewer.pan = [0.0, 0.0];
return Ok(Value::Null);
}
- "view.rulers" => app.ui.viewer.rulers = !app.ui.viewer.rulers,
- "view.grid" => app.ui.viewer.grid = !app.ui.viewer.grid,
"view.safeMargins" => app.ui.viewer.safe_margins = !app.ui.viewer.safe_margins,
"view.transparencyGrid" => app.ui.viewer.transparency_grid = !app.ui.viewer.transparency_grid,
- "view.layerControls" => app.ui.viewer.show_layer_controls = !app.ui.viewer.show_layer_controls,
"view.fastPreviews" => app.ui.viewer.fast_preview = !app.ui.viewer.fast_preview,
"timeline.zoomIn" | "timeline.zoomOut" => {
let k = if id == "timeline.zoomIn" { 1.5 } else { 1.0 / 1.5 };
@@ -233,71 +201,278 @@ pub fn invoke(app: &mut EffectcraftApp, ctx: &egui::Context, id: &str, params: V
"timeline.moveOutToTime" => return timing(app, "moveOutToTime"),
"timeline.trimInToTime" => return timing(app, "trimInToTime"),
"timeline.trimOutToTime" => return timing(app, "trimOutToTime"),
- "app.about" => app.dialog = Some(crate::Dialog::About),
"app.home" => app.ui.start_screen = !app.ui.start_screen,
- "app.commandPalette" => {
- app.dialog_state.palette_query.clear();
- app.dialog = Some(crate::Dialog::CommandPalette);
- }
- "app.newComp" | "comp.new" if params.as_object().is_none_or(|m| m.is_empty()) => {
- crate::panels::dialogs::open_new_comp(app);
- }
- "app.compSettings" | "comp.settings" if params.as_object().is_none_or(|m| m.is_empty()) => {
- crate::panels::dialogs::open_comp_settings(app)?;
- }
- "app.solidSettings" | "layer.newSolid" if params.as_object().is_none_or(|m| m.is_empty()) => {
- crate::panels::dialogs::open_new_solid(app)?;
- }
+ "app.newComp" | "comp.new" if no_params(¶ms) => crate::panels::dialogs::open_new_comp(app),
+ "app.compSettings" | "comp.settings" if no_params(¶ms) => crate::panels::dialogs::open_comp_settings(app)?,
+ "app.solidSettings" | "layer.newSolid" if no_params(¶ms) => crate::panels::dialogs::open_new_solid(app)?,
_ => {
- if (id == "file.import" && params.get("paths").is_none() && params.get("path").is_none())
- || (id == "file.saveAs" && params.get("path").is_none())
- || (id == "file.open" && params.get("path").is_none())
- || (id == "file.save" && params.get("path").is_none() && app.session.path.is_none())
- {
- return file_dialog(app, id);
+ if let Some(r) = file_dialog(app, id, ¶ms) {
+ return r;
+ }
+ if crate::panels::dialogs::open_form(app, id, ¶ms) {
+ return Ok(json!({"dialog": id}));
}
if id == "layer.rename" && params.get("name").is_none() {
crate::panels::timeline::begin_rename(app, ctx);
return Ok(Value::Null);
}
- let r = app.session.execute(id, params).map_err(|e| e.to_string());
- if let Err(e) = &r {
- app.ui.status = e.clone();
- }
- return r;
+ return run_engine(app, ctx, id, params);
}
}
Ok(Value::Null)
}
-fn file_dialog(app: &mut EffectcraftApp, id: &str) -> Result {
- match id {
- "file.import" => {
- let f = app.hooks.pick_files.as_ref().ok_or("no file dialog available (pass `paths`)")?;
+/// Run an engine command and perform the frontend events it emitted right away.
+fn run_engine(app: &mut EffectcraftApp, ctx: &egui::Context, id: &str, params: Value) -> Result {
+ let r = app.session.execute(id, params).map_err(|e| e.to_string());
+ if let Err(e) = &r {
+ app.ui.status = e.clone();
+ }
+ let events = app.session.drain_events();
+ for ev in events {
+ match ev {
+ effectcraft_engine::Event::Frontend { command, params } => {
+ if let Err(e) = frontend(app, ctx, &command, params) {
+ app.ui.status = e;
+ }
+ }
+ other => app.session.events.push(other),
+ }
+ }
+ r
+}
+
+fn toggle(slot: &mut bool, p: &Value) -> Value {
+ *slot = p.get("value").and_then(Value::as_bool).unwrap_or(!*slot);
+ json!(*slot)
+}
+
+/// Perform a frontend command (from `Event::Frontend`).
+pub fn frontend(app: &mut EffectcraftApp, ctx: &egui::Context, id: &str, p: Value) -> Result {
+ let now = ctx.input(|i| i.time);
+ let v = &mut app.ui.viewer;
+ Ok(match id {
+ "app.about" => {
+ app.dialog = Some(crate::Dialog::About);
+ Value::Null
+ }
+ "app.settings" => {
+ app.dialog_state.settings_page = p.get("page").and_then(Value::as_str).unwrap_or("general").to_string();
+ app.dialog = Some(crate::Dialog::Settings);
+ Value::Null
+ }
+ "app.hide" => {
+ ctx.send_viewport_cmd(egui::ViewportCommand::Minimized(true));
+ Value::Null
+ }
+ "app.quit" => {
+ ctx.send_viewport_cmd(egui::ViewportCommand::Close);
+ Value::Null
+ }
+ "app.commandPalette" => {
+ app.dialog_state.palette_query = p.get("query").and_then(Value::as_str).unwrap_or_default().to_string();
+ app.dialog_state.palette_sel = 0;
+ app.dialog = Some(crate::Dialog::CommandPalette);
+ Value::Null
+ }
+ "app.keyboardShortcuts" => {
+ app.dialog = Some(crate::Dialog::Shortcuts);
+ Value::Null
+ }
+ "app.templates" => {
+ let kind = p.get("kind").and_then(Value::as_str).unwrap_or("renderSettings");
+ let title = if kind == "outputModule" { "Output Module Templates" } else { "Render Settings Templates" };
+ crate::panels::dialogs::info(app, title, "Render and output templates are managed from the Render Queue panel (Window ▸ Render Queue).");
+ Value::Null
+ }
+ "app.find" => {
+ if let Some(q) = p.get("query").and_then(Value::as_str) {
+ app.ui.project_search = q.to_string();
+ }
+ app.show_panel(PanelKind::Project);
+ Value::Null
+ }
+ "playback.toggle" => {
+ app.toggle_play(now);
+ json!({"playing": app.playback.playing})
+ }
+ "playback.cacheWhenIdle" => toggle(&mut app.ui.cache_when_idle, &p),
+ "view.zoomIn" | "view.zoomOut" => {
+ let cur = v.zoom.unwrap_or_else(|| crate::panels::viewer::last_fit(ctx));
+ const STEPS: [f32; 16] = [0.015, 0.03, 0.0625, 0.125, 0.25, 0.333, 0.5, 0.66, 1.0, 1.5, 2.0, 3.0, 4.0, 8.0, 16.0, 32.0];
+ let next = if id == "view.zoomIn" {
+ STEPS.iter().copied().find(|s| *s > cur + 1e-3).unwrap_or(32.0)
+ } else {
+ STEPS.iter().rev().copied().find(|s| *s < cur - 1e-3).unwrap_or(0.015)
+ };
+ v.zoom = Some(next);
+ json!({"zoom": next})
+ }
+ "view.res.full" | "view.res.half" | "view.res.third" | "view.res.quarter" => {
+ let r = id.trim_start_matches("view.res.");
+ v.res = Resolution::ALL.into_iter().find(|x| x.label().eq_ignore_ascii_case(r)).ok_or("unknown resolution")?;
+ Value::Null
+ }
+ "view.rulers" => toggle(&mut v.rulers, &p),
+ "view.guides" => toggle(&mut v.guides, &p),
+ "view.snapToGuides" => toggle(&mut v.snap_guides, &p),
+ "view.lockGuides" => toggle(&mut v.lock_guides, &p),
+ "view.grid" => toggle(&mut v.grid, &p),
+ "view.snapToGrid" => toggle(&mut v.snap_grid, &p),
+ "view.layerControls" => toggle(&mut v.show_layer_controls, &p),
+ "view.options" => {
+ app.dialog = Some(crate::Dialog::ViewOptions);
+ Value::Null
+ }
+ "view.panelBackground" => {
+ if p.get("pick").and_then(Value::as_bool) == Some(true) {
+ let [r, g, b] = v.custom_pasteboard;
+ crate::panels::dialogs::form(
+ app,
+ "Panel Background Color",
+ "view.panelBackground",
+ json!({}),
+ vec![crate::panels::dialogs::Field::text("color", "Color (#rrggbb)", &format!("#{r:02x}{g:02x}{b:02x}"))],
+ );
+ return Ok(Value::Null);
+ }
+ let c = p.get("color").and_then(Value::as_str).unwrap_or("mediumGray");
+ v.pasteboard = match c {
+ "black" => Some([0, 0, 0]),
+ "darkGray" => Some([0x2a, 0x2a, 0x2a]),
+ "mediumGray" => None,
+ "lightGray" => Some([0xb4, 0xb4, 0xb4]),
+ "white" => Some([0xff, 0xff, 0xff]),
+ "custom" => Some(v.custom_pasteboard),
+ hex => {
+ let c = effectcraft_engine::color::Rgba::from_hex(hex).ok_or_else(|| format!("unknown colour `{hex}`"))?;
+ let rgb = [(c.r * 255.0).round() as u8, (c.g * 255.0).round() as u8, (c.b * 255.0).round() as u8];
+ v.custom_pasteboard = rgb;
+ Some(rgb)
+ }
+ };
+ Value::Null
+ }
+ "view.fullScreen" => {
+ let full = ctx.input(|i| i.viewport().fullscreen.unwrap_or(false));
+ ctx.send_viewport_cmd(egui::ViewportCommand::Fullscreen(!full));
+ json!(!full)
+ }
+ "window.panel" => {
+ let name = p.get("panel").and_then(Value::as_str).unwrap_or_default();
+ if name.eq_ignore_ascii_case("tools") {
+ app.ui.status = "The Tools panel is the toolbar in the header".into();
+ return Ok(Value::Null);
+ }
+ let panel = PanelKind::from_name(name).ok_or_else(|| format!("unknown panel `{name}`"))?;
+ app.show_panel(panel);
+ Value::Null
+ }
+ "window.workspace" => {
+ let want = p.get("name").and_then(Value::as_str).unwrap_or("Default").to_ascii_lowercase().replace(' ', "");
+ let name = crate::dock::WORKSPACES
+ .iter()
+ .find(|w| w.to_ascii_lowercase().replace(' ', "") == want)
+ .ok_or_else(|| format!("unknown workspace `{want}`"))?;
+ app.set_workspace(name);
+ json!({"workspace": name})
+ }
+ "window.resetWorkspace" => {
+ let name = app.ui.workspace.clone();
+ app.set_workspace(&name);
+ Value::Null
+ }
+ "comp.flowchart" | "comp.miniFlowchart" => {
+ app.show_panel(PanelKind::Flowchart);
+ Value::Null
+ }
+ "layer.openLayer" => {
+ app.show_panel(PanelKind::Layer);
+ Value::Null
+ }
+ "effect.manage" | "anim.browsePresets" => {
+ app.show_panel(PanelKind::EffectsPresets);
+ Value::Null
+ }
+ "timeline.revealProps" => {
+ let props = p.get("props").and_then(Value::as_array).cloned().unwrap_or_default();
+ let tl = &mut app.ui.timeline;
+ tl.reveal_props = props.iter().filter_map(|x| x.get("prop").and_then(Value::as_u64)).collect();
+ tl.open_layers = props.iter().filter_map(|x| x.get("layer").and_then(Value::as_u64)).collect();
+ tl.reveal = if tl.reveal_props.is_empty() { vec![] } else { vec!["props".into()] };
+ json!({"revealed": tl.reveal_props.len()})
+ }
+ _ => return Err(format!("`{id}` is not a frontend command")),
+ })
+}
+
+/// Commands that need a file or folder path: ask the host's file dialog when `params` lacks one.
+fn file_dialog(app: &mut EffectcraftApp, id: &str, params: &Value) -> Option> {
+ enum Ask {
+ Import,
+ OpenProject,
+ Save(&'static str),
+ Open(&'static [&'static str]),
+ }
+ let (key, ask) = match id {
+ "file.import" | "file.importMultiple" => ("paths", Ask::Import),
+ "file.open" => ("path", Ask::OpenProject),
+ "file.save" if app.session.path.is_none() => ("path", Ask::Save("Untitled Project.ecproj")),
+ "file.saveAs" | "file.saveCopy" => ("path", Ask::Save("Untitled Project.ecproj")),
+ "comp.saveFrameAs" => ("path", Ask::Save("Frame.png")),
+ "anim.savePreset" => ("path", Ask::Save("Preset.ecpreset")),
+ "anim.applyPreset" => ("path", Ask::Open(&["ecpreset", "json"])),
+ "view.exportGuides" => ("path", Ask::Save("Guides.json")),
+ "view.importGuides" => ("path", Ask::Open(&["json"])),
+ "file.runScript" => ("path", Ask::Open(&["jsonl", "json", "txt"])),
+ "file.replaceFootage" => ("path", Ask::Import),
+ "file.collectFiles" => ("folder", Ask::Save("Collected Files")),
+ _ => return None,
+ };
+ if params.get(key).is_some()
+ || params.get("path").is_some()
+ || params.get("paths").is_some()
+ || params.get("steps").is_some()
+ || params.get("preset").is_some()
+ {
+ return None;
+ }
+ let mut p = params.as_object().cloned().unwrap_or_default();
+ let picked: Option = match ask {
+ Ask::Import => {
+ let Some(f) = app.hooks.pick_files.as_ref() else { return Some(Err("no file dialog available (pass `paths`)".into())) };
let paths = f(&[
"mp4", "mov", "m4v", "mkv", "webm", "png", "jpg", "jpeg", "gif", "webp", "tif", "tiff", "bmp", "exr", "wav", "aif", "aiff", "mp3", "flac",
"ogg", "opus", "svg",
]);
- if paths.is_empty() {
- return Ok(Value::Null);
- }
- app.session.execute("file.import", json!({"paths": paths})).map_err(|e| e.to_string())
- }
- "file.open" => {
- let f = app.hooks.pick_open_project.as_ref().ok_or("no file dialog available (pass `path`)")?;
- match f() {
- Some(p) => app.session.execute("file.open", json!({"path": p})).map_err(|e| e.to_string()),
- None => Ok(Value::Null),
+ match (paths.is_empty(), key) {
+ (true, _) => None,
+ (false, "paths") => Some(json!(paths)),
+ (false, _) => paths.first().map(|s| json!(s)),
}
}
- _ => {
- let f = app.hooks.pick_save.as_ref().ok_or("no file dialog available (pass `path`)")?;
- match f("Untitled Project.ecproj") {
- Some(p) => app.session.execute("file.saveAs", json!({"path": p})).map_err(|e| e.to_string()),
- None => Ok(Value::Null),
- }
+ Ask::OpenProject => {
+ let Some(f) = app.hooks.pick_open_project.as_ref() else { return Some(Err("no file dialog available (pass `path`)".into())) };
+ f().map(|s| json!(s))
}
+ Ask::Open(exts) => {
+ let Some(f) = app.hooks.pick_files.as_ref() else { return Some(Err("no file dialog available (pass `path`)".into())) };
+ f(exts).first().map(|s| json!(s))
+ }
+ Ask::Save(default) => {
+ let Some(f) = app.hooks.pick_save.as_ref() else { return Some(Err("no file dialog available (pass `path`)".into())) };
+ f(default).map(|s| json!(s))
+ }
+ };
+ let Some(v) = picked else { return Some(Ok(Value::Null)) };
+ p.insert(key.to_string(), v);
+ // Save (untitled) becomes Save As.
+ let id = if id == "file.save" { "file.saveAs" } else { id };
+ let r = app.session.execute(id, Value::Object(p)).map_err(|e| e.to_string());
+ if let Err(e) = &r {
+ app.ui.status = e.clone();
}
+ Some(r)
}
/// A menu entry for display / `ui.menu.list`.
@@ -308,70 +483,89 @@ pub struct MenuItem {
pub path: Vec,
pub shortcut: Option,
pub enabled: bool,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub checked: Option,
/// Parameters bound to the entry (e.g. the effect for Effect menu items).
#[serde(skip_serializing_if = "Value::is_null")]
pub params: Value,
}
-pub const MENUS: [&str; 9] = ["File", "Edit", "Composition", "Layer", "Effect", "Animation", "View", "Window", "Help"];
+/// Top-level menus in order.
+pub fn menus() -> Vec<&'static str> {
+ effectcraft_engine::menus::top_level()
+}
+fn entry_label(app: &EffectcraftApp, e: &MenuEntry) -> String {
+ match e.command.as_str() {
+ "edit.undo" => app.session.history.undo.last().map(|u| format!("Undo {}", u.0)).unwrap_or_else(|| "Can't Undo".into()),
+ "edit.redo" => app.session.history.redo.last().map(|u| format!("Redo {}", u.0)).unwrap_or_else(|| "Can't Redo".into()),
+ _ => e.label.clone(),
+ }
+}
+
+/// Check-mark state of frontend toggles (engine state is answered by the engine).
+fn entry_checked(app: &EffectcraftApp, e: &MenuEntry) -> Option {
+ let v = &app.ui.viewer;
+ let pstr = |k: &str| e.params.get(k).and_then(Value::as_str);
+ match e.command.as_str() {
+ "view.rulers" => Some(v.rulers),
+ "view.guides" => Some(v.guides),
+ "view.snapToGuides" => Some(v.snap_guides),
+ "view.lockGuides" => Some(v.lock_guides),
+ "view.grid" => Some(v.grid),
+ "view.snapToGrid" => Some(v.snap_grid),
+ "view.layerControls" => Some(v.show_layer_controls),
+ "playback.cacheWhenIdle" => Some(app.ui.cache_when_idle),
+ "view.res.full" | "view.res.half" | "view.res.third" | "view.res.quarter" => {
+ Some(v.res.label().eq_ignore_ascii_case(e.command.trim_start_matches("view.res.")))
+ }
+ "window.workspace" => Some(pstr("name").is_some_and(|n| n == app.ui.workspace)),
+ "view.panelBackground" if e.params.get("pick").is_none() => {
+ let cur = match v.pasteboard {
+ None => "mediumGray",
+ Some([0, 0, 0]) => "black",
+ Some([0x2a, 0x2a, 0x2a]) => "darkGray",
+ Some([0xb4, 0xb4, 0xb4]) => "lightGray",
+ Some([0xff, 0xff, 0xff]) => "white",
+ Some(_) => "custom",
+ };
+ Some(pstr("color") == Some(cur))
+ }
+ _ => effectcraft_engine::menus::checked(&app.session, &e.command, &e.params),
+ }
+}
+
+fn entry_enabled(app: &EffectcraftApp, e: &MenuEntry) -> bool {
+ if e.command == "window.panel" {
+ return true;
+ }
+ app.session.is_enabled(&e.command)
+}
+
+/// Every menu entry, flattened with its submenu path.
pub fn menu_items(app: &EffectcraftApp) -> Vec {
- let mut out = Vec::new();
- for c in effectcraft_engine::command_specs() {
- if c.menu.is_empty() {
- continue;
- }
- out.push(MenuItem {
- id: c.id.into(),
- label: c.label.into(),
- path: c.menu.iter().map(|s| s.to_string()).collect(),
- shortcut: c.shortcut.map(str::to_string),
- enabled: app.session.is_enabled(c.id),
- params: Value::Null,
- });
- }
- for c in UI_COMMANDS {
- if c.menu.is_empty() {
- continue;
- }
- out.push(MenuItem {
- id: c.id.into(),
- label: c.label.into(),
- path: c.menu.iter().map(|s| s.to_string()).collect(),
- shortcut: c.shortcut.map(str::to_string),
- enabled: true,
- params: Value::Null,
- });
- }
- for p in PanelKind::ALL {
- out.push(MenuItem {
- id: panel_command_id(p),
- label: p.title().into(),
- path: vec!["Window".into()],
- shortcut: p.window_shortcut().map(str::to_string),
- enabled: true,
- params: Value::Null,
- });
- }
- let has_layer = !app.session.state.selected_layers.is_empty();
- for e in effectcraft_engine::effects::registry() {
- out.push(MenuItem {
- id: "effect.apply".into(),
- label: e.name.into(),
- path: vec!["Effect".into(), e.category.into()],
- shortcut: None,
- enabled: has_layer,
- params: json!({"effect": e.id}),
- });
- }
- out
+ effectcraft_engine::menus::entries()
+ .into_iter()
+ .map(|(path, e)| MenuItem {
+ id: e.command.clone(),
+ label: entry_label(app, e),
+ path,
+ shortcut: e.shortcut.clone(),
+ enabled: entry_enabled(app, e),
+ checked: entry_checked(app, e),
+ params: e.params.clone(),
+ })
+ .collect()
}
/// Shortcut text in this OS's notation (`⇧⌘K` on macOS, `Ctrl+Shift+K` elsewhere).
pub fn shortcut_text(s: &str) -> String {
if cfg!(target_os = "macos") {
let mut out = String::new();
- let parts: Vec<&str> = s.split('+').collect();
+ let parts: Vec<&str> = match s.strip_suffix("++") {
+ Some(head) => vec![head, "+"],
+ None => s.split('+').collect(),
+ };
let (mods, key) = parts.split_at(parts.len().saturating_sub(1));
for m in mods {
out.push_str(match *m {
@@ -382,7 +576,12 @@ pub fn shortcut_text(s: &str) -> String {
x => x,
});
}
- out.push_str(key.first().copied().unwrap_or(""));
+ out.push_str(match key.first().copied().unwrap_or("") {
+ "Space" => "Space",
+ "Escape" => "Esc",
+ "Home" => "↖",
+ k => k,
+ });
out
} else {
s.replace("Cmd", "Ctrl")
@@ -429,22 +628,53 @@ pub fn parse_shortcut(s: &str) -> Option<(egui::Modifiers, egui::Key)> {
key.map(|k| (m, k))
}
+/// The key some keyboards report for a shifted punctuation key (`Shift+=` arrives as `+`).
+fn shifted_alias(k: egui::Key) -> Option {
+ use egui::Key::*;
+ Some(match k {
+ Equals => Plus,
+ Semicolon => Colon,
+ OpenBracket => OpenCurlyBracket,
+ CloseBracket => CloseCurlyBracket,
+ Slash => Questionmark,
+ Backslash => Pipe,
+ _ => return None,
+ })
+}
+
+/// A key binding: modifiers, key, command id and bound params.
+pub type Binding = (egui::Modifiers, egui::Key, String, Value);
+
/// All active bindings, most modifiers first.
-pub fn bindings() -> Vec<(egui::Modifiers, egui::Key, String)> {
- let mut v: Vec<(egui::Modifiers, egui::Key, String)> = Vec::new();
+pub fn bindings() -> Vec {
+ let mut v: Vec = Vec::new();
+ let mut push = |sc: &str, id: &str, params: Value| {
+ if let Some((m, k)) = parse_shortcut(sc) {
+ if m.shift
+ && let Some(alias) = shifted_alias(k)
+ {
+ v.push((m, alias, id.to_string(), params.clone()));
+ }
+ v.push((m, k, id.to_string(), params));
+ }
+ };
+ // Menu entries (their shortcuts may bind params), then command defaults not in the menus.
+ let entries = effectcraft_engine::menus::entries();
+ for (_, e) in &entries {
+ if let Some(sc) = &e.shortcut {
+ push(sc, &e.command, e.params.clone());
+ }
+ }
for c in effectcraft_engine::command_specs() {
- if let Some((m, k)) = c.shortcut.and_then(parse_shortcut) {
- v.push((m, k, c.id.to_string()));
+ if let Some(sc) = c.shortcut
+ && !entries.iter().any(|(_, e)| e.command == c.id)
+ {
+ push(sc, c.id, Value::Null);
}
}
for c in UI_COMMANDS {
- if let Some((m, k)) = c.shortcut.and_then(parse_shortcut) {
- v.push((m, k, c.id.to_string()));
- }
- }
- for p in PanelKind::ALL {
- if let Some((m, k)) = p.window_shortcut().and_then(parse_shortcut) {
- v.push((m, k, panel_command_id(p)));
+ if let Some(sc) = c.shortcut {
+ push(sc, c.id, Value::Null);
}
}
v.sort_by_key(|(m, ..)| std::cmp::Reverse(m.command as u8 + m.shift as u8 + m.alt as u8 + m.ctrl as u8));
@@ -491,57 +721,30 @@ pub fn handle_shortcuts(app: &mut EffectcraftApp, ctx: &egui::Context) {
let _ = invoke(app, ctx, "edit.clear", json!({}));
continue;
}
- if let Some((_, _, id)) = binds.iter().find(|(m, k, _)| *k == key && mods_match(*m, mods)) {
- let id = id.clone();
- if let Err(e) = invoke(app, ctx, &id, json!({})) {
+ if let Some((_, _, id, params)) = binds.iter().find(|(m, k, ..)| *k == key && mods_match(*m, mods)) {
+ let (id, params) = (id.clone(), if params.is_null() { json!({}) } else { params.clone() });
+ if let Err(e) = invoke(app, ctx, &id, params) {
app.ui.status = e;
}
}
}
}
-/// Draw the in-window menu bar.
+/// Draw the in-window menu bar (the engine's AE menu tree).
pub fn menu_bar(app: &mut EffectcraftApp, ui: &mut egui::Ui) {
- let items = menu_items(app);
let ctx = ui.ctx().clone();
let mut clicked: Option<(String, Value)> = None;
ui.horizontal_centered(|ui| {
ui.add_space(6.0);
egui::MenuBar::new().ui(ui, |ui| {
- for top in MENUS {
- let mine: Vec<&MenuItem> = items.iter().filter(|i| i.path.first().map(String::as_str) == Some(top)).collect();
- ui.menu_button(top, |ui| {
- ui.set_min_width(260.0);
- let mut subs: Vec<&str> = Vec::new();
- let mut last_was_sub = false;
- for it in &mine {
- if it.path.len() > 1 {
- let sub = it.path[1].as_str();
- if !subs.contains(&sub) {
- subs.push(sub);
- ui.menu_button(sub, |ui| {
- ui.set_min_width(220.0);
- for s in mine.iter().filter(|x| x.path.get(1).map(String::as_str) == Some(sub)) {
- if menu_entry(ui, s) {
- clicked = Some((s.id.clone(), s.params.clone()));
- ui.close();
- }
- }
- });
- last_was_sub = true;
- }
- } else {
- if last_was_sub && top != "Effect" {
- ui.separator();
- last_was_sub = false;
- }
- if menu_entry(ui, it) {
- clicked = Some((it.id.clone(), it.params.clone()));
- ui.close();
- }
- }
- }
- });
+ for node in effectcraft_engine::menus::menu_bar() {
+ if let MenuNode::Submenu { label, children } = node {
+ let r = ui.menu_button(label, |ui| {
+ ui.set_min_width(if label == "Effect" { 200.0 } else { 280.0 });
+ menu_nodes(app, ui, children, &mut clicked);
+ });
+ app.auto.add(&format!("menu.{label}"), r.response.rect, label);
+ }
}
});
});
@@ -552,10 +755,81 @@ pub fn menu_bar(app: &mut EffectcraftApp, ui: &mut egui::Ui) {
}
}
-fn menu_entry(ui: &mut egui::Ui, it: &MenuItem) -> bool {
- let mut b = egui::Button::new(&it.label);
- if let Some(s) = &it.shortcut {
+fn menu_nodes(app: &mut EffectcraftApp, ui: &mut egui::Ui, nodes: &[MenuNode], clicked: &mut Option<(String, Value)>) {
+ for n in nodes {
+ match n {
+ MenuNode::Separator => {
+ ui.separator();
+ }
+ MenuNode::Submenu { label, children } => {
+ ui.menu_button((gutter(false), label.as_str()), |ui| {
+ ui.set_min_width(if children.len() > 30 { 200.0 } else { 240.0 });
+ // Long submenus (Blending Mode, effect categories) scroll instead of running
+ // off the screen.
+ let max_h = ui.ctx().content_rect().height() - 40.0;
+ egui::ScrollArea::vertical().max_height(max_h).show(ui, |ui| menu_nodes(app, ui, children, clicked));
+ });
+ }
+ MenuNode::Item(e) => {
+ if menu_entry(app, ui, e) {
+ *clicked = Some((e.command.clone(), e.params.clone()));
+ ui.close();
+ }
+ }
+ }
+ }
+}
+
+/// The check-mark column every menu row reserves (like macOS / After Effects menus).
+fn gutter(checked: bool) -> egui::Atom<'static> {
+ use egui::AtomExt;
+ (if checked { "✔" } else { "" }).atom_size(egui::vec2(14.0, 14.0))
+}
+
+fn menu_entry(app: &EffectcraftApp, ui: &mut egui::Ui, e: &MenuEntry) -> bool {
+ let label = entry_label(app, e);
+ let mut b = egui::Button::new((gutter(entry_checked(app, e) == Some(true)), label));
+ if let Some(s) = &e.shortcut {
b = b.shortcut_text(shortcut_text(s));
}
- ui.add_enabled(it.enabled, b).clicked()
+ ui.add_enabled(entry_enabled(app, e), b).clicked()
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn every_ui_shortcut_parses() {
+ for c in UI_COMMANDS {
+ if let Some(sc) = c.shortcut {
+ assert!(parse_shortcut(sc).is_some() || sc == "Num*", "{sc}");
+ }
+ }
+ for (_, e) in effectcraft_engine::menus::entries() {
+ if let Some(sc) = &e.shortcut {
+ assert!(parse_shortcut(sc).is_some() || sc == "Num*", "{} ({sc})", e.label);
+ }
+ }
+ }
+
+ #[test]
+ fn ui_and_menu_shortcuts_do_not_collide() {
+ let mut seen: std::collections::BTreeMap<(String, String), (String, String)> = Default::default();
+ for (m, k, id, params) in bindings() {
+ let key = (format!("{m:?}"), format!("{k:?}"));
+ let target = (id.clone(), params.to_string());
+ if let Some(prev) = seen.get(&key) {
+ assert_eq!(prev, &target, "{key:?} bound to {prev:?} and {target:?}");
+ } else {
+ seen.insert(key, target);
+ }
+ }
+ }
+
+ #[test]
+ fn menu_items_cover_the_tree() {
+ assert_eq!(menus().last(), Some(&"Help"));
+ assert!(effectcraft_engine::menus::entries().len() > 500);
+ }
}
diff --git a/crates/ui-egui/src/panels/dialogs.rs b/crates/ui-egui/src/panels/dialogs.rs
index 87a2a2cfd..9b401c2ad 100644
--- a/crates/ui-egui/src/panels/dialogs.rs
+++ b/crates/ui-egui/src/panels/dialogs.rs
@@ -4,9 +4,10 @@
use egui::{Align2, Color32, Rect, Sense, pos2, vec2};
use serde_json::json;
+pub use super::forms::{Field, form, info, open_form};
use crate::icons::{self, Icon};
use crate::theme::Tokens;
-use crate::{Dialog, EffectcraftApp, widgets};
+use crate::{Dialog, EffectcraftApp};
#[derive(Clone, Debug)]
pub struct CompDraft {
@@ -34,6 +35,12 @@ pub struct DialogState {
pub solid_size: [u32; 2],
pub palette_query: String,
pub palette_sel: usize,
+ /// Settings dialog page id (`general`, `appearance`…).
+ pub settings_page: String,
+ /// The open parameter form.
+ pub form: super::forms::Form,
+ /// Message box (title, body).
+ pub info: (String, String),
}
pub fn open_new_comp(app: &mut EffectcraftApp) {
@@ -72,7 +79,7 @@ pub fn open_new_solid(app: &mut EffectcraftApp) -> Result<(), String> {
Ok(())
}
-fn modal(ctx: &egui::Context, title: &str, size: egui::Vec2, t: &Tokens, body: impl FnOnce(&mut egui::Ui)) {
+pub(crate) fn modal(ctx: &egui::Context, title: &str, size: egui::Vec2, t: &Tokens, body: impl FnOnce(&mut egui::Ui)) {
// Dim the app.
let screen = ctx.content_rect();
ctx.layer_painter(egui::LayerId::new(egui::Order::Middle, egui::Id::new("modal-dim"))).rect_filled(screen, 0.0, Color32::from_black_alpha(120));
@@ -95,6 +102,11 @@ pub fn show(app: &mut EffectcraftApp, ctx: &egui::Context) {
Dialog::NewComp | Dialog::CompSettings => comp_settings(app, ctx, &t, d == Dialog::CompSettings),
Dialog::SolidSettings => solid(app, ctx, &t),
Dialog::CommandPalette => palette(app, ctx, &t),
+ Dialog::Settings => super::forms::show_settings(app, ctx, &t),
+ Dialog::Shortcuts => super::forms::show_shortcuts(app, ctx, &t),
+ Dialog::Form => super::forms::show_form(app, ctx, &t),
+ Dialog::Info => super::forms::show_info(app, ctx, &t),
+ Dialog::ViewOptions => super::forms::show_view_options(app, ctx, &t),
}
}
diff --git a/crates/ui-egui/src/panels/forms.rs b/crates/ui-egui/src/panels/forms.rs
new file mode 100644
index 000000000..b02340b35
--- /dev/null
+++ b/crates/ui-egui/src/panels/forms.rs
@@ -0,0 +1,547 @@
+//! Menu dialogs: a generic parameter form (numeric Transform dialogs, Mask Feather/Opacity/
+//! Expansion, Auto-Orient, Go to Time, Add Guide, Sequence Layers, Interpret Footage, Project
+//! Settings, placeholders…), Settings (Preferences), Keyboard Shortcuts, View Options and simple
+//! message boxes. Every form runs an engine command with the collected parameters, so whatever a
+//! dialog does an agent can do with one `engine.execute`.
+
+use egui::{Color32, vec2};
+use serde_json::{Map, Value, json};
+
+use crate::theme::Tokens;
+use crate::{Dialog, EffectcraftApp};
+
+#[derive(Clone, Debug)]
+pub enum FieldKind {
+ Number {
+ value: f64,
+ speed: f64,
+ },
+ Text(String),
+ Bool(bool),
+ /// Options as (label, value); `sel` is the chosen index.
+ Choice {
+ options: Vec<(String, Value)>,
+ sel: usize,
+ },
+}
+
+/// One form field. `key` may index into an array param (`value[1]`).
+#[derive(Clone, Debug)]
+pub struct Field {
+ pub key: String,
+ pub label: String,
+ pub kind: FieldKind,
+}
+
+impl Field {
+ pub fn num(key: &str, label: &str, value: f64) -> Field {
+ Field { key: key.into(), label: label.into(), kind: FieldKind::Number { value, speed: 1.0 } }
+ }
+ pub fn text(key: &str, label: &str, value: &str) -> Field {
+ Field { key: key.into(), label: label.into(), kind: FieldKind::Text(value.into()) }
+ }
+ pub fn bool(key: &str, label: &str, value: bool) -> Field {
+ Field { key: key.into(), label: label.into(), kind: FieldKind::Bool(value) }
+ }
+ pub fn choice(key: &str, label: &str, options: &[(&str, Value)], sel: usize) -> Field {
+ Field {
+ key: key.into(),
+ label: label.into(),
+ kind: FieldKind::Choice { options: options.iter().map(|(l, v)| (l.to_string(), v.clone())).collect(), sel },
+ }
+ }
+}
+
+#[derive(Clone, Debug, Default)]
+pub struct Form {
+ pub title: String,
+ pub command: String,
+ pub base: Value,
+ pub fields: Vec,
+}
+
+impl Form {
+ /// The command parameters: `base` plus every field.
+ pub fn params(&self) -> Value {
+ let mut m: Map = self.base.as_object().cloned().unwrap_or_default();
+ for f in &self.fields {
+ let v = match &f.kind {
+ FieldKind::Number { value, .. } => json!(value),
+ FieldKind::Text(s) => json!(s),
+ FieldKind::Bool(b) => json!(b),
+ FieldKind::Choice { options, sel } => options.get(*sel).map(|o| o.1.clone()).unwrap_or(Value::Null),
+ };
+ match f.key.split_once('[') {
+ Some((name, idx)) => {
+ let i: usize = idx.trim_end_matches(']').parse().unwrap_or(0);
+ let arr = m.entry(name.to_string()).or_insert_with(|| json!([]));
+ if let Value::Array(a) = arr {
+ while a.len() <= i {
+ a.push(json!(0));
+ }
+ a[i] = v;
+ }
+ }
+ None => {
+ m.insert(f.key.clone(), v);
+ }
+ }
+ }
+ Value::Object(m)
+ }
+}
+
+/// Open a form dialog.
+pub fn form(app: &mut EffectcraftApp, title: &str, command: &str, base: Value, fields: Vec) {
+ app.dialog_state.form = Form { title: title.into(), command: command.into(), base, fields };
+ app.dialog = Some(Dialog::Form);
+}
+
+/// Open a message box.
+pub fn info(app: &mut EffectcraftApp, title: &str, body: &str) {
+ app.dialog_state.info = (title.into(), body.into());
+ app.dialog = Some(Dialog::Info);
+}
+
+fn has(p: &Value, keys: &[&str]) -> bool {
+ keys.iter().any(|k| p.get(*k).is_some())
+}
+
+/// If `id` is a dialog command invoked without its parameters, open its form and return true.
+pub fn open_form(app: &mut EffectcraftApp, id: &str, p: &Value) -> bool {
+ let s = &app.session;
+ let comp = s.active_comp();
+ let layer = comp.and_then(|c| s.state.selected_layers.first().and_then(|l| c.layer(*l)));
+ let t = s.time();
+ let lt = layer.map(|l| l.layer_time(t)).unwrap_or(t);
+ let base = p.clone();
+ let (title, fields): (String, Vec) = match id {
+ "layer.setTransform" if !has(p, &["value"]) => {
+ let prop = p.get("prop").and_then(Value::as_str).unwrap_or("position");
+ let cur = layer.and_then(|l| l.transform()).and_then(|tr| tr.get(if prop == "anchorPoint" { "anchor" } else { prop })).map(|pr| pr.value_at(lt));
+ let v = cur.map(|c| c.as_vec3()).unwrap_or([0.0; 3]);
+ let three = layer.is_some_and(|l| l.is_3d());
+ let title = match prop {
+ "anchor" => "Anchor Point",
+ "position" => "Position",
+ "scale" => "Scale",
+ "orientation" => "Orientation",
+ "rotation" => "Rotation",
+ _ => "Opacity",
+ };
+ let fields = match prop {
+ "rotation" | "opacity" => vec![Field::num("value", if prop == "rotation" { "Degrees" } else { "Opacity (%)" }, v[0])],
+ "orientation" => vec![Field::num("value[0]", "X", v[0]), Field::num("value[1]", "Y", v[1]), Field::num("value[2]", "Z", v[2])],
+ _ if three => vec![Field::num("value[0]", "X", v[0]), Field::num("value[1]", "Y", v[1]), Field::num("value[2]", "Z", v[2])],
+ _ => vec![Field::num("value[0]", "X", v[0]), Field::num("value[1]", "Y", v[1])],
+ };
+ (title.into(), fields)
+ }
+ "layer.mask.set" if !has(p, &["value"]) => {
+ let field = p.get("field").and_then(Value::as_str).unwrap_or("feather");
+ let first = layer.and_then(|l| l.masks()).and_then(|m| m.groups().next()).and_then(|g| g.get(field)).map(|pr| pr.value_at(lt).as_f64());
+ let (title, label, d) = match field {
+ "feather" => ("Mask Feather", "Feather (pixels)", 0.0),
+ "opacity" => ("Mask Opacity", "Opacity (%)", 100.0),
+ _ => ("Mask Expansion", "Expansion (pixels)", 0.0),
+ };
+ (title.into(), vec![Field::num("value", label, first.unwrap_or(d))])
+ }
+ "layer.mask.shape" if !has(p, &["rect"]) => {
+ let (w, h) = layer.map(|l| effectcraft_engine::render::source_size(&s.project, l)).unwrap_or((100, 100));
+ (
+ "Mask Shape".into(),
+ vec![
+ Field::num("rect[0]", "Left", 0.0),
+ Field::num("rect[1]", "Top", 0.0),
+ Field::num("rect[2]", "Width", w as f64),
+ Field::num("rect[3]", "Height", h as f64),
+ Field::choice("shape", "Shape", &[("Rectangle", json!("rect")), ("Ellipse", json!("ellipse"))], 0),
+ ],
+ )
+ }
+ "layer.autoOrient" if !has(p, &["mode"]) => {
+ let cur = layer.map(|l| l.auto_orient as usize).unwrap_or(0);
+ (
+ "Auto-Orientation".into(),
+ vec![Field::choice(
+ "mode",
+ "Mode",
+ &[
+ ("Off", json!("off")),
+ ("Orient Along Path", json!("alongPath")),
+ ("Orient Towards Camera", json!("towardsCamera")),
+ ("Orient Towards Point of Interest", json!("towardsPointOfInterest")),
+ ],
+ cur.min(3),
+ )],
+ )
+ }
+ "time.set" if !has(p, &["time", "frame", "timecode"]) => {
+ let frame = comp.map(|c| c.frame_rate.frame_at(t)).unwrap_or(0);
+ ("Go to Time".into(), vec![Field::num("frame", "Frame", frame as f64)])
+ }
+ "view.addGuide" if !has(p, &["position"]) => {
+ let (w, _) = comp.map(|c| (c.width, c.height)).unwrap_or((1920, 1080));
+ (
+ "Add Guide".into(),
+ vec![
+ Field::choice("orientation", "Orientation", &[("Vertical", json!("vertical")), ("Horizontal", json!("horizontal"))], 0),
+ Field::num("position", "Position (pixels)", w as f64 / 2.0),
+ ],
+ )
+ }
+ "layer.sequence" if !has(p, &["overlap"]) => (
+ "Sequence Layers".into(),
+ vec![
+ Field::bool("overlap", "Overlap", false),
+ Field::num("duration", "Duration (seconds)", 1.0),
+ Field::choice(
+ "transition",
+ "Transition",
+ &[
+ ("Off", json!("off")),
+ ("Dissolve Front Layer", json!("dissolveFront")),
+ ("Cross Dissolve Front and Back Layers", json!("crossDissolve")),
+ ],
+ 0,
+ ),
+ ],
+ ),
+ "file.interpretFootage" if !has(p, &["frameRate", "alpha", "loop", "pixelAspect"]) => {
+ let f = s.state.project_selection.first().and_then(|i| s.project.item(*i)).and_then(|it| match &it.kind {
+ effectcraft_engine::project::ItemKind::Footage(f) => Some(f.clone()),
+ _ => None,
+ });
+ let Some(f) = f else { return false };
+ (
+ "Interpret Footage".into(),
+ vec![
+ Field::num("frameRate", "Frame rate", f.frame_rate.as_f64()),
+ Field::choice(
+ "alpha",
+ "Alpha",
+ &[("Straight", json!("straight")), ("Premultiplied", json!("premultiplied")), ("Ignore", json!("ignore"))],
+ f.alpha as usize,
+ ),
+ Field::num("loop", "Loop (times)", f.loop_count as f64),
+ Field::num("pixelAspect", "Pixel aspect ratio", f.pixel_aspect),
+ ],
+ )
+ }
+ "file.projectSettings" if p.as_object().is_none_or(|m| m.is_empty()) => {
+ let st = &s.project.settings;
+ let depth = match st.bit_depth.label() {
+ l if l.starts_with("16") => 1,
+ l if l.starts_with("32") => 2,
+ _ => 0,
+ };
+ (
+ "Project Settings".into(),
+ vec![
+ Field::choice(
+ "bitDepth",
+ "Depth",
+ &[("8 bits per channel", json!(8)), ("16 bits per channel", json!(16)), ("32 bits per channel (float)", json!(32))],
+ depth,
+ ),
+ Field::choice(
+ "timeDisplay",
+ "Time display style",
+ &[("Timecode", json!("timecode")), ("Frames", json!("frames"))],
+ usize::from(matches!(st.time_display, effectcraft_engine::project::TimeDisplayStyle::Frames)),
+ ),
+ Field::bool("linearize", "Linearize working space", st.linearize),
+ ],
+ )
+ }
+ "layer.timeStretch" if !has(p, &["percent", "op"]) => {
+ ("Time Stretch".into(), vec![Field::num("percent", "Stretch factor (%)", layer.map(|l| l.stretch).unwrap_or(100.0))])
+ }
+ "layer.precompose" if !has(p, &["name"]) => {
+ let n = s.project.comps().count() + 1;
+ ("Pre-compose".into(), vec![Field::text("name", "New composition name", &format!("Pre-comp {n}"))])
+ }
+ "file.importPlaceholder" | "file.replaceWithPlaceholder" if p.as_object().is_none_or(|m| m.is_empty()) => (
+ "New Placeholder".into(),
+ vec![
+ Field::text("name", "Name", "Placeholder"),
+ Field::num("width", "Width", 1920.0),
+ Field::num("height", "Height", 1080.0),
+ Field::num("frameRate", "Frame rate", 29.97),
+ Field::num("duration", "Duration (seconds)", 30.0),
+ ],
+ ),
+ "file.importSolid" | "file.replaceWithSolid" if p.as_object().is_none_or(|m| m.is_empty()) => {
+ let (w, h) = comp.map(|c| (c.width, c.height)).unwrap_or((1920, 1080));
+ (
+ "Solid Settings".into(),
+ vec![
+ Field::text("name", "Name", "Solid"),
+ Field::text("color", "Color (#rrggbb)", "#808080"),
+ Field::num("width", "Width", w as f64),
+ Field::num("height", "Height", h as f64),
+ ],
+ )
+ }
+ _ => return false,
+ };
+ form(app, &title, id, base, fields);
+ true
+}
+
+pub fn show_form(app: &mut EffectcraftApp, ctx: &egui::Context, t: &Tokens) {
+ let mut f = app.dialog_state.form.clone();
+ let (mut ok, mut close) = (false, false);
+ let h = 120.0 + f.fields.len() as f32 * 30.0;
+ super::dialogs::modal(ctx, &f.title.clone(), vec2(440.0, h), t, |ui| {
+ egui::Grid::new("form-grid").num_columns(2).spacing([14.0, 10.0]).show(ui, |ui| {
+ for fl in &mut f.fields {
+ ui.label(&fl.label);
+ match &mut fl.kind {
+ FieldKind::Number { value, speed } => {
+ ui.add(egui::DragValue::new(value).speed(*speed).max_decimals(3));
+ }
+ FieldKind::Text(s) => {
+ ui.add(egui::TextEdit::singleline(s).desired_width(220.0));
+ }
+ FieldKind::Bool(b) => {
+ ui.checkbox(b, "");
+ }
+ FieldKind::Choice { options, sel } => {
+ let cur = options.get(*sel).map(|o| o.0.clone()).unwrap_or_default();
+ egui::ComboBox::from_id_salt(("form", fl.key.as_str())).selected_text(cur).width(240.0).show_ui(ui, |ui| {
+ for (i, (l, _)) in options.iter().enumerate() {
+ ui.selectable_value(sel, i, l);
+ }
+ });
+ }
+ }
+ ui.end_row();
+ }
+ });
+ ui.add_space(14.0);
+ ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
+ if ui.add(egui::Button::new(egui::RichText::new(" OK ").color(Color32::WHITE)).fill(t.accent)).clicked() {
+ ok = true;
+ }
+ if ui.button("Cancel").clicked() {
+ close = true;
+ }
+ });
+ });
+ let enter = !ctx.egui_wants_keyboard_input() && ctx.input(|i| i.key_pressed(egui::Key::Enter));
+ app.dialog_state.form = f.clone();
+ if ok || enter {
+ app.dialog = None;
+ let params = f.params();
+ if let Err(e) = app.session.execute(&f.command, params) {
+ app.ui.status = e.to_string();
+ }
+ return;
+ }
+ if close {
+ app.dialog = None;
+ }
+}
+
+pub fn show_info(app: &mut EffectcraftApp, ctx: &egui::Context, t: &Tokens) {
+ let (title, body) = app.dialog_state.info.clone();
+ let mut close = false;
+ super::dialogs::modal(ctx, &title, vec2(440.0, 160.0), t, |ui| {
+ ui.label(body);
+ ui.add_space(16.0);
+ ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
+ if ui.add(egui::Button::new(egui::RichText::new(" OK ").color(Color32::WHITE)).fill(t.accent)).clicked() {
+ close = true;
+ }
+ });
+ });
+ if close {
+ app.dialog = None;
+ }
+}
+
+pub const SETTINGS_PAGES: [(&str, &str); 17] = [
+ ("general", "General"),
+ ("startup", "Startup & Repair"),
+ ("project", "Project"),
+ ("composition", "Composition"),
+ ("previews", "Previews"),
+ ("appearance", "Appearance"),
+ ("grids", "Grids & Guides"),
+ ("labels", "Labels"),
+ ("type", "Type"),
+ ("import", "Import"),
+ ("export", "Export"),
+ ("audio", "Audio"),
+ ("disk", "Disk"),
+ ("memory", "Memory & CPU"),
+ ("video", "Video"),
+ ("3d", "3D"),
+ ("scripting", "Scripting & Expressions"),
+];
+
+pub fn show_settings(app: &mut EffectcraftApp, ctx: &egui::Context, t: &Tokens) {
+ let mut page = app.dialog_state.settings_page.clone();
+ let mut close = false;
+ let mut theme = None;
+ super::dialogs::modal(ctx, "Settings", vec2(640.0, 440.0), t, |ui| {
+ ui.horizontal_top(|ui| {
+ ui.vertical(|ui| {
+ ui.set_width(170.0);
+ for (id, label) in SETTINGS_PAGES {
+ if ui.selectable_label(page == id, label).clicked() {
+ page = id.to_string();
+ }
+ }
+ });
+ ui.separator();
+ ui.vertical(|ui| {
+ let title = SETTINGS_PAGES.iter().find(|p| p.0 == page).map(|p| p.1).unwrap_or("General");
+ ui.label(egui::RichText::new(title).font(Tokens::semibold(13.0)));
+ ui.add_space(8.0);
+ match page.as_str() {
+ "general" => {
+ ui.checkbox(&mut app.ui.show_menu_bar, "Show the in-window menu bar");
+ ui.checkbox(&mut app.ui.snapping, "Snapping");
+ }
+ "appearance" => {
+ for (k, name) in [("dark", "Dark"), ("darker", "Darker"), ("light", "Light")] {
+ if ui.button(name).clicked() {
+ theme = crate::theme::ThemeKind::from_name(k);
+ }
+ }
+ }
+ "previews" => {
+ ui.checkbox(&mut app.ui.cache_when_idle, "Cache frames when idle");
+ ui.checkbox(&mut app.ui.viewer.fast_preview, "Fast previews");
+ }
+ "grids" => {
+ ui.checkbox(&mut app.ui.viewer.grid, "Show grid");
+ ui.checkbox(&mut app.ui.viewer.guides, "Show guides");
+ ui.checkbox(&mut app.ui.viewer.safe_margins, "Show title/action safe");
+ }
+ "labels" => {
+ for l in effectcraft_engine::color::Label::ALL.into_iter().skip(1) {
+ ui.horizontal(|ui| {
+ let [r, g, b] = l.rgb();
+ let (rect, _) = ui.allocate_exact_size(vec2(26.0, 14.0), egui::Sense::hover());
+ ui.painter().rect_filled(rect, 2.0, Color32::from_rgb(r, g, b));
+ ui.label(l.name());
+ });
+ }
+ }
+ _ => {
+ ui.label(egui::RichText::new("No options on this page yet.").color(t.text_dim));
+ }
+ }
+ });
+ });
+ ui.add_space(10.0);
+ ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
+ if ui.add(egui::Button::new(egui::RichText::new(" OK ").color(Color32::WHITE)).fill(t.accent)).clicked() {
+ close = true;
+ }
+ });
+ });
+ app.dialog_state.settings_page = page;
+ if let Some(k) = theme {
+ app.set_theme(ctx, k);
+ }
+ if close {
+ app.dialog = None;
+ }
+}
+
+pub fn show_shortcuts(app: &mut EffectcraftApp, ctx: &egui::Context, t: &Tokens) {
+ let mut q = app.dialog_state.palette_query.clone();
+ let mut close = false;
+ // (shortcut, where, label)
+ let mut rows: Vec<(String, String, String)> = vec![];
+ for (path, e) in effectcraft_engine::menus::entries() {
+ if let Some(sc) = &e.shortcut {
+ rows.push((crate::menus::shortcut_text(sc), path.join(" ▸ "), e.label.clone()));
+ }
+ }
+ for c in effectcraft_engine::command_specs().iter().filter(|c| c.menu.is_empty()) {
+ if let Some(sc) = c.shortcut
+ && !rows.iter().any(|r| r.2 == c.label)
+ {
+ rows.push((crate::menus::shortcut_text(sc), "Commands".into(), c.label.to_string()));
+ }
+ }
+ for c in crate::menus::UI_COMMANDS {
+ if let Some(sc) = c.shortcut {
+ rows.push((crate::menus::shortcut_text(sc), "Panels & Tools".into(), c.label.to_string()));
+ }
+ }
+ super::dialogs::modal(ctx, "Keyboard Shortcuts", vec2(640.0, 520.0), t, |ui| {
+ ui.add(egui::TextEdit::singleline(&mut q).hint_text("Search commands or shortcuts").desired_width(f32::INFINITY));
+ ui.add_space(8.0);
+ let ql = q.to_lowercase();
+ egui::ScrollArea::vertical().max_height(400.0).show(ui, |ui| {
+ egui::Grid::new("shortcut-grid").num_columns(3).striped(true).spacing([18.0, 4.0]).show(ui, |ui| {
+ for (sc, place, label) in rows.iter().filter(|r| ql.is_empty() || format!("{} {} {}", r.0, r.1, r.2).to_lowercase().contains(&ql)) {
+ ui.label(egui::RichText::new(sc).monospace());
+ ui.label(label);
+ ui.label(egui::RichText::new(place).color(t.text_dim));
+ ui.end_row();
+ }
+ });
+ });
+ ui.add_space(8.0);
+ ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
+ if ui.add(egui::Button::new(egui::RichText::new(" OK ").color(Color32::WHITE)).fill(t.accent)).clicked() {
+ close = true;
+ }
+ });
+ });
+ app.dialog_state.palette_query = q;
+ if close {
+ app.dialog = None;
+ }
+}
+
+pub fn show_view_options(app: &mut EffectcraftApp, ctx: &egui::Context, t: &Tokens) {
+ let mut close = false;
+ super::dialogs::modal(ctx, "View Options", vec2(360.0, 330.0), t, |ui| {
+ let v = &mut app.ui.viewer;
+ ui.checkbox(&mut v.show_layer_controls, "Layer controls");
+ ui.checkbox(&mut v.show_masks, "Masks");
+ ui.checkbox(&mut v.rulers, "Rulers");
+ ui.checkbox(&mut v.guides, "Guides");
+ ui.checkbox(&mut v.grid, "Grid");
+ ui.checkbox(&mut v.safe_margins, "Title/action safe");
+ ui.checkbox(&mut v.transparency_grid, "Transparency grid");
+ ui.add_space(12.0);
+ ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
+ if ui.add(egui::Button::new(egui::RichText::new(" OK ").color(Color32::WHITE)).fill(t.accent)).clicked() {
+ close = true;
+ }
+ });
+ });
+ if close {
+ app.dialog = None;
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn form_params_build_arrays_and_choices() {
+ let f = Form {
+ title: "T".into(),
+ command: "layer.setTransform".into(),
+ base: json!({"prop": "position"}),
+ fields: vec![
+ Field::num("value[0]", "X", 10.0),
+ Field::num("value[1]", "Y", 20.0),
+ Field::choice("mode", "M", &[("A", json!("a")), ("B", json!("b"))], 1),
+ ],
+ };
+ assert_eq!(f.params(), json!({"prop": "position", "value": [10.0, 20.0], "mode": "b"}));
+ }
+}
diff --git a/crates/ui-egui/src/panels/mod.rs b/crates/ui-egui/src/panels/mod.rs
index 2d5924dd0..0e51c6fec 100644
--- a/crates/ui-egui/src/panels/mod.rs
+++ b/crates/ui-egui/src/panels/mod.rs
@@ -3,6 +3,7 @@
pub mod dialogs;
pub mod effect_controls;
pub mod effects_presets;
+pub mod forms;
pub mod info;
pub mod misc;
pub mod project;
diff --git a/crates/ui-egui/src/panels/project.rs b/crates/ui-egui/src/panels/project.rs
index bba588ad4..939eaed0d 100644
--- a/crates/ui-egui/src/panels/project.rs
+++ b/crates/ui-egui/src/panels/project.rs
@@ -167,10 +167,8 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
if resp.double_clicked() {
match &it.kind {
ItemKind::Comp(_) => actions.push(("comp.open".into(), json!({"comp": id.0}))),
- ItemKind::Folder => {
- if !app.ui.project_open_folders.remove(&id.0) {
- app.ui.project_open_folders.insert(id.0);
- }
+ ItemKind::Folder if !app.ui.project_open_folders.remove(&id.0) => {
+ app.ui.project_open_folders.insert(id.0);
}
_ => {}
}
diff --git a/crates/ui-egui/src/panels/timeline.rs b/crates/ui-egui/src/panels/timeline.rs
index 53b0cdc8d..a86fd1318 100644
--- a/crates/ui-egui/src/panels/timeline.rs
+++ b/crates/ui-egui/src/panels/timeline.rs
@@ -42,6 +42,7 @@ struct Cols {
label: f32,
num: f32,
name: f32,
+ #[allow(dead_code)]
name_w: f32,
switches: f32,
mode: f32,
@@ -211,6 +212,36 @@ fn build_rows(app: &EffectcraftApp, comp: &Comp) -> Vec {
}
}
}
+ "props" => {
+ // Animation ▸ Reveal Properties…: the engine picked the uids.
+ fn groups_in<'a>(g: &'a PropGroup, set: &std::collections::BTreeSet, out: &mut Vec<&'a PropGroup>) {
+ for sg in g.groups() {
+ if set.contains(&sg.uid) {
+ out.push(sg);
+ } else {
+ groups_in(sg, set, out);
+ }
+ }
+ }
+ let mut groups = vec![];
+ groups_in(&l.props, &tl.reveal_props, &mut groups);
+ for g in groups {
+ let open = tl.open_groups.contains(&g.uid);
+ rows.push(Row {
+ layer: l.id,
+ depth: 1,
+ kind: RowKind::Group { uid: g.uid, name: g.name.clone(), open, has_children: !g.children.is_empty(), fx: None },
+ });
+ if open {
+ push_group(&mut rows, l, g, 2, &tl.open_groups);
+ }
+ }
+ let mut found = vec![];
+ collect_props(&l.props, &mut found, &|p| prop_visible(p, l) && tl.reveal_props.contains(&p.uid));
+ for uid in found {
+ rows.push(Row { layer: l.id, depth: 1, kind: RowKind::Prop { uid } });
+ }
+ }
_ => {
let mut found = vec![];
let root = if group.is_empty() {
@@ -439,7 +470,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
let fd = comp.frame_duration().seconds();
let cy0 = ruler.min.y + 11.0;
let mut run: Option<(i64, i64)> = None;
- let mut draw_run = |a: i64, b: i64| {
+ let draw_run = |a: i64, b: i64| {
let x0 = tm.x(a as f64 * fd);
let x1 = tm.x((b + 1) as f64 * fd);
p.rect_filled(Rect::from_min_max(pos2(x0, cy0), pos2(x1, cy0 + 2.5)), 0.0, t.cache_green);
@@ -785,10 +816,8 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
if lin.hovered() || lout.hovered() || lin.dragged() || lout.dragged() {
ctx.set_cursor_icon(egui::CursorIcon::ResizeHorizontal);
}
- if body.clicked() || body.drag_started() {
- if !is_sel {
- actions.push(("layer.select".into(), json!({"layers": [layer.id.0], "add": ui.input(|i| i.modifiers.shift)})));
- }
+ if (body.clicked() || body.drag_started()) && !is_sel {
+ actions.push(("layer.select".into(), json!({"layers": [layer.id.0], "add": ui.input(|i| i.modifiers.shift)})));
}
layer_context_menu(&body, layer, &mut actions);
let drag_key = format!("bar-{}", layer.id.0);
@@ -1049,7 +1078,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
actions.push(("keys.select".into(), json!({"keys": []})));
}
if let (true, Some(origin), Some(cur)) =
- (empty.dragged(), empty.interact_pointer_pos().map(|_| ctx.input(|i| i.pointer.press_origin())).flatten(), empty.interact_pointer_pos())
+ (empty.dragged(), empty.interact_pointer_pos().and_then(|_| ctx.input(|i| i.pointer.press_origin())), empty.interact_pointer_pos())
{
let br = Rect::from_two_pos(origin, cur);
gp.rect_filled(br, 0.0, t.accent.gamma_multiply(0.12));
diff --git a/crates/ui-egui/src/panels/viewer.rs b/crates/ui-egui/src/panels/viewer.rs
index b1ae92af1..e524a3d19 100644
--- a/crates/ui-egui/src/panels/viewer.rs
+++ b/crates/ui-egui/src/panels/viewer.rs
@@ -55,13 +55,43 @@ pub fn last_fit(ctx: &egui::Context) -> f32 {
/// What a drag in the viewer is doing.
#[derive(Clone, Debug)]
enum Gesture {
- Move { layers: Vec<(LayerId, [f64; 3], Mat3)>, start: [f64; 2] },
- Scale { layer: LayerId, anchor_screen: Pos2, start_scale: [f64; 3], start_local: [f64; 2], inv: Mat3, uniform: bool },
- Rotate { layer: LayerId, center: Pos2, start_angle: f64, start_rot: f64 },
- Anchor { layer: LayerId, start_anchor: [f64; 3], start_pos: [f64; 3], start: [f64; 2], inv: Mat3, l2p: Mat3 },
- Pan { start_pan: [f32; 2] },
- Create { tool: Tool, start: [f64; 2] },
- Marquee { start: Pos2 },
+ Move {
+ layers: Vec<(LayerId, [f64; 3], Mat3)>,
+ start: [f64; 2],
+ },
+ #[allow(dead_code)]
+ Scale {
+ layer: LayerId,
+ anchor_screen: Pos2,
+ start_scale: [f64; 3],
+ start_local: [f64; 2],
+ inv: Mat3,
+ uniform: bool,
+ },
+ Rotate {
+ layer: LayerId,
+ center: Pos2,
+ start_angle: f64,
+ start_rot: f64,
+ },
+ Anchor {
+ layer: LayerId,
+ start_anchor: [f64; 3],
+ start_pos: [f64; 3],
+ start: [f64; 2],
+ inv: Mat3,
+ l2p: Mat3,
+ },
+ Pan {
+ start_pan: [f32; 2],
+ },
+ Create {
+ tool: Tool,
+ start: [f64; 2],
+ },
+ Marquee {
+ start: Pos2,
+ },
}
const HANDLE: f32 = 7.0;
@@ -168,7 +198,8 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
let bar_h = 30.0;
let bar = Rect::from_min_max(pos2(rect.min.x, rect.max.y - bar_h), rect.max);
let area = Rect::from_min_max(pos2(rect.min.x, nav.max.y), pos2(rect.max.x, bar.min.y));
- p.rect_filled(area, 0.0, t.pasteboard);
+ let pasteboard = app.ui.viewer.pasteboard.map(|[r, g, b]| Color32::from_rgb(r, g, b)).unwrap_or(t.pasteboard);
+ p.rect_filled(area, 0.0, pasteboard);
let (cw, ch) = (comp.width as f32, comp.height as f32);
let fit = ((area.width() - 40.0) / cw).min((area.height() - 40.0) / ch).max(0.01);
@@ -241,6 +272,24 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
}
}
+ // Comp guides (View ▸ Show Guides) and the region of interest.
+ if app.ui.viewer.guides {
+ let stroke = Stroke::new(1.0, Color32::from_rgb(0x3c, 0xc8, 0xf0));
+ for g in &comp.guides {
+ if g.vertical {
+ let x = comp_rect.min.x + g.position as f32 * zoom;
+ painter.line_segment([pos2(x, area.min.y), pos2(x, area.max.y)], stroke);
+ } else {
+ let y = comp_rect.min.y + g.position as f32 * zoom;
+ painter.line_segment([pos2(area.min.x, y), pos2(area.max.x, y)], stroke);
+ }
+ }
+ }
+ if let Some([rx, ry, rw, rh]) = app.session.state.region_of_interest {
+ let r = Rect::from_min_size(comp_rect.min + vec2(rx as f32 * zoom, ry as f32 * zoom), vec2(rw as f32 * zoom, rh as f32 * zoom));
+ painter.rect_stroke(r, 0.0, Stroke::new(1.0, Color32::WHITE), StrokeKind::Middle);
+ }
+
// Overlays + interaction.
let snap_project = app.session.project.clone();
let snap_expr = app.session.expr.clone();
@@ -491,14 +540,14 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
let _ = app.session.execute("prop.set", json!({"layer": lid.0, "path": "transform/position", "value": v, "merge": merge}));
}
}
- Gesture::Scale { layer, start_scale, start_local, inv, uniform, .. } => {
+ Gesture::Scale { layer, start_scale, start_local, inv, .. } => {
let lp = inv.apply(gv2(cpt[0], cpt[1]));
// Local point relative to the anchor in *unscaled* layer space.
let a = comp.layer(layer).and_then(|l| l.transform().map(|tr| ectx.v3(l, tr, "anchor", [0.0; 3]))).unwrap_or([0.0; 3]);
let cur = [lp.x - a[0], lp.y - a[1]];
let fx = if start_local[0].abs() > 1e-6 { cur[0] / start_local[0] } else { 1.0 };
let fy = if start_local[1].abs() > 1e-6 { cur[1] / start_local[1] } else { 1.0 };
- let (fx, fy) = if mods.shift || uniform && start_local[0].abs() > 1e-6 && start_local[1].abs() > 1e-6 && mods.shift {
+ let (fx, fy) = if mods.shift {
let f = (fx + fy) / 2.0;
(f, f)
} else {
@@ -847,7 +896,16 @@ fn bottom_bar(app: &mut EffectcraftApp, ui: &mut egui::Ui, bar: Rect, zoom: f32,
app.ui.viewer.res = Resolution::ALL[i];
}
x = r.max.x + 6.0;
- if tog(ui, &mut app.auto, &mut x, Icon::Region, false, "roi", "Region of Interest") {}
+ let has_roi = app.session.state.region_of_interest.is_some();
+ if tog(ui, &mut app.auto, &mut x, Icon::Region, has_roi, "roi", "Region of Interest") {
+ // Toggle a centred region of interest (Composition ▸ Crop Comp to Region of Interest).
+ let rect = if has_roi {
+ serde_json::Value::Null
+ } else {
+ json!([comp.width as f64 / 4.0, comp.height as f64 / 4.0, comp.width as f64 / 2.0, comp.height as f64 / 2.0])
+ };
+ let _ = app.session.execute("view.setRegionOfInterest", json!({"rect": rect}));
+ }
if tog(ui, &mut app.auto, &mut x, Icon::Checker, app.ui.viewer.transparency_grid, "transparency", "Toggle Transparency Grid") {
app.ui.viewer.transparency_grid = !app.ui.viewer.transparency_grid;
}
diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs
index 05a85121b..c06ff70d1 100644
--- a/crates/ui-egui/src/state.rs
+++ b/crates/ui-egui/src/state.rs
@@ -199,6 +199,7 @@ impl Resolution {
}
#[derive(Clone, Debug, Serialize, Deserialize)]
+#[serde(default)]
pub struct ViewerState {
/// Magnification (1 = 100%); None = fit.
pub zoom: Option,
@@ -213,6 +214,14 @@ pub struct ViewerState {
pub channel: String,
pub show_layer_controls: bool,
pub fast_preview: bool,
+ /// View ▸ Show Guides / Snap to Guides / Lock Guides / Snap to Grid.
+ pub guides: bool,
+ pub snap_guides: bool,
+ pub lock_guides: bool,
+ pub snap_grid: bool,
+ /// View ▸ Panel Background Color (`None` = theme default).
+ pub pasteboard: Option<[u8; 3]>,
+ pub custom_pasteboard: [u8; 3],
}
impl Default for ViewerState {
@@ -229,6 +238,12 @@ impl Default for ViewerState {
channel: "RGB".into(),
show_layer_controls: true,
fast_preview: false,
+ guides: true,
+ snap_guides: false,
+ lock_guides: false,
+ snap_grid: false,
+ pasteboard: None,
+ custom_pasteboard: [0x80, 0x80, 0x80],
}
}
}
@@ -249,6 +264,9 @@ pub struct TimelineState {
pub open_groups: BTreeSet,
/// "Reveal" filter: only show these property match ids (P/S/R/T/A…) — empty = normal.
pub reveal: Vec,
+ /// Properties / groups (uids) shown by the `props` reveal (Animation ▸ Reveal Properties…).
+ #[serde(default)]
+ pub reveal_props: BTreeSet,
}
impl Default for TimelineState {
@@ -264,6 +282,7 @@ impl Default for TimelineState {
open_layers: BTreeSet::new(),
open_groups: BTreeSet::new(),
reveal: vec![],
+ reveal_props: BTreeSet::new(),
}
}
}
@@ -299,6 +318,8 @@ pub struct UiState {
pub preview_loop: bool,
pub preview_cache_first: bool,
pub start_screen: bool,
+ /// Composition ▸ Preview ▸ Cache Frames When Idle.
+ pub cache_when_idle: bool,
}
impl Default for UiState {
@@ -327,6 +348,7 @@ impl Default for UiState {
preview_loop: true,
preview_cache_first: false,
start_screen: false,
+ cache_when_idle: false,
}
}
}
From c925ac8ae8af62df9444afa3051ebb3ed410920e Mon Sep 17 00:00:00 2001
From: Brandon Thomas
Date: Thu, 1 Oct 2026 23:31:40 -0400
Subject: [PATCH 2/4] M0.11: README rewrite with headless screenshots (hero,
graph editor, effects, 3D, render queue)
Co-Authored-By: Claude Opus 5.5
---
ATTRIBUTION.md | 12 ++
README.md | 162 +++++++++++-------
docs/images/effectcraft-3d.png | Bin 0 -> 673719 bytes
docs/images/effectcraft-3d.png.attribution | 8 +
docs/images/effectcraft-effects.png | Bin 0 -> 456209 bytes
.../effectcraft-effects.png.attribution | 8 +
docs/images/effectcraft-graph-editor.png | Bin 0 -> 757446 bytes
.../effectcraft-graph-editor.png.attribution | 8 +
docs/images/effectcraft-hero.png | Bin 0 -> 764159 bytes
docs/images/effectcraft-hero.png.attribution | 8 +
docs/images/effectcraft-render-queue.png | Bin 0 -> 626062 bytes
.../effectcraft-render-queue.png.attribution | 8 +
12 files changed, 148 insertions(+), 66 deletions(-)
create mode 100644 docs/images/effectcraft-3d.png
create mode 100644 docs/images/effectcraft-3d.png.attribution
create mode 100644 docs/images/effectcraft-effects.png
create mode 100644 docs/images/effectcraft-effects.png.attribution
create mode 100644 docs/images/effectcraft-graph-editor.png
create mode 100644 docs/images/effectcraft-graph-editor.png.attribution
create mode 100644 docs/images/effectcraft-hero.png
create mode 100644 docs/images/effectcraft-hero.png.attribution
create mode 100644 docs/images/effectcraft-render-queue.png
create mode 100644 docs/images/effectcraft-render-queue.png.attribution
diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md
index 8e6e35339..97598349b 100644
--- a/ATTRIBUTION.md
+++ b/ATTRIBUTION.md
@@ -17,6 +17,18 @@ iconography, images or other Adobe assets; open licences only; every asset attri
| `assets/fonts/NotoSerif-Regular.ttf` | The Noto Project Authors | https://github.com/notofonts/latin-greek-cyrillic | OFL-1.1 (`assets/fonts/OFL-NotoSerif.txt`) |
| `assets/fonts/JetBrainsMono-Regular.ttf` | The JetBrains Mono Project Authors | https://github.com/JetBrains/JetBrainsMono | OFL-1.1 (`assets/fonts/OFL-JetBrainsMono.txt`) |
+## Screenshots
+
+Screenshots of EffectCraft itself, rendered headlessly, showing only procedurally generated demo content.
+
+| Asset | Author | Source | Licence |
+|---|---|---|---|
+| `docs/images/effectcraft-hero.png` | EffectCraft contributors | Original work: screenshot of EffectCraft (EffectCraft main window) | MIT OR Apache-2.0 |
+| `docs/images/effectcraft-3d.png` | EffectCraft contributors | Original work: screenshot of EffectCraft (EffectCraft Classic 3D) | MIT OR Apache-2.0 |
+| `docs/images/effectcraft-graph-editor.png` | EffectCraft contributors | Original work: screenshot of EffectCraft (EffectCraft Graph Editor) | MIT OR Apache-2.0 |
+| `docs/images/effectcraft-effects.png` | EffectCraft contributors | Original work: screenshot of EffectCraft (EffectCraft effects) | MIT OR Apache-2.0 |
+| `docs/images/effectcraft-render-queue.png` | EffectCraft contributors | Original work: screenshot of EffectCraft (EffectCraft Render Queue panel with the demo compositions queued for H.264 and ProRes export) | MIT OR Apache-2.0 |
+
## Code-drawn assets (original work, MIT OR Apache-2.0)
- UI icons drawn in code: `crates/ui-egui/src/icons.rs`.
diff --git a/README.md b/README.md
index 8f0ac5887..f1f9d7119 100644
--- a/README.md
+++ b/README.md
@@ -15,12 +15,12 @@
A free, open-source compositor in the spirit of After Effects: compositions, layers,
- keyframes, effects and expressions, native on macOS, Windows and Linux, and in the browser later on.
- It is in early development. The engine crates are being written now and there is no app to run yet.
+ keyframes, 241 effects, expressions, 3D cameras and lights, and a render queue, native on macOS,
+ Windows and Linux, and in the browser later on. Young, moving fast, and already usable.
-
+
@@ -35,6 +35,12 @@
All Crafting Apps
+
+
+
+
+
+
> [!NOTE]
> **ArtCraft is a community of artists from all walks of life.** Painters, photographers,
> filmmakers, illustrators, designers, animators, hobbyists, and people who picked up a pencil
@@ -42,9 +48,13 @@
What it is ·
- Where it stands ·
- The plan ·
- Building ·
+ Animate ·
+ Effects ·
+ 3D ·
+ Export ·
+ Agents ·
+ Get started ·
+ Status ·
How it's made ·
The Crafting Apps ·
License
@@ -71,84 +81,104 @@ then to go further in a few places where it matters to us:
- **No FFmpeg.** Video and audio decoding and encoding come from FilmCraft's own pure-Rust
codecs.
-## Where it stands
+## Animate
-> [!IMPORTANT]
-> **There is no app to run yet.** EffectCraft is in its first milestone. The planning is done and
-> the low-level engine crates are being written. The windowed app, the renderer and the effects
-> come next. If you want to follow along or help shape it, the
-> [Discord](https://discord.gg/artcraft) is the place.
+The panels, menus and shortcuts follow After Effects, so your muscle memory carries over:
+Project, Composition, Timeline, Effect Controls, Properties, Effects & Presets, Character,
+Paragraph, Align, Info, Preview, Audio and the Render Queue, docked the way you expect.
-| | What | State |
-|---|---|---|
-| **Built** | The plan: an After Effects UI and feature reference, a full effects list, the architecture and a milestone plan (see [`plan/`](plan/)) | Done |
-| **In progress** | Engine foundation crates: time, geometry, color and blend modes, keyframes, the project model, raster images, Bezier paths, text | Early code and first tests |
-| **Next** | The compositor, a first set of effects, the editing engine and the After Effects style interface rendering an animated demo composition | Not started |
-| **Later** | Precomps and preview, shapes and masks, 3D, expressions, text animators, export, GPU rendering, the web build | Planned |
+- **Layers of every kind:** solids, shapes, text, footage, nested compositions, nulls,
+ adjustment layers, cameras and lights; parenting, track mattes, all 38 blend modes, motion blur.
+- **Keyframes that behave the same:** linear, Bezier, hold, auto and continuous Bezier, roving
+ keys, Easy Ease (F9), Keyframe Velocity and Interpolation dialogs, copy and paste at the current
+ time, and a **Graph Editor** with value and speed graphs and draggable handles.
+- **Time:** time remapping, time stretch, time-reverse, freeze frame, work area, markers, exact
+ frame-accurate timing at every frame rate including 29.97 drop-frame.
+- **Shapes and masks:** shape layers with trim paths, repeaters, round corners, offset, zig zag,
+ twist, wiggle, merge paths and gradient strokes; masks drawn with the pen tool, with modes,
+ feather, expansion and vertex editing in the viewer.
+- **Text:** point and paragraph text with real shaping, the Character and Paragraph panels, and
+ text animators with range selectors.
+- **Expressions:** JavaScript with the After Effects object model (`wiggle`, `loopOut`,
+ `thisComp.layer("…")`, vector maths on arrays), an inline editor and the pick-whip.
-The live checklist is [`plan/STATUS.md`](plan/STATUS.md).
+
+
+
-### The crates so far
+## Effects
-| Crate | What it does |
-|---|---|
-| `effectcraft-time` | Exact media time in integer ticks, so 23.976 and 29.97 fps, drop-frame timecode and audio sample rates never drift |
-| `effectcraft-geom` | 2D and 3D vectors, matrices and the layer transform (anchor, position, scale, rotation, orientation) |
-| `effectcraft-color` | RGBA color, sRGB transfer, HSL and HSV, and the 38 After Effects blend modes |
-| `effectcraft-keyframe` | Animated values: linear, hold and Bezier keyframes with speed and influence, and spatial motion paths |
-| `effectcraft-project` | The document: project items, compositions, layers and the property tree |
-| `effectcraft-raster` | Floating-point premultiplied images with warps, blurs and compositing, parallel across cores |
-| `effectcraft-path` | Bezier shapes, path operations (trim, round corners, zig zag, offset and more), stroking and anti-aliased fills |
-| `effectcraft-text` | Fonts, shaping, bidirectional text, line breaking and glyph outlines for text layers |
+241 effects across After Effects' categories, each with its parameter names, order and
+defaults: blur and sharpen, channel, color correction (Curves, Levels, Hue/Saturation, Lumetri
+Color…), distort (Warp, Bulge, Turbulent Displace, CC Power Pin…), generate (Fractal Noise,
+Gradient Ramp, Stroke, Write-on, Audio Spectrum…), keying, matte, noise and grain, perspective,
+**simulation** (CC Particle World, CC Rainfall, Shatter, Card Dance, Caustics, Wave World…),
+stylize (Glow, CC Glass…), text, transitions, utility and expression controls.
-These are moving fast. Expect names and APIs to change.
+
+
+
-## The plan
+## 3D
-EffectCraft is built in milestones. The first one is about getting something you can see on
-screen as early as possible, then filling in depth underneath.
+Classic 3D the way After Effects does it: 3D layers with orientation and material options,
+one- and two-node **cameras** with depth of field, **lights** (parallel, spot, point, ambient)
+with soft ray-traced shadows, layers that intersect correctly, orbit, pan and dolly camera
+tools, and Front, Top, Left and Custom views.
-| | Milestone | What you'll get |
-|---|---|---|
-| **M0** | Skeleton and visual shell | The full panel layout over a real CPU compositor playing an animated demo composition, about 8 effects, and the control channel and MCP server |
-| M1 | Keyframes | Complete temporal and spatial interpolation, Easy Ease, roving keys, velocity |
-| M2 | Compositing | All 38 blend modes, track mattes, parenting, 8/16/32 bit per channel behaviour |
-| M3 | Project operations | Composition and layer settings, layer commands, save and open `.ecproj`, undo, clipboard |
-| M4 | Preview and precomps | Nested compositions, adjustment layers, motion blur, cached RAM preview with audio |
-| M5 | Timeline depth | Keyframe editing, the graph editor, markers, trims, time remapping |
-| M6 | Shapes, masks and footage | Shape layers and path operations, masks, the pen tool, video and image import |
-| M7 | 3D | 3D layers, cameras and lights |
-| M8 | Expressions | JavaScript expressions with the After Effects object model (`wiggle`, `loopOut`, `thisComp` and friends) |
-| M9 | Text and effects | Text animators, text on a path, layer styles, the first 60 effects |
-| M10 | Export | Render queue, image sequences, H.264 and ProRes, GIF, command-line rendering |
-| M11 | Animation tools | Motion Sketch, Wiggler, presets, Lottie import and export, audio |
-| M12 | Performance | GPU compositing and effects, disk cache, motion tracking |
-| M13 to M16 | Beyond | More effects, puppet and paint tools, polish, the web app, a plugin API |
+
+
+
-The details, with an acceptance test for every task, are in
-[`plan/execution-plan.md`](plan/execution-plan.md) and [`plan/architecture.md`](plan/architecture.md).
+## Export
-## Building from source
+A Render Queue like After Effects', with Render Settings and Output Modules: **H.264** MP4 and
+**ProRes** MOV (Proxy to 4444 XQ with alpha) with audio, PNG, JPEG, TIFF and 32-bit EXR
+sequences, and animated GIF. The same queue runs from the command line. Every encoder is
+FilmCraft's pure-Rust code; there is no FFmpeg inside.
-You need [Rust](https://rustup.rs/) 1.95 or newer. There is nothing to launch yet, but you can
-build and test the engine crates:
+
+
+
+
+## Built for agents
+
+Everything you can do from a menu is a command with an id, and agents can reach every one of
+them:
+
+- **MCP server:** `effectcraft-cli mcp` speaks the Model Context Protocol over stdio, headless
+ or bridged to the running app (`--bridge 9877`). Tools cover commands, the project and property
+ tree, keyframes and rendered frames. This repository ships a ready [`.mcp.json`](.mcp.json).
+- **Command line:** one-shot calls with JSON output, for example
+ `effectcraft-cli set Main '#1' transform/position '[100,360]' --time 0 main.ecproj --save`
+ or `effectcraft-cli render --comp Main --out main.mp4`.
+- **Control channel:** `effectcraft --control 9877` accepts JSON lines to run commands, inspect
+ and click any widget by its automation id, and take screenshots.
+
+See [docs/agents.md](docs/agents.md) and [docs/control-protocol.md](docs/control-protocol.md).
+
+## Get started
+
+You need [Rust](https://rustup.rs/) 1.95 or newer.
```sh
git clone https://github.com/storytold/effectcraft
cd effectcraft
-cargo build
-cargo test
+cargo run --release -p effectcraft # the app, with the demo project open
+cargo run --release -p effectcraft-cli -- render --out intro.mp4 # render the demo headless
```
-To work on one crate:
+To work on it: `cargo test --workspace`, and `cargo xtask ci` before every commit (format, lints,
+tests, layering, asset attribution and the WebAssembly build). See [CONTRIBUTING.md](CONTRIBUTING.md),
+[docs/architecture.md](docs/architecture.md) and [docs/testing.md](docs/testing.md).
-```sh
-cargo test -p effectcraft-keyframe
-```
+## Where it stands
-The workspace picks up every crate under `crates/`, so while a new crate is half-written the
-whole build can break for a while. The `cargo xtask` helpers named in the plan (layer checks,
-asset checks, CI) are not written yet.
+EffectCraft is young. The core of After Effects is in place and gets deeper every week: what is
+done and what comes next is in the [ROADMAP](ROADMAP.md). Not there yet: layer styles, time and
+audio effects, audio playback, motion tracking, puppet and paint tools, the web build and GPU
+compositing. Projects are saved as `.ecproj`, readable versioned JSON; After Effects `.aep`
+files cannot be opened.
## How it's made
@@ -156,10 +186,10 @@ asset checks, CI) are not written yet.
top and nothing underneath depends on it.
- **Clean room.** We work from After Effects' public documentation and how it behaves, never
from Adobe's files, icons, presets or code. No code is copied from GPL projects. The full rules
- are in [`plan/README.md`](plan/README.md).
+ are in [AGENTS.md](AGENTS.md).
- **Private by default.** No telemetry, and no network access unless you ask for it.
- **One family.** EffectCraft shares its time model and text engine design with FilmCraft, and
- gets its video and audio codecs from it (see [`plan/adr/`](plan/adr/)).
+ gets its video and audio codecs from it.
## The Crafting Apps
diff --git a/docs/images/effectcraft-3d.png b/docs/images/effectcraft-3d.png
new file mode 100644
index 0000000000000000000000000000000000000000..4f0d003a45b0b4e6b4b70a4ec5721ee621c975c5
GIT binary patch
literal 673719
zcmc$`XH-*Pw>^v$0a1$i(K{%pG*RgYf)tgiNYT(FbO^n-&=ioSQkAACptKN5LJPe}
z?*sybX6OMa36N0!@xJ$dcs|@ae4a1w7$+l#!xOZfLKV0Mw1qIdT3lvo3?+bsPeWv`M|I%B3ruv_I8rYu~YaGLmDJULLJl0Tq9&ll6
zj<(U>ICSUScktt2zv0Ci5?+TWAx+4~}te4Pp&Xs6U
zA;4zSYWZ{v_Nx10{sAV&X|)*>Y}UTqu5h_6a1x?kqfE{-W4f7iPf
zd%A?J>M?yNrvEGpS6N%p(4j|n1g=u$J9JgETmrWz$Clz=*qf+YRIa=EL
zv}yt|w4UIdH0M2Zzb{`izSkFJfiR9Q{rDM)J*2*PdN*C$E)5y!%Ae{y?wF}=+PP4K~G{@g{16FC*b
zym{m@R4(GC>ISX7u|J#s(v&}n-gd8i{L)8x){q4%))
z{L~W+8xHy@7?aBDKMOlKgq-_}K9DC&ff~TjzyX(D_ptq}?J0Pz!~h{wJWGW96iK*+
zXqdzGM$$0U`_K!79X8CT?GGxs4@!j_z)L}$sL5P>sY4nSlXAsLyXwiqy5DUKa%l~o
z@ZqGf606gVz5TrN#>RC$_YL%vS^PE#E1fk{ofmpIhnPJc^p{jUT{q~PcF05aoK5%p
zyL>BC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