diff --git a/crates/aep/src/export/fx_defs.rs b/crates/aep/src/export/fx_defs.rs index ee24879c6..893ea83ef 100644 --- a/crates/aep/src/export/fx_defs.rs +++ b/crates/aep/src/export/fx_defs.rs @@ -736,10 +736,6 @@ mod tests { ("ec.time.pixelmotionblur", "shutterSamples", 3482), ("ec.noise.fractal", "subSettings/subInfluence", 3485), ("ec.noise.fractal", "subSettings/subScaling", 3486), - ("ec.distort.ccpowerpin", "expandTop", 3492), - ("ec.distort.ccpowerpin", "expandLeft", 3492), - ("ec.distort.ccpowerpin", "expandRight", 3492), - ("ec.distort.ccpowerpin", "expandBottom", 3492), ]; /// `a` is at most `b`, allowing for the `f32` the recorded bounds were read from. diff --git a/crates/effects/src/distort3.rs b/crates/effects/src/distort3.rs index 34fc282ed..ed88e2d84 100644 --- a/crates/effects/src/distort3.rs +++ b/crates/effects/src/distort3.rs @@ -955,10 +955,12 @@ pub fn specs() -> Vec { p("bottomRight", "Bottom Right", pt(1.0, 1.0), ParamUi::Point), p("perspective", "Perspective", num(100.0), pct()), p("unstretch", "Unstretch", Value::Bool(false), ParamUi::Checkbox), - p("expandTop", "Top", num(0.0), slider(-100.0, 1000.0, 0.0, 100.0, 1)), - p("expandLeft", "Left", num(0.0), slider(-100.0, 1000.0, 0.0, 100.0, 1)), - p("expandRight", "Right", num(0.0), slider(-100.0, 1000.0, 0.0, 100.0, 1)), - p("expandBottom", "Bottom", num(0.0), slider(-100.0, 1000.0, 0.0, 100.0, 1)), + // Expansion: percent of the layer size each source edge moves out (After Effects' + // valid range is -200..200; the maximum stays at 1000 so existing values are kept). + p("expandTop", "Top", num(0.0), slider(-200.0, 1000.0, 0.0, 100.0, 1)), + p("expandLeft", "Left", num(0.0), slider(-200.0, 1000.0, 0.0, 100.0, 1)), + p("expandRight", "Right", num(0.0), slider(-200.0, 1000.0, 0.0, 100.0, 1)), + p("expandBottom", "Bottom", num(0.0), slider(-200.0, 1000.0, 0.0, 100.0, 1)), ], cc_power_pin, ), diff --git a/crates/effects/src/distort3/tests.rs b/crates/effects/src/distort3/tests.rs index b50d6b450..8ccc80ad4 100644 --- a/crates/effects/src/distort3/tests.rs +++ b/crates/effects/src/distort3/tests.rs @@ -250,6 +250,57 @@ fn power_pin_unstretch_expands_pinned_region() { assert!(maxd(&id.img, &im) < 1e-4); } +/// #3492: an Expansion side moves that edge of the source rectangle by a percent of the layer +/// size. When two opposite sides add up to less than -100 % the edges cross and the rectangle +/// flips: Top -200 and Bottom -100 take rows 40 down to 0 of a 20-row layer, a mirrored copy +/// squeezed into the bottom half (the top half samples below the layer and is transparent). +/// -100 for both (the most the old minimum allowed) mirrors the whole layer. +#[test] +fn power_pin_crossed_expansion_flips_the_source() { + let im = img(20, 20); + let o = run("ec.distort.ccpowerpin", &[("expandTop", num(-200.0)), ("expandBottom", num(-100.0))], im.clone(), &[]); + assert_eq!((o.img.width, o.img.height), (20, 20)); + // Output row 15: v = 15.5 / 20, source y = 40 - 40 v = 9 (between rows 8 and 9). + let px = o.img.get(10, 15); + assert!((px[1] - 8.5 / 20.0).abs() < 1e-3, "{px:?}"); + assert_eq!(o.img.get(10, 5)[3], 0.0); + let both = run("ec.distort.ccpowerpin", &[("expandTop", num(-100.0)), ("expandBottom", num(-100.0))], im.clone(), &[]); + // Source y = 20 - 20 v = 4.5, row 4's centre. + let px = both.img.get(10, 15); + assert!((px[1] - 4.0 / 20.0).abs() < 1e-3, "{px:?}"); +} + +/// #3492: the buffer is sized by the pins alone, and Expansions at the ends of -200..1000 render +/// finite images: all sides at either end, flipped sources, a zero-size source (Top -50, Bottom +/// -50), and Unstretch, which divides by the source size (a zero size renders transparent). +#[test] +fn power_pin_is_finite_at_the_expansion_extremes() { + let im = img(24, 16); + let pins = [("topLeft", pt(3.0, -4.0)), ("topRight", pt(26.0, 2.0)), ("bottomRight", pt(20.0, 18.0)), ("bottomLeft", pt(-2.0, 14.0))]; + let sides = ["expandTop", "expandLeft", "expandRight", "expandBottom"]; + let cases: &[[f64; 4]] = + &[[-200.0; 4], [1000.0; 4], [-50.0, 0.0, 0.0, -50.0], [0.0, -200.0, -200.0, 0.0], [-200.0, 1000.0, -200.0, 1000.0], [-100.0, -150.0, 50.0, -200.0]]; + for unstretch in [false, true] { + for perspective in [100.0, 40.0] { + let mut base: Vec<(&str, Value)> = pins.to_vec(); + base.push(("unstretch", Value::Bool(unstretch))); + base.push(("perspective", num(perspective))); + let size = |o: &Buf| (o.img.width, o.img.height); + let neutral = size(&run("ec.distort.ccpowerpin", &base, im.clone(), &[])); + for ex in cases { + let mut set = base.clone(); + set.extend(sides.iter().zip(ex).map(|(s, v)| (*s, num(*v)))); + let o = run("ec.distort.ccpowerpin", &set, im.clone(), &[]); + let at = format!("{ex:?} unstretch {unstretch} perspective {perspective}"); + assert_eq!(size(&o), neutral, "{at}"); + for p in &o.img.data { + assert!(p.iter().all(|c| c.is_finite()) && (0.0..=1.0).contains(&p[3]), "{at}: {p:?}"); + } + } + } + } +} + #[test] fn split_opens_a_gap() { let im = img(40, 30); diff --git a/crates/engine/src/tests/effect_ranges.rs b/crates/engine/src/tests/effect_ranges.rs index 49721e136..d0619f2d4 100644 --- a/crates/engine/src/tests/effect_ranges.rs +++ b/crates/engine/src/tests/effect_ranges.rs @@ -61,6 +61,10 @@ const ROWS: &[(u32, &str, &str, f64, f64)] = &[ (3471, "ec.distort.transform", "scaleWidth", -30000.0, 30000.0), (3470, "ec.distort.turbulentdisplace", "evolutionOptions/randomSeed", 0.0, 100000.0), (3460, "ec.blur.gaussian", "blurriness", 0.0, 30000.0), + (3492, "ec.distort.ccpowerpin", "expandTop", -200.0, 1000.0), + (3492, "ec.distort.ccpowerpin", "expandLeft", -200.0, 1000.0), + (3492, "ec.distort.ccpowerpin", "expandRight", -200.0, 1000.0), + (3492, "ec.distort.ccpowerpin", "expandBottom", -200.0, 1000.0), ]; fn path(effect: &str, param: &str) -> String { diff --git a/crates/gpu/src/tests/fx_stylize.rs b/crates/gpu/src/tests/fx_stylize.rs index 8c6c7be33..108dfca53 100644 --- a/crates/gpu/src/tests/fx_stylize.rs +++ b/crates/gpu/src/tests/fx_stylize.rs @@ -218,6 +218,13 @@ fn twirl_legacy_ripple_pulse_power_pin() { // Perspective below 100 %: blended toward the bilinear inverse. effect_case("ec.distort.ccpowerpin", &[("topRight", pt(80.0, -6.0)), ("bottomLeft", pt(-4.0, 50.0)), ("perspective", n(0.0))]); effect_case("ec.distort.ccpowerpin", &[("topLeft", pt(12.0, 6.0)), ("bottomRight", pt(75.0, 30.0)), ("perspective", n(40.0)), ("expandTop", n(15.0))]); + // #3492: Expansion down to -200; opposite sides adding up to less than -100 % flip the source, + // and Top -50 / Bottom -50 leave it zero high. + effect_case("ec.distort.ccpowerpin", &[("topRight", pt(80.0, -6.0)), ("expandTop", n(-200.0)), ("expandBottom", n(-100.0)), ("expandLeft", n(-150.0))]); + effect_case( + "ec.distort.ccpowerpin", + &[("bottomLeft", pt(-4.0, 50.0)), ("perspective", n(40.0)), ("expandTop", n(-50.0)), ("expandBottom", n(-50.0)), ("expandRight", n(-200.0))], + ); } #[test] diff --git a/crates/ui-egui/src/menus/shortcuts.rs b/crates/ui-egui/src/menus/shortcuts.rs index a573a2f6d..eaca5568a 100644 --- a/crates/ui-egui/src/menus/shortcuts.rs +++ b/crates/ui-egui/src/menus/shortcuts.rs @@ -403,7 +403,7 @@ fn handle_shortcuts_impl(app: &mut EffectcraftApp, ctx: &egui::Context, tab_only if app.dialog.is_some() { continue; } - if !mods.any() && crate::panels::effect_controls::handle_disclosure_key(app, key) { + if !mods.any() && crate::panels::effect_controls::handle_arrow_key(app, ctx, key) { ctx.input_mut(|i| i.consume_key(egui::Modifiers::NONE, key)); continue; } diff --git a/crates/ui-egui/src/panels/effect_controls.rs b/crates/ui-egui/src/panels/effect_controls.rs index 4c297f9e6..0b2ee437b 100644 --- a/crates/ui-egui/src/panels/effect_controls.rs +++ b/crates/ui-egui/src/panels/effect_controls.rs @@ -43,7 +43,7 @@ mod viewer; pub use common::{choose_files_after_apply, reveal_applied, set_lock}; pub(crate) use common::{gesture_key, scope_lock, shown_layer_id}; -pub(crate) use panel::handle_disclosure_key; +pub(crate) use panel::handle_arrow_key; pub use panel::{show, start_rename}; pub(crate) use rows::toggle_pick; pub use viewer::viewer_hook; diff --git a/crates/ui-egui/src/panels/effect_controls/panel.rs b/crates/ui-egui/src/panels/effect_controls/panel.rs index ac11bc7a2..5ced41673 100644 --- a/crates/ui-egui/src/panels/effect_controls/panel.rs +++ b/crates/ui-egui/src/panels/effect_controls/panel.rs @@ -1,39 +1,66 @@ -use super::common::{Actions, PARAM_NAME_X, ROW, effect_active, prune_lock, shown_layer}; +use super::common::{Actions, PARAM_NAME_X, ROW, effect_active, prune_lock, shown_layer, shown_layer_id}; use super::editors::{curves_editor, editor_height, histogram_only, levels_editor, object_matte_editor, roto_editor, warp_editor}; use super::rows::{FxScope, group_rows, toggle_closed}; use super::{Align2, Color32, EffectcraftApp, EvalCtx, GroupKind, Icon, Layer, PropGroup, Rect, Sense, Stroke, Tokens, json, pos2, vec2, widgets}; use crate::dock::{PanelKind, WorkspaceExt as _}; -/// Plain Right / Left Arrow expand / collapse the selected effects, as in After Effects, before -/// the arrows' layer nudge runs. Only while Effect Controls has the focus and is on screen: the -/// front tab of its frame, drawn last frame (a maximized frame hides every other frame and every -/// floating window), not behind Home. With no effect header selected the arrows still nudge. -pub(crate) fn handle_disclosure_key(app: &mut EffectcraftApp, key: egui::Key) -> bool { +/// Plain arrows in Effect Controls, as in After Effects, before their layer nudge runs: Right / +/// Left expand / collapse the selected effects, and Down / Up select the next / previous effect +/// in the stacking order, from the lowest / highest selected one, stopping at the last / first. +/// Only while Effect Controls has the focus and is on screen: the front tab of its frame, drawn +/// last frame (a maximized frame hides every other frame and every floating window), not behind +/// Home. Only the effect headers selected on the layer the panel shows (the locked one when it is +/// locked) count: with none the arrows still nudge. +pub(crate) fn handle_arrow_key(app: &mut EffectcraftApp, ctx: &egui::Context, key: egui::Key) -> bool { + use egui::Key::{ArrowDown, ArrowLeft, ArrowRight, ArrowUp}; let panel = PanelKind::EffectControls; if app.ui.focused != panel || app.ui.start_screen || app.session.state.text_edit.is_some() || !app.ui.dock.is_visible(panel) || !app.dock_rects.iter().any(|(p, _)| *p == panel) - || !matches!(key, egui::Key::ArrowLeft | egui::Key::ArrowRight) + || !matches!(key, ArrowLeft | ArrowRight | ArrowUp | ArrowDown) { return false; } - let Some(comp) = app.session.active_comp() else { return false }; - let Some(layer) = app.session.state.selected_layers.first().and_then(|id| comp.layer(*id)) else { return false }; - let Some(effects) = layer.effects() else { return false }; - let mut handled = false; - for g in effects.groups() { - if matches!(&g.kind, GroupKind::Effect { .. }) && app.session.state.selected_props.contains(&(layer.id, g.uid)) { - if key == egui::Key::ArrowLeft { - app.ui.fx_closed.insert(g.uid); - } else { - app.ui.fx_closed.remove(&g.uid); + let Some(layer_id) = shown_layer_id(app) else { return false }; + let Some(effects) = app.session.active_comp().and_then(|c| c.layer(layer_id)).and_then(|l| l.effects()) else { return false }; + let headers: Vec = effects.groups().filter(|g| matches!(&g.kind, GroupKind::Effect { .. })).map(|g| g.uid).collect(); + let selected = &app.session.state.selected_props; + let picked: Vec = headers.iter().enumerate().filter(|(_, u)| selected.contains(&(layer_id, **u))).map(|(i, _)| i).collect(); + let (Some(&top), Some(&bottom)) = (picked.first(), picked.last()) else { return false }; + match key { + ArrowUp | ArrowDown => { + // Clamped at the ends, where the key still doesn't nudge the layer. + let to = if key == ArrowUp { top.saturating_sub(1) } else { bottom.saturating_add(1).min(headers.len().saturating_sub(1)) }; + if let Some(&uid) = headers.get(to) { + // A selection, as a click on the header makes it: no undo step. + app.session.state.selected_props = vec![(layer_id, uid)]; + reveal_effect(ctx, uid); + } + } + _ => { + for uid in picked.iter().filter_map(|i| headers.get(*i)) { + if key == ArrowLeft { + app.ui.fx_closed.insert(*uid); + } else { + app.ui.fx_closed.remove(uid); + } } - handled = true; } } - handled + true +} + +/// The effect header the next Effect Controls pass scrolls into view. +fn reveal_id() -> egui::Id { + egui::Id::unique("ec-reveal") +} + +/// Scroll Effect Controls so effect `uid`'s header is in view, once it has been laid out. +fn reveal_effect(ctx: &egui::Context, uid: u64) { + ctx.data_mut(|d| d.insert_temp(reveal_id(), uid)); + ctx.request_repaint(); } // --------------------------------------------------------------------------------------------- @@ -434,7 +461,18 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) { actions.extend(crate::menus::menu_contents(app, ui, "Effect")); }); let content_h = y + scroll.offset - body.min.y; + let offset = scroll.offset; scroll.end(ui, &mut app.auto, "effectControls.scroll", content_h, &t); + // Up / Down picked an effect: bring its header into view from the next pass (after `end`, + // which stores this pass's offset). + if let Some(uid) = ctx.data_mut(|d| d.remove_temp::(reveal_id())) + && let Some(&(_, top)) = tops.iter().find(|(u, _)| *u == uid) + { + // (With the 4-point gap above it: the panel starts with one and every effect ends with one.) + let top = top - body.min.y + offset; + widgets::PanelScroll::reveal(&ctx, egui::Id::unique("ec-scroll"), top - 4.0, top + ROW + 2.0, body.height()); + ctx.request_repaint(); + } drop_payload(ui, rect, &p, &t, layer.id.0, &mut actions); if ui.input(|i| i.pointer.primary_down()) && actions.iter().any(|(id, _)| id == "prop.set") { app.ui.viewer.property_interacting = true; diff --git a/crates/ui-egui/tests/it/ui_effect_controls.rs b/crates/ui-egui/tests/it/ui_effect_controls.rs index bfeea16aa..49de1f24c 100644 --- a/crates/ui-egui/tests/it/ui_effect_controls.rs +++ b/crates/ui-egui/tests/it/ui_effect_controls.rs @@ -264,6 +264,202 @@ fn effect_header_arrows_leave_viewer_text_editing_alone() { assert_eq!(h.state().ui.fx_closed.iter().copied().collect::>(), vec![fx], "with the edit over, Left collapses the effect"); } +/// The x and y of `lid`'s Position, which the arrows' layer nudge moves. +fn position(h: &Harness<'_, EffectcraftApp>, lid: LayerId) -> [f64; 2] { + let p = layer(&h.state().session, lid.0).props.prop("transform/position").unwrap().value.as_vec3(); + [p[0], p[1]] +} + +/// #3585: plain Down / Up select the next / previous effect, a collapsed one too, and stop at the +/// last / first one without nudging the layer. Only the selection changes: not the document, the +/// time, the history or what is open. +#[test] +fn effect_header_down_and_up_select_the_next_and_previous_effect() { + let (mut h, lid, [(first, _), (second, _), (third, _)]) = header_arrow_harness(); + let at = rect_of(&h, &format!("effectControls.effect.{first}.name")).center(); + click(&mut h, at); + assert_eq!(h.state().session.state.selected_props, vec![(lid, first)]); + h.state_mut().ui.fx_closed.insert(second); + let project = serde_json::to_value(&h.state().session.project).unwrap(); + let time = h.state().session.time(); + let history = (h.state().session.history.undo.len(), h.state().session.history.redo.len()); + let closed = h.state().ui.fx_closed.clone(); + let (down, up) = (egui::Key::ArrowDown, egui::Key::ArrowUp); + for (key, want) in [(down, second), (down, third), (down, third), (up, second), (up, first), (up, first)] { + header_arrow_key(&mut h, key, egui::Modifiers::NONE); + assert_eq!(h.state().session.state.selected_props, vec![(lid, want)], "{key:?}"); + assert_eq!(serde_json::to_value(&h.state().session.project).unwrap(), project, "{key:?}: the layer is not nudged"); + assert_eq!(h.state().session.time(), time, "{key:?}"); + assert_eq!((h.state().session.history.undo.len(), h.state().session.history.redo.len()), history, "{key:?}: no undo step"); + assert_eq!(h.state().ui.fx_closed, closed, "{key:?}: nothing opens or closes"); + assert_eq!(h.state().ui.focused, PanelKind::EffectControls); + } +} + +/// #3585: with several effects selected, Down goes on from the lowest one and Up from the highest, +/// leaving one effect selected. Headers of other layers, stale ids and parameters don't count. +#[test] +fn effect_header_down_and_up_go_on_from_the_ends_of_a_multiple_selection() { + let (mut h, lid, [(first, _), (second, prop), (third, _)]) = header_arrow_harness(); + for (picked, key, want) in [ + (vec![(lid, second), (lid, first)], egui::Key::ArrowDown, third), + (vec![(lid, third), (lid, second)], egui::Key::ArrowUp, first), + (vec![(lid, first), (lid, third)], egui::Key::ArrowDown, third), + (vec![(lid, first), (lid, third)], egui::Key::ArrowUp, first), + (vec![(LayerId(0), first), (lid, u64::MAX), (lid, prop), (lid, second)], egui::Key::ArrowDown, third), + ] { + h.state_mut().session.state.selected_props = picked.clone(); + header_arrow_key(&mut h, key, egui::Modifiers::NONE); + assert_eq!(h.state().session.state.selected_props, vec![(lid, want)], "{picked:?} {key:?}"); + } + // A shift-click range, picked from the third effect up to the first, as a user would. + let at = rect_of(&h, &format!("effectControls.effect.{third}.name")).center(); + click(&mut h, at); + let at = rect_of(&h, &format!("effectControls.effect.{first}.name")).center(); + h.event(egui::Event::ModifiersChanged(egui::Modifiers::SHIFT)); + click(&mut h, at); + h.event(egui::Event::ModifiersChanged(Default::default())); + h.step(); + assert_eq!(h.state().session.state.selected_props.len(), 3, "the range is selected"); + header_arrow_key(&mut h, egui::Key::ArrowUp, egui::Modifiers::NONE); + assert_eq!(h.state().session.state.selected_props, vec![(lid, first)]); +} + +/// #3585: without an effect header selected on the panel's layer, or with the panel or the +/// keyboard elsewhere, plain Up / Down keep nudging the layer (or go to whoever owns the keys), +/// and the effect selection stays. +#[test] +fn effect_header_down_and_up_leave_the_nudge_and_other_keyboard_owners_alone() { + let (mut h, lid, [(first, _), (second, prop), _]) = header_arrow_harness(); + // A parameter, a stale header and another layer's header: the layer moves down, then up. + let picked = vec![(lid, prop), (lid, u64::MAX), (LayerId(0), first)]; + h.state_mut().session.state.selected_props = picked.clone(); + let y = position(&h, lid)[1]; + header_arrow_key(&mut h, egui::Key::ArrowDown, egui::Modifiers::NONE); + // (One pixel at the viewer's magnification.) + let step = position(&h, lid)[1] - y; + assert!(step > 0.0, "Down still nudges the layer"); + header_arrow_key(&mut h, egui::Key::ArrowUp, egui::Modifiers::NONE); + assert!((position(&h, lid)[1] - y).abs() < 1e-6, "Up still nudges the layer"); + assert_eq!(h.state().session.state.selected_props, picked); + + // With an effect selected: Shift nudges ten pixels, Cmd/Ctrl keeps its own meaning. + h.state_mut().session.state.selected_props = vec![(lid, second)]; + header_arrow_key(&mut h, egui::Key::ArrowDown, egui::Modifiers::SHIFT); + assert!((position(&h, lid)[1] - (y + 10.0 * step)).abs() < 1e-6, "Shift+Down nudges ten pixels"); + header_arrow_key(&mut h, egui::Key::ArrowUp, egui::Modifiers::SHIFT); + assert!((position(&h, lid)[1] - y).abs() < 1e-6); + header_arrow_key(&mut h, egui::Key::ArrowDown, egui::Modifiers::COMMAND); + assert_eq!(h.state().session.state.selected_props, vec![(lid, second)], "Cmd/Ctrl+Down keeps the effect selection"); + + // Another panel, a dialog, the context menu and the rename field own the arrows. + let stays = |h: &mut Harness<'_, EffectcraftApp>, why: &str| { + for key in [egui::Key::ArrowDown, egui::Key::ArrowUp] { + header_arrow_key(h, key, egui::Modifiers::NONE); + assert_eq!(h.state().session.state.selected_props, vec![(lid, second)], "{why}: {key:?}"); + } + }; + h.state_mut().ui.focused = PanelKind::Composition; + stays(&mut h, "another panel"); + h.state_mut().ui.focused = PanelKind::EffectControls; + h.state_mut().dialog = Some(effectcraft_ui_egui::Dialog::About); + stays(&mut h, "a dialog"); + h.state_mut().dialog = None; + h.run_steps(3); + let at = rect_of(&h, &format!("effectControls.effect.{second}.name")).center(); + h.event(egui::Event::PointerMoved(at)); + for pressed in [true, false] { + h.event(egui::Event::PointerButton { pos: at, button: egui::PointerButton::Secondary, pressed, modifiers: egui::Modifiers::NONE }); + h.step(); + } + h.run_steps(2); + assert!(egui::Popup::is_any_open(&h.ctx), "the effect context menu is open"); + stays(&mut h, "the context menu"); + header_arrow_key(&mut h, egui::Key::Escape, egui::Modifiers::NONE); + h.run_steps(3); + double_click(&mut h, at); + h.run_steps(3); + assert!(h.state().auto.find(&format!("effectControls.effect.{second}.nameEdit")).is_some(), "the rename field is open"); + stays(&mut h, "the rename field"); + assert!(h.state().auto.find(&format!("effectControls.effect.{second}.nameEdit")).is_some()); +} + +/// #3585: a hidden Effect Controls (closed, under a maximized frame, behind Home) with the focus +/// left on it doesn't take Up / Down: they nudge the layer. +#[test] +fn effect_header_down_and_up_ignore_a_hidden_panel() { + for hidden in ["closed", "maximized", "home"] { + let (mut h, lid, [(fx, _), _, _]) = header_arrow_harness(); + h.state_mut().session.state.selected_props = vec![(lid, fx)]; + match hidden { + "closed" => h.state_mut().close_panel(PanelKind::EffectControls), + "maximized" => h.state_mut().toggle_maximize(PanelKind::Composition), + _ => h.state_mut().ui.start_screen = true, + } + h.run_steps(2); + assert_eq!(h.state().ui.focused, PanelKind::EffectControls, "{hidden}: stale focus is preserved"); + let y = position(&h, lid)[1]; + header_arrow_key(&mut h, egui::Key::ArrowDown, egui::Modifiers::NONE); + assert_eq!(h.state().session.state.selected_props, vec![(lid, fx)], "{hidden}"); + assert!(position(&h, lid)[1] > y, "{hidden}: Down still nudges the layer"); + } +} + +/// #3585: locked to a layer that isn't selected, Effect Controls' arrows act on the effects it +/// shows: Down / Up select among them and Left / Right close and open them. +#[test] +fn effect_header_arrows_act_on_the_locked_layer() { + let (mut h, lid, [(first, _), (second, _), _]) = header_arrow_harness(); + let comp = h.state().session.active_comp_id().unwrap().0; + let other = h.state_mut().session.execute("layer.newSolid", json!({"name": "Other", "color": "#202020"})).unwrap()["layer"].as_u64().unwrap(); + h.state_mut().ui.effect_controls_lock = Some(effectcraft_ui_egui::state::EffectControlsLock { comp, layer: lid.0 }); + h.state_mut().session.state.selected_layers = vec![LayerId(other)]; + h.state_mut().session.state.selected_props = vec![(lid, first)]; + h.state_mut().ui.focused = PanelKind::EffectControls; + h.run_steps(3); + assert!(shows_effect(&h, first), "the locked panel shows the first layer"); + header_arrow_key(&mut h, egui::Key::ArrowDown, egui::Modifiers::NONE); + assert_eq!(h.state().session.state.selected_props, vec![(lid, second)]); + header_arrow_key(&mut h, egui::Key::ArrowLeft, egui::Modifiers::NONE); + assert_eq!(h.state().ui.fx_closed.iter().copied().collect::>(), vec![second], "Left closes the locked layer's effect"); + header_arrow_key(&mut h, egui::Key::ArrowRight, egui::Modifiers::NONE); + assert!(h.state().ui.fx_closed.is_empty()); +} + +/// #3585: a long effect list scrolls so the effect Down / Up picks stays in view. +#[test] +fn effect_header_down_and_up_scroll_the_picked_effect_into_view() { + let mut s = Session::default(); + s.execute("comp.new", json!({"name": "Long", "width": 32, "height": 18, "frameRate": 30, "duration": 2})).unwrap(); + let lid = s.execute("layer.newSolid", json!({"name": "Controls", "color": "#40b080"})).unwrap()["layer"].as_u64().unwrap(); + let fx: Vec = + (0..16).map(|_| s.execute("effect.apply", json!({"layers": [lid], "effect": "Point Control"})).unwrap()["effects"][0].as_u64().unwrap()).collect(); + s.state.selected_props = vec![(LayerId(lid), fx[0])]; + let mut app = EffectcraftApp::new(s); + app.show_panel(PanelKind::EffectControls); + app.toggle_maximize(PanelKind::EffectControls); + app.ui.focused = PanelKind::EffectControls; + let mut h = Harness::builder().with_size(egui::vec2(800.0, 300.0)).with_step_dt(1.0 / 60.0).build_eframe(|_| app); + h.run_steps(4); + let panel = rect_of(&h, "panel.EffectControls"); + let last = fx[fx.len() - 1]; + assert!(!panel.contains_rect(rect_of(&h, &format!("effectControls.effect.{last}"))), "the last effect starts out of view"); + for _ in 1..fx.len() { + header_arrow_key(&mut h, egui::Key::ArrowDown, egui::Modifiers::NONE); + h.run_steps(2); + let (_, uid) = h.state().session.state.selected_props[0]; + assert!(panel.contains_rect(rect_of(&h, &format!("effectControls.effect.{uid}"))), "Down keeps effect {uid} in view"); + } + assert_eq!(h.state().session.state.selected_props, vec![(LayerId(lid), last)]); + for _ in 1..fx.len() { + header_arrow_key(&mut h, egui::Key::ArrowUp, egui::Modifiers::NONE); + h.run_steps(2); + let (_, uid) = h.state().session.state.selected_props[0]; + assert!(panel.contains_rect(rect_of(&h, &format!("effectControls.effect.{uid}"))), "Up keeps effect {uid} in view"); + } + assert_eq!(h.state().session.state.selected_props, vec![(LayerId(lid), fx[0])]); +} + #[test] fn effect_controls_widgets_register_automation_ids() { let (app, x) = app(); diff --git a/docs/effects-parity.md b/docs/effects-parity.md index 6675bc131..f305ce2e4 100644 --- a/docs/effects-parity.md +++ b/docs/effects-parity.md @@ -65,6 +65,7 @@ the GPU is performance, not parity. | Date | Change | Summary | |---|---|---| | 2026-11-17 | minor | Gaussian Blur: Blurriness takes After Effects' recorded valid range 0..30000 (was 0..3000; default and 0..50 slider unchanged). Padding stays within the effect pixel budget at the top of the range (CPU and GPU), and Roto Brush analyses 0.24 saved below a Gaussian Blur still match (#3460) | +| 2026-11-17 | minor | CC Power Pin: Expansion (Top, Left, Right, Bottom) takes After Effects' minimum of −200 % (hard range −200..1000; defaults and sliders unchanged). When two opposite sides add up to less than −100 % the source rectangle flips (CPU and GPU) | | 2026-11-12 | minor | Parameters take After Effects' recorded valid ranges (hard range; defaults and sliders unchanged): Levels (Individual Controls) levels −10000..10000 and Gamma from 0; 4-Color Gradient Blend to 10000 and Jitter to 500 %; Change Color Hue Transform ±1800°; Noise HLS (and Auto) amounts to 1000 % and Grain Size from 0; Grid Border to 2000; Venetian Blinds Width 1..32000 and Feather to 32000; Radial Wipe Feather to 32000; Scatter Amount to 1000; Beam thicknesses to 4000; Transform Scale ±30000 %; Turbulent Displace Random Seed to 100000. A test checks every mapped parameter's range against the recorded table (CPU and GPU) | | 2026-10-19 | minor | Glow (original colours): bright pass per channel, 8 × (value − threshold + 0.061), measured against After Effects 2026 (CPU and GPU) | | 2026-10-19 | minor | Glow (colour channels): the glow covers the layer's blurred alpha, blur σ = 0.384 × radius, measured against After Effects 2026 renders (CPU and GPU) |