EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
Merge main (layer styles, engine menu tree) into time/audio branch
Brandon Thomas0b3c12eed1fa
diff --cc crates/engine/src/commands/frontend.rsindex 000000000,f83af9219..b344c2a0amode 000000,100644..100644--- a/crates/engine/src/commands/frontend.rs+++ b/crates/engine/src/commands/frontend.rs@@@ -1,0 -1,77 +1,78 @@@+ //! 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<CommandSpec> {+ 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),++ fe!("playback.audio", "Audio", ["Composition", "Preview"], None, "{value?: include audio in previews}", 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 --cc crates/engine/src/commands/stubs.rsindex 000000000,b9229f74f..40e323edemode 000000,100644..100644--- a/crates/engine/src/commands/stubs.rs+++ b/crates/engine/src/commands/stubs.rs@@@ -1,0 -1,102 +1,100 @@@+ //! 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<CommandSpec> {+ 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.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.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.alignVideoToData", "Align Video to Data", ["Layer", "Time"], "{}"),+ stub!("layer.environment", "Environment Layer", ["Layer"], "{}"),+ stub!("layer.updateMarkersFromSource", "Update Markers From Source", ["Layer", "Markers"], "{}"),+ 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!("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.default", "Default", ["View", "Switch 3D View"], "{}"),+ 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!("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 --cc crates/render/src/lib.rsindex 62f9ed44e,066fd7527..1e5e2f3f2--- a/crates/render/src/lib.rs+++ b/crates/render/src/lib.rs@@@ -74,29 -70,6 +75,29 @@@ impl EffectHost for FxHost<'_, '_, '_>let st = other.layer_time(Tick::from_seconds_f64(start));self.r.footage.audio(*item, f, st, frames, rate)}++ fn self_at(&self, layer_time: f64, effects: usize) -> Option<Buf> {+ if self.r.depth > MAX_FX_DEPTH || self.layer.switches.adjustment {+ return None;+ }+ let n = effects.min(self.index.load(std::sync::atomic::Ordering::Relaxed));+ let t = self.layer.comp_time(Tick::from_seconds_f64(layer_time));+ let sub = Renderer { depth: self.r.depth + 1, ..*self.r };+ sub.layer_input(&self.ctx.at(t), self.layer, n).map(|b| (*b).clone())+ }++ fn layer_at(&self, id: u64, comp_time: f64, masks_and_effects: bool) -> Option<LayerPixels> {+ let other = self.ctx.layer(effectcraft_project::LayerId(id))?;+ if other.id == self.layer.id || self.r.depth > MAX_FX_DEPTH {+ return None;+ }+ let ctx = self.ctx.at(Tick::from_seconds_f64(comp_time));+ let sub = Renderer { depth: self.r.depth + 1, ..*self.r };- let buf = if masks_and_effects { (*sub.layer_buf(&ctx, other)?).clone() } else { (*sub.layer_input(&ctx, other, 0)?).clone() };++ let buf = if masks_and_effects { (*sub.content_buf(&ctx, other)?).clone() } else { (*sub.layer_input(&ctx, other, 0)?).clone() };+ let size = source_size(self.r.project, other);+ let size = if size.0 == 0 { [self.ctx.comp.width as f64, self.ctx.comp.height as f64] } else { [size.0 as f64, size.1 as f64] };+ Some(LayerPixels { buf, size })+ }}/// No footage available (renders footage layers as transparent).@@@ -330,31 -304,44 +350,66 @@@ impl<'a> Renderer<'a>if let (Some(c), Some(k)) = (self.cache, key) {c.insert(k, buf.clone());}- Some(buf)+ Some((buf, key))}+ /// A layer's input at the context time: source → masks → its first `effects` effects+ /// (what Time effects read at neighbouring times). Served from / stored in the layer cache+ /// under its own key, so scrubbing reuses frames rendered for earlier output frames.+ pub fn layer_input(&self, ctx: &EvalCtx, layer: &Layer, effects: usize) -> Option<Arc<Buf>> {+ let key = self.cache.and_then(|_| cache::input_key(ctx, layer, self.opts.scale, self.opts.draft, effects));+ if let (Some(c), Some(k)) = (self.cache, key)+ && let Some(b) = c.get(k)+ {+ return Some(b);+ }+ let mut buf = self.source(ctx, layer)?;+ masks::apply(ctx, layer, &mut buf);+ if effects > 0 {+ buf = self.apply_effects_timed(ctx, layer, buf, false, effects, None);+ }+ let buf = Arc::new(buf);+ if let (Some(c), Some(k)) = (self.cache, key) {+ c.insert(k, buf.clone());+ }+ Some(buf)+ }++ /// The layer with its styles: exterior passes and body (cached per pass).+ fn styled(&self, ctx: &EvalCtx, layer: &Layer, mut timing: Option<&mut LayerTiming>) -> Option<StyledLayer> {+ let (content, ckey) = self.content_buf_timed(ctx, layer, timing.as_deref_mut())?;+ if !styles::active(ctx, layer) {+ return Some(StyledLayer { passes: vec![], body: content.clone(), content, key: None, plain: true });+ }+ let modes = styles::pass_modes(ctx, layer);+ let key = ckey.map(|k| cache::styles_key(ctx, layer, k));+ if let (Some(c), Some(k)) = (self.cache, key)+ && let Some(body) = c.get(k)+ {+ let passes: Option<Vec<_>> = modes.iter().enumerate().map(|(i, m)| c.get(cache::derive(k, i as u64 + 1)).map(|b| (b, *m))).collect();+ if let Some(passes) = passes {+ return Some(StyledLayer { passes, body, content, key, plain: false });+ }+ }+ let t0 = std::time::Instant::now();+ let size = source_size(self.project, layer);+ let layer_size = if size.0 == 0 { [ctx.comp.width as f64, ctx.comp.height as f64] } else { [size.0 as f64, size.1 as f64] };+ let st = styles::render(ctx, layer, &content, layer_size);+ if let Some(t) = timing {+ t.cached = false;+ t.effects.push(("layerStyles".into(), t0.elapsed().as_secs_f64() * 1e3));+ }+ let body = Arc::new(st.body);+ let passes: Vec<_> = st.passes.into_iter().map(|(b, m)| (Arc::new(b), m)).collect();+ if let (Some(c), Some(k)) = (self.cache, key) {+ c.insert(k, body.clone());+ for (i, (b, _)) in passes.iter().enumerate() {+ c.insert(cache::derive(k, i as u64 + 1), b.clone());+ }+ }+ Some(StyledLayer { passes, body, content, key, plain: false })+ }+fn sampling(&self, layer: &Layer) -> effectcraft_raster::Sampling {if self.opts.draft || layer.switches.quality == Quality::Draft {effectcraft_raster::Sampling::Bilineardiff --cc crates/ui-egui/src/menus.rsindex 0f5ec7f62,d3c01f687..a81ac54a1--- a/crates/ui-egui/src/menus.rs+++ b/crates/ui-egui/src/menus.rs@@@ -63,22 -57,7 +57,9 @@@ pub const UI_COMMANDS: &[UiCommand] = &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.reveal.levels", "Reveal Audio Levels (press twice: Waveform)", [], Some("L")),+ uic!("timeline.reveal.waveform", "Reveal Audio Waveform", [], None),- uic!("playback.muteAudio", "Mute Audio", ["Composition", "Preview"], None),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")),@@@ -178,11 -148,14 +156,14 @@@ pub fn invoke(app: &mut EffectcraftAppreturn 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);+ reveal(app, k, now);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.") {@@@ -312,10 -267,225 +275,232 @@@Ok(Value::Null)}- fn file_dialog(app: &mut EffectcraftApp, id: &str) -> Result<Value, String> {- 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<Value, String> {+ 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<Value, String> {+ 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),++ "playback.audio" => {++ let r = toggle(&mut app.ui.preview_audio, &p);++ if !app.ui.preview_audio {++ app.audio = None;++ }++ r++ }+ "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<Result<Value, String>> {+ 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<Value> = 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",@@@ -355,58 -535,72 +550,73 @@@ pub struct MenuItempub 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()+ }- pub fn menu_items(app: &EffectcraftApp) -> Vec<MenuItem> {- 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,- });+ 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(),}- for c in UI_COMMANDS {- if c.menu.is_empty() {- continue;+ }++ /// Check-mark state of frontend toggles (engine state is answered by the engine).+ fn entry_checked(app: &EffectcraftApp, e: &MenuEntry) -> Option<bool> {+ 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),++ "playback.audio" => Some(app.ui.preview_audio),+ "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.")))}- 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,- });+ "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),}- 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}),- });+ }++ fn entry_enabled(app: &EffectcraftApp, e: &MenuEntry) -> bool {+ if e.command == "window.panel" {+ return true;}- out+ app.session.is_enabled(&e.command)+ }++ /// Every menu entry, flattened with its submenu path.+ pub fn menu_items(app: &EffectcraftApp) -> Vec<MenuItem> {+ 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).diff --cc crates/ui-egui/src/panels/misc.rsindex 8f487a5e1,99edc106a..056e6acda--- a/crates/ui-egui/src/panels/misc.rs+++ b/crates/ui-egui/src/panels/misc.rs@@@ -51,12 -51,6 +51,12 @@@ pub fn preview(app: &mut EffectcraftApp}app.auto.add("preview.loop", lr, "Loop");p.text(pos2(lr.max.x + 6.0, yy), Align2::LEFT_CENTER, "Loop", Tokens::ui(12.0), t.text);+ let ar = Rect::from_min_size(pos2(rect.min.x + 90.0, yy - 8.0), vec2(16.0, 16.0));+ if widgets::checkbox(ui, ar, app.ui.preview_audio, &t, egui::Id::new("pv-audio")).clicked() {- let _ = crate::menus::invoke(app, &ctx, "playback.muteAudio", json!({}));++ let _ = crate::menus::invoke(app, &ctx, "playback.audio", json!({}));+ }+ app.auto.add("preview.audio", ar, "Include Audio");+ p.text(pos2(ar.max.x + 6.0, yy), Align2::LEFT_CENTER, "Include Audio", Tokens::ui(12.0), t.text);yy += 24.0;row(&p, yy, "Range", "Work Area Extended By Current Time");yy += 22.0;diff --cc crates/ui-egui/src/panels/timeline.rsindex 1bb42fce3,afaad9e50..d2ae6ed34--- a/crates/ui-egui/src/panels/timeline.rs+++ b/crates/ui-egui/src/panels/timeline.rs@@@ -308,21 -341,6 +355,21 @@@ fn build_rows(app: &EffectcraftApp, com});if open {push_group(&mut rows, l, g, 2, &tl.open_groups);+ // Audio > Waveform > Waveform (footage with audio).+ if g.match_id == "audio"+ && let Some(item) = super::waveform::audio_item(&app.session.project, l)+ {+ let wuid = WAVE_BIT | g.uid;+ let wopen = tl.open_groups.contains(&wuid);+ rows.push(Row {+ layer: l.id,+ depth: 2,- kind: RowKind::Group { uid: wuid, name: "Waveform".into(), open: wopen, has_children: true, fx: None },++ kind: RowKind::Group { uid: wuid, name: "Waveform".into(), open: wopen, has_children: true, fx: None, eye: None },+ });+ if wopen {+ rows.push(Row { layer: l.id, depth: 3, kind: RowKind::Waveform { item: item.0 } });+ }+ }}}Node::Prop(p) if prop_visible(p, l) => rows.push(Row { layer: l.id, depth: 1, kind: RowKind::Prop { uid: p.uid } }),diff --cc crates/ui-egui/src/state.rsindex 3b238da17,4cb2d9aba..9c14fbef6--- a/crates/ui-egui/src/state.rs+++ b/crates/ui-egui/src/state.rs@@@ -338,10 -357,9 +357,12 @@@ pub struct UiState/// Preview panel options.pub preview_loop: bool,pub preview_cache_first: bool,+ /// Preview panel "Include Audio" (Mute Audio off).+ #[serde(default = "yes")]+ pub preview_audio: bool,pub start_screen: bool,+ /// Composition ▸ Preview ▸ Cache Frames When Idle.+ pub cache_when_idle: bool,}impl Default for UiState {@@@ -372,8 -390,8 +393,9 @@@tool_creates_shape: true,preview_loop: true,preview_cache_first: false,+ preview_audio: true,start_screen: false,+ cache_when_idle: false,}}}diff --cc docs/architecture.mdindex bf057ef99,ee0b78766..512f4fef5--- a/docs/architecture.md+++ b/docs/architecture.md@@@ -71,16 -71,14 +71,24 @@@ its evaluated inputs, excluding the traediting one layer re-renders only that layer. Effects that read the clock directly are declared in`effects::TIME_DEPENDENT`, and a test checks every registered effect against that list.+**Time effects** (Echo, Posterize Time, Timewarp…) read the layer at other times through+`EffectHost::self_at`: the renderer renders the layer's source and masks (plus, optionally, the+effects before it) at that layer time via `Renderer::layer_input`, cached under separate *input*+keys, with a nesting-depth guard.++**Audio** is mixed by `render::audio::mix_comp` in blocks: Audio switch, solo, Audio Levels and+the Effect > Audio effects (`effects::audio_fx`, applied per layer with a pre-roll so blocks are+independent). Export and preview playback share it; the desktop app plays it through cpal and the+audio clock drives preview playback (`ui-egui::audio`).++ **Layer styles** (Layer ▸ Layer Styles; `crates/render/src/styles.rs`) render in layer space and+ may grow the layer's bounds. Drop Shadow and Outer Glow become separate passes composited below the+ layer with their own blend modes; the interior styles, Stroke and Bevel and Emboss are baked into+ the layer body. Layer opacity fades the whole stack; Knockout and the R/G/B channel switches apply+ at composite time. Styled pixels are cached separately from the layer content, so editing a style+ reuses the cached source/masks/effects. Global Light is one setting per comp, mirrored into every+ layer's Blending Options and kept in step after each edit.+Half, Third and Quarter resolution render proportionally fewer pixels end to end.## 5. Expressions