Merge pull request #774 from vangel76/gap-proportional-scrubbing
#770: Proportional Scrubbing of Timeline values (Ctrl+Alt / Cmd+Opt) # Conflicts: # docs/ui-parity.md
This commit is contained in:
@@ -3546,8 +3546,14 @@ fn value_editor(
|
||||
// With several layers selected the edit applies to all of them (#491): a scrub by the same
|
||||
// change, a typed value as it is.
|
||||
let scrub = ui.ctx().dragged_id().is_some() && ui.input(|i| i.pointer.is_decidedly_dragging());
|
||||
// Proportional Scrubbing (After Effects 26.2): Ctrl+Alt (Cmd+Opt) spreads the change over the
|
||||
// selected layers by selection order, the first unchanged and the last by all of it.
|
||||
let proportional = scrub && ui.input(|i| widgets::proportional_scrub(i.modifiers));
|
||||
let set = |actions: &mut Vec<(String, serde_json::Value)>, v: serde_json::Value| {
|
||||
actions.push(("prop.set".into(), json!({"layer": layer.id.0, "prop": uid, "value": v, "merge": merge, "selected": true, "offset": scrub})))
|
||||
actions.push((
|
||||
"prop.set".into(),
|
||||
json!({"layer": layer.id.0, "prop": uid, "value": v, "merge": merge, "selected": true, "offset": scrub, "proportional": proportional}),
|
||||
))
|
||||
};
|
||||
let is_3d = layer.is_3d();
|
||||
let mut x = at.x;
|
||||
@@ -3602,8 +3608,8 @@ fn value_editor(
|
||||
dims.push(r);
|
||||
if let Some(nv) = nv {
|
||||
let mut nc = c.clone();
|
||||
// Alt edits one value of a linked pair.
|
||||
let shown = if linked && !ui.input(|i| i.modifiers.alt) { n.min(c.len()) } else { 1 };
|
||||
// Alt edits one value of a linked pair (Ctrl+Alt is a proportional scrub).
|
||||
let shown = if linked && !ui.input(|i| i.modifiers.alt && !widgets::proportional_scrub(i.modifiers)) { n.min(c.len()) } else { 1 };
|
||||
let from = if shown == 1 { d } else { 0 };
|
||||
for (e, v) in widgets::constrained(c.get(from..from + shown).unwrap_or_default(), d - from, nv).into_iter().enumerate() {
|
||||
if let Some(slot) = nc.get_mut(from + e) {
|
||||
|
||||
@@ -121,7 +121,7 @@ pub fn hot_number_at(
|
||||
let mult = ui.input(|i| {
|
||||
if i.modifiers.shift {
|
||||
10.0
|
||||
} else if i.modifiers.command {
|
||||
} else if i.modifiers.command && !proportional_scrub(i.modifiers) {
|
||||
0.1
|
||||
} else {
|
||||
1.0
|
||||
@@ -138,6 +138,13 @@ pub fn hot_number_at(
|
||||
(rect, out, resp.drag_stopped())
|
||||
}
|
||||
|
||||
/// Ctrl+Alt (Cmd+Opt on macOS) held while scrubbing hot text: After Effects' Proportional
|
||||
/// Scrubbing, which spreads the change over the selected layers by selection order. Ctrl alone
|
||||
/// still scrubs finely and Shift by tens.
|
||||
pub fn proportional_scrub(m: egui::Modifiers) -> bool {
|
||||
m.command && m.alt
|
||||
}
|
||||
|
||||
/// [`hot_number_at`] for a whole number (an angle's revolutions): a drag steps it once every
|
||||
/// `1 / speed` pixels however slowly the pointer moves (the fractions add up between frames),
|
||||
/// and a typed value is truncated. Returns (rect, Some(new value) when changed, drag finished).
|
||||
|
||||
@@ -398,3 +398,40 @@ fn properties_panel_edits_every_selected_layer() {
|
||||
assert!((a - b - d).abs() < 1e-6, "same change on every layer: {before:?} → {after:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// #770: Proportional Scrubbing (After Effects 26.2). With three layers selected, a Ctrl+Alt
|
||||
/// (Cmd+Opt) scrub of Position X in the Timeline leaves the first selected layer where it is,
|
||||
/// moves the last by the whole change and the middle one by half, whichever layer is scrubbed.
|
||||
#[test]
|
||||
fn ctrl_alt_scrub_in_the_timeline_is_proportional() {
|
||||
let mut s = Session::default();
|
||||
s.execute("comp.new", json!({"name": "Three", "width": 320, "height": 180, "frameRate": 30, "duration": 4})).unwrap();
|
||||
let mut ids = vec![];
|
||||
for c in ["#e04020", "#20e040", "#2040e0"] {
|
||||
let l = s.execute("layer.newSolid", json!({"color": c, "width": 40, "height": 40})).unwrap()["layer"].as_u64().unwrap();
|
||||
s.execute("prop.set", json!({"layer": l, "path": "transform/position", "value": [100.0, 90.0]})).unwrap();
|
||||
ids.push(l);
|
||||
}
|
||||
// Selection order: the first created, then the second, then the third.
|
||||
for (i, l) in ids.iter().enumerate() {
|
||||
s.execute("layer.select", json!({"layers": [l], "add": i > 0})).unwrap();
|
||||
}
|
||||
let middle = ids[1];
|
||||
let uid = s.active_comp().unwrap().layer(LayerId(middle)).unwrap().props.prop("transform/position").unwrap().uid;
|
||||
let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).build_eframe(|_| EffectcraftApp::new(s));
|
||||
h.run_steps(3);
|
||||
let ctx = h.ctx.clone();
|
||||
effectcraft_ui_egui::menus::invoke(h.state_mut(), &ctx, "timeline.reveal.position", json!({})).unwrap();
|
||||
h.run_steps(4);
|
||||
let x = |h: &Harness<'_, EffectcraftApp>, l: u64| {
|
||||
h.state().session.active_comp().unwrap().layer(LayerId(l)).unwrap().props.prop("transform/position").unwrap().value.components()[0]
|
||||
};
|
||||
let e = h.state().auto.find(&format!("timeline.prop.{uid}.value.0")).cloned().expect("the middle layer's Position X shows");
|
||||
let from = pos2(e.rect[0] + e.rect[2] / 2.0, e.rect[1] + e.rect[3] / 2.0);
|
||||
let ctrl_alt = egui::Modifiers { alt: true, ctrl: true, command: true, ..Default::default() };
|
||||
drag(&mut h, from, from + egui::vec2(40.0, 0.0), ctrl_alt);
|
||||
let moved: Vec<f64> = ids.iter().map(|l| x(&h, *l) - 100.0).collect();
|
||||
assert!(moved[2] > 1.0, "the last selected layer moved: {moved:?}");
|
||||
assert!(moved[0].abs() < 1e-9, "the first selected layer stays: {moved:?}");
|
||||
assert!((moved[1] - moved[2] / 2.0).abs() < 1e-6, "the middle one moves by half: {moved:?}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user