diff --git a/crates/compositor/src/cursor.rs b/crates/compositor/src/cursor.rs index cec135311..f30f376f1 100644 --- a/crates/compositor/src/cursor.rs +++ b/crates/compositor/src/cursor.rs @@ -28,6 +28,68 @@ fn smoothstep01(x: f32) -> f32 { u * u * (3.0 - 2.0 * u) } +/// Grid every reshaped track is resampled on (`CursorTrack::shaped`): the spring's step, and fine +/// enough that a curve drawn from ~30 Hz telemetry does not come out as a polyline. +const SHAPE_STEP_S: f32 = 1.0 / 240.0; +/// Longest crossfade between a motion region and the globally smoothed path on each side of it. +const MOTION_BLEND_S: f32 = 0.12; +/// Narrowest and widest Gaussian of a `smooth` region (standard deviation, seconds). +const MOTION_SMOOTH_MIN_SIGMA_S: f32 = 0.01; +const MOTION_SMOOTH_MAX_SIGMA_S: f32 = 0.16; +/// A click this close to a `straight` region's end is where the line goes. +const MOTION_CLICK_SNAP_S: f32 = 0.05; + +/// What a cursor-motion region does over its span (`cursorMotionRegionSchema` app-side). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MotionMode { + /// The raw samples, unsmoothed. + Recorded, + /// A zero-phase Gaussian of the raw samples: no lag, no overshoot. + Smooth, + /// A straight line from the start position to the end (or click) position. + Straight, + /// The start position, held. + Freeze, +} + +/// Progress curve of a `straight` region. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MotionEasing { + EaseInOut, + Linear, + EaseIn, + EaseOut, +} + +impl MotionEasing { + fn apply(self, u: f32) -> f32 { + let u = u.clamp(0.0, 1.0); + match self { + MotionEasing::Linear => u, + MotionEasing::EaseIn => u * u * u, + MotionEasing::EaseOut => 1.0 - (1.0 - u).powi(3), + MotionEasing::EaseInOut => { + if u < 0.5 { + 4.0 * u * u * u + } else { + 1.0 - (-2.0 * u + 2.0).powi(3) / 2.0 + } + } + } + } +} + +/// One section of the track whose path is replaced, in the track's own (source) seconds. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct MotionRegion { + pub start: f32, + pub end: f32, + pub mode: MotionMode, + /// 0..1, `Smooth` only. + pub strength: f32, + pub easing: MotionEasing, +} + #[derive(Clone)] pub struct CursorTrack { /// (t_secondes, cx, cy) normalisés dans le cadre screen, triés. @@ -513,7 +575,22 @@ impl CursorTrack { /// du slider (0 = passthrough, retourne un clone). Les clics restent sur leurs instants /// bruts (le bounce est temporel, pas positionnel — ne doit pas suivre le lissage). pub fn smoothed(&self, factor: f32) -> CursorTrack { - if self.samples.len() < 2 || factor <= 0.0 { + self.shaped(factor, &[], &[]) + } + + /// `smoothed(factor)`, plus two things the editor adds on top of the global slider: + /// + /// - `breaks`: source instants where the spring restarts, as it already does when the cursor + /// reappears. The callers pass the start of the clip window being played + /// (`Scene::cursor_break_for_clip`), so footage a trim or a clip boundary removed no longer + /// drags the drawn cursor: without it the spring crossed the cut material and the cursor + /// teleported at the cut. + /// - `motion`: sections whose path is replaced (`MotionRegion`), each crossfaded into the + /// smoothed path over up to `MOTION_BLEND_S` at both edges so no section starts with a jump. + /// + /// Clicks, click points, cursor types and visibility keep their raw values, as in `smoothed`. + pub fn shaped(&self, factor: f32, breaks: &[f32], motion: &[MotionRegion]) -> CursorTrack { + if self.samples.len() < 2 || (factor <= 0.0 && motion.is_empty()) { return CursorTrack::new_with_visibility( self.samples.clone(), self.clicks.clone(), @@ -521,53 +598,65 @@ impl CursorTrack { self.visibility.clone(), ); } - const STEP_S: f32 = 1.0 / 240.0; + const STEP_S: f32 = SHAPE_STEP_S; let start = self.samples[0].0; let end = self.samples[self.samples.len() - 1].0; let step_count = (((end - start) / STEP_S).round() as usize).max(1); - let n = step_count + 1; - let mut times = Vec::with_capacity(n); + let mut sorted_breaks: Vec = breaks.iter().copied().filter(|b| b.is_finite()).collect(); + sorted_breaks.sort_by(|a, b| a.partial_cmp(b).unwrap()); + let mut times: Vec = (0..=step_count) + .map(|i| if i == step_count { end } else { start + i as f32 * STEP_S }) + .collect(); + // Each break is a sample of its own, the first of its run: a clip rarely starts on the + // 240 Hz grid, and restarting at the next grid sample instead left the clip's first frame + // interpolating from the run before, still trailing. The one step this shortens is + // integrated as a whole one; the run starts at rest on its target, so nothing visible + // changes. + times.extend(sorted_breaks.iter().copied().filter(|&b| b > start && b < end)); + times.sort_by(|a, b| a.partial_cmp(b).unwrap()); + times.dedup_by(|later, earlier| (*later - *earlier).abs() < 1e-6); + let n = times.len(); let mut raw_x = Vec::with_capacity(n); let mut raw_y = Vec::with_capacity(n); - for i in 0..n { - let t = if i == n - 1 { - end - } else { - start + i as f32 * STEP_S - }; + for &t in × { let (cx, cy) = self.at(t).unwrap_or((0.0, 0.0)); - times.push(t); raw_x.push(cx); raw_y.push(cy); } - let (stiffness, damping, mass) = cursor_spring_config(factor); // Une phase masquée coupe le ressort. Au retour, le curseur repart du premier point - // réellement visible au lieu de traverser la trajectoire cachée avec du retard. - let mut xs = Vec::with_capacity(n); - let mut ys = Vec::with_capacity(n); + // réellement visible au lieu de traverser la trajectoire cachée avec du retard. A break + // (a clip window's start) cuts it the same way. + let segment_of = |t: f32| sorted_breaks.partition_point(|&b| b <= t + 1e-6); + let mut runs: Vec<(usize, usize)> = Vec::new(); let mut run_start = 0; while run_start < n { let visible = self.visible_at(times[run_start]); + let segment = segment_of(times[run_start]); let mut run_end = run_start + 1; - while run_end < n && self.visible_at(times[run_end]) == visible { + while run_end < n + && self.visible_at(times[run_end]) == visible + && segment_of(times[run_end]) == segment + { run_end += 1; } - xs.extend(spring_smooth( - &raw_x[run_start..run_end], - stiffness, - damping, - mass, - STEP_S, - )); - ys.extend(spring_smooth( - &raw_y[run_start..run_end], - stiffness, - damping, - mass, - STEP_S, - )); + runs.push((run_start, run_end)); run_start = run_end; } + let (mut xs, mut ys) = if factor > 0.0 { + let (stiffness, damping, mass) = cursor_spring_config(factor); + let mut xs = Vec::with_capacity(n); + let mut ys = Vec::with_capacity(n); + for &(a, b) in &runs { + xs.extend(spring_smooth(&raw_x[a..b], stiffness, damping, mass, STEP_S)); + ys.extend(spring_smooth(&raw_y[a..b], stiffness, damping, mass, STEP_S)); + } + (xs, ys) + } else { + (raw_x.clone(), raw_y.clone()) + }; + for region in motion { + self.apply_motion_region(region, ×, &raw_x, &raw_y, &runs, &mut xs, &mut ys); + } let samples = times .into_iter() .zip(xs) @@ -588,6 +677,89 @@ impl CursorTrack { } } + /// Replace `xs`/`ys` (the smoothed path on the `times` grid) over `region` by what its mode + /// draws from the raw path, crossfaded at both edges. `runs` are the grid's spring runs + /// (visibility × clip window): a Gaussian never averages across one, for the reason the + /// spring restarts there. + #[allow(clippy::too_many_arguments)] + fn apply_motion_region( + &self, + region: &MotionRegion, + times: &[f32], + raw_x: &[f32], + raw_y: &[f32], + runs: &[(usize, usize)], + xs: &mut [f32], + ys: &mut [f32], + ) { + let n = times.len(); + if n == 0 || !(region.end > region.start) { + return; + } + let lo = times.partition_point(|&t| t < region.start); + let hi = times.partition_point(|&t| t <= region.end); + if lo >= hi { + return; + } + let span = region.end - region.start; + let blend = MOTION_BLEND_S.min(span / 2.0); + let weight = |t: f32| -> f32 { + if blend <= 0.0 { + return 1.0; + } + smoothstep01((t - region.start) / blend).min(smoothstep01((region.end - t) / blend)) + }; + let start_point = self.at(region.start).unwrap_or((raw_x[lo], raw_y[lo])); + let end_point = self + .clicks + .iter() + .zip(&self.click_points) + .filter(|(&tc, _)| (tc - region.end).abs() <= MOTION_CLICK_SNAP_S) + .min_by(|(a, _), (b, _)| { + (*a - region.end).abs().partial_cmp(&(*b - region.end).abs()).unwrap() + }) + .map(|(_, &point)| point) + .or_else(|| self.at(region.end)) + .unwrap_or((raw_x[hi - 1], raw_y[hi - 1])); + let sigma_steps = (MOTION_SMOOTH_MIN_SIGMA_S + + (MOTION_SMOOTH_MAX_SIGMA_S - MOTION_SMOOTH_MIN_SIGMA_S) * region.strength.clamp(0.0, 1.0)) + / SHAPE_STEP_S; + let radius = (sigma_steps * 3.0).ceil() as usize; + let kernel: Vec = (0..=radius) + .map(|k| (-(k as f32 * k as f32) / (2.0 * sigma_steps * sigma_steps)).exp()) + .collect(); + for i in lo..hi { + let t = times[i]; + let (rx, ry) = match region.mode { + MotionMode::Recorded => (raw_x[i], raw_y[i]), + MotionMode::Freeze => start_point, + MotionMode::Straight => { + let u = region.easing.apply((t - region.start) / span); + ( + start_point.0 + (end_point.0 - start_point.0) * u, + start_point.1 + (end_point.1 - start_point.1) * u, + ) + } + MotionMode::Smooth => { + let run = runs[runs.partition_point(|&(_, b)| b <= i).min(runs.len() - 1)]; + let a = i.saturating_sub(radius).max(run.0); + let b = (i + radius + 1).min(run.1); + let (mut sx, mut sy, mut sw) = (0.0f32, 0.0f32, 0.0f32); + for j in a..b { + let w = kernel[i.abs_diff(j)]; + sx += raw_x[j] * w; + sy += raw_y[j] * w; + sw += w; + } + (sx / sw, sy / sw) + } + }; + let w = weight(t); + xs[i] += (rx - xs[i]) * w; + ys[i] += (ry - ys[i]) * w; + } + } + /// Opacité du curseur (0.0..1.0) selon l'inactivité (auto-hide). /// Si `auto_hide` est faux, retourne toujours 1.0. /// Si `auto_hide` est vrai : @@ -1215,3 +1387,155 @@ mod tests { assert_eq!(track.opacity_at(5.9, true), 0.0); } } + +#[cfg(test)] +mod motion_tests { + use super::*; + + fn arrow() -> Vec<(f32, String)> { + vec![(0.0, "arrow".to_string())] + } + + /// A pointer moving right at `speed` per second from x = 0.1, sampled at 30 Hz. + fn moving(duration: f32, speed: f32) -> CursorTrack { + let samples = (0..=((duration * 30.0) as usize)) + .map(|i| { + let t = i as f32 / 30.0; + (t, 0.1 + speed * t, 0.5) + }) + .collect(); + CursorTrack::new(samples, vec![], arrow()) + } + + fn region(start: f32, end: f32, mode: MotionMode) -> MotionRegion { + MotionRegion { start, end, mode, strength: 0.5, easing: MotionEasing::Linear } + } + + #[test] + fn shaped_without_breaks_or_motion_is_smoothed() { + let raw = moving(2.0, 0.3); + for t in [0.0, 0.4, 1.3, 2.0] { + assert_eq!(raw.shaped(0.4, &[], &[]).at(t), raw.smoothed(0.4).at(t)); + } + } + + #[test] + fn a_break_restarts_the_spring_so_a_cut_does_not_teleport_late() { + // Still at x = 0.1 until 2 s, then at x = 0.9: what a cut to later footage looks like. + let samples: Vec<_> = (0..=120) + .map(|i| { + let t = i as f32 / 30.0; + (t, if t < 2.0 { 0.1 } else { 0.9 }, 0.5) + }) + .collect(); + let raw = CursorTrack::new(samples, vec![], arrow()); + let lagging = raw.shaped(0.5, &[], &[]).at(2.05).unwrap().0; + let restarted = raw.shaped(0.5, &[2.0], &[]).at(2.05).unwrap().0; + assert!(lagging < 0.8, "without a break the spring still trails: {lagging}"); + assert!((restarted - 0.9).abs() < 1e-3, "after a break it starts on the pointer: {restarted}"); + } + + #[test] + fn a_break_between_grid_samples_restarts_exactly_on_it() { + // The clip starts at 2.001 s, off the 240 Hz grid: its first frame must already be on the + // pointer, not interpolated from the run before the break. + let samples: Vec<_> = (0..=120) + .map(|i| { + let t = i as f32 / 30.0; + (t, if t < 2.0 { 0.1 } else { 0.9 }, 0.5) + }) + .collect(); + let raw = CursorTrack::new(samples, vec![], arrow()); + let at_break = 2.001; + let target = raw.at(at_break).unwrap().0; + let restarted = raw.shaped(0.5, &[at_break], &[]).at(at_break).unwrap().0; + assert!((restarted - target).abs() < 1e-4, "{restarted} vs the pointer at {target}"); + } + + #[test] + fn smooth_mode_neither_lags_nor_overshoots() { + // Lag: on a straight move the zero-phase Gaussian sits on the pointer. + let raw = moving(3.0, 0.2); + let shaped = raw.shaped(0.5, &[], &[region(0.5, 2.5, MotionMode::Smooth)]); + let (x, _) = shaped.at(1.5).unwrap(); + assert!((x - (0.1 + 0.2 * 1.5)).abs() < 2e-3, "no lag on a linear move: {x}"); + + // Overshoot: a hard stop never carries the drawn pointer past where it stopped. + let samples: Vec<_> = (0..=90) + .map(|i| { + let t = i as f32 / 30.0; + (t, (0.1 + 0.8 * t).min(0.5), 0.5) + }) + .collect(); + let stop = CursorTrack::new(samples, vec![], arrow()); + let shaped = stop.shaped(0.0, &[], &[region(0.0, 3.0, MotionMode::Smooth)]); + let mut t = 0.0; + while t <= 3.0 { + let (x, _) = shaped.at(t).unwrap(); + assert!(x <= 0.5 + 1e-4, "overshoot at {t}: {x}"); + t += 1.0 / 240.0; + } + } + + #[test] + fn straight_mode_runs_on_the_line_and_ends_on_the_click() { + // A wandering path, clicked at 2 s. + let samples: Vec<_> = (0..=90) + .map(|i| { + let t = i as f32 / 30.0; + (t, 0.2 + 0.3 * t, 0.5 + 0.1 * (t * 9.0).sin()) + }) + .collect(); + let raw = CursorTrack::new(samples, vec![2.0], arrow()); + let start = raw.at(0.5).unwrap(); + let click = raw.at(2.0).unwrap(); + let shaped = raw.shaped(0.3, &[], &[region(0.5, 2.0, MotionMode::Straight)]); + let (x, y) = shaped.at(1.25).unwrap(); + let mid = ((start.0 + click.0) / 2.0, (start.1 + click.1) / 2.0); + assert!((x - mid.0).abs() < 1e-3 && (y - mid.1).abs() < 1e-3, "({x}, {y}) vs {mid:?}"); + } + + #[test] + fn freeze_mode_holds_the_start_position() { + let raw = moving(3.0, 0.2); + let start = raw.at(1.0).unwrap(); + let shaped = raw.shaped(0.3, &[], &[region(1.0, 2.5, MotionMode::Freeze)]); + for t in [1.2, 1.7, 2.3] { + let (x, y) = shaped.at(t).unwrap(); + assert!((x - start.0).abs() < 1e-4 && (y - start.1).abs() < 1e-4, "{t}: ({x}, {y})"); + } + } + + #[test] + fn region_edges_blend_without_a_jump() { + let raw = moving(4.0, 0.25); + let shaped = raw.shaped(0.3, &[], &[region(1.0, 3.0, MotionMode::Freeze)]); + let frame = 1.0 / 60.0; + let mut t = 0.5; + let mut previous = shaped.at(t).unwrap(); + while t < 3.5 { + t += frame; + let next = shaped.at(t).unwrap(); + let step = ((next.0 - previous.0).powi(2) + (next.1 - previous.1).powi(2)).sqrt(); + // Leaving a 2 s freeze the pointer is 0.5 away: the blend spreads that over + // MOTION_BLEND_S (about 7 frames, peak 1.5× the mean) instead of one frame. + assert!(step < 0.12, "jump of {step} at {t}"); + previous = next; + } + } + + #[test] + fn shaping_keeps_visibility_clicks_and_types() { + let raw = CursorTrack::new_with_visibility( + vec![(0.0, 0.1, 0.1), (1.0, 0.5, 0.5), (2.0, 0.9, 0.9)], + vec![1.0], + arrow(), + vec![(0.0, true), (1.5, false)], + ); + let shaped = raw.shaped(0.5, &[0.8], &[region(0.2, 1.8, MotionMode::Smooth)]); + assert!(shaped.visible_at(1.0)); + assert!(!shaped.visible_at(1.6)); + assert_eq!(shaped.clicks_between(0.0, 2.0), raw.clicks_between(0.0, 2.0)); + assert_eq!(shaped.type_at(1.0), raw.type_at(1.0)); + } +} diff --git a/crates/compositor/src/live.rs b/crates/compositor/src/live.rs index 52a95f905..059829c1f 100644 --- a/crates/compositor/src/live.rs +++ b/crates/compositor/src/live.rs @@ -903,6 +903,7 @@ fn reload_cursor_if_changed( screen_path: &str, turned: bool, smoothing: f32, + shape: &CursorShape, ) -> bool { let key = cursor_key(screen_path, turned); if key == *loaded_cursor_path { @@ -929,12 +930,30 @@ fn reload_cursor_if_changed( // curseur (`Compositor::resized`), et le relisser parcourt tout // l'enregistrement à chaque bascule d'un scrub. match raw_cursor { - Some(track) => comp.set_cursor(track.smoothed(smoothing)), + Some(track) => comp.set_cursor(track.shaped(smoothing, &shape.0, &shape.1)), None => comp.clear_cursor(), } true } +/// What reshapes a cursor track besides the smoothing slider (`CursorTrack::shaped`): where its +/// spring restarts and the editor's cursor-motion sections, both for one recording file. +type CursorShape = (Vec, Vec); + +/// The break is the playing clip's own start (`Scene::cursor_break_for_clip`), so it changes +/// with the active clip and the track is shaped again on a clip change even when the file stays +/// the same: one spring pass over the recording. +fn cursor_shape_inputs(scene: Option<&Scene>, clip_index: usize, screen_path: &str) -> CursorShape { + scene + .map(|s| { + ( + s.cursor_break_for_clip(clip_index).into_iter().collect(), + s.cursor.motion_for(screen_path), + ) + }) + .unwrap_or_default() +} + fn scene_for_clip(scene: &Scene, clip_index: usize) -> Scene { match scene.clips.get(clip_index) { Some(clip) => scene.for_clip_window( @@ -1699,6 +1718,8 @@ unsafe fn render_thread( let mut last_preview_size: (u32, u32) = (0, 0); let mut last_ip: Option = None; let mut last_smoothing: f32 = -1.0; // force la 1re application (0.0 est une valeur valide) + // The breaks and motion sections the current track was shaped with (`cursor_shape_inputs`). + let mut last_shape: CursorShape = Default::default(); // Fenêtre de stabilisation après un changement EN PAUSE. Un seul recompose ne suffit pas // quand l'effet demandé est asynchrone : la segmentation webcam (détourage / flou / fond // personnalisé) démarre son worker au 1er compose, ne SOUMET la frame qu'au 2e et ne @@ -1812,6 +1833,7 @@ unsafe fn render_thread( // construction identique. Mesuré : 66 bascules sur un scrub de deux clips, // donc 66 relectures du même fichier. // The key also carries the clip's turn: the same file turned is another track. + let shape = cursor_shape_inputs(full_scene.as_ref(), active_clip_index, &active_screen_path); if reload_cursor_if_changed( &comp, &mut raw_cursor, @@ -1819,8 +1841,10 @@ unsafe fn render_thread( &active_screen_path, turned, ip.cursor_smoothing, + &shape, ) { last_smoothing = ip.cursor_smoothing; + last_shape = shape; } clip_changed = true; } @@ -1858,10 +1882,14 @@ unsafe fn render_thread( }); // Lissage ressort-amortisseur : re-génère la piste (240 Hz) uniquement quand la valeur // change (pas à chaque frame — le resample+ressort parcourt tout l'enregistrement). + // The cursor-motion sections and clip breaks reshape it the same way, when the scene + // changes them. if let Some(raw) = &raw_cursor { - if ip.cursor_smoothing != last_smoothing { - comp.set_cursor(raw.smoothed(ip.cursor_smoothing)); + let shape = cursor_shape_inputs(full_scene.as_ref(), active_clip_index, &active_screen_path); + if ip.cursor_smoothing != last_smoothing || shape != last_shape { + comp.set_cursor(raw.shaped(ip.cursor_smoothing, &shape.0, &shape.1)); last_smoothing = ip.cursor_smoothing; + last_shape = shape; } } // un changement de param doit se voir même en pause (édition live des sliders) : @@ -1894,6 +1922,7 @@ unsafe fn render_thread( // here, mirrored the new way. let turned = scene.as_ref().is_some_and(Scene::screen_turned); comp.set_scene(scene); + let shape = cursor_shape_inputs(full_scene.as_ref(), active_clip_index, &active_screen_path); if reload_cursor_if_changed( &comp, &mut raw_cursor, @@ -1901,8 +1930,10 @@ unsafe fn render_thread( &active_screen_path, turned, ip.cursor_smoothing, + &shape, ) { last_smoothing = ip.cursor_smoothing; + last_shape = shape; } } // Le temps programme dépend du clip actif ET de la scène entière (durées des clips diff --git a/crates/compositor/src/scene.rs b/crates/compositor/src/scene.rs index b4a5fb11d..96720185d 100644 --- a/crates/compositor/src/scene.rs +++ b/crates/compositor/src/scene.rs @@ -743,6 +743,76 @@ pub struct SceneCursor { /// `#[serde(default)]` : champ ajouté après coup, absent des JSON de test existants. #[serde(default)] pub cursor_sprites: std::collections::HashMap, + /// Per-section path overrides (`SceneCursorMotionRegion` app-side). `#[serde(default)]`: the + /// app omits the key when there are none. + #[serde(default)] + pub motion: Vec, +} + +/// One cursor-motion region, in the SOURCE time of the recording `screen_path` names. +#[derive(Debug, Clone, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct SceneCursorMotionRegion { + pub screen_path: String, + pub start_sec: f32, + pub end_sec: f32, + pub mode: SceneCursorMotionMode, + #[serde(default)] + pub strength: f32, + #[serde(default)] + pub easing: SceneCursorMotionEasing, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum SceneCursorMotionMode { + Recorded, + Smooth, + Straight, + Freeze, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub enum SceneCursorMotionEasing { + #[default] + EaseInOut, + Linear, + EaseIn, + EaseOut, +} + +impl SceneCursor { + /// The motion regions that apply to the cursor track of `screen_path`, for + /// `CursorTrack::shaped`. Paths compare as the live clip resolution compares them + /// (`same_source_path`): without regard to ASCII case. + pub fn motion_for(&self, screen_path: &str) -> Vec { + use crate::cursor::{MotionEasing, MotionMode, MotionRegion}; + self.motion + .iter() + .filter(|region| { + region.screen_path.eq_ignore_ascii_case(screen_path) + && region.end_sec > region.start_sec + }) + .map(|region| MotionRegion { + start: region.start_sec, + end: region.end_sec, + mode: match region.mode { + SceneCursorMotionMode::Recorded => MotionMode::Recorded, + SceneCursorMotionMode::Smooth => MotionMode::Smooth, + SceneCursorMotionMode::Straight => MotionMode::Straight, + SceneCursorMotionMode::Freeze => MotionMode::Freeze, + }, + strength: region.strength.clamp(0.0, 1.0), + easing: match region.easing { + SceneCursorMotionEasing::EaseInOut => MotionEasing::EaseInOut, + SceneCursorMotionEasing::Linear => MotionEasing::Linear, + SceneCursorMotionEasing::EaseIn => MotionEasing::EaseIn, + SceneCursorMotionEasing::EaseOut => MotionEasing::EaseOut, + }, + }) + .collect() + } } /// Un sprite de curseur : image + point de pivot. @@ -973,6 +1043,25 @@ pub struct Scene { } impl Scene { + /// Where the cursor spring restarts while clip `clip_index` plays + /// (`CursorTrack::shaped`): its own source start, and nothing else. Another + /// clip's start on the same file is no cut in this one, so it must not reset this clip's + /// cursor mid-window. `None` when the clip before it is the same file ending exactly where + /// this one starts: the source runs on across that boundary (a split with nothing removed), + /// and a restart there would itself be a jump. The clips are addressed by index, as + /// everywhere else in the scene, so no path comparison picks the clip. + pub fn cursor_break_for_clip(&self, clip_index: usize) -> Option { + let clip = self.clips.get(clip_index)?; + let continues = clip_index + .checked_sub(1) + .and_then(|previous| self.clips.get(previous)) + .is_some_and(|previous| { + previous.screen_path.eq_ignore_ascii_case(&clip.screen_path) + && (previous.source_end_sec - clip.source_start_sec).abs() < 1e-3 + }); + (!continues).then_some(clip.source_start_sec as f32) + } + pub fn layout_at(&self, t: f32) -> Option> { self.layout_regions.iter().find(|r| r.clip_index == self.active_clip_index && t >= r.start_sec && t < r.end_sec).map(|r| r.sample(t)) @@ -1428,3 +1517,87 @@ mod annotation_tests { ); } } + +#[cfg(test)] +mod cursor_motion_tests { + use super::*; + + fn cursor(extra: serde_json::Value) -> SceneCursor { + let mut json = serde_json::json!({ + "show": true, "size": 1.0, "smoothing": 0.3, "motionBlur": 0.0, + "clickBounce": 1.0, "clipToBounds": false, "theme": "default" + }); + json.as_object_mut().unwrap().extend(extra.as_object().unwrap().clone()); + serde_json::from_value(json).unwrap() + } + + #[test] + fn a_scene_without_motion_parses_with_none() { + assert!(cursor(serde_json::json!({})).motion.is_empty()); + } + + #[test] + fn motion_regions_parse_and_are_matched_by_file() { + let c = cursor(serde_json::json!({ "motion": [ + { "screenPath": "a.mp4", "startSec": 1.0, "endSec": 2.0, "mode": "smooth", + "strength": 0.7, "easing": "linear" }, + { "screenPath": "a.mp4", "startSec": 3.0, "endSec": 4.0, "mode": "straight", + "strength": 0.5, "easing": "ease-out" }, + { "screenPath": "b.mp4", "startSec": 0.0, "endSec": 1.0, "mode": "freeze" }, + { "screenPath": "a.mp4", "startSec": 5.0, "endSec": 5.0, "mode": "recorded" } + ]})); + let regions = c.motion_for("a.mp4"); + assert_eq!(regions.len(), 2, "the other file and the empty span are left out"); + assert_eq!(regions[0].mode, crate::cursor::MotionMode::Smooth); + assert!((regions[0].strength - 0.7).abs() < 1e-6); + assert_eq!(regions[1].easing, crate::cursor::MotionEasing::EaseOut); + assert_eq!(c.motion_for("A.MP4").len(), 2, "paths compare without regard to ASCII case"); + let b = c.motion_for("b.mp4"); + assert_eq!(b[0].mode, crate::cursor::MotionMode::Freeze); + assert_eq!(b[0].easing, crate::cursor::MotionEasing::EaseInOut, "absent easing defaults"); + } +} + +#[cfg(test)] +mod cursor_break_tests { + use super::*; + + fn scene_with_clips(clips: &[(&str, f64, f64)]) -> Scene { + let clips: Vec = clips + .iter() + .map(|(path, start, end)| { + format!( + r#"{{"screenPath":"{path}","webcamPath":"","sourceStartSec":{start},"sourceEndSec":{end},"webcamOffsetSec":0}}"# + ) + }) + .collect(); + let json = format!( + r##"{{"clips":[{}],"layout":{{"preset":"no-webcam","webcamSize":1,"webcamShape":"rectangle","webcamMirror":false,"webcamPosition":null,"webcamReactiveZoom":false}},"effects":{{"padding":0,"blur":false,"shadow":0,"roundnessFrac":0,"motionBlur":0}},"background":{{"kind":"color","color":"#000000"}},"zoomRegions":[],"cursor":{{"show":false,"size":1,"smoothing":0,"motionBlur":0,"clickBounce":0,"clipToBounds":false,"theme":"default"}},"cropByClip":[],"output":{{"width":1920,"height":1080,"fps":30}}}}"##, + clips.join(",") + ); + Scene::from_json(&json).expect("scene") + } + + #[test] + fn each_clip_restarts_at_its_own_start_only() { + // A = [0, 6] and B = [2, 4] on one file: B's start is no cut inside A. + let scene = scene_with_clips(&[("a.mp4", 0.0, 6.0), ("a.mp4", 2.0, 4.0)]); + assert_eq!(scene.cursor_break_for_clip(0), Some(0.0)); + assert_eq!(scene.cursor_break_for_clip(1), Some(2.0)); + assert_eq!(scene.cursor_break_for_clip(2), None, "no such clip"); + } + + #[test] + fn a_clip_that_continues_the_one_before_it_does_not_restart() { + // A trim removed 4..6: the segment after the cut restarts, a plain split at 2 does not. + let scene = scene_with_clips(&[ + ("C:/Capture.mp4", 0.0, 2.0), + ("c:/capture.mp4", 2.0, 4.0), + ("C:/Capture.mp4", 6.0, 9.0), + ("other.mp4", 9.0, 12.0), + ]); + assert_eq!(scene.cursor_break_for_clip(1), None, "same file, source runs on"); + assert_eq!(scene.cursor_break_for_clip(2), Some(6.0), "footage was removed before it"); + assert_eq!(scene.cursor_break_for_clip(3), Some(9.0), "another file"); + } +} diff --git a/crates/compositor/src/timeline_walk.rs b/crates/compositor/src/timeline_walk.rs index ac05f17a1..5032057c9 100644 --- a/crates/compositor/src/timeline_walk.rs +++ b/crates/compositor/src/timeline_walk.rs @@ -350,6 +350,8 @@ unsafe fn walk_timeline( let cursor_enabled = scene.is_some(); let cursor_smoothing = scene.as_ref().map(|s| s.cursor.smoothing).unwrap_or(0.0); let mut cursor_tracks: HashMap = HashMap::new(); + // `None`: the file has no readable telemetry, so it is not read again for the next clip. + let mut raw_cursor_tracks: HashMap> = HashMap::new(); let mut cursor_active_path: Option = None; let mut frames: u64 = 0; @@ -506,13 +508,33 @@ unsafe fn walk_timeline( } if cursor_enabled { - // Keyed by file AND turn: the same file turned is another track. - let key = cursor_key(&clip.screen, turned); + // Keyed by file AND turn: the same file turned is another track. The raw file is read + // once; the shaped track is also keyed by where this clip's spring restarts + // (`Scene::cursor_break_for_clip`, as in preview), so one clip's start never resets + // the cursor inside another clip on the same file. The editor's cursor-motion + // sections reshape it too (`CursorTrack::shaped`); they are the file's, the same for + // every clip on it. + let raw_key = cursor_key(&clip.screen, turned); + let clip_break = scene.as_ref().and_then(|s| s.cursor_break_for_clip(clip_index)); + let key = match clip_break { + Some(at) => format!("{raw_key}#{}", at.to_bits()), + None => raw_key.clone(), + }; if !cursor_tracks.contains_key(&key) { - let path = format!("{}.cursor.json", clip.screen); - if let Ok(raw) = CursorTrack::load(&path, 0.0, 24.0 * 3600.0) { - let raw = if turned { raw.turned() } else { raw }; - cursor_tracks.insert(key.clone(), raw.smoothed(cursor_smoothing)); + if !raw_cursor_tracks.contains_key(&raw_key) { + let path = format!("{}.cursor.json", clip.screen); + let raw = CursorTrack::load(&path, 0.0, 24.0 * 3600.0) + .ok() + .map(|raw| if turned { raw.turned() } else { raw }); + raw_cursor_tracks.insert(raw_key.clone(), raw); + } + if let Some(Some(raw)) = raw_cursor_tracks.get(&raw_key) { + let breaks: Vec = clip_break.into_iter().collect(); + let motion = scene + .as_ref() + .map(|s| s.cursor.motion_for(&clip.screen)) + .unwrap_or_default(); + cursor_tracks.insert(key.clone(), raw.shaped(cursor_smoothing, &breaks, &motion)); } // absente/illisible → pas d'entrée : ce clip s'exporte sans curseur (visible, // pas masqué en un curseur fantôme d'un autre clip). diff --git a/electron/ai-edition/agent-tools.test.ts b/electron/ai-edition/agent-tools.test.ts index 44fa595e3..91a8a9fa5 100644 --- a/electron/ai-edition/agent-tools.test.ts +++ b/electron/ai-edition/agent-tools.test.ts @@ -196,6 +196,8 @@ describe("the mutating-tool table", () => { "addAnnotation", "addAudio", "addCameraFullscreen", + "addCursorMotion", + "setCursorMotion", "addEffect", "addLayoutChange", "addSpeed", @@ -847,6 +849,43 @@ describe("executeAgentTool", () => { expect(() => documentSchema.parse(result.document)).not.toThrow(); }); + it("addCursorMotion / setCursorMotion / removeModifier round-trip a cursor motion section", () => { + const added = executeAgentTool( + fixtureDocument(), + "addCursorMotion", + JSON.stringify({ startSec: 2, endSec: 4, mode: "straight" }), + ); + expect(added.ok).toBe(true); + const id = JSON.parse(added.resultJson).cursorMotionId as string; + expect(added.document?.cursorMotionRanges).toEqual([ + expect.objectContaining({ id, startMs: 2000, endMs: 4000, mode: "straight" }), + ]); + expect(() => documentSchema.parse(added.document)).not.toThrow(); + const snapshot = documentSnapshotForModel(added.document as AxcutDocument) as { + cursorMotionRegions: unknown[]; + }; + expect(snapshot.cursorMotionRegions).toEqual([ + { id, startSec: 2, endSec: 4, mode: "straight", easing: "ease-in-out" }, + ]); + + const set = executeAgentTool( + added.document as AxcutDocument, + "setCursorMotion", + JSON.stringify({ cursorMotionId: id, mode: "smooth", strength: 0.8 }), + ); + expect(set.ok).toBe(true); + expect(set.document?.cursorMotionRanges?.[0]).toMatchObject({ mode: "smooth", strength: 0.8 }); + + const removed = executeAgentTool( + set.document as AxcutDocument, + "removeModifier", + JSON.stringify({ id }), + ); + expect(removed.ok).toBe(true); + expect(JSON.parse(removed.resultJson).kind).toBe("cursorMotion"); + expect(removed.document?.cursorMotionRanges).toEqual([]); + }); + it("refuses a speed outside the range every reader plays", () => { for (const speed of [100, 0.1]) { const result = executeAgentTool( diff --git a/electron/ai-edition/agent-tools.ts b/electron/ai-edition/agent-tools.ts index 3cbccdb01..0621ab266 100644 --- a/electron/ai-edition/agent-tools.ts +++ b/electron/ai-edition/agent-tools.ts @@ -58,7 +58,10 @@ import { type AxcutShaderEffect, type AxcutShaderEffectRange, blurDataSchema, + CURSOR_MOTION_EASINGS, + CURSOR_MOTION_MODES, clipCropRegionSchema, + DEFAULT_CURSOR_MOTION_STRENGTH, figureDataSchema, shaderEffectParamSchema, shaderEffectSchema, @@ -161,6 +164,8 @@ function modifierIds(document: AxcutDocument, kind: ModifierKind): string[] { return [...new Set(document.audioTracks.map(trackGroupId))]; case "shaderEffect": return (document.shaderEffectRanges ?? []).map((region) => region.id); + case "cursorMotion": + return (document.cursorMotionRanges ?? []).map((region) => region.id); } } @@ -619,6 +624,7 @@ function modifierIdsOf(document: AxcutDocument): string[] { ...speedRegions.map((r) => r.id), ...cameraFullscreenRegions.map((r) => r.id), ...(document.shaderEffectRanges ?? []).map((r) => r.id), + ...(document.cursorMotionRanges ?? []).map((r) => r.id), ]; } @@ -917,6 +923,26 @@ export const setSpeedArgs = z.object({ speed: speedSchema.optional(), }); +const cursorMotionModeSchema = z.enum(CURSOR_MOTION_MODES); +const cursorMotionEasingSchema = z.enum(CURSOR_MOTION_EASINGS); + +export const addCursorMotionArgs = z.object({ + startSec: secondsSchema, + endSec: secondsSchema, + mode: cursorMotionModeSchema.default("smooth"), + strength: z.number().min(0).max(1).optional(), + easing: cursorMotionEasingSchema.optional(), +}); + +export const setCursorMotionArgs = z.object({ + cursorMotionId: z.string().min(1), + startSec: secondsSchema.optional(), + endSec: secondsSchema.optional(), + mode: cursorMotionModeSchema.optional(), + strength: z.number().min(0).max(1).optional(), + easing: cursorMotionEasingSchema.optional(), +}); + /** How a text annotation looks: the settings the editor's inspector offers for one. */ const annotationLookArgs = { fontSize: z @@ -1144,6 +1170,8 @@ export const OPENSCREEN_TOOL_NAMES = [ "setZoom", "addSpeed", "setSpeed", + "addCursorMotion", + "setCursorMotion", "addAnnotation", "setAnnotation", "addLayoutChange", @@ -1227,6 +1255,8 @@ export const MUTATING_TOOL_NAMES: ReadonlySet = new Set([ "setZoom", "addSpeed", "setSpeed", + "addCursorMotion", + "setCursorMotion", "addAnnotation", "setAnnotation", "addLayoutChange", @@ -1508,6 +1538,14 @@ export function documentSnapshotForModel( endSec: roundSec(a.endMs), ...annotationForAgent(a), })), + cursorMotionRegions: coalesceForAgent(document.cursorMotionRanges ?? []).map((r) => ({ + id: r.id, + startSec: roundSec(r.startMs), + endSec: roundSec(r.endMs), + mode: r.mode, + ...(r.mode === "smooth" ? { strength: r.strength ?? DEFAULT_CURSOR_MOTION_STRENGTH } : {}), + ...(r.mode === "straight" ? { easing: r.easing ?? "ease-in-out" } : {}), + })), cameraFullscreenRegions: coalesceForAgent(cameraFullscreenRegions).map((c) => ({ id: c.id, startSec: roundSec(c.startMs), @@ -3172,6 +3210,86 @@ export function executeAgentTool( }; } + case "addCursorMotion": { + const parsed = addCursorMotionArgs.safeParse(args); + if (!parsed.success) return failure(parsed.error.message); + const startMs = toMs(Math.min(parsed.data.startSec, parsed.data.endSec)); + const endMs = toMs(Math.max(parsed.data.startSec, parsed.data.endSec)); + const { mode, strength, easing } = parsed.data; + const region = { + id: createId("curm"), + startMs, + endMs, + mode, + ...(strength !== undefined ? { strength } : {}), + ...(easing !== undefined ? { easing } : {}), + }; + const placed = anchorForAgent(region, document, "curm"); + const landing = landingOf(placed, document); + if (!landing.anchored) { + return coversNoClip("cursor motion section", startMs / 1000, endMs / 1000, document); + } + const next: AxcutDocument = { + ...document, + cursorMotionRanges: [...(document.cursorMotionRanges ?? []), ...placed], + }; + return { + ok: true, + document: next, + resultJson: JSON.stringify({ + cursorMotionId: landing.ids[0], + mode, + ...landingReport(landing, startMs / 1000, endMs / 1000), + }), + summary: + `added cursor motion (${mode}) ${formatSec(landing.startSec)} – ${formatSec(landing.endSec)}` + + landingSuffix(landing, startMs / 1000, endMs / 1000), + }; + } + + case "setCursorMotion": { + const parsed = setCursorMotionArgs.safeParse(args); + if (!parsed.success) return failure(parsed.error.message); + const prev = document.cursorMotionRanges ?? []; + const id = parsed.data.cursorMotionId; + const existing = prev.find((r) => r.id === id); + if (!existing) return failure(`Unknown cursor motion section: ${id}`); + const pill = new Set(resolvePillIds(prev, id)); + const { startMs, endMs } = resolveSpanMs(existing, parsed.data.startSec, parsed.data.endSec); + const blocked = refuseIfBlocked("cursor motion section", prev, id, { startMs, endMs }); + if (blocked) return blocked; + const patch = { + ...(parsed.data.mode !== undefined ? { mode: parsed.data.mode } : {}), + ...(parsed.data.strength !== undefined ? { strength: parsed.data.strength } : {}), + ...(parsed.data.easing !== undefined ? { easing: parsed.data.easing } : {}), + }; + const rebuilt = replacePillSpan( + prev.map((r) => (pill.has(r.id) ? { ...r, ...patch } : r)), + id, + startMs, + endMs, + document.timeline.clips, + () => createId("curm"), + ); + const landing = landingAfterPillEdit(prev, rebuilt, pill, document); + if (!landing.anchored) { + return coversNoClip("cursor motion section", startMs / 1000, endMs / 1000, document); + } + const mode = patch.mode ?? existing.mode; + return { + ok: true, + document: { ...document, cursorMotionRanges: rebuilt }, + resultJson: JSON.stringify({ + cursorMotionId: landing.ids[0] ?? id, + mode, + ...landingReport(landing, startMs / 1000, endMs / 1000), + }), + summary: + `updated cursor motion (${mode}) over ${formatSec(landing.startSec)} – ${formatSec(landing.endSec)}` + + landingSuffix(landing, startMs / 1000, endMs / 1000), + }; + } + case "addAnnotation": { const parsed = addAnnotationArgs.safeParse(args); if (!parsed.success) return failure(parsed.error.message); @@ -3897,13 +4015,14 @@ export function executeAgentTool( else if (cameraFullscreenRegions.some((c) => c.id === id)) kind = "cameraFullscreen"; else if (document.audioTracks.some((t) => trackGroupId(t) === id)) kind = "audio"; else if ((document.shaderEffectRanges ?? []).some((r) => r.id === id)) kind = "shaderEffect"; + else if ((document.cursorMotionRanges ?? []).some((r) => r.id === id)) kind = "cursorMotion"; else if (layoutRuns(document).some((r) => r.ids.includes(id))) kind = "layout"; if (kind === "layout" && layoutRuns(document)[0]?.ids.includes(id)) { return failure("The first layout cannot be removed. Change its preset instead."); } if (!kind) { return failure( - `No zoom / speed / annotation / full-camera / audio / effect modifier with id ${id}. ` + + `No zoom / speed / annotation / full-camera / audio / effect / cursor-motion modifier with id ${id}. ` + `For a trim use removeTrim; for a clip use removeClip.`, ); } diff --git a/electron/ai-edition/deep-agent/service.test.ts b/electron/ai-edition/deep-agent/service.test.ts index 839d33a0a..10fefba44 100644 --- a/electron/ai-edition/deep-agent/service.test.ts +++ b/electron/ai-edition/deep-agent/service.test.ts @@ -86,6 +86,8 @@ const ARGS: Record = { setZoom: { zoomId: "zoom_nope" }, addSpeed: { startSec: 1, endSec: 2 }, setSpeed: { speedId: "speed_nope" }, + addCursorMotion: { startSec: 1, endSec: 2 }, + setCursorMotion: { cursorMotionId: "curm_nope" }, addAnnotation: { startSec: 1, endSec: 2, text: "hi" }, setAnnotation: { annotationId: "ann_nope" }, addCameraFullscreen: { startSec: 1, endSec: 2 }, diff --git a/electron/ai-edition/deep-agent/service.ts b/electron/ai-edition/deep-agent/service.ts index b7dafcb93..1c049b2df 100644 --- a/electron/ai-edition/deep-agent/service.ts +++ b/electron/ai-edition/deep-agent/service.ts @@ -57,6 +57,7 @@ import { addAnnotationArgs, addAudioArgs, addAutoZoomsArgs, + addCursorMotionArgs, addEffectArgs, addLayoutChangeArgs, addSpeedArgs, @@ -85,6 +86,7 @@ import { setAspectRatioArgs, setAudioArgs, setClipRangeArgs, + setCursorMotionArgs, setEffectArgs, setEffectDefinitionArgs, setLayoutPresetArgs, @@ -270,6 +272,10 @@ export const TOOL_DESCRIPTIONS: Record = { "Add a speed-change region over a span of the edited timeline (virtual seconds). speed > 1 fast-forwards, < 1 slows down, from 0.25× to 16× (default 1.5×). Use to speed through slow stretches without cutting them.", setSpeed: "Move, resize, or change the multiplier of an existing speed region by id (virtual-timeline seconds). Only the fields you pass are changed.", + addCursorMotion: + "Override how the cursor moves over a span of the edited timeline (virtual seconds), on top of the global smoothing. mode 'smooth' (the default) removes jitter and loops without lag, its strength 0–1 (default 0.5) the amount; 'straight' moves in a straight line from where the pointer is at the start to where it is at the end, or to a click right at the end, with easing 'ease-in-out' (default), 'linear', 'ease-in' or 'ease-out'; 'freeze' holds the pointer where the span starts; 'recorded' shows the raw pointer without smoothing. The edges blend into the surrounding path. Use it where the recorded cursor wanders, shakes or drifts while nothing happens.", + setCursorMotion: + "Move, resize, or change the mode, strength or easing of an existing cursor motion section by id (virtual-timeline seconds). Only the fields you pass are changed.", addAnnotation: "Add an annotation over a span of the edited timeline (virtual seconds). type picks what it is: 'text' (the default) for callouts, labels and titles; 'figure' for an arrow pointing at something; 'blur' for a privacy mask that blurs or pixelates what is under it, the way to hide an email address, a token, a password field or any private detail the recording shows. Image annotations are not available here: they need a file, added in the editor. x/y place the centre, 0–100 percent of the annotation's box (default the centre). Text and arrows sit on the output frame, the whole picture padding included, as the editor places them: zooms and padding never move them. A blur sits on the recording's picture instead, so x/y/width/height are percent of the recording and it stays on what it hides when padding or a zoom moves the picture. A text box is sized to its words and kept inside the frame; it is drawn on a dark plate by default, and fontSize, color, background, bold and animation set its look. An arrow or a blur takes width/height (default 30 × 20) and its own data: figureData {arrowDirection, color, strokeWidth} for an arrow, blurData {type 'blur' or 'mosaic', shape 'rectangle' or 'oval', color, intensity, blockSize} for a blur. The result reads the annotation back as getCurrentDocument reports it.", setAnnotation: @@ -609,6 +615,8 @@ export const TOOL_ARG_SCHEMAS: ReadonlyArray = [ ["setZoom", setZoomArgs], ["addSpeed", addSpeedArgs], ["setSpeed", setSpeedArgs], + ["addCursorMotion", addCursorMotionArgs], + ["setCursorMotion", setCursorMotionArgs], ["addAnnotation", addAnnotationArgs], ["setAnnotation", setAnnotationArgs], ["addLayoutChange", addLayoutChangeArgs], diff --git a/src/components/ai-edition/NewEditorShell.timelineHeight.test.tsx b/src/components/ai-edition/NewEditorShell.timelineHeight.test.tsx index 7183ee1d4..d5c0275ea 100644 --- a/src/components/ai-edition/NewEditorShell.timelineHeight.test.tsx +++ b/src/components/ai-edition/NewEditorShell.timelineHeight.test.tsx @@ -103,7 +103,7 @@ describe("NewEditorShell timeline height", () => { }); it("exports expected constants allowing all lanes to fit without vertical clipping", () => { - expect(DEFAULT_TIMELINE_HEIGHT_PX).toBe(392); + expect(DEFAULT_TIMELINE_HEIGHT_PX).toBe(421); expect(MIN_TIMELINE_HEIGHT_PX).toBe(160); expect(MAX_TIMELINE_HEIGHT_PX).toBe(560); }); diff --git a/src/components/ai-edition/NewEditorShell.tsx b/src/components/ai-edition/NewEditorShell.tsx index 008255319..3a9f05d7a 100644 --- a/src/components/ai-edition/NewEditorShell.tsx +++ b/src/components/ai-edition/NewEditorShell.tsx @@ -130,7 +130,8 @@ function NativePlaybackSync({ return null; } -export const DEFAULT_TIMELINE_HEIGHT_PX = 392; +/** 392 until the cursor-motion lane (one `.tlLane`, 29px) joined the always-shown lanes. */ +export const DEFAULT_TIMELINE_HEIGHT_PX = 421; export const MIN_TIMELINE_HEIGHT_PX = 160; export const MAX_TIMELINE_HEIGHT_PX = 560; /** The Effects lane's height (`.tlLane`: 24px and a 5px margin), added while the project has an @@ -253,7 +254,9 @@ export function NewEditorShell() { localStorage.setItem("os-editor-timeline-height", String(DEFAULT_TIMELINE_HEIGHT_PX)); return DEFAULT_TIMELINE_HEIGHT_PX; } - if (raw === "344") { + // 344 and 392 were earlier defaults: a user who never resized still has one saved, and + // would see the newest lane cut off. + if (raw === "344" || raw === "392") { localStorage.setItem("os-editor-timeline-height", String(DEFAULT_TIMELINE_HEIGHT_PX)); return DEFAULT_TIMELINE_HEIGHT_PX; } @@ -1231,7 +1234,9 @@ export function NewEditorShell() { ? "ann" : snapshot.kind === "shaderEffect" ? "fxr" - : snapshot.kind; + : snapshot.kind === "cursorMotion" + ? "curm" + : snapshot.kind; // Audio re-ventilates through its own anchorer, which advances each // fragment's source offset — the generic one would copy the offset into @@ -1298,6 +1303,17 @@ export function NewEditorShell() { return; } await saveDocument(next, { history: true }); + } else if (snapshot.kind === "cursorMotion") { + await saveDocument( + { + ...doc, + cursorMotionRanges: [ + ...(doc.cursorMotionRanges ?? []), + ...(anchored as NonNullable), + ], + }, + { history: true }, + ); } else { const key = "speedRegions"; const legacy = (doc.legacyEditor as Record) ?? {}; @@ -1390,7 +1406,9 @@ export function NewEditorShell() { ? tl.annotationRegions : sel.kind === "speed" ? tl.speedRegions - : tl.cameraFullscreenRegions; + : sel.kind === "cursorMotion" + ? tl.cursorMotionRegions + : tl.cameraFullscreenRegions; const region = wholePillOf( source as Array<{ id: string; startMs: number; endMs: number }>, sel.id, @@ -1556,6 +1574,11 @@ export function NewEditorShell() { void tl.addSpeed(newRegionDurationSec()); return; } + if (matchesShortcut(e, shortcuts.addCursorMotion, isMac)) { + e.preventDefault(); + void tl.addCursorMotion(newRegionDurationSec()); + return; + } if (matchesShortcut(e, shortcuts.addCameraFullscreen, isMac)) { e.preventDefault(); window.dispatchEvent(new Event("openscreen:change-layout")); diff --git a/src/components/ai-edition/v4/CursorMotionControl.test.tsx b/src/components/ai-edition/v4/CursorMotionControl.test.tsx new file mode 100644 index 000000000..8fbc767cd --- /dev/null +++ b/src/components/ai-edition/v4/CursorMotionControl.test.tsx @@ -0,0 +1,63 @@ +// @vitest-environment jsdom +import "@testing-library/jest-dom"; +import { fireEvent, render, screen } from "@testing-library/react"; +import { describe, expect, it, vi } from "vitest"; +import type { CursorMotionMode } from "@/lib/ai-edition/schema"; + +// Driven directly, like SpeedControl: the pane needs a project and a selected section. The +// translator echoes keys so the assertions read against keys, not copy. +vi.mock("@/contexts/I18nContext", () => ({ + useScopedT: () => (key: string, vars?: Record) => + vars ? `${key}:${Object.values(vars).join(",")}` : key, +})); + +import { CursorMotionControl } from "./FloatingInspector"; + +function renderControl(mode: CursorMotionMode) { + const tl = { + updateCursorMotionSettings: vi.fn(async () => undefined), + updateCursorMotionLive: vi.fn(), + commitCursorMotionChange: vi.fn(async () => undefined), + }; + render(); + return tl; +} + +describe("CursorMotionControl", () => { + it("offers the strength only for a smooth section", () => { + renderControl("smooth"); + expect(screen.getByText("cursorMotion.strength")).toBeInTheDocument(); + expect(screen.queryByText("cursorMotion.easing")).not.toBeInTheDocument(); + expect(screen.getByText("cursorMotion.descriptions.smooth")).toBeInTheDocument(); + }); + + it("offers the speed curve only for a straight section", () => { + renderControl("straight"); + expect(screen.getByText("cursorMotion.easing")).toBeInTheDocument(); + expect(screen.queryByText("cursorMotion.strength")).not.toBeInTheDocument(); + }); + + it("shows neither parameter for a frozen or recorded section", () => { + for (const mode of ["freeze", "recorded"] as const) { + const { unmount } = render( + , + ); + expect(screen.queryByText("cursorMotion.strength")).not.toBeInTheDocument(); + expect(screen.queryByText("cursorMotion.easing")).not.toBeInTheDocument(); + unmount(); + } + }); + + it("writes the picked mode", () => { + const tl = renderControl("smooth"); + fireEvent.click(screen.getByRole("button", { name: "cursorMotion.modes.freeze" })); + expect(tl.updateCursorMotionSettings).toHaveBeenCalledWith("m1", { mode: "freeze" }); + }); +}); diff --git a/src/components/ai-edition/v4/EditorShellV4.module.css b/src/components/ai-edition/v4/EditorShellV4.module.css index fa9e8a0de..af6e1df35 100644 --- a/src/components/ai-edition/v4/EditorShellV4.module.css +++ b/src/components/ai-edition/v4/EditorShellV4.module.css @@ -1693,6 +1693,9 @@ .laneShaderEffect { --_c: #14b8a6; } +.laneCursorMotion { + --_c: #f59e0b; +} /* A zoom's camera moves (#1028): a trail on each side of the pill, fading away from it, BELOW it (a chained neighbour's pill stays on top). Thinner than the pill so it reads as part of it, not as another region. The part a trim cuts is hatched in the trim lane's red. */ diff --git a/src/components/ai-edition/v4/FloatingInspector.tsx b/src/components/ai-edition/v4/FloatingInspector.tsx index f0ec3e2e2..75fa7fe45 100644 --- a/src/components/ai-edition/v4/FloatingInspector.tsx +++ b/src/components/ai-edition/v4/FloatingInspector.tsx @@ -57,12 +57,16 @@ import { TEXT_ANIMATION_VALUES, } from "@/lib/ai-edition/annotations/textAnimation"; import { resolveAspectRatioValue } from "@/lib/ai-edition/document/outputFormat"; -import type { - AxcutAnnotationRegion, - AxcutClip, - AxcutShaderEffect, - AxcutShaderEffectParam, - AxcutShaderEffectRange, +import { + type AxcutAnnotationRegion, + type AxcutClip, + type AxcutCursorMotionRegion, + type AxcutShaderEffect, + type AxcutShaderEffectParam, + type AxcutShaderEffectRange, + CURSOR_MOTION_EASINGS, + CURSOR_MOTION_MODES, + DEFAULT_CURSOR_MOTION_STRENGTH, } from "@/lib/ai-edition/schema"; import { resolveShaderEffectValue } from "@/lib/ai-edition/shaderEffects"; import { useProjectStore } from "@/lib/ai-edition/store/projectStore"; @@ -94,6 +98,11 @@ import { zoomRecordingPaths, } from "../recordedCursorTypes"; import { TextColorField } from "../TextColorField"; +import { + cursorMotionEasingLabel, + cursorMotionLabel, + cursorMotionModeLabel, +} from "./cursorMotionLabels"; import styles from "./EditorShellV4.module.css"; import { LayoutPicker } from "./LayoutPicker"; @@ -657,6 +666,75 @@ export function SpeedControl({ ); } +/** What a cursor-motion section does to the pointer, and the one parameter its mode reads. */ +export function CursorMotionControl({ + region, + tl, +}: { + region: Pick; + tl: Pick< + TimelineApi, + "updateCursorMotionSettings" | "updateCursorMotionLive" | "commitCursorMotionChange" + >; +}) { + const ts = useScopedT("settings"); + const strength = Math.round((region.strength ?? DEFAULT_CURSOR_MOTION_STRENGTH) * 100); + const description = + region.mode === "recorded" + ? ts("cursorMotion.descriptions.recorded") + : region.mode === "smooth" + ? ts("cursorMotion.descriptions.smooth") + : region.mode === "straight" + ? ts("cursorMotion.descriptions.straight") + : ts("cursorMotion.descriptions.freeze"); + return ( + <> + {paneStack( + ts("cursorMotion.mode"), + ({ + value: mode, + label: cursorMotionModeLabel(mode, ts), + }))} + value={region.mode} + columns={2} + onChange={(mode) => void tl.updateCursorMotionSettings(region.id, { mode })} + />, + )} +

{description}

+ {region.mode === "smooth" ? ( + tl.updateCursorMotionLive(region.id, { strength: next / 100 })} + onCommit={() => void tl.commitCursorMotionChange()} + full + /> + ) : null} + {region.mode === "straight" + ? paneStack( + ts("cursorMotion.easing"), + ({ + value: easing, + label: cursorMotionEasingLabel(easing, ts), + }))} + value={region.easing ?? "ease-in-out"} + columns={2} + onChange={(easing) => void tl.updateCursorMotionSettings(region.id, { easing })} + />, + ) + : null} + + ); +} + // The sizes a text reaches for, in pixels at 1080 (`annotationScale.ts`): a caption-sized note, // the default, a heading and a title. Anything else, down to 8 and up to 200, is typed in the // field at the end of the row, the zoom level's pair. @@ -987,6 +1065,28 @@ function SelectionPane({ tl, onClose }: { tl: TimelineApi; onClose: () => void } ); } + if (selection.kind === "cursorMotion") { + const region = tl.cursorMotionRegions.find((r) => r.id === selection.id); + if (!region) return null; + return ( +
+ {paneHeader( + , + tt("labels.cursorMotion"), + onClose, + tc("actions.close"), + )} +
+ + +
+
+ ); + } + if (selection.kind === "annotation") { const region = tl.annotationRegions.find((a) => a.id === selection.id); if (!region) return null; diff --git a/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx b/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx index f5638d659..4cedab459 100644 --- a/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx +++ b/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx @@ -125,6 +125,7 @@ function renderTimeline( speedRegions: [], cameraFullscreenRegions: [], shaderEffectRanges: [], + cursorMotionRegions: [], shaderEffects: [], layoutSegments: [], hasDoc: true, @@ -1001,6 +1002,7 @@ describe("V4Timeline audio lane drag", () => { layoutSegments: [], hasDoc: true, shaderEffectRanges: [], + cursorMotionRegions: [], shaderEffects: [], zoomRegions: [], trimRanges: [], diff --git a/src/components/ai-edition/v4/V4Timeline.tsx b/src/components/ai-edition/v4/V4Timeline.tsx index 3eb1abf98..b2cb91e1b 100644 --- a/src/components/ai-edition/v4/V4Timeline.tsx +++ b/src/components/ai-edition/v4/V4Timeline.tsx @@ -7,6 +7,7 @@ import { Maximize2, MessageSquare, Mic, + MousePointer2, Music, PanelsTopLeft, Pencil, @@ -88,6 +89,7 @@ import { formatBinding } from "@/lib/shortcuts"; import { nativeBridgeClient } from "@/native/client"; import { TransportBar } from "../TransportBar"; import type { VideoSource } from "../VirtualPreview"; +import { cursorMotionLabel } from "./cursorMotionLabels"; import styles from "./EditorShellV4.module.css"; import { LayoutLane } from "./LayoutLane"; import { LayoutPicker } from "./LayoutPicker"; @@ -113,7 +115,7 @@ type TimelineApi = ReturnType; const ASSET_MIME = "application/x-axcut-asset"; -type ToolId = "cut" | "comment" | "speed"; +type ToolId = "cut" | "comment" | "speed" | "cursorMotion"; // "Nice" ruler steps, from a 20th of a second up to an hour. The one that gets // used depends on the zoom (see rulerTicks), so the ladder has to cover both a @@ -611,7 +613,14 @@ const AudioLanePill = memo(function AudioLanePill({ interface LanePill { id: string; - kind: "annotation" | "speed" | "trim" | "zoom" | "cameraFullscreen" | "shaderEffect"; + kind: + | "annotation" + | "speed" + | "trim" + | "zoom" + | "cameraFullscreen" + | "shaderEffect" + | "cursorMotion"; start: number; end: number; label: string; @@ -832,6 +841,16 @@ export function V4Timeline({ sourceIds: p.ids, }; }); + const cursorMotionPills: LanePill[] = coalesceRegionsForRuler(tl.cursorMotionRegions).map( + (p) => ({ + id: p.ids[0], + kind: "cursorMotion", + start: p.start, + end: p.end, + label: cursorMotionLabel(p.member, ts), + sourceIds: p.ids, + }), + ); const effectNames = new Map(tl.shaderEffects.map((effect) => [effect.id, effect.name])); const shaderEffectPills: LanePill[] = coalesceRegionsForRuler(tl.shaderEffectRanges).map((p) => ({ id: p.ids[0], @@ -1033,6 +1052,7 @@ export function V4Timeline({ zoom: tl.zoomRegions, cameraFullscreen: tl.cameraFullscreenRegions, shaderEffect: tl.shaderEffectRanges, + cursorMotion: tl.cursorMotionRegions, // Nothing to edit on a trim but its span, and a span edit moves the whole pill. trim: [], }; @@ -1117,6 +1137,8 @@ export function V4Timeline({ await tl.updateCameraFullscreenSpan(grabbed, s * 1000, en * 1000); else if (pill.kind === "shaderEffect") await tl.updateShaderEffectSpan(grabbed, s * 1000, en * 1000); + else if (pill.kind === "cursorMotion") + await tl.updateCursorMotionSpan(grabbed, s * 1000, en * 1000); else { // Trims are stored in source-time per asset but manipulated on the // timeline like every other pill. Ventilate the new span across the @@ -1576,7 +1598,9 @@ export function V4Timeline({ ? styles.laneCameraFullscreen : kind === "shaderEffect" ? styles.laneShaderEffect - : styles.laneZoom; + : kind === "cursorMotion" + ? styles.laneCursorMotion + : styles.laneZoom; const pillIcon = (kind: LanePill["kind"]) => kind === "annotation" ? ( @@ -1588,6 +1612,8 @@ export function V4Timeline({ ) : kind === "shaderEffect" ? ( + ) : kind === "cursorMotion" ? ( + ) : ( ); @@ -1709,6 +1735,12 @@ export function V4Timeline({ shortcut: formatBinding(shortcuts.addSpeed, isMac), icon: , }, + { + id: "cursorMotion", + label: t("buttons.addCursorMotion"), + shortcut: formatBinding(shortcuts.addCursorMotion, isMac), + icon: , + }, ]; // Auto-enhance option 1 — the deterministic cursor-telemetry auto-zoom @@ -2211,6 +2243,7 @@ export function V4Timeline({ // notch stale when the user zooms and immediately creates. const dur = newRegionDurationSec(); if (tool.id === "speed") void tl.addSpeed(dur); + if (tool.id === "cursorMotion") void tl.addCursorMotion(dur); if (tool.id === "comment") void tl.addAnnotation(dur); if (tool.id === "cut") void tl.addTrim(dur); }} @@ -2477,6 +2510,14 @@ export function V4Timeline({ t("hints.pressZoom", { key: formatBinding(shortcuts.addZoom, isMac) }), )} +
+ {renderPills( + cursorMotionPills, + t("hints.pressCursorMotion", { + key: formatBinding(shortcuts.addCursorMotion, isMac), + }), + )} +
{/* Agent-written shader effects: one at a time, so one row. Only when the project has one: an agent writes them, nothing in the editor adds one, so an empty diff --git a/src/components/ai-edition/v4/V4Timeline.waveform.test.tsx b/src/components/ai-edition/v4/V4Timeline.waveform.test.tsx index a6da1cfc2..4e0c6535d 100644 --- a/src/components/ai-edition/v4/V4Timeline.waveform.test.tsx +++ b/src/components/ai-edition/v4/V4Timeline.waveform.test.tsx @@ -121,6 +121,7 @@ function renderBars(atGainDb: number): string[] { speedRegions: [], cameraFullscreenRegions: [], shaderEffectRanges: [], + cursorMotionRegions: [], shaderEffects: [], layoutSegments: [], hasDoc: true, diff --git a/src/components/ai-edition/v4/cursorMotionLabels.ts b/src/components/ai-edition/v4/cursorMotionLabels.ts new file mode 100644 index 000000000..209b31bf7 --- /dev/null +++ b/src/components/ai-edition/v4/cursorMotionLabels.ts @@ -0,0 +1,47 @@ +import { + type AxcutCursorMotionRegion, + type CursorMotionEasing, + type CursorMotionMode, + DEFAULT_CURSOR_MOTION_STRENGTH, +} from "@/lib/ai-edition/schema"; + +type Translate = (key: string, vars?: Record) => string; + +// Literal keys, one per value: `npm run i18n:check` reads keys out of the source, so a key built +// from a template would be invisible to it. +export function cursorMotionModeLabel(mode: CursorMotionMode, ts: Translate): string { + switch (mode) { + case "recorded": + return ts("cursorMotion.modes.recorded"); + case "smooth": + return ts("cursorMotion.modes.smooth"); + case "straight": + return ts("cursorMotion.modes.straight"); + case "freeze": + return ts("cursorMotion.modes.freeze"); + } +} + +export function cursorMotionEasingLabel(easing: CursorMotionEasing, ts: Translate): string { + switch (easing) { + case "ease-in-out": + return ts("cursorMotion.easings.easeInOut"); + case "linear": + return ts("cursorMotion.easings.linear"); + case "ease-in": + return ts("cursorMotion.easings.easeIn"); + case "ease-out": + return ts("cursorMotion.easings.easeOut"); + } +} + +/** The pill's text: the mode, and the strength when it is the one parameter that matters. */ +export function cursorMotionLabel( + region: Pick, + ts: Translate, +): string { + const mode = cursorMotionModeLabel(region.mode, ts); + if (region.mode !== "smooth") return mode; + const strength = Math.round((region.strength ?? DEFAULT_CURSOR_MOTION_STRENGTH) * 100); + return `${mode} · ${strength}%`; +} diff --git a/src/i18n/locales/ar/settings.json b/src/i18n/locales/ar/settings.json index 2e599890e..d8ccd2081 100644 --- a/src/i18n/locales/ar/settings.json +++ b/src/i18n/locales/ar/settings.json @@ -459,5 +459,29 @@ "dark": "داكنة", "light": "فاتحة", "custom": "مخصصة" + }, + "cursorMotion": { + "mode": "Mode", + "strength": "Strength", + "easing": "Speed curve", + "deleteRegion": "Delete cursor motion", + "modes": { + "recorded": "As recorded", + "smooth": "Smooth", + "straight": "Straight", + "freeze": "Freeze" + }, + "easings": { + "easeInOut": "Smooth", + "linear": "Linear", + "easeIn": "Speed up", + "easeOut": "Slow down" + }, + "descriptions": { + "recorded": "The pointer exactly as it was recorded, without smoothing.", + "smooth": "Removes jitter and loops without lagging behind the pointer.", + "straight": "Moves in a straight line from where the pointer starts to where it ends or clicks.", + "freeze": "Holds the pointer where the section starts." + } } } diff --git a/src/i18n/locales/ar/shortcuts.json b/src/i18n/locales/ar/shortcuts.json index a30a4ab0b..3c8773edc 100644 --- a/src/i18n/locales/ar/shortcuts.json +++ b/src/i18n/locales/ar/shortcuts.json @@ -27,7 +27,8 @@ "deleteSelected": "حذف المحدد", "playPause": "تشغيل / إيقاف مؤقت", "copySelected": "نسخ المحدد", - "paste": "لصق" + "paste": "لصق", + "addCursorMotion": "Add Cursor Motion" }, "fixedActions": { "undo": "تراجع", diff --git a/src/i18n/locales/ar/timeline.json b/src/i18n/locales/ar/timeline.json index 5e1550073..573d4311a 100644 --- a/src/i18n/locales/ar/timeline.json +++ b/src/i18n/locales/ar/timeline.json @@ -7,7 +7,8 @@ "addTrim": "إضافة قص: يزيل جزءًا من الفيديو عند الوقت الحالي", "addAnnotation": "إضافة نص أو سهم أو صورة أو تمويه عند الوقت الحالي", "addSpeed": "إضافة تغيير في السرعة عند الوقت الحالي", - "addCameraFullscreen": "تغيير التخطيط هنا" + "addCameraFullscreen": "تغيير التخطيط هنا", + "addCursorMotion": "Add a cursor motion section at the current time" }, "hints": { "pressZoom": "اضغط {{key}} لإضافة تكبير", @@ -15,7 +16,8 @@ "pressAnnotation": "اضغط {{key}} لإضافة شرح", "pressAudio": "اضغط {{audioKey}} لإضافة صوت، و{{voiceoverKey}} لتسجيل تعليق صوتي", "pressSpeed": "اضغط {{key}} لإضافة سرعة", - "pressCameraFullscreen": "اضغط {{key}} لإضافة مقطع كاميرا كاملة الشاشة" + "pressCameraFullscreen": "اضغط {{key}} لإضافة مقطع كاميرا كاملة الشاشة", + "pressCursorMotion": "Press {{key}} to add cursor motion" }, "labels": { "pan": "تحريك", @@ -31,7 +33,8 @@ "imageItem": "صورة", "emptyText": "نص فارغ", "cameraFullscreen": "كاميرا كاملة الشاشة", - "cameraFullscreenItem": "كاميرا كاملة الشاشة {{index}}" + "cameraFullscreenItem": "كاميرا كاملة الشاشة {{index}}", + "cursorMotion": "Cursor motion" }, "trails": { "zoomIn": "التكبير التدريجي: تقترب الصورة حتى بداية التكبير", diff --git a/src/i18n/locales/cs/settings.json b/src/i18n/locales/cs/settings.json index bdfc5bd6e..32c73454b 100644 --- a/src/i18n/locales/cs/settings.json +++ b/src/i18n/locales/cs/settings.json @@ -459,5 +459,29 @@ "dark": "Tmavý", "light": "Světlý", "custom": "Vlastní" + }, + "cursorMotion": { + "mode": "Mode", + "strength": "Strength", + "easing": "Speed curve", + "deleteRegion": "Delete cursor motion", + "modes": { + "recorded": "As recorded", + "smooth": "Smooth", + "straight": "Straight", + "freeze": "Freeze" + }, + "easings": { + "easeInOut": "Smooth", + "linear": "Linear", + "easeIn": "Speed up", + "easeOut": "Slow down" + }, + "descriptions": { + "recorded": "The pointer exactly as it was recorded, without smoothing.", + "smooth": "Removes jitter and loops without lagging behind the pointer.", + "straight": "Moves in a straight line from where the pointer starts to where it ends or clicks.", + "freeze": "Holds the pointer where the section starts." + } } } diff --git a/src/i18n/locales/cs/shortcuts.json b/src/i18n/locales/cs/shortcuts.json index 40ed15e88..e9ad12b57 100644 --- a/src/i18n/locales/cs/shortcuts.json +++ b/src/i18n/locales/cs/shortcuts.json @@ -27,7 +27,8 @@ "deleteSelected": "Smazat vybrané", "playPause": "Přehrát / Pozastavit", "copySelected": "Kopírovat vybrané", - "paste": "Vložit" + "paste": "Vložit", + "addCursorMotion": "Add Cursor Motion" }, "fixedActions": { "undo": "Zpět", diff --git a/src/i18n/locales/cs/timeline.json b/src/i18n/locales/cs/timeline.json index ac484aeb3..bea203eac 100644 --- a/src/i18n/locales/cs/timeline.json +++ b/src/i18n/locales/cs/timeline.json @@ -7,7 +7,8 @@ "addTrim": "Přidat oříznutí: odstraní část videa v aktuálním čase", "addAnnotation": "Přidat text, šipku, obrázek nebo rozmazání v aktuálním čase", "addSpeed": "Přidat změnu rychlosti v aktuálním čase", - "addCameraFullscreen": "Změnit rozvržení zde" + "addCameraFullscreen": "Změnit rozvržení zde", + "addCursorMotion": "Add a cursor motion section at the current time" }, "hints": { "pressZoom": "Stiskněte {{key}} pro přidání přiblížení", @@ -15,7 +16,8 @@ "pressAnnotation": "Stiskněte {{key}} pro přidání anotace", "pressAudio": "Stiskněte {{audioKey}} pro přidání zvuku, {{voiceoverKey}} pro nahrání komentáře", "pressSpeed": "Stiskněte {{key}} pro přidání rychlosti", - "pressCameraFullscreen": "Stiskněte {{key}} pro přidání segmentu celé kamery" + "pressCameraFullscreen": "Stiskněte {{key}} pro přidání segmentu celé kamery", + "pressCursorMotion": "Press {{key}} to add cursor motion" }, "labels": { "pan": "Posun", @@ -31,7 +33,8 @@ "imageItem": "Obrázek", "emptyText": "Prázdný text", "cameraFullscreen": "Celá kamera", - "cameraFullscreenItem": "Celá kamera {{index}}" + "cameraFullscreenItem": "Celá kamera {{index}}", + "cursorMotion": "Cursor motion" }, "trails": { "zoomIn": "Najetí: pohled se přibližuje až do začátku přiblížení", diff --git a/src/i18n/locales/de/settings.json b/src/i18n/locales/de/settings.json index 61707f28e..2d74847d1 100644 --- a/src/i18n/locales/de/settings.json +++ b/src/i18n/locales/de/settings.json @@ -459,5 +459,29 @@ "dark": "Dunkel", "light": "Hell", "custom": "Eigene" + }, + "cursorMotion": { + "mode": "Mode", + "strength": "Strength", + "easing": "Speed curve", + "deleteRegion": "Delete cursor motion", + "modes": { + "recorded": "As recorded", + "smooth": "Smooth", + "straight": "Straight", + "freeze": "Freeze" + }, + "easings": { + "easeInOut": "Smooth", + "linear": "Linear", + "easeIn": "Speed up", + "easeOut": "Slow down" + }, + "descriptions": { + "recorded": "The pointer exactly as it was recorded, without smoothing.", + "smooth": "Removes jitter and loops without lagging behind the pointer.", + "straight": "Moves in a straight line from where the pointer starts to where it ends or clicks.", + "freeze": "Holds the pointer where the section starts." + } } } diff --git a/src/i18n/locales/de/shortcuts.json b/src/i18n/locales/de/shortcuts.json index dd326b83f..08427050a 100644 --- a/src/i18n/locales/de/shortcuts.json +++ b/src/i18n/locales/de/shortcuts.json @@ -27,7 +27,8 @@ "deleteSelected": "Auswahl löschen", "playPause": "Wiedergabe / Pause", "copySelected": "Auswahl kopieren", - "paste": "Einfügen" + "paste": "Einfügen", + "addCursorMotion": "Add Cursor Motion" }, "fixedActions": { "undo": "Rückgängig", diff --git a/src/i18n/locales/de/timeline.json b/src/i18n/locales/de/timeline.json index 76ac955df..7c937ba4e 100644 --- a/src/i18n/locales/de/timeline.json +++ b/src/i18n/locales/de/timeline.json @@ -7,7 +7,8 @@ "addTrim": "Trim hinzufügen: entfernt einen Abschnitt des Videos zum aktuellen Zeitpunkt", "addAnnotation": "Text, Pfeil, Bild oder Weichzeichner zum aktuellen Zeitpunkt hinzufügen", "addSpeed": "Tempowechsel zum aktuellen Zeitpunkt hinzufügen", - "addCameraFullscreen": "Layout hier ändern" + "addCameraFullscreen": "Layout hier ändern", + "addCursorMotion": "Add a cursor motion section at the current time" }, "hints": { "pressZoom": "Drücke {{key}}, um einen Zoom hinzuzufügen", @@ -15,7 +16,8 @@ "pressAnnotation": "Drücke {{key}}, um eine Anmerkung hinzuzufügen", "pressAudio": "Drücke {{audioKey}} für Audio, {{voiceoverKey}} für ein Voiceover", "pressSpeed": "Drücke {{key}}, um ein Tempo hinzuzufügen", - "pressCameraFullscreen": "Drücke {{key}}, um einen Vollbild-Kamera-Abschnitt hinzuzufügen" + "pressCameraFullscreen": "Drücke {{key}}, um einen Vollbild-Kamera-Abschnitt hinzuzufügen", + "pressCursorMotion": "Press {{key}} to add cursor motion" }, "labels": { "pan": "Verschieben", @@ -31,7 +33,8 @@ "imageItem": "Bild", "emptyText": "Leerer Text", "cameraFullscreen": "Vollbild-Kamera", - "cameraFullscreenItem": "Vollbild-Kamera {{index}}" + "cameraFullscreenItem": "Vollbild-Kamera {{index}}", + "cursorMotion": "Cursor motion" }, "trails": { "zoomIn": "Hineinzoomen: Die Ansicht zoomt bis zum Beginn des Zooms hinein", diff --git a/src/i18n/locales/en/settings.json b/src/i18n/locales/en/settings.json index 122ff4814..1b998a404 100644 --- a/src/i18n/locales/en/settings.json +++ b/src/i18n/locales/en/settings.json @@ -459,5 +459,29 @@ "dark": "Dark", "light": "Light", "custom": "Custom" + }, + "cursorMotion": { + "mode": "Mode", + "strength": "Strength", + "easing": "Speed curve", + "deleteRegion": "Delete cursor motion", + "modes": { + "recorded": "As recorded", + "smooth": "Smooth", + "straight": "Straight", + "freeze": "Freeze" + }, + "easings": { + "easeInOut": "Smooth", + "linear": "Linear", + "easeIn": "Speed up", + "easeOut": "Slow down" + }, + "descriptions": { + "recorded": "The pointer exactly as it was recorded, without smoothing.", + "smooth": "Removes jitter and loops without lagging behind the pointer.", + "straight": "Moves in a straight line from where the pointer starts to where it ends or clicks.", + "freeze": "Holds the pointer where the section starts." + } } } diff --git a/src/i18n/locales/en/shortcuts.json b/src/i18n/locales/en/shortcuts.json index 483d051b5..803a874b5 100644 --- a/src/i18n/locales/en/shortcuts.json +++ b/src/i18n/locales/en/shortcuts.json @@ -27,7 +27,8 @@ "deleteSelected": "Delete Selected", "playPause": "Play / Pause", "copySelected": "Copy Selected", - "paste": "Paste" + "paste": "Paste", + "addCursorMotion": "Add Cursor Motion" }, "fixedActions": { "undo": "Undo", diff --git a/src/i18n/locales/en/timeline.json b/src/i18n/locales/en/timeline.json index f5459f727..f33d4c158 100644 --- a/src/i18n/locales/en/timeline.json +++ b/src/i18n/locales/en/timeline.json @@ -7,7 +7,8 @@ "addTrim": "Add a trim: removes a section of the video at the current time", "addAnnotation": "Add text, an arrow, an image or a blur at the current time", "addSpeed": "Add a speed change at the current time", - "addCameraFullscreen": "Change layout here" + "addCameraFullscreen": "Change layout here", + "addCursorMotion": "Add a cursor motion section at the current time" }, "hints": { "pressZoom": "Press {{key}} to add zoom", @@ -15,7 +16,8 @@ "pressAnnotation": "Press {{key}} to add annotation", "pressAudio": "Press {{audioKey}} to add audio, {{voiceoverKey}} to record a voiceover", "pressSpeed": "Press {{key}} to add speed", - "pressCameraFullscreen": "Press {{key}} to add a Full Camera segment" + "pressCameraFullscreen": "Press {{key}} to add a Full Camera segment", + "pressCursorMotion": "Press {{key}} to add cursor motion" }, "labels": { "pan": "Pan", @@ -31,7 +33,8 @@ "imageItem": "Image", "emptyText": "Empty text", "cameraFullscreen": "Full Camera", - "cameraFullscreenItem": "Full Camera {{index}}" + "cameraFullscreenItem": "Full Camera {{index}}", + "cursorMotion": "Cursor motion" }, "trails": { "zoomIn": "Zoom-in: the view moves in until the zoom starts", diff --git a/src/i18n/locales/es/settings.json b/src/i18n/locales/es/settings.json index 7f6ae7492..6767a547a 100644 --- a/src/i18n/locales/es/settings.json +++ b/src/i18n/locales/es/settings.json @@ -459,5 +459,29 @@ "dark": "Oscura", "light": "Clara", "custom": "Personalizada" + }, + "cursorMotion": { + "mode": "Mode", + "strength": "Strength", + "easing": "Speed curve", + "deleteRegion": "Delete cursor motion", + "modes": { + "recorded": "As recorded", + "smooth": "Smooth", + "straight": "Straight", + "freeze": "Freeze" + }, + "easings": { + "easeInOut": "Smooth", + "linear": "Linear", + "easeIn": "Speed up", + "easeOut": "Slow down" + }, + "descriptions": { + "recorded": "The pointer exactly as it was recorded, without smoothing.", + "smooth": "Removes jitter and loops without lagging behind the pointer.", + "straight": "Moves in a straight line from where the pointer starts to where it ends or clicks.", + "freeze": "Holds the pointer where the section starts." + } } } diff --git a/src/i18n/locales/es/shortcuts.json b/src/i18n/locales/es/shortcuts.json index 914ea529f..0b78f8f20 100644 --- a/src/i18n/locales/es/shortcuts.json +++ b/src/i18n/locales/es/shortcuts.json @@ -27,7 +27,8 @@ "deleteSelected": "Eliminar seleccionado", "playPause": "Reproducir / Pausar", "copySelected": "Copiar selección", - "paste": "Pegar" + "paste": "Pegar", + "addCursorMotion": "Add Cursor Motion" }, "fixedActions": { "undo": "Deshacer", diff --git a/src/i18n/locales/es/timeline.json b/src/i18n/locales/es/timeline.json index 4f419decb..e3c832701 100644 --- a/src/i18n/locales/es/timeline.json +++ b/src/i18n/locales/es/timeline.json @@ -7,7 +7,8 @@ "addTrim": "Agregar un recorte: quita una parte del video en el momento actual", "addAnnotation": "Agregar texto, una flecha, una imagen o un desenfoque en el momento actual", "addSpeed": "Agregar un cambio de velocidad en el momento actual", - "addCameraFullscreen": "Cambiar disposición aquí" + "addCameraFullscreen": "Cambiar disposición aquí", + "addCursorMotion": "Add a cursor motion section at the current time" }, "hints": { "pressZoom": "Presiona {{key}} para agregar zoom", @@ -15,7 +16,8 @@ "pressAnnotation": "Presiona {{key}} para agregar anotación", "pressAudio": "Pulsa {{audioKey}} para añadir audio, {{voiceoverKey}} para grabar una voz en off", "pressSpeed": "Presiona {{key}} para agregar velocidad", - "pressCameraFullscreen": "Presiona {{key}} para agregar un segmento de cámara a pantalla completa" + "pressCameraFullscreen": "Presiona {{key}} para agregar un segmento de cámara a pantalla completa", + "pressCursorMotion": "Press {{key}} to add cursor motion" }, "labels": { "pan": "Desplazar", @@ -31,7 +33,8 @@ "imageItem": "Imagen", "emptyText": "Texto vacío", "cameraFullscreen": "Cámara a pantalla completa", - "cameraFullscreenItem": "Cámara a pantalla completa {{index}}" + "cameraFullscreenItem": "Cámara a pantalla completa {{index}}", + "cursorMotion": "Cursor motion" }, "trails": { "zoomIn": "Acercamiento: la vista se acerca hasta que empieza el zoom", diff --git a/src/i18n/locales/fr/settings.json b/src/i18n/locales/fr/settings.json index 8cee3e846..d9a17c2e0 100644 --- a/src/i18n/locales/fr/settings.json +++ b/src/i18n/locales/fr/settings.json @@ -459,5 +459,29 @@ "dark": "Sombre", "light": "Claire", "custom": "Personnalisée" + }, + "cursorMotion": { + "mode": "Mode", + "strength": "Strength", + "easing": "Speed curve", + "deleteRegion": "Delete cursor motion", + "modes": { + "recorded": "As recorded", + "smooth": "Smooth", + "straight": "Straight", + "freeze": "Freeze" + }, + "easings": { + "easeInOut": "Smooth", + "linear": "Linear", + "easeIn": "Speed up", + "easeOut": "Slow down" + }, + "descriptions": { + "recorded": "The pointer exactly as it was recorded, without smoothing.", + "smooth": "Removes jitter and loops without lagging behind the pointer.", + "straight": "Moves in a straight line from where the pointer starts to where it ends or clicks.", + "freeze": "Holds the pointer where the section starts." + } } } diff --git a/src/i18n/locales/fr/shortcuts.json b/src/i18n/locales/fr/shortcuts.json index 40028519b..593324c77 100644 --- a/src/i18n/locales/fr/shortcuts.json +++ b/src/i18n/locales/fr/shortcuts.json @@ -27,7 +27,8 @@ "deleteSelected": "Supprimer la sélection", "playPause": "Lecture / Pause", "copySelected": "Copier la sélection", - "paste": "Coller" + "paste": "Coller", + "addCursorMotion": "Add Cursor Motion" }, "fixedActions": { "undo": "Annuler", diff --git a/src/i18n/locales/fr/timeline.json b/src/i18n/locales/fr/timeline.json index 21b8d50dd..43ff73636 100644 --- a/src/i18n/locales/fr/timeline.json +++ b/src/i18n/locales/fr/timeline.json @@ -7,7 +7,8 @@ "addTrim": "Ajouter une coupe : retire une partie de la vidéo à l'instant actuel", "addAnnotation": "Ajouter du texte, une flèche, une image ou un flou à l'instant actuel", "addSpeed": "Ajouter un changement de vitesse à l'instant actuel", - "addCameraFullscreen": "Changer la disposition ici" + "addCameraFullscreen": "Changer la disposition ici", + "addCursorMotion": "Add a cursor motion section at the current time" }, "hints": { "pressZoom": "Appuyez sur {{key}} pour ajouter un zoom", @@ -15,7 +16,8 @@ "pressAnnotation": "Appuyez sur {{key}} pour ajouter une annotation", "pressAudio": "Appuyez sur {{audioKey}} pour ajouter un audio, {{voiceoverKey}} pour enregistrer une voix off", "pressSpeed": "Appuyez sur {{key}} pour ajouter une vitesse", - "pressCameraFullscreen": "Appuyez sur {{key}} pour ajouter un segment Caméra plein écran" + "pressCameraFullscreen": "Appuyez sur {{key}} pour ajouter un segment Caméra plein écran", + "pressCursorMotion": "Press {{key}} to add cursor motion" }, "labels": { "pan": "Panoramique", @@ -31,7 +33,8 @@ "imageItem": "Image", "emptyText": "Texte vide", "cameraFullscreen": "Caméra plein écran", - "cameraFullscreenItem": "Caméra plein écran {{index}}" + "cameraFullscreenItem": "Caméra plein écran {{index}}", + "cursorMotion": "Cursor motion" }, "trails": { "zoomIn": "Zoom avant : l'image se resserre jusqu'au début du zoom", diff --git a/src/i18n/locales/it/settings.json b/src/i18n/locales/it/settings.json index 977040db8..0b634d474 100644 --- a/src/i18n/locales/it/settings.json +++ b/src/i18n/locales/it/settings.json @@ -459,5 +459,29 @@ "dark": "Scura", "light": "Chiara", "custom": "Personalizzata" + }, + "cursorMotion": { + "mode": "Mode", + "strength": "Strength", + "easing": "Speed curve", + "deleteRegion": "Delete cursor motion", + "modes": { + "recorded": "As recorded", + "smooth": "Smooth", + "straight": "Straight", + "freeze": "Freeze" + }, + "easings": { + "easeInOut": "Smooth", + "linear": "Linear", + "easeIn": "Speed up", + "easeOut": "Slow down" + }, + "descriptions": { + "recorded": "The pointer exactly as it was recorded, without smoothing.", + "smooth": "Removes jitter and loops without lagging behind the pointer.", + "straight": "Moves in a straight line from where the pointer starts to where it ends or clicks.", + "freeze": "Holds the pointer where the section starts." + } } } diff --git a/src/i18n/locales/it/shortcuts.json b/src/i18n/locales/it/shortcuts.json index 66bd8c9fd..f385c9bd1 100644 --- a/src/i18n/locales/it/shortcuts.json +++ b/src/i18n/locales/it/shortcuts.json @@ -27,7 +27,8 @@ "deleteSelected": "Elimina selezionato", "playPause": "Riproduci / Pausa", "copySelected": "Copia selezione", - "paste": "Incolla" + "paste": "Incolla", + "addCursorMotion": "Add Cursor Motion" }, "fixedActions": { "undo": "Annulla", diff --git a/src/i18n/locales/it/timeline.json b/src/i18n/locales/it/timeline.json index 1fe98db13..418c40e4c 100644 --- a/src/i18n/locales/it/timeline.json +++ b/src/i18n/locales/it/timeline.json @@ -7,7 +7,8 @@ "addTrim": "Aggiungi un taglio: rimuove una parte del video nel momento attuale", "addAnnotation": "Aggiungi testo, una freccia, un'immagine o una sfocatura nel momento attuale", "addSpeed": "Aggiungi un cambio di velocità nel momento attuale", - "addCameraFullscreen": "Cambia disposizione qui" + "addCameraFullscreen": "Cambia disposizione qui", + "addCursorMotion": "Add a cursor motion section at the current time" }, "hints": { "pressZoom": "Premi {{key}} per aggiungere zoom", @@ -15,7 +16,8 @@ "pressAnnotation": "Premi {{key}} per aggiungere annotazione", "pressAudio": "Premi {{audioKey}} per aggiungere audio, {{voiceoverKey}} per registrare una voce fuori campo", "pressSpeed": "Premi {{key}} per aggiungere velocità", - "pressCameraFullscreen": "Premi {{key}} per aggiungere un segmento Camera a schermo intero" + "pressCameraFullscreen": "Premi {{key}} per aggiungere un segmento Camera a schermo intero", + "pressCursorMotion": "Press {{key}} to add cursor motion" }, "labels": { "pan": "Panoramica", @@ -31,7 +33,8 @@ "imageItem": "Immagine", "emptyText": "Testo vuoto", "cameraFullscreen": "Camera a schermo intero", - "cameraFullscreenItem": "Camera a schermo intero {{index}}" + "cameraFullscreenItem": "Camera a schermo intero {{index}}", + "cursorMotion": "Cursor motion" }, "trails": { "zoomIn": "Zoom in: la vista si avvicina fino all'inizio dello zoom", diff --git a/src/i18n/locales/ja-JP/settings.json b/src/i18n/locales/ja-JP/settings.json index ec739e70e..156f04ba8 100644 --- a/src/i18n/locales/ja-JP/settings.json +++ b/src/i18n/locales/ja-JP/settings.json @@ -459,5 +459,29 @@ "dark": "ダーク", "light": "ライト", "custom": "カスタム" + }, + "cursorMotion": { + "mode": "Mode", + "strength": "Strength", + "easing": "Speed curve", + "deleteRegion": "Delete cursor motion", + "modes": { + "recorded": "As recorded", + "smooth": "Smooth", + "straight": "Straight", + "freeze": "Freeze" + }, + "easings": { + "easeInOut": "Smooth", + "linear": "Linear", + "easeIn": "Speed up", + "easeOut": "Slow down" + }, + "descriptions": { + "recorded": "The pointer exactly as it was recorded, without smoothing.", + "smooth": "Removes jitter and loops without lagging behind the pointer.", + "straight": "Moves in a straight line from where the pointer starts to where it ends or clicks.", + "freeze": "Holds the pointer where the section starts." + } } } diff --git a/src/i18n/locales/ja-JP/shortcuts.json b/src/i18n/locales/ja-JP/shortcuts.json index 93284c34f..ef4e2d370 100644 --- a/src/i18n/locales/ja-JP/shortcuts.json +++ b/src/i18n/locales/ja-JP/shortcuts.json @@ -27,7 +27,8 @@ "deleteSelected": "選択を削除", "playPause": "再生 / 一時停止", "copySelected": "選択をコピー", - "paste": "貼り付け" + "paste": "貼り付け", + "addCursorMotion": "Add Cursor Motion" }, "fixedActions": { "undo": "元に戻す", diff --git a/src/i18n/locales/ja-JP/timeline.json b/src/i18n/locales/ja-JP/timeline.json index ee0b499c9..768374c54 100644 --- a/src/i18n/locales/ja-JP/timeline.json +++ b/src/i18n/locales/ja-JP/timeline.json @@ -7,7 +7,8 @@ "addTrim": "トリムを追加:現在の再生位置で動画の一部を削除します", "addAnnotation": "現在の再生位置にテキスト、矢印、画像、ぼかしを追加", "addSpeed": "現在の再生位置に再生速度の変更を追加", - "addCameraFullscreen": "ここでレイアウトを変更" + "addCameraFullscreen": "ここでレイアウトを変更", + "addCursorMotion": "Add a cursor motion section at the current time" }, "hints": { "pressZoom": "{{key}}キーを押してズームを追加", @@ -15,7 +16,8 @@ "pressAnnotation": "{{key}}キーを押して注釈を追加", "pressAudio": "{{audioKey}} キーで音声を追加、{{voiceoverKey}} キーでナレーションを録音", "pressSpeed": "{{key}}キーを押して再生速度を追加", - "pressCameraFullscreen": "{{key}}キーを押してフルスクリーンカメラのセグメントを追加" + "pressCameraFullscreen": "{{key}}キーを押してフルスクリーンカメラのセグメントを追加", + "pressCursorMotion": "Press {{key}} to add cursor motion" }, "labels": { "pan": "移動", @@ -31,7 +33,8 @@ "imageItem": "画像", "emptyText": "空のテキスト", "cameraFullscreen": "フルスクリーンカメラ", - "cameraFullscreenItem": "フルスクリーンカメラ {{index}}" + "cameraFullscreenItem": "フルスクリーンカメラ {{index}}", + "cursorMotion": "Cursor motion" }, "trails": { "zoomIn": "ズームイン:ズームの開始まで画面が拡大していきます", diff --git a/src/i18n/locales/ko-KR/settings.json b/src/i18n/locales/ko-KR/settings.json index 12c13cd7f..40bbacb6c 100644 --- a/src/i18n/locales/ko-KR/settings.json +++ b/src/i18n/locales/ko-KR/settings.json @@ -459,5 +459,29 @@ "dark": "어둡게", "light": "밝게", "custom": "사용자 지정" + }, + "cursorMotion": { + "mode": "Mode", + "strength": "Strength", + "easing": "Speed curve", + "deleteRegion": "Delete cursor motion", + "modes": { + "recorded": "As recorded", + "smooth": "Smooth", + "straight": "Straight", + "freeze": "Freeze" + }, + "easings": { + "easeInOut": "Smooth", + "linear": "Linear", + "easeIn": "Speed up", + "easeOut": "Slow down" + }, + "descriptions": { + "recorded": "The pointer exactly as it was recorded, without smoothing.", + "smooth": "Removes jitter and loops without lagging behind the pointer.", + "straight": "Moves in a straight line from where the pointer starts to where it ends or clicks.", + "freeze": "Holds the pointer where the section starts." + } } } diff --git a/src/i18n/locales/ko-KR/shortcuts.json b/src/i18n/locales/ko-KR/shortcuts.json index 5d1a150c6..9e5afbf99 100644 --- a/src/i18n/locales/ko-KR/shortcuts.json +++ b/src/i18n/locales/ko-KR/shortcuts.json @@ -27,7 +27,8 @@ "deleteSelected": "선택 항목 삭제", "playPause": "재생 / 일시정지", "copySelected": "선택 항목 복사", - "paste": "붙여넣기" + "paste": "붙여넣기", + "addCursorMotion": "Add Cursor Motion" }, "fixedActions": { "undo": "실행 취소", diff --git a/src/i18n/locales/ko-KR/timeline.json b/src/i18n/locales/ko-KR/timeline.json index aec7627e7..b605e1f44 100644 --- a/src/i18n/locales/ko-KR/timeline.json +++ b/src/i18n/locales/ko-KR/timeline.json @@ -7,7 +7,8 @@ "addTrim": "트림 추가: 현재 시점에서 영상의 한 구간을 제거합니다", "addAnnotation": "현재 시점에 텍스트, 화살표, 이미지 또는 블러 추가", "addSpeed": "현재 시점에 속도 변경 추가", - "addCameraFullscreen": "여기서 레이아웃 변경" + "addCameraFullscreen": "여기서 레이아웃 변경", + "addCursorMotion": "Add a cursor motion section at the current time" }, "hints": { "pressZoom": "{{key}}를 눌러 줌 추가", @@ -15,7 +16,8 @@ "pressAnnotation": "{{key}}를 눌러 주석 추가", "pressAudio": "{{audioKey}} 키로 오디오 추가, {{voiceoverKey}} 키로 보이스오버 녹음", "pressSpeed": "{{key}}를 눌러 속도 추가", - "pressCameraFullscreen": "{{key}}를 눌러 전체 화면 카메라 구간을 추가하세요" + "pressCameraFullscreen": "{{key}}를 눌러 전체 화면 카메라 구간을 추가하세요", + "pressCursorMotion": "Press {{key}} to add cursor motion" }, "labels": { "pan": "이동", @@ -31,7 +33,8 @@ "imageItem": "이미지", "emptyText": "빈 텍스트", "cameraFullscreen": "전체 화면 카메라", - "cameraFullscreenItem": "전체 화면 카메라 {{index}}" + "cameraFullscreenItem": "전체 화면 카메라 {{index}}", + "cursorMotion": "Cursor motion" }, "trails": { "zoomIn": "줌 인: 줌이 시작될 때까지 화면이 확대됩니다", diff --git a/src/i18n/locales/nl/settings.json b/src/i18n/locales/nl/settings.json index 9483b1b27..5f4dc0f4f 100644 --- a/src/i18n/locales/nl/settings.json +++ b/src/i18n/locales/nl/settings.json @@ -459,5 +459,29 @@ "dark": "Donker", "light": "Licht", "custom": "Aangepast" + }, + "cursorMotion": { + "mode": "Mode", + "strength": "Strength", + "easing": "Speed curve", + "deleteRegion": "Delete cursor motion", + "modes": { + "recorded": "As recorded", + "smooth": "Smooth", + "straight": "Straight", + "freeze": "Freeze" + }, + "easings": { + "easeInOut": "Smooth", + "linear": "Linear", + "easeIn": "Speed up", + "easeOut": "Slow down" + }, + "descriptions": { + "recorded": "The pointer exactly as it was recorded, without smoothing.", + "smooth": "Removes jitter and loops without lagging behind the pointer.", + "straight": "Moves in a straight line from where the pointer starts to where it ends or clicks.", + "freeze": "Holds the pointer where the section starts." + } } } diff --git a/src/i18n/locales/nl/shortcuts.json b/src/i18n/locales/nl/shortcuts.json index 0d7253cbe..4ea29c087 100644 --- a/src/i18n/locales/nl/shortcuts.json +++ b/src/i18n/locales/nl/shortcuts.json @@ -27,7 +27,8 @@ "deleteSelected": "Selectie verwijderen", "playPause": "Afspelen / Pauzeren", "copySelected": "Selectie kopiëren", - "paste": "Plakken" + "paste": "Plakken", + "addCursorMotion": "Add Cursor Motion" }, "fixedActions": { "undo": "Ongedaan maken", diff --git a/src/i18n/locales/nl/timeline.json b/src/i18n/locales/nl/timeline.json index 85e53218e..94fb18a02 100644 --- a/src/i18n/locales/nl/timeline.json +++ b/src/i18n/locales/nl/timeline.json @@ -7,7 +7,8 @@ "addTrim": "Trim toevoegen: verwijdert een deel van de video op het huidige tijdstip", "addAnnotation": "Tekst, pijl, afbeelding of blur toevoegen op het huidige tijdstip", "addSpeed": "Snelheidswijziging toevoegen op het huidige tijdstip", - "addCameraFullscreen": "Full Camera toevoegen: toont de camera op volledig scherm op het huidige tijdstip" + "addCameraFullscreen": "Full Camera toevoegen: toont de camera op volledig scherm op het huidige tijdstip", + "addCursorMotion": "Add a cursor motion section at the current time" }, "hints": { "pressZoom": "Druk op {{key}} om zoom toe te voegen", @@ -15,7 +16,8 @@ "pressAnnotation": "Druk op {{key}} om een annotatie toe te voegen", "pressAudio": "Druk op {{audioKey}} om audio toe te voegen, op {{voiceoverKey}} om een voice-over op te nemen", "pressSpeed": "Druk op {{key}} om snelheid toe te voegen", - "pressCameraFullscreen": "Druk op {{key}} om een Full Camera-segment toe te voegen" + "pressCameraFullscreen": "Druk op {{key}} om een Full Camera-segment toe te voegen", + "pressCursorMotion": "Press {{key}} to add cursor motion" }, "labels": { "pan": "Pan", @@ -31,7 +33,8 @@ "imageItem": "Afbeelding", "emptyText": "Lege tekst", "cameraFullscreen": "Full Camera", - "cameraFullscreenItem": "Full Camera {{index}}" + "cameraFullscreenItem": "Full Camera {{index}}", + "cursorMotion": "Cursor motion" }, "trails": { "zoomIn": "Inzoomen: het beeld beweegt naar binnen tot de zoom begint", diff --git a/src/i18n/locales/pl/settings.json b/src/i18n/locales/pl/settings.json index 1e00b6bcb..a8540699a 100644 --- a/src/i18n/locales/pl/settings.json +++ b/src/i18n/locales/pl/settings.json @@ -459,5 +459,29 @@ "dark": "Ciemne", "light": "Jasne", "custom": "Własne" + }, + "cursorMotion": { + "mode": "Mode", + "strength": "Strength", + "easing": "Speed curve", + "deleteRegion": "Delete cursor motion", + "modes": { + "recorded": "As recorded", + "smooth": "Smooth", + "straight": "Straight", + "freeze": "Freeze" + }, + "easings": { + "easeInOut": "Smooth", + "linear": "Linear", + "easeIn": "Speed up", + "easeOut": "Slow down" + }, + "descriptions": { + "recorded": "The pointer exactly as it was recorded, without smoothing.", + "smooth": "Removes jitter and loops without lagging behind the pointer.", + "straight": "Moves in a straight line from where the pointer starts to where it ends or clicks.", + "freeze": "Holds the pointer where the section starts." + } } } diff --git a/src/i18n/locales/pl/shortcuts.json b/src/i18n/locales/pl/shortcuts.json index 8bc5ffc90..c64a36c80 100644 --- a/src/i18n/locales/pl/shortcuts.json +++ b/src/i18n/locales/pl/shortcuts.json @@ -27,7 +27,8 @@ "deleteSelected": "Usuń zaznaczone", "playPause": "Odtwórz / Wstrzymaj", "copySelected": "Kopiuj zaznaczone", - "paste": "Wklej" + "paste": "Wklej", + "addCursorMotion": "Add Cursor Motion" }, "fixedActions": { "undo": "Cofnij", diff --git a/src/i18n/locales/pl/timeline.json b/src/i18n/locales/pl/timeline.json index 9b04a30cf..d4fd4bd22 100644 --- a/src/i18n/locales/pl/timeline.json +++ b/src/i18n/locales/pl/timeline.json @@ -7,7 +7,8 @@ "addTrim": "Dodaj przycięcie: usuwa fragment wideo w bieżącym czasie", "addAnnotation": "Dodaj tekst, strzałkę, obraz lub rozmycie w bieżącym czasie", "addSpeed": "Dodaj zmianę prędkości w bieżącym czasie", - "addCameraFullscreen": "Zmień układ tutaj" + "addCameraFullscreen": "Zmień układ tutaj", + "addCursorMotion": "Add a cursor motion section at the current time" }, "hints": { "pressZoom": "Naciśnij {{key}}, aby dodać powiększenie", @@ -15,7 +16,8 @@ "pressAnnotation": "Naciśnij {{key}}, aby dodać adnotację", "pressAudio": "Naciśnij {{audioKey}}, aby dodać dźwięk, {{voiceoverKey}}, aby nagrać lektora", "pressSpeed": "Naciśnij {{key}}, aby dodać zmianę prędkości", - "pressCameraFullscreen": "Naciśnij {{key}}, aby dodać segment Pełnej kamery" + "pressCameraFullscreen": "Naciśnij {{key}}, aby dodać segment Pełnej kamery", + "pressCursorMotion": "Press {{key}} to add cursor motion" }, "labels": { "pan": "Przesuń", @@ -31,7 +33,8 @@ "imageItem": "Obraz", "emptyText": "Pusty tekst", "cameraFullscreen": "Pełna kamera", - "cameraFullscreenItem": "Pełna kamera {{index}}" + "cameraFullscreenItem": "Pełna kamera {{index}}", + "cursorMotion": "Cursor motion" }, "trails": { "zoomIn": "Najazd: widok przybliża się aż do początku powiększenia", diff --git a/src/i18n/locales/pt-BR/settings.json b/src/i18n/locales/pt-BR/settings.json index 65f8c2761..18644b979 100644 --- a/src/i18n/locales/pt-BR/settings.json +++ b/src/i18n/locales/pt-BR/settings.json @@ -459,5 +459,29 @@ "dark": "Escura", "light": "Clara", "custom": "Personalizada" + }, + "cursorMotion": { + "mode": "Mode", + "strength": "Strength", + "easing": "Speed curve", + "deleteRegion": "Delete cursor motion", + "modes": { + "recorded": "As recorded", + "smooth": "Smooth", + "straight": "Straight", + "freeze": "Freeze" + }, + "easings": { + "easeInOut": "Smooth", + "linear": "Linear", + "easeIn": "Speed up", + "easeOut": "Slow down" + }, + "descriptions": { + "recorded": "The pointer exactly as it was recorded, without smoothing.", + "smooth": "Removes jitter and loops without lagging behind the pointer.", + "straight": "Moves in a straight line from where the pointer starts to where it ends or clicks.", + "freeze": "Holds the pointer where the section starts." + } } } diff --git a/src/i18n/locales/pt-BR/shortcuts.json b/src/i18n/locales/pt-BR/shortcuts.json index 0341d7dea..fb0c1e3d5 100644 --- a/src/i18n/locales/pt-BR/shortcuts.json +++ b/src/i18n/locales/pt-BR/shortcuts.json @@ -27,7 +27,8 @@ "deleteSelected": "Excluir Selecionado", "playPause": "Reproduzir / Pausar", "copySelected": "Copiar seleção", - "paste": "Colar" + "paste": "Colar", + "addCursorMotion": "Add Cursor Motion" }, "fixedActions": { "undo": "Desfazer", diff --git a/src/i18n/locales/pt-BR/timeline.json b/src/i18n/locales/pt-BR/timeline.json index dc214ae0b..7d33c86e6 100644 --- a/src/i18n/locales/pt-BR/timeline.json +++ b/src/i18n/locales/pt-BR/timeline.json @@ -7,7 +7,8 @@ "addTrim": "Adicionar um recorte: remove uma parte do vídeo no momento atual", "addAnnotation": "Adicionar texto, seta, imagem ou desfoque no momento atual", "addSpeed": "Adicionar uma mudança de velocidade no momento atual", - "addCameraFullscreen": "Alterar disposição aqui" + "addCameraFullscreen": "Alterar disposição aqui", + "addCursorMotion": "Add a cursor motion section at the current time" }, "hints": { "pressZoom": "Pressione {{key}} para adicionar zoom", @@ -15,7 +16,8 @@ "pressAnnotation": "Pressione {{key}} para adicionar anotação", "pressAudio": "Pressione {{audioKey}} para adicionar áudio, {{voiceoverKey}} para gravar uma narração", "pressSpeed": "Pressione {{key}} para adicionar velocidade", - "pressCameraFullscreen": "Pressione {{key}} para adicionar um segmento de Câmera em Tela Cheia" + "pressCameraFullscreen": "Pressione {{key}} para adicionar um segmento de Câmera em Tela Cheia", + "pressCursorMotion": "Press {{key}} to add cursor motion" }, "labels": { "pan": "Mover", @@ -31,7 +33,8 @@ "imageItem": "Imagem", "emptyText": "Texto vazio", "cameraFullscreen": "Câmera em Tela Cheia", - "cameraFullscreenItem": "Câmera em Tela Cheia {{index}}" + "cameraFullscreenItem": "Câmera em Tela Cheia {{index}}", + "cursorMotion": "Cursor motion" }, "trails": { "zoomIn": "Aproximação: a visão se aproxima até o início do zoom", diff --git a/src/i18n/locales/ru/settings.json b/src/i18n/locales/ru/settings.json index d548578b6..f540c83fc 100644 --- a/src/i18n/locales/ru/settings.json +++ b/src/i18n/locales/ru/settings.json @@ -459,5 +459,29 @@ "dark": "Тёмная", "light": "Светлая", "custom": "Своя" + }, + "cursorMotion": { + "mode": "Режим", + "strength": "Сила", + "easing": "Кривая скорости", + "deleteRegion": "Удалить участок курсора", + "modes": { + "recorded": "Как записано", + "smooth": "Сгладить", + "straight": "Прямо", + "freeze": "Заморозить" + }, + "easings": { + "easeInOut": "Плавно", + "linear": "Линейно", + "easeIn": "Ускорение", + "easeOut": "Торможение" + }, + "descriptions": { + "recorded": "Курсор точно как записан, без сглаживания.", + "smooth": "Убирает дрожание и петли и не отстаёт от курсора.", + "straight": "Ведёт курсор по прямой от точки начала к точке конца или клика.", + "freeze": "Удерживает курсор в точке начала участка." + } } } diff --git a/src/i18n/locales/ru/shortcuts.json b/src/i18n/locales/ru/shortcuts.json index 39e444a6b..93424aade 100644 --- a/src/i18n/locales/ru/shortcuts.json +++ b/src/i18n/locales/ru/shortcuts.json @@ -27,7 +27,8 @@ "deleteSelected": "Удалить выбранное", "playPause": "Воспроизведение / Пауза", "copySelected": "Копировать выбранное", - "paste": "Вставить" + "paste": "Вставить", + "addCursorMotion": "Добавить движение курсора" }, "fixedActions": { "undo": "Отменить", diff --git a/src/i18n/locales/ru/timeline.json b/src/i18n/locales/ru/timeline.json index a6cc4874b..79b4160e2 100644 --- a/src/i18n/locales/ru/timeline.json +++ b/src/i18n/locales/ru/timeline.json @@ -7,7 +7,8 @@ "addTrim": "Добавить обрезку: удаляет фрагмент видео в текущий момент", "addAnnotation": "Добавить текст, стрелку, изображение или размытие в текущий момент", "addSpeed": "Добавить изменение скорости в текущий момент", - "addCameraFullscreen": "Изменить макет здесь" + "addCameraFullscreen": "Изменить макет здесь", + "addCursorMotion": "Добавить участок движения курсора в текущий момент" }, "hints": { "pressZoom": "Нажмите {{key}} для добавления масштабирования", @@ -15,7 +16,8 @@ "pressAnnotation": "Нажмите {{key}} для добавления аннотации", "pressAudio": "Нажмите {{audioKey}}, чтобы добавить аудио, {{voiceoverKey}} — чтобы записать закадровый голос", "pressSpeed": "Нажмите {{key}} для изменения скорости", - "pressCameraFullscreen": "Нажмите {{key}}, чтобы добавить сегмент камеры на весь экран" + "pressCameraFullscreen": "Нажмите {{key}}, чтобы добавить сегмент камеры на весь экран", + "pressCursorMotion": "Нажмите {{key}} для участка движения курсора" }, "labels": { "pan": "Панорамирование", @@ -31,7 +33,8 @@ "imageItem": "Изображение", "emptyText": "Пустой текст", "cameraFullscreen": "Камера на весь экран", - "cameraFullscreenItem": "Камера на весь экран {{index}}" + "cameraFullscreenItem": "Камера на весь экран {{index}}", + "cursorMotion": "Движение курсора" }, "trails": { "zoomIn": "Приближение: вид приближается до начала масштабирования", diff --git a/src/i18n/locales/tr/settings.json b/src/i18n/locales/tr/settings.json index 26842ec8a..46f1d82f1 100644 --- a/src/i18n/locales/tr/settings.json +++ b/src/i18n/locales/tr/settings.json @@ -459,5 +459,29 @@ "dark": "Koyu", "light": "Açık", "custom": "Özel" + }, + "cursorMotion": { + "mode": "Mode", + "strength": "Strength", + "easing": "Speed curve", + "deleteRegion": "Delete cursor motion", + "modes": { + "recorded": "As recorded", + "smooth": "Smooth", + "straight": "Straight", + "freeze": "Freeze" + }, + "easings": { + "easeInOut": "Smooth", + "linear": "Linear", + "easeIn": "Speed up", + "easeOut": "Slow down" + }, + "descriptions": { + "recorded": "The pointer exactly as it was recorded, without smoothing.", + "smooth": "Removes jitter and loops without lagging behind the pointer.", + "straight": "Moves in a straight line from where the pointer starts to where it ends or clicks.", + "freeze": "Holds the pointer where the section starts." + } } } diff --git a/src/i18n/locales/tr/shortcuts.json b/src/i18n/locales/tr/shortcuts.json index 8e2843cfe..9ede9a36c 100644 --- a/src/i18n/locales/tr/shortcuts.json +++ b/src/i18n/locales/tr/shortcuts.json @@ -27,7 +27,8 @@ "deleteSelected": "Seçileni Sil", "playPause": "Oynat / Duraklat", "copySelected": "Seçileni Kopyala", - "paste": "Yapıştır" + "paste": "Yapıştır", + "addCursorMotion": "Add Cursor Motion" }, "fixedActions": { "undo": "Geri Al", diff --git a/src/i18n/locales/tr/timeline.json b/src/i18n/locales/tr/timeline.json index 8e80e1953..49d4da36f 100644 --- a/src/i18n/locales/tr/timeline.json +++ b/src/i18n/locales/tr/timeline.json @@ -7,7 +7,8 @@ "addTrim": "Kırpma ekle: videonun bir bölümünü şu anki zamanda çıkarır", "addAnnotation": "Şu anki zamanda metin, ok, resim veya bulanıklık ekle", "addSpeed": "Şu anki zamanda hız değişikliği ekle", - "addCameraFullscreen": "Yerleşimi burada değiştir" + "addCameraFullscreen": "Yerleşimi burada değiştir", + "addCursorMotion": "Add a cursor motion section at the current time" }, "hints": { "pressZoom": "Yakınlaştırma eklemek için {{key}} tuşuna basın", @@ -15,7 +16,8 @@ "pressAnnotation": "Açıklama eklemek için {{key}} tuşuna basın", "pressAudio": "Ses eklemek için {{audioKey}}, seslendirme kaydetmek için {{voiceoverKey}} tuşuna basın", "pressSpeed": "Hız eklemek için {{key}} tuşuna basın", - "pressCameraFullscreen": "Tam Ekran Kamera bölümü eklemek için {{key}} tuşuna basın" + "pressCameraFullscreen": "Tam Ekran Kamera bölümü eklemek için {{key}} tuşuna basın", + "pressCursorMotion": "Press {{key}} to add cursor motion" }, "labels": { "pan": "Kaydır", @@ -31,7 +33,8 @@ "imageItem": "Görüntü", "emptyText": "Boş metin", "cameraFullscreen": "Tam Ekran Kamera", - "cameraFullscreenItem": "Tam Ekran Kamera {{index}}" + "cameraFullscreenItem": "Tam Ekran Kamera {{index}}", + "cursorMotion": "Cursor motion" }, "trails": { "zoomIn": "Yakınlaşma: görüntü, yakınlaştırma başlayana kadar yaklaşır", diff --git a/src/i18n/locales/vi/settings.json b/src/i18n/locales/vi/settings.json index ff225df50..dab9a6788 100644 --- a/src/i18n/locales/vi/settings.json +++ b/src/i18n/locales/vi/settings.json @@ -459,5 +459,29 @@ "dark": "Tối", "light": "Sáng", "custom": "Tùy chỉnh" + }, + "cursorMotion": { + "mode": "Mode", + "strength": "Strength", + "easing": "Speed curve", + "deleteRegion": "Delete cursor motion", + "modes": { + "recorded": "As recorded", + "smooth": "Smooth", + "straight": "Straight", + "freeze": "Freeze" + }, + "easings": { + "easeInOut": "Smooth", + "linear": "Linear", + "easeIn": "Speed up", + "easeOut": "Slow down" + }, + "descriptions": { + "recorded": "The pointer exactly as it was recorded, without smoothing.", + "smooth": "Removes jitter and loops without lagging behind the pointer.", + "straight": "Moves in a straight line from where the pointer starts to where it ends or clicks.", + "freeze": "Holds the pointer where the section starts." + } } } diff --git a/src/i18n/locales/vi/shortcuts.json b/src/i18n/locales/vi/shortcuts.json index f6e910a6e..f4cc4b12d 100644 --- a/src/i18n/locales/vi/shortcuts.json +++ b/src/i18n/locales/vi/shortcuts.json @@ -27,7 +27,8 @@ "deleteSelected": "Xóa mục đã chọn", "playPause": "Phát / Tạm dừng", "copySelected": "Sao chép mục đã chọn", - "paste": "Dán" + "paste": "Dán", + "addCursorMotion": "Add Cursor Motion" }, "fixedActions": { "undo": "Hoàn tác", diff --git a/src/i18n/locales/vi/timeline.json b/src/i18n/locales/vi/timeline.json index 1c2c48256..07c7b6767 100644 --- a/src/i18n/locales/vi/timeline.json +++ b/src/i18n/locales/vi/timeline.json @@ -7,7 +7,8 @@ "addTrim": "Thêm cắt: xóa một đoạn video tại thời điểm hiện tại", "addAnnotation": "Thêm văn bản, mũi tên, hình ảnh hoặc làm mờ tại thời điểm hiện tại", "addSpeed": "Thêm thay đổi tốc độ tại thời điểm hiện tại", - "addCameraFullscreen": "Đổi bố cục tại đây" + "addCameraFullscreen": "Đổi bố cục tại đây", + "addCursorMotion": "Add a cursor motion section at the current time" }, "hints": { "pressZoom": "Nhấn {{key}} để thêm thu phóng", @@ -15,7 +16,8 @@ "pressAnnotation": "Nhấn {{key}} để thêm chú thích", "pressAudio": "Nhấn {{audioKey}} để thêm âm thanh, {{voiceoverKey}} để ghi âm lời thuyết minh", "pressSpeed": "Nhấn {{key}} để thêm tốc độ", - "pressCameraFullscreen": "Nhấn {{key}} để thêm một đoạn Camera Toàn màn hình" + "pressCameraFullscreen": "Nhấn {{key}} để thêm một đoạn Camera Toàn màn hình", + "pressCursorMotion": "Press {{key}} to add cursor motion" }, "labels": { "pan": "Xoay", @@ -31,7 +33,8 @@ "imageItem": "Hình ảnh", "emptyText": "Văn bản trống", "cameraFullscreen": "Camera Toàn màn hình", - "cameraFullscreenItem": "Camera Toàn màn hình {{index}}" + "cameraFullscreenItem": "Camera Toàn màn hình {{index}}", + "cursorMotion": "Cursor motion" }, "trails": { "zoomIn": "Phóng to: khung hình phóng to dần cho đến khi bắt đầu thu phóng", diff --git a/src/i18n/locales/zh-CN/settings.json b/src/i18n/locales/zh-CN/settings.json index 47a62d2ff..803f74319 100644 --- a/src/i18n/locales/zh-CN/settings.json +++ b/src/i18n/locales/zh-CN/settings.json @@ -459,5 +459,29 @@ "dark": "深色", "light": "浅色", "custom": "自定义" + }, + "cursorMotion": { + "mode": "Mode", + "strength": "Strength", + "easing": "Speed curve", + "deleteRegion": "Delete cursor motion", + "modes": { + "recorded": "As recorded", + "smooth": "Smooth", + "straight": "Straight", + "freeze": "Freeze" + }, + "easings": { + "easeInOut": "Smooth", + "linear": "Linear", + "easeIn": "Speed up", + "easeOut": "Slow down" + }, + "descriptions": { + "recorded": "The pointer exactly as it was recorded, without smoothing.", + "smooth": "Removes jitter and loops without lagging behind the pointer.", + "straight": "Moves in a straight line from where the pointer starts to where it ends or clicks.", + "freeze": "Holds the pointer where the section starts." + } } } diff --git a/src/i18n/locales/zh-CN/shortcuts.json b/src/i18n/locales/zh-CN/shortcuts.json index 9402bd230..4285146fc 100644 --- a/src/i18n/locales/zh-CN/shortcuts.json +++ b/src/i18n/locales/zh-CN/shortcuts.json @@ -27,7 +27,8 @@ "deleteSelected": "删除所选", "playPause": "播放 / 暂停", "copySelected": "复制所选", - "paste": "粘贴" + "paste": "粘贴", + "addCursorMotion": "Add Cursor Motion" }, "fixedActions": { "undo": "撤销", diff --git a/src/i18n/locales/zh-CN/timeline.json b/src/i18n/locales/zh-CN/timeline.json index f66bc081e..28aff00de 100644 --- a/src/i18n/locales/zh-CN/timeline.json +++ b/src/i18n/locales/zh-CN/timeline.json @@ -7,7 +7,8 @@ "addTrim": "在当前时间添加删减区间,移除这段视频", "addAnnotation": "在当前时间添加文字、箭头、图片或模糊效果", "addSpeed": "在当前时间添加变速效果", - "addCameraFullscreen": "在此更改布局" + "addCameraFullscreen": "在此更改布局", + "addCursorMotion": "Add a cursor motion section at the current time" }, "hints": { "pressZoom": "按 {{key}} 添加缩放", @@ -15,7 +16,8 @@ "pressAnnotation": "按 {{key}} 添加标注", "pressAudio": "按 {{audioKey}} 添加音频,按 {{voiceoverKey}} 录制配音", "pressSpeed": "按 {{key}} 添加速度", - "pressCameraFullscreen": "按 {{key}} 添加一个全屏摄像头片段" + "pressCameraFullscreen": "按 {{key}} 添加一个全屏摄像头片段", + "pressCursorMotion": "Press {{key}} to add cursor motion" }, "labels": { "pan": "平移", @@ -31,7 +33,8 @@ "imageItem": "图片", "emptyText": "空文本", "cameraFullscreen": "全屏摄像头", - "cameraFullscreenItem": "全屏摄像头 {{index}}" + "cameraFullscreenItem": "全屏摄像头 {{index}}", + "cursorMotion": "Cursor motion" }, "trails": { "zoomIn": "放大过程:画面在缩放开始前逐渐放大", diff --git a/src/i18n/locales/zh-TW/settings.json b/src/i18n/locales/zh-TW/settings.json index 9725a48f6..2c13d8f0d 100644 --- a/src/i18n/locales/zh-TW/settings.json +++ b/src/i18n/locales/zh-TW/settings.json @@ -459,5 +459,29 @@ "dark": "深色", "light": "淺色", "custom": "自訂" + }, + "cursorMotion": { + "mode": "Mode", + "strength": "Strength", + "easing": "Speed curve", + "deleteRegion": "Delete cursor motion", + "modes": { + "recorded": "As recorded", + "smooth": "Smooth", + "straight": "Straight", + "freeze": "Freeze" + }, + "easings": { + "easeInOut": "Smooth", + "linear": "Linear", + "easeIn": "Speed up", + "easeOut": "Slow down" + }, + "descriptions": { + "recorded": "The pointer exactly as it was recorded, without smoothing.", + "smooth": "Removes jitter and loops without lagging behind the pointer.", + "straight": "Moves in a straight line from where the pointer starts to where it ends or clicks.", + "freeze": "Holds the pointer where the section starts." + } } } diff --git a/src/i18n/locales/zh-TW/shortcuts.json b/src/i18n/locales/zh-TW/shortcuts.json index 2430cce82..971cde940 100644 --- a/src/i18n/locales/zh-TW/shortcuts.json +++ b/src/i18n/locales/zh-TW/shortcuts.json @@ -27,7 +27,8 @@ "deleteSelected": "刪除所選", "playPause": "播放 / 暫停", "copySelected": "複製所選", - "paste": "貼上" + "paste": "貼上", + "addCursorMotion": "Add Cursor Motion" }, "fixedActions": { "undo": "復原", diff --git a/src/i18n/locales/zh-TW/timeline.json b/src/i18n/locales/zh-TW/timeline.json index fd50868b0..641d243e4 100644 --- a/src/i18n/locales/zh-TW/timeline.json +++ b/src/i18n/locales/zh-TW/timeline.json @@ -7,7 +7,8 @@ "addTrim": "新增剪輯:在目前時間移除一段影片", "addAnnotation": "在目前時間新增文字、箭頭、圖片或模糊", "addSpeed": "在目前時間新增速度變化", - "addCameraFullscreen": "在此變更版面配置" + "addCameraFullscreen": "在此變更版面配置", + "addCursorMotion": "Add a cursor motion section at the current time" }, "hints": { "pressZoom": "按 {{key}} 新增縮放", @@ -15,7 +16,8 @@ "pressAnnotation": "按 {{key}} 新增標註", "pressAudio": "按 {{audioKey}} 新增音訊,按 {{voiceoverKey}} 錄製配音", "pressSpeed": "按 {{key}} 新增速度", - "pressCameraFullscreen": "按 {{key}} 新增一個全螢幕攝影機片段" + "pressCameraFullscreen": "按 {{key}} 新增一個全螢幕攝影機片段", + "pressCursorMotion": "Press {{key}} to add cursor motion" }, "labels": { "pan": "平移", @@ -31,7 +33,8 @@ "imageItem": "圖片", "emptyText": "空文字", "cameraFullscreen": "全螢幕攝影機", - "cameraFullscreenItem": "全螢幕攝影機 {{index}}" + "cameraFullscreenItem": "全螢幕攝影機 {{index}}", + "cursorMotion": "Cursor motion" }, "trails": { "zoomIn": "放大過程:畫面在縮放開始前逐漸放大", diff --git a/src/lib/ai-edition/document/timeline.test.ts b/src/lib/ai-edition/document/timeline.test.ts index f826e8da8..ceb2695e4 100644 --- a/src/lib/ai-edition/document/timeline.test.ts +++ b/src/lib/ai-edition/document/timeline.test.ts @@ -2149,6 +2149,32 @@ describe("removeClip — delete a clip, close the gap, drop its pills", () => { expect(gone.shaderEffects).toEqual([]); }); + // The gap the closed cursor-choreography PR (#556) left: its sections were not in the clip + // walk, so a clip edit left them on the wrong place and a removed clip left phantoms behind. + it("moves a cursor motion section with its clip and drops it with the clip", () => { + const section = (id: string, clipId: string, startMs: number) => ({ + id, + clipId, + sourceStartSec: 2, + sourceEndSec: 4, + startMs, + endMs: startMs + 2000, + mode: "smooth" as const, + }); + const next = removeClip( + { + ...doc(), + cursorMotionRanges: [section("m_a", "clip_a", 2000), section("m_b", "clip_b", 12000)], + }, + "clip_a", + ); + expect(next.cursorMotionRanges).toEqual([ + expect.objectContaining({ id: "m_b", startMs: 2000, endMs: 4000 }), + ]); + // A document that never had any keeps no key. + expect(removeClip(doc(), "clip_a")).not.toHaveProperty("cursorMotionRanges"); + }); + it("preserves a bare clipId that is not a complete source anchor", () => { const before = doc(); before.zoomRanges.push( diff --git a/src/lib/ai-edition/document/timeline.ts b/src/lib/ai-edition/document/timeline.ts index da05eca5e..6fc170d52 100644 --- a/src/lib/ai-edition/document/timeline.ts +++ b/src/lib/ai-edition/document/timeline.ts @@ -54,7 +54,8 @@ export type RegionKind = | "layout" | "cameraFullscreen" | "audio" - | "shaderEffect"; + | "shaderEffect" + | "cursorMotion"; /** Length a clip is given before its media has been probed. Lives here, in the pure * document layer, because that layer decides which clips are still waiting for a real @@ -403,6 +404,15 @@ export function mapAllRegionCollections( (document.shaderEffectRanges ?? []) as unknown as StoredRegion[], "fxr", ) as unknown as AxcutDocument["shaderEffectRanges"], + // Conditional like `layoutRegions`: a document that never had cursor motion keeps no key. + ...(document.cursorMotionRanges + ? { + cursorMotionRanges: fn( + document.cursorMotionRanges as unknown as StoredRegion[], + "curm", + ) as unknown as AxcutDocument["cursorMotionRanges"], + } + : {}), annotations: fn( document.annotations as unknown as StoredRegion[], "ann", @@ -759,6 +769,7 @@ function anchoredRegionsOf(document: AxcutDocument): Array<{ id: string; clipId: (legacy?.speedRegions as StoredRegion[] | undefined) ?? [], (legacy?.cameraFullscreenRegions as StoredRegion[] | undefined) ?? [], (document.shaderEffectRanges ?? []) as unknown as StoredRegion[], + (document.cursorMotionRanges ?? []) as unknown as StoredRegion[], ]; return collections .flat() @@ -1252,6 +1263,11 @@ export function removeRegion(document: AxcutDocument, kind: RegionKind, id: stri ...document, shaderEffectRanges: dropPillById(document.shaderEffectRanges ?? [], id), }); + case "cursorMotion": + return { + ...document, + cursorMotionRanges: dropPillById(document.cursorMotionRanges ?? [], id), + }; default: { // ponytail: exhaustive — TS errors here if a new RegionKind is added. const exhaustive: never = kind; @@ -1304,6 +1320,10 @@ const EDIT_REGIONS: Record< count: (d) => (d.shaderEffectRanges ?? []).length, clear: (d) => ({ ...d, shaderEffectRanges: [], shaderEffects: [] }), }, + cursorMotion: { + count: (d) => (d.cursorMotionRanges ?? []).length, + clear: (d) => (d.cursorMotionRanges ? { ...d, cursorMotionRanges: [] } : d), + }, }; /** How many edit regions the document holds, stored rows and not pills. Pure. */ diff --git a/src/lib/ai-edition/schema/index.ts b/src/lib/ai-edition/schema/index.ts index e9bf15f1f..03e8a53e4 100644 --- a/src/lib/ai-edition/schema/index.ts +++ b/src/lib/ai-edition/schema/index.ts @@ -535,6 +535,30 @@ export const zoomRegionSchema = endGteStart( "startMs", ); +/** How a cursor-motion region replaces the recorded pointer path over its span. `recorded` shows + * the raw samples (no smoothing), `smooth` a zero-lag Gaussian of them, `straight` a straight + * line from where the pointer is at the start to where it is at the end, `freeze` the start + * position held. The compositor blends each edge into the globally smoothed path + * (`CursorTrack::with_motion` in `crates/compositor/src/cursor.rs`). */ +export const CURSOR_MOTION_MODES = ["recorded", "smooth", "straight", "freeze"] as const; +export const CURSOR_MOTION_EASINGS = ["ease-in-out", "linear", "ease-in", "ease-out"] as const; + +export const cursorMotionRegionSchema = endGteStart( + z.object({ + id: z.string().min(1), + startMs: z.number().nonnegative(), + endMs: z.number().nonnegative(), + ...clipAnchorShape, + mode: z.enum(CURSOR_MOTION_MODES), + /** `smooth` only: 0..1 of the widest Gaussian. Absent reads as the default. */ + strength: z.number().min(0).max(1).optional(), + /** `straight` only: the progress curve along the line. Absent reads as ease-in-out. */ + easing: z.enum(CURSOR_MOTION_EASINGS).optional(), + }), + "endMs", + "startMs", +); + // Agent-written shader effects (docs/shader-effects.md, B). A definition carries the WGSL and its // declared parameters; a range poses it on the timeline, clip-anchored like a zoom, with its own // parameter values. Additive: a document written before these existed loads unchanged. @@ -785,6 +809,9 @@ const documentSchemaShape = z.object({ audioTracks: z.array(audioTrackSchema).default([]), // Absent/empty means one global layout; fragments are materialised on first change. layoutRegions: z.array(layoutRegionSchema).optional(), + // Per-section overrides of the cursor's path. Optional like `shaderEffectRanges`: additive, no + // schemaVersion bump, and an older build drops the key on save. + cursorMotionRanges: z.array(cursorMotionRegionSchema).optional(), legacyEditor: legacyEditorSchema.nullable().default(null), }); @@ -1444,6 +1471,11 @@ export type AxcutAudioTrack = z.infer; export type AxcutShaderEffect = z.infer; export type AxcutShaderEffectParam = z.infer; export type AxcutShaderEffectRange = z.infer; +export type AxcutCursorMotionRegion = z.infer; +export type CursorMotionMode = (typeof CURSOR_MOTION_MODES)[number]; +export type CursorMotionEasing = (typeof CURSOR_MOTION_EASINGS)[number]; +/** Applied when a region carries no `strength`. */ +export const DEFAULT_CURSOR_MOTION_STRENGTH = 0.5; export type AxcutShaderEffectValue = z.infer; export type AxcutLegacyEditor = z.infer; export type AxcutDocument = z.infer; diff --git a/src/lib/ai-edition/store/documentWriteAudit.test.ts b/src/lib/ai-edition/store/documentWriteAudit.test.ts index a27d74ef1..0d2d8c46d 100644 --- a/src/lib/ai-edition/store/documentWriteAudit.test.ts +++ b/src/lib/ai-edition/store/documentWriteAudit.test.ts @@ -166,6 +166,7 @@ const DECLARED: WritePath[] = [ w("src/components/ai-edition/NewEditorShell.tsx", "pasteRegion", "save", "gesture"), w("src/components/ai-edition/NewEditorShell.tsx", "pasteRegion", "save", "gesture"), w("src/components/ai-edition/NewEditorShell.tsx", "pasteRegion", "save", "gesture"), + w("src/components/ai-edition/NewEditorShell.tsx", "pasteRegion", "save", "gesture"), // The window is closing and the user answered "save". w("src/components/ai-edition/NewEditorShell.tsx", "unsubSaveBeforeClose", "save", "gesture"), // Changing a passage from the Layout pane is an explicit edit. @@ -261,6 +262,7 @@ const DECLARED: WritePath[] = [ w("src/lib/ai-edition/store/useTimeline.ts", "addCameraFullscreen", "save", "gesture"), w("src/lib/ai-edition/store/useTimeline.ts", "addLayoutChange", "save", "gesture"), w("src/lib/ai-edition/store/useTimeline.ts", "addSpeed", "save", "gesture"), + w("src/lib/ai-edition/store/useTimeline.ts", "addCursorMotion", "save", "gesture"), w("src/lib/ai-edition/store/useTimeline.ts", "addTrim", "save", "gesture"), w("src/lib/ai-edition/store/useTimeline.ts", "addZoom", "save", "gesture"), w("src/lib/ai-edition/store/useTimeline.ts", "addZoomsBulk", "save", "gesture"), @@ -276,6 +278,8 @@ const DECLARED: WritePath[] = [ // The effect inspector's sliders and colours, committed as the annotations' are. w("src/lib/ai-edition/store/useTimeline.ts", "commitShaderEffectChange", "save", "gesture"), w("src/lib/ai-edition/store/useTimeline.ts", "commitShaderEffectChange", "state", "unrecorded"), + w("src/lib/ai-edition/store/useTimeline.ts", "commitCursorMotionChange", "save", "gesture"), + w("src/lib/ai-edition/store/useTimeline.ts", "commitCursorMotionChange", "state", "unrecorded"), w("src/lib/ai-edition/store/useTimeline.ts", "commitZoomFocus", "save", "gesture"), w("src/lib/ai-edition/store/useTimeline.ts", "commitZoomFocus", "state", "unrecorded"), w("src/lib/ai-edition/store/useTimeline.ts", "duplicateClip", "save", "gesture"), @@ -308,6 +312,9 @@ const DECLARED: WritePath[] = [ w("src/lib/ai-edition/store/useTimeline.ts", "updateAnnotationLive", "set", "automatic"), w("src/lib/ai-edition/store/useTimeline.ts", "updateAnnotationSpan", "save", "gesture"), w("src/lib/ai-edition/store/useTimeline.ts", "updateCameraFullscreenSpan", "save", "gesture"), + w("src/lib/ai-edition/store/useTimeline.ts", "updateCursorMotionLive", "set", "automatic"), + w("src/lib/ai-edition/store/useTimeline.ts", "updateCursorMotionSettings", "save", "gesture"), + w("src/lib/ai-edition/store/useTimeline.ts", "updateCursorMotionSpan", "save", "gesture"), w("src/lib/ai-edition/store/useTimeline.ts", "updateShaderEffect", "save", "gesture"), w("src/lib/ai-edition/store/useTimeline.ts", "updateShaderEffectLive", "set", "automatic"), w("src/lib/ai-edition/store/useTimeline.ts", "updateShaderEffectSpan", "save", "gesture"), diff --git a/src/lib/ai-edition/store/regionClipboard.ts b/src/lib/ai-edition/store/regionClipboard.ts index 74bbf8c5e..947ac9528 100644 --- a/src/lib/ai-edition/store/regionClipboard.ts +++ b/src/lib/ai-edition/store/regionClipboard.ts @@ -12,6 +12,7 @@ export type RegionSnapshot = | { kind: "annotation"; region: Record } | { kind: "speed"; region: Record } | { kind: "cameraFullscreen"; region: Record } + | { kind: "cursorMotion"; region: Record } // An audio track copies its whole payload (asset, gain, fades, loop) so a // paste is a second placement of the same audio, like every other kind. The // snapshot is the COLLAPSED pill, never a stored fragment. diff --git a/src/lib/ai-edition/store/useTimeline.test.ts b/src/lib/ai-edition/store/useTimeline.test.ts index 229b8f8f4..463e4ff28 100644 --- a/src/lib/ai-edition/store/useTimeline.test.ts +++ b/src/lib/ai-edition/store/useTimeline.test.ts @@ -1614,6 +1614,94 @@ describe("useTimeline.addAnnotation", () => { }); }); +describe("useTimeline cursor motion", () => { + const sections = () => useProjectStore.getState().document?.cursorMotionRanges ?? []; + + beforeEach(() => { + useProjectStore.getState().clear(); + clearHistory(); + for (const mock of Object.values(bridgeMocks)) mock.mockReset(); + bridgeMocks.save.mockImplementation(async (doc: typeof sampleDoc) => ({ + success: true, + document: doc, + })); + useProjectStore.setState({ + projectId: "proj_test", + document: sampleDoc, + currentTimeSec: 1, + revision: 1, + status: "ready", + error: null, + }); + }); + + afterEach(() => { + vi.clearAllMocks(); + }); + + it("adds a clip-anchored smooth section at the playhead and selects it", async () => { + const { result } = renderTimeline(); + let id: string | null = null; + await act(async () => { + id = await result.current.addCursorMotion(2); + }); + expect(sections()).toEqual([ + expect.objectContaining({ id, startMs: 1000, endMs: 3000, mode: "smooth" }), + ]); + expect(sections()[0].clipId).toBeTruthy(); + expect(result.current.selection).toEqual({ kind: "cursorMotion", id }); + const saved = useProjectStore.getState().document as AxcutDocument; + expect(parseDocumentFile(JSON.parse(JSON.stringify(saved))).cursorMotionRanges).toEqual( + sections(), + ); + }); + + it("changes the mode in one write and drags the strength as one undo step", async () => { + const { result } = renderTimeline(); + let id = ""; + await act(async () => { + id = (await result.current.addCursorMotion(2)) ?? ""; + }); + await act(async () => { + await result.current.updateCursorMotionSettings(id, { mode: "straight", easing: "linear" }); + }); + expect(sections()[0]).toMatchObject({ mode: "straight", easing: "linear" }); + await act(async () => { + await result.current.updateCursorMotionSettings(id, { mode: "smooth" }); + }); + const before = past.length; + act(() => { + result.current.updateCursorMotionLive(id, { strength: 0.2 }); + result.current.updateCursorMotionLive(id, { strength: 0.9 }); + }); + await act(async () => { + await result.current.commitCursorMotionChange(); + }); + expect(sections()[0].strength).toBe(0.9); + expect(past.length).toBe(before + 1); + await act(async () => { + await undo(); + }); + expect(sections()[0].strength).toBeUndefined(); + }); + + it("moves a section and removes it", async () => { + const { result } = renderTimeline(); + let id = ""; + await act(async () => { + id = (await result.current.addCursorMotion(2)) ?? ""; + }); + await act(async () => { + await result.current.updateCursorMotionSpan(id, 4000, 5000); + }); + expect(sections()[0]).toMatchObject({ startMs: 4000, endMs: 5000 }); + await act(async () => { + await result.current.removeRegion("cursorMotion", sections()[0].id); + }); + expect(sections()).toEqual([]); + }); +}); + // The Clear timeline button. Every edit region on every clip, one write; the content stays. describe("useTimeline.clearTimeline", () => { type Timeline = ReturnType; @@ -1627,6 +1715,7 @@ describe("useTimeline.clearTimeline", () => { trim: (tl) => tl.addTrim(), annotation: (tl) => tl.addAnnotation(), speed: (tl) => tl.addSpeed(), + cursorMotion: (tl) => tl.addCursorMotion(), layout: (tl) => tl.addLayoutChange("no-webcam", 2), // The editor has no effect lane: agents add effects, so this one is written as they do. shaderEffect: async () => { @@ -1674,6 +1763,7 @@ describe("useTimeline.clearTimeline", () => { speed: doc ? readSpeedRegions(doc).length : 0, layout: doc ? Math.max(0, layoutRuns(doc).length - 1) : 0, shaderEffect: doc?.shaderEffectRanges?.length ?? 0, + cursorMotion: doc?.cursorMotionRanges?.length ?? 0, }; }; const noRegions: Record = { @@ -1683,6 +1773,7 @@ describe("useTimeline.clearTimeline", () => { speed: 0, layout: 0, shaderEffect: 0, + cursorMotion: 0, }; // A project holding everything that is NOT an edit: two clips, a webcam, an imported @@ -1843,6 +1934,7 @@ describe("useTimeline.clearTimeline", () => { speed: 1, layout: 1, shaderEffect: 1, + cursorMotion: 1, }); await act(async () => { @@ -1883,6 +1975,7 @@ describe("useTimeline.clearTimeline", () => { speed: 1, layout: 1, shaderEffect: 1, + cursorMotion: 1, }); act(() => { diff --git a/src/lib/ai-edition/store/useTimeline.ts b/src/lib/ai-edition/store/useTimeline.ts index 3171ac416..1c49834c5 100644 --- a/src/lib/ai-edition/store/useTimeline.ts +++ b/src/lib/ai-edition/store/useTimeline.ts @@ -51,6 +51,7 @@ import { import type { AxcutAudioTrack, AxcutClipCropRegion, + AxcutCursorMotionRegion, AxcutDocument, AxcutShaderEffectRange, } from "../schema"; @@ -151,6 +152,11 @@ function playheadSec(): number { return useProjectStore.getState().currentTimeSec; } +/** What the inspector changes on a cursor-motion region. */ +export type CursorMotionPatch = Partial< + Pick +>; + /** What the inspector changes on an effect region: its parameter values, or its target. */ export interface ShaderEffectPatch { values?: Record; @@ -223,6 +229,8 @@ export function useTimeline() { const annotationLiveRef = useRef(null); const shaderEffectRollbackRef = useRef(null); const shaderEffectLiveRef = useRef(null); + const cursorMotionRollbackRef = useRef(null); + const cursorMotionLiveRef = useRef(null); // A drag does not always end in a commit: `ZoomFocusOverlay` unmounts the moment // `focusMode` flips to "auto", so `endDrag` never runs and the snapshot outlives the @@ -239,6 +247,8 @@ export function useTimeline() { annotationLiveRef.current = null; shaderEffectRollbackRef.current = null; shaderEffectLiveRef.current = null; + cursorMotionRollbackRef.current = null; + cursorMotionLiveRef.current = null; }, [projectId]); const hasDoc = document !== null && projectId !== null; @@ -1266,6 +1276,105 @@ export function useTimeline() { } }, [saveDocument]); + // --- Cursor motion: per-section overrides of the cursor's path -------------------------- + // Plain top-level collection, clip-anchored like a zoom; the ops mirror speed's. + const addCursorMotion = useCallback( + async (durationSec = DEFAULT_NEW_REGION_SEC): Promise => { + if (!document) return null; + const timeMs = Math.round(playheadSec() * 1000); + const endMs = timeMs + Math.round(durationSec * 1000); + const id = createId("curm"); + const added = anchorRegionsWithDerivedMs( + [{ id, startMs: timeMs, endMs, mode: "smooth" as const }], + document.timeline.clips, + () => createId("curm"), + ) as AxcutCursorMotionRegion[]; + if (added.length === 0) return null; + const next: AxcutDocument = { + ...document, + cursorMotionRanges: [...(document.cursorMotionRanges ?? []), ...added], + }; + if (!(await saveDocument(next, { history: true }))) return null; + const firstId = added[0].id; + setClipSelection(null); + setMultiSelection([{ kind: "cursorMotion", id: firstId }]); + setSelection({ kind: "cursorMotion", id: firstId }); + return firstId; + }, + [document, saveDocument], + ); + + const updateCursorMotionSpan = useCallback( + async (id: string, startMs: number, endMs: number) => { + if (!document) return; + const s = finiteMs(startMs); + const e = finiteMs(endMs); + const next: AxcutDocument = { + ...document, + cursorMotionRanges: replacePillSpan( + document.cursorMotionRanges ?? [], + id, + Math.min(s, e), + Math.max(s, e), + document.timeline.clips, + () => createId("curm"), + ), + }; + await saveDocument(next, { history: true }); + }, + [document, saveDocument], + ); + + const updateCursorMotionSettings = useCallback( + async (id: string, patch: CursorMotionPatch) => { + if (!document) return; + const next: AxcutDocument = { + ...document, + cursorMotionRanges: patchRegionById( + document.cursorMotionRanges ?? [], + id, + patch, + ), + }; + await saveDocument(next, { history: true }); + }, + [document, saveDocument], + ); + + // A slider: local writes while it lasts, then one save and one undo step from + // `commitCursorMotionChange`. The shader effects' live path. + const updateCursorMotionLive = useCallback( + (id: string, patch: CursorMotionPatch) => { + const doc = useProjectStore.getState().document; + if (!doc?.cursorMotionRanges) return; + const next: AxcutDocument = { + ...doc, + cursorMotionRanges: patchRegionById( + doc.cursorMotionRanges, + id, + patch, + ), + }; + if (cursorMotionLiveRef.current !== doc) cursorMotionRollbackRef.current = doc; + setDocument(next, { history: false }); + cursorMotionLiveRef.current = next; + }, + [setDocument], + ); + + const commitCursorMotionChange = useCallback(async () => { + const doc = useProjectStore.getState().document; + if (!doc) return; + const rollback = cursorMotionLiveRef.current === doc ? cursorMotionRollbackRef.current : null; + cursorMotionRollbackRef.current = null; + cursorMotionLiveRef.current = null; + if (!(await saveDocument(doc, { history: true, historyBase: rollback })) && rollback) { + useProjectStore.setState((state) => + state.document === doc ? { document: rollback, revision: state.revision + 1 } : {}, + ); + } + }, [saveDocument]); + const updateSpeedValue = useCallback( async (id: string, speed: number) => { if (!document) return; @@ -1317,6 +1426,9 @@ export function useTimeline() { const shaderEffectIds = new Set( handles.filter((h) => h.kind === "shaderEffect").map((h) => h.id), ); + const cursorMotionIds = new Set( + handles.filter((h) => h.kind === "cursorMotion").map((h) => h.id), + ); const legacy = (document.legacyEditor as Record) ?? {}; const prevSpeed = dropPillsByIds( (legacy.speedRegions as Array<{ id: string; startMs: number; endMs: number }>) ?? [], @@ -1339,6 +1451,14 @@ export function useTimeline() { ), } : {}), + ...(cursorMotionIds.size > 0 + ? { + cursorMotionRanges: dropPillsByIds( + document.cursorMotionRanges ?? [], + cursorMotionIds, + ), + } + : {}), timeline: { ...document.timeline, // Whole-pill delete, same as the zoom/annotation lines above — a trim grown @@ -1720,6 +1840,7 @@ export function useTimeline() { // One region per effect, never two at once; each names its definition. const shaderEffectRanges = hasDoc ? (document.shaderEffectRanges ?? []) : []; const shaderEffects = hasDoc ? (document.shaderEffects ?? []) : []; + const cursorMotionRegions = hasDoc ? (document.cursorMotionRanges ?? []) : []; // --- Timeline audio tracks (issue #350) ------------------------------------- // CLIP-ANCHORED like every region above: one user-visible track is one pill @@ -1917,6 +2038,7 @@ export function useTimeline() { cameraFullscreenRegions, shaderEffectRanges, shaderEffects, + cursorMotionRegions, layoutSegments, addLayoutChange, setLayoutPreset, @@ -1978,6 +2100,11 @@ export function useTimeline() { updateShaderEffect, updateShaderEffectLive, commitShaderEffectChange, + addCursorMotion, + updateCursorMotionSpan, + updateCursorMotionSettings, + updateCursorMotionLive, + commitCursorMotionChange, // T19 — drives the preview video during trim-edge resize. setCurrentTime: useProjectStore((s) => s.setCurrentTime), }; diff --git a/src/lib/shortcuts.ts b/src/lib/shortcuts.ts index f39eaef87..56f923f37 100644 --- a/src/lib/shortcuts.ts +++ b/src/lib/shortcuts.ts @@ -3,6 +3,7 @@ export const SHORTCUT_ACTIONS = [ "addZoom", "addTrim", "addSpeed", + "addCursorMotion", "addCameraFullscreen", "addAnnotation", "addAudio", @@ -113,6 +114,8 @@ export const DEFAULT_SHORTCUTS: ShortcutsConfig = { addZoom: { key: "z" }, addTrim: { key: "t" }, addSpeed: { key: "s" }, + // "P" for pointer: a cursor-motion section at the playhead. + addCursorMotion: { key: "p" }, addCameraFullscreen: { key: "c" }, addAnnotation: { key: "a" }, addAudio: { key: "m" }, @@ -129,6 +132,7 @@ export const SHORTCUT_LABELS: Record = { addZoom: "Add Zoom", addTrim: "Add Trim", addSpeed: "Add Speed", + addCursorMotion: "Add Cursor Motion", addCameraFullscreen: "Change layout here", addAnnotation: "Add Annotation", addAudio: "Add Audio", diff --git a/src/native/sceneDescription.test.ts b/src/native/sceneDescription.test.ts index 010ba7708..0ffd2b8dc 100644 --- a/src/native/sceneDescription.test.ts +++ b/src/native/sceneDescription.test.ts @@ -105,6 +105,7 @@ function makeDoc( audioTracks: overrides.audioTracks ?? [], ...(overrides.shaderEffects ? { shaderEffects: overrides.shaderEffects } : {}), ...(overrides.shaderEffectRanges ? { shaderEffectRanges: overrides.shaderEffectRanges } : {}), + ...(overrides.cursorMotionRanges ? { cursorMotionRanges: overrides.cursorMotionRanges } : {}), legacyEditor: overrides.legacyEditor ?? null, }; } @@ -3228,3 +3229,59 @@ describe("buildSceneDescription.rotationByClip", () => { expect(scene.rotationByClip).toEqual([0]); }); }); + +describe("buildSceneDescription.cursor.motion", () => { + const asset = makeAsset({ id: "a", originalPath: "/a.mp4" }); + const clip = makeClip({ + id: "c1", + assetId: "a", + sourceStartSec: 100, + sourceEndSec: 110, + timelineStartSec: 0, + timelineEndSec: 10, + }); + + it("omits the key when the project has no cursor motion", () => { + const doc = makeDoc({ assets: [asset], clips: [clip] }); + expect(buildSceneDescription(doc).cursor).not.toHaveProperty("motion"); + }); + + it("sends each section in the recording's source seconds, named by its file", () => { + const doc = makeDoc({ + assets: [asset], + clips: [clip], + cursorMotionRanges: [ + { id: "m1", startMs: 2000, endMs: 4500, mode: "straight", easing: "linear" }, + { id: "m2", startMs: 6000, endMs: 7000, mode: "smooth" }, + ], + }); + expect(buildSceneDescription(doc).cursor.motion).toEqual([ + { + screenPath: "/a.mp4", + startSec: 102, + endSec: 104.5, + mode: "straight", + strength: 0.5, + easing: "linear", + }, + { + screenPath: "/a.mp4", + startSec: 106, + endSec: 107, + mode: "smooth", + strength: 0.5, + easing: "ease-in-out", + }, + ]); + }); + + it("drops a section on a clip whose asset has no file", () => { + const orphan = makeAsset({ id: "b", originalPath: "" }); + const doc = makeDoc({ + assets: [orphan], + clips: [{ ...clip, assetId: "b" }], + cursorMotionRanges: [{ id: "m1", startMs: 1000, endMs: 2000, mode: "freeze" }], + }); + expect(buildSceneDescription(doc).cursor).not.toHaveProperty("motion"); + }); +}); diff --git a/src/native/sceneDescription.ts b/src/native/sceneDescription.ts index f5946a44f..348345bfe 100644 --- a/src/native/sceneDescription.ts +++ b/src/native/sceneDescription.ts @@ -40,7 +40,14 @@ import { readSpeedRegions, resolvePlaybackSegments, } from "@/lib/ai-edition/document/timeline"; -import type { AxcutAudioTrack, AxcutClip, AxcutDocument } from "@/lib/ai-edition/schema"; +import { + type AxcutAudioTrack, + type AxcutClip, + type AxcutDocument, + type CursorMotionEasing, + type CursorMotionMode, + DEFAULT_CURSOR_MOTION_STRENGTH, +} from "@/lib/ai-edition/schema"; import { nativeShaderEffectValue } from "@/lib/ai-edition/shaderEffects"; import { getEditorSettings } from "@/lib/ai-edition/store/editorSettings"; import { assetCameraSource } from "@/lib/ai-edition/timeline/camera"; @@ -483,6 +490,22 @@ export interface SceneEffects { depthOfField: boolean; } +/** + * One section where the cursor's path is replaced (`cursor.rs` `CursorTrack::with_motion`), in + * the SOURCE time of the recording named by `screenPath`: the compositor builds one cursor track + * per recording file, so a region is matched to a track by file rather than by clip index (which + * `clips` can shift when an asset has no file). + */ +export interface SceneCursorMotionRegion { + screenPath: string; + startSec: number; + endSec: number; + mode: CursorMotionMode; + /** 0..1, `smooth` only. */ + strength: number; + easing: CursorMotionEasing; +} + /** Cursor rendering, from the editor settings. */ export interface SceneCursor { show: boolean; @@ -507,6 +530,9 @@ export interface SceneCursor { clipToBounds: boolean; /** Cursor theme id (sprite set). */ theme: string; + /** Per-section path overrides. Omitted when there are none, so a scene without them is + * byte-for-byte what it was. */ + motion?: SceneCursorMotionRegion[]; } /** Everything native needs to compose the scene, serialized from one document. */ @@ -1181,6 +1207,31 @@ export function buildSceneDescription( // `projectRegionsToSource` accepts any `T extends { id; startMs; endMs }` and copies // every other field verbatim via `{...region}` — so the `speed` field passes through, // and the splitting-across-clips semantics match zoomRegions / cameraFullscreenRegions. + // Cursor motion: projected like the zooms, then named by recording file (see + // `SceneCursorMotionRegion`). A fragment under a trim is never on screen and is dropped; a + // fragment whose clip has no file has no cursor track to apply to. + const cursorMotion: SceneCursorMotionRegion[] = projectRegionsToSource( + document.cursorMotionRanges ?? [], + visibleClips, + document.timeline.clips, + () => createId("curm"), + ).flatMap((region) => { + if (region.underTrim) return []; + const clip = region.clipIndex === undefined ? undefined : visibleClips[region.clipIndex]; + const screenPath = clip ? assetById.get(clip.assetId)?.originalPath : undefined; + if (!screenPath || region.endMs <= region.startMs) return []; + return [ + { + screenPath, + startSec: region.startMs / 1000, + endSec: region.endMs / 1000, + mode: region.mode, + strength: region.strength ?? DEFAULT_CURSOR_MOTION_STRENGTH, + easing: region.easing ?? "ease-in-out", + }, + ]; + }); + const projectedSpeedRegions = projectRegionsToSource( readSpeedRegions(document), visibleClips, @@ -1541,6 +1592,7 @@ export function buildSceneDescription( // background. The field stays because the compositor's scene requires it. clipToBounds: false, theme: settings.cursorTheme, + ...(cursorMotion.length > 0 ? { motion: cursorMotion } : {}), }, audio: { gainDb: settings.audioGainDb,