mirror of
https://github.com/storytold/filmcraft.git
synced 2026-11-21 20:29:08 +00:00
Slip Monitor: a live four-up in the Program monitor while slipping
With the Slip tool (Y), dragging a clip showed nothing until release. Now the Program monitor
shows the previous clip's Out, the new In and Out (large, side by side, with their source
timecodes) and the next clip's In while the drag runs, plus the offset as a signed timecode and in
frames ("Slip: +25 frames", red "at the media limit" when the media's end holds it back); the
Timeline shows the offset at the pointer. Release commits `timeline.slip`, Escape drops it.
- `timeline.slipPreview` (`engine::slip::preview`) runs `slip_linked`, the function
`timeline.slip` now calls too, on a copy of the sequence: the preview is the commit at every
delta, linked picture and sound clamped together (#529, #594), with no project change or undo
step.
- `panels::slip_monitor` draws with the Trim Monitor's `picture()`, each picture in its own
frame-server view (`FrameServer::request_in_view`, #2366), so a fast drag keeps about one decode
per picture waiting and the newest frame wins.
- The slipped sound's waveform slides on the Timeline while dragging.
- New strings in every full-interface catalog (de, es, fr, id, it, ja, ko, pt-br, ru, zh-cn); uk
is still a small catalog and shows them in English.
Builds on #2366 (frame-server views); #2365 (the `slip_together` i64::MIN fix) is on main.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
99b5e12d0b
commit
00fa496944
@@ -88,7 +88,7 @@ FilmCraft is a professional non-linear editor: familiar panels, workspaces, tool
|
||||
**A timeline you already know.** Source and Program monitors, bins with thumbnails, a multi-track timeline with patch and target buttons, sync locks and linked selection. The Editing, Assembly, Color, Effects and Audio workspaces are all there, and every panel docks wherever you want it.
|
||||
|
||||
- **Three-point editing.** Mark In and Out in the Source monitor, then insert (`,`) or overwrite (`.`) onto the patched tracks. Lift (`;`) and extract (`'`) take ranges back out.
|
||||
- **Every trim.** Ripple, roll, slip, slide, rate stretch and razor tools. Trim mode selects edit points as ripple, roll or trim, nudges them a frame at a time (`⌥←` `⌥→`, ×5 with `⇧`), toggles the trim type with `⌃T` and extends them to the playhead with `E`. `Q` and `W` ripple-trim to the playhead. The **Trim Monitor** shows both sides of the edit, and **dynamic trimming** trims live while it plays: `L` forward, `J` back, `K` to stop and commit as one undo step.
|
||||
- **Every trim.** Ripple, roll, slip, slide, rate stretch and razor tools. Trim mode selects edit points as ripple, roll or trim, nudges them a frame at a time (`⌥←` `⌥→`, ×5 with `⇧`), toggles the trim type with `⌃T` and extends them to the playhead with `E`. `Q` and `W` ripple-trim to the playhead. The **Trim Monitor** shows both sides of the edit, the **Slip Monitor** shows the frames around a slip as you drag it (previous clip's Out, the new In and Out, next clip's In), and **dynamic trimming** trims live while it plays: `L` forward, `J` back, `K` to stop and commit as one undo step.
|
||||
- **Exact time.** Every edit is computed on integer ticks: 254,016,000,000 per second, which divides evenly by every common frame rate and sample rate. 23.976, 29.97 drop-frame and 59.94 are exact, not approximate.
|
||||
- **The details pros rely on.** Markers with colours, names and durations; export sequence review notes with **Markers ▸ Export Markers as CSV…**; add edit (`⌘K`) on one or all tracks; nesting; copy, paste and paste insert; ripple delete and close gap; snapping; unlimited undo with a History panel.
|
||||
- **Your keys.** A Keyboard Shortcuts editor (`⌥⌘K`) with a drawn keyboard, panel-specific shortcuts, conflict warnings and presets for FilmCraft and standard NLE key layouts.
|
||||
|
||||
@@ -752,6 +752,25 @@ pub(crate) fn slip_together(q: &mut filmcraft_project::Sequence, ctx: &mut edit:
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// `timeline.slip`'s edit: `clips` (a clip and its linked partners) slipped by one media delta,
|
||||
/// clamped together so picture and sound stay in sync (#529). The Slip Monitor runs this same
|
||||
/// function on a copy of the sequence ([`crate::slip::preview`]), so the drag shows what the
|
||||
/// release commits.
|
||||
pub(crate) fn slip_linked(q: &mut filmcraft_project::Sequence, ctx: &mut edit::EditCtx<'_>, clips: &[ClipId], delta: Tick) -> Result<()> {
|
||||
let deltas: Vec<(ClipId, Tick)> = clips.iter().map(|c| (*c, delta)).collect();
|
||||
slip_together(q, ctx, &deltas)
|
||||
}
|
||||
|
||||
/// The media delta of `timeline.slip` / `timeline.slipPreview`: `delta` ticks, else `deltaFrames`
|
||||
/// sequence frames, else none.
|
||||
fn slip_delta_p(s: &Session, p: &Value) -> Tick {
|
||||
p.get("delta")
|
||||
.and_then(Value::as_i64)
|
||||
.map(Tick)
|
||||
.or_else(|| p.get("deltaFrames").and_then(Value::as_i64).map(|f| s.sequence_rate().tick_of(f)))
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Clips an audio effect should land on: audio ids as given, plus the linked audio of any video
|
||||
/// clip in the list (so applying Parametric EQ to an A/V pair hits the sound).
|
||||
pub fn audio_effect_targets(s: &Session, clips: &[ClipId]) -> Vec<ClipId> {
|
||||
@@ -3554,20 +3573,16 @@ fn build() -> Vec<CommandSpec> {
|
||||
}),
|
||||
cmd!("timeline.slip", "Slip", [], None, r#"{"clip":id,"delta":ticks|"deltaFrames":i64}"#, has_seq, |s, p| {
|
||||
let c = clip_p(p, "clip").ok_or_else(|| bad("timeline.slip", "need `clip`"))?;
|
||||
let d = p
|
||||
.get("delta")
|
||||
.and_then(Value::as_i64)
|
||||
.map(Tick)
|
||||
.or_else(|| p.get("deltaFrames").and_then(Value::as_i64).map(|f| s.sequence_rate().tick_of(f)))
|
||||
.unwrap_or_default();
|
||||
let d = slip_delta_p(s, p);
|
||||
let clips = with_links(s, &[c]);
|
||||
s.edit_sequence("Slip", |q, ctx, _| {
|
||||
// clamp across all linked partners, then slip them by the common delta
|
||||
let deltas: Vec<(ClipId, Tick)> = clips.iter().map(|c| (*c, d)).collect();
|
||||
slip_together(q, ctx, &deltas)
|
||||
})?;
|
||||
s.edit_sequence("Slip", |q, ctx, _| slip_linked(q, ctx, &clips, d))?;
|
||||
Ok(Value::Null)
|
||||
}),
|
||||
// What `timeline.slip` with the same params would do, without editing: the Slip Monitor
|
||||
query!("timeline.slipPreview", "Slip Preview", r#"{"clip":id,"delta":ticks|"deltaFrames":i64}"#, |s, p| {
|
||||
let c = clip_p(p, "clip").ok_or_else(|| bad("timeline.slipPreview", "need `clip`"))?;
|
||||
crate::slip::preview(s, c, slip_delta_p(s, p))
|
||||
}),
|
||||
cmd!("timeline.slide", "Slide", [], None, r#"{"clip":id,"delta":ticks|"deltaFrames":i64}"#, has_seq, |s, p| {
|
||||
let c = clip_p(p, "clip").ok_or_else(|| bad("timeline.slide", "need `clip`"))?;
|
||||
let d = p
|
||||
|
||||
@@ -56,6 +56,7 @@ pub mod sequence_tools;
|
||||
pub mod settings;
|
||||
pub mod shortcut_presets;
|
||||
pub mod shortcuts;
|
||||
pub mod slip;
|
||||
pub mod source_monitor;
|
||||
pub mod sync;
|
||||
pub mod transcript;
|
||||
@@ -1518,6 +1519,8 @@ mod settings_tests;
|
||||
#[cfg(test)]
|
||||
mod shortcuts_tests;
|
||||
#[cfg(test)]
|
||||
mod slip_tests;
|
||||
#[cfg(test)]
|
||||
mod split_edit_ripple_trim_tests;
|
||||
#[cfg(test)]
|
||||
mod stored_paths_tests;
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
//! The Slip Monitor (Premiere's four-up slip view): while the Slip tool drags a clip, the Program
|
||||
//! monitor shows the previous clip's last frame, the slipped clip's new first and last frames and
|
||||
//! the next clip's first frame, with the new source timecodes and the slip offset.
|
||||
//!
|
||||
//! [`preview`] works the slip out on a copy of the sequence with the edit `timeline.slip` applies
|
||||
//! ([`crate::commands::slip_linked`]: one delta for the clip and its linked partners, clamped by
|
||||
//! the most constrained one's media, #529), so the drag shows exactly what the release commits.
|
||||
//! Nothing in the project changes and no undo step is made. `timeline.slipPreview` returns it.
|
||||
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use filmcraft_edit as edit;
|
||||
use filmcraft_project::{ClipId, ItemId, Sequence, TrackKind};
|
||||
use filmcraft_time::{Tick, TimeDisplay, format_time};
|
||||
|
||||
use crate::commands::{slip_linked, with_links};
|
||||
use crate::trim::side_json;
|
||||
use crate::{EngineError, Result, Session};
|
||||
|
||||
/// What slipping `clip` by `delta` (media ticks, as `timeline.slip` takes) would show.
|
||||
///
|
||||
/// `in` / `out` are the slipped clip's first and last frames after the slip, `previous` / `next`
|
||||
/// the last frame of the clip that ends where it starts and the first frame of the clip that
|
||||
/// starts where it ends, on its track (null at a gap or the end of the track). When the dragged
|
||||
/// clip is sound with linked picture, the picture is what's shown (`shown`). Each side carries
|
||||
/// `sourceTimecode`, the media timecode of its frame. `delta` is the slip actually applied (the
|
||||
/// request clamped at the media's ends; `atLimit` when that held it back) and `offsetFrames` that
|
||||
/// in sequence frames. `clips` lists each slipped clip's new source range.
|
||||
pub fn preview(s: &Session, clip: ClipId, delta: Tick) -> Result<Value> {
|
||||
let seq = s.active_sequence().ok_or(EngineError::NoSequence)?;
|
||||
let (_, before) = seq.find_item(clip).ok_or_else(|| EngineError::Other(format!("no clip {}", clip.0)))?;
|
||||
let clips = with_links(s, &[clip]);
|
||||
let mut q = seq.clone();
|
||||
let durations = |id: ItemId| crate::media_duration(&s.project, &s.media, id);
|
||||
let starts = |id: ItemId| crate::media_start(&s.project, id);
|
||||
let mut next_id = s.project.next_id;
|
||||
let rate = seq.settings.frame_rate;
|
||||
let mut ctx = edit::EditCtx { next_id: &mut next_id, media_duration: &durations, media_start: &starts, min_duration: rate.frame_duration() };
|
||||
slip_linked(&mut q, &mut ctx, &clips, delta)?;
|
||||
|
||||
let applied = q.find_item(clip).map(|(_, it)| it.source_in - before.source_in).unwrap_or_default();
|
||||
let on_video = |c: &ClipId| seq.find_item(*c).and_then(|(tid, _)| seq.track(tid)).is_some_and(|t| t.kind == TrackKind::Video);
|
||||
let shown = if on_video(&clip) { clip } else { clips.iter().copied().find(on_video).unwrap_or(clip) };
|
||||
let (prev, next) = neighbours(&q, shown);
|
||||
let side = |c: Option<ClipId>, outgoing: bool| c.and_then(|c| side_json(s, &q, c, outgoing)).map(|v| with_timecode(s, v)).unwrap_or(Value::Null);
|
||||
let slipped: Vec<Value> = clips
|
||||
.iter()
|
||||
.filter_map(|c| {
|
||||
let (_, was) = seq.find_item(*c)?;
|
||||
let (_, it) = q.find_item(*c)?;
|
||||
Some(json!({"clip": c.0, "sourceIn": it.source_in.0, "sourceOut": it.source_out().0, "delta": (it.source_in - was.source_in).0}))
|
||||
})
|
||||
.collect();
|
||||
Ok(json!({
|
||||
"clip": clip.0,
|
||||
"shown": shown.0,
|
||||
"video": on_video(&shown),
|
||||
"requested": delta.0,
|
||||
"delta": applied.0,
|
||||
"offsetFrames": rate.frame_at(rate.snap_nearest(applied)),
|
||||
"atLimit": applied != delta,
|
||||
"previous": side(prev, true),
|
||||
"in": side(Some(shown), false),
|
||||
"out": side(Some(shown), true),
|
||||
"next": side(next, false),
|
||||
"clips": slipped,
|
||||
}))
|
||||
}
|
||||
|
||||
/// The clips that touch `clip` on its track: the one ending where it starts and the one starting
|
||||
/// where it ends. A slip moves neither.
|
||||
fn neighbours(seq: &Sequence, clip: ClipId) -> (Option<ClipId>, Option<ClipId>) {
|
||||
let Some((tid, it)) = seq.find_item(clip) else { return (None, None) };
|
||||
let Some(track) = seq.track(tid) else { return (None, None) };
|
||||
let prev = track.items.iter().find(|o| o.id != clip && o.end() == it.start).map(|o| o.id);
|
||||
let next = track.items.iter().find(|o| o.id != clip && o.start == it.end()).map(|o| o.id);
|
||||
(prev, next)
|
||||
}
|
||||
|
||||
/// Add `sourceTimecode` to a side: its media time as the media's own timecode (its start
|
||||
/// timecode plus the media time, at the media's rate), as the Timecode panel shows it.
|
||||
fn with_timecode(s: &Session, mut side: Value) -> Value {
|
||||
let item = side["item"].as_u64().map(ItemId);
|
||||
let media_time = Tick(side["mediaTime"].as_i64().unwrap_or(0));
|
||||
if let Some(it) = item.and_then(|i| s.project.item(i)) {
|
||||
let rate = it.frame_rate();
|
||||
let start = it.as_media().and_then(|m| m.info.start_timecode).map(|f| rate.tick_of(f)).unwrap_or_default();
|
||||
side["sourceTimecode"] = json!(format_time(start + media_time, rate, false, TimeDisplay::Timecode, 48000));
|
||||
}
|
||||
side
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
//! The Slip Monitor's preview (`timeline.slipPreview`, [`crate::slip::preview`]): it shows what
|
||||
//! `timeline.slip` with the same delta commits, frame for frame, never edits the project, and keeps
|
||||
//! linked picture and sound in sync at unequal media limits (#529).
|
||||
|
||||
use filmcraft_project::TrackItem;
|
||||
use filmcraft_time::Tick;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::Session;
|
||||
|
||||
fn clip(s: &Session, id: u64) -> TrackItem {
|
||||
s.active_sequence().unwrap().find_item(filmcraft_project::ClipId(id)).unwrap().1.clone()
|
||||
}
|
||||
|
||||
/// A 25 fps sequence with `fps` media of `seconds`; returns the session and the media item.
|
||||
fn session(fps: u32, seconds: u32) -> (Session, u64) {
|
||||
let mut s = Session::default();
|
||||
s.execute("file.newProject", json!({"name": "Slip"})).unwrap();
|
||||
s.execute("file.newSequence", json!({"name": "Sequence", "fps": 25, "video": 1, "audio": 1, "width": 16, "height": 16})).unwrap();
|
||||
let r = s.execute("file.newOfflineFile", json!({"name": "Media", "seconds": seconds, "fps": fps, "video": true, "audio": true})).unwrap();
|
||||
(s, r["item"].as_u64().unwrap())
|
||||
}
|
||||
|
||||
fn frame(s: &Session) -> i64 {
|
||||
s.sequence_rate().tick_of(1).0
|
||||
}
|
||||
|
||||
/// The #529 split edit: a linked pair at source In 20 frames, 60 long, the picture lengthened by
|
||||
/// 10 frames on its own, so it has 10 frames of tail handle and the sound 20 (4 s media).
|
||||
fn split_edit() -> (Session, u64, u64) {
|
||||
let (mut s, item) = session(25, 4);
|
||||
let fr = frame(&s);
|
||||
let r = s.execute("timeline.place", json!({"item": item, "track": "V1", "audioTrack": "A1", "time": 0, "sourceIn": fr * 20, "duration": fr * 60})).unwrap();
|
||||
let (v, a) = (r["clips"][0].as_u64().unwrap(), r["clips"][1].as_u64().unwrap());
|
||||
s.execute("sequence.linkedSelection", json!({"on": false})).unwrap();
|
||||
s.execute("timeline.trim", json!({"clip": v, "edge": "out", "deltaFrames": 10})).unwrap();
|
||||
s.execute("sequence.linkedSelection", json!({"on": true})).unwrap();
|
||||
(s, v, a)
|
||||
}
|
||||
|
||||
fn preview(s: &mut Session, clip: u64, frames: i64) -> Value {
|
||||
s.execute("timeline.slipPreview", json!({"clip": clip, "deltaFrames": frames})).unwrap()
|
||||
}
|
||||
|
||||
fn source_ins(v: &Value) -> Vec<(u64, i64)> {
|
||||
let mut out: Vec<(u64, i64)> = v["clips"].as_array().unwrap().iter().map(|c| (c["clip"].as_u64().unwrap(), c["sourceIn"].as_i64().unwrap())).collect();
|
||||
out.sort();
|
||||
out
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_preview_is_what_the_slip_commits_for_every_delta() {
|
||||
let (mut s, v, a) = split_edit();
|
||||
for frames in (-40..=40).step_by(3) {
|
||||
for dragged in [v, a] {
|
||||
let p = preview(&mut s, dragged, frames);
|
||||
s.execute("timeline.slip", json!({"clip": dragged, "deltaFrames": frames})).unwrap();
|
||||
let committed = {
|
||||
let mut c = vec![(v, clip(&s, v).source_in.0), (a, clip(&s, a).source_in.0)];
|
||||
c.sort();
|
||||
c
|
||||
};
|
||||
assert_eq!(source_ins(&p), committed, "slip of {frames} frames dragging {dragged}");
|
||||
// the frames shown are the committed clip's first and last
|
||||
let pic = clip(&s, v);
|
||||
let fd = Tick(frame(&s));
|
||||
assert_eq!(p["in"]["mediaTime"].as_i64(), Some(pic.source_time_at(pic.start).0));
|
||||
assert_eq!(p["out"]["mediaTime"].as_i64(), Some(pic.source_time_at(pic.end() - fd).0));
|
||||
if frames != 0 {
|
||||
s.execute("edit.undo", json!({})).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn linked_picture_and_sound_stop_together_at_the_shorter_handle() {
|
||||
let (mut s, v, a) = split_edit();
|
||||
let fr = frame(&s);
|
||||
// the picture has 10 frames of tail handle: a 30 frame slip later stops both at 10
|
||||
let p = preview(&mut s, a, 30);
|
||||
assert_eq!(source_ins(&p), vec![(v, fr * 30), (a, fr * 30)]);
|
||||
assert_eq!(p["atLimit"], json!(true));
|
||||
assert_eq!(p["offsetFrames"], json!(10));
|
||||
assert_eq!(p["requested"], json!(fr * 30));
|
||||
// the head has 20 frames for both
|
||||
let p = preview(&mut s, v, -25);
|
||||
assert_eq!(source_ins(&p), vec![(v, 0), (a, 0)]);
|
||||
assert_eq!(p["offsetFrames"], json!(-20));
|
||||
let p = preview(&mut s, v, 5);
|
||||
assert_eq!(p["atLimit"], json!(false));
|
||||
assert_eq!(p["offsetFrames"], json!(5));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_preview_changes_nothing_and_makes_no_undo_step() {
|
||||
let (mut s, v, a) = split_edit();
|
||||
let before = s.project.clone();
|
||||
let undo = s.history.undo.len();
|
||||
let revision = s.revision;
|
||||
for frames in [-100, -3, 0, 7, 100] {
|
||||
preview(&mut s, v, frames);
|
||||
preview(&mut s, a, frames);
|
||||
}
|
||||
assert_eq!(*s.project, *before);
|
||||
assert_eq!(s.history.undo.len(), undo);
|
||||
assert_eq!(s.revision, revision);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_neighbours_are_the_touching_clips_and_do_not_move() {
|
||||
let (mut s, item) = session(25, 20);
|
||||
let fr = frame(&s);
|
||||
s.execute("sequence.linkedSelection", json!({"on": false})).unwrap();
|
||||
let place = |s: &mut Session, time: i64, source_in: i64| {
|
||||
let r = s.execute("timeline.place", json!({"item": item, "track": "V1", "time": fr * time, "sourceIn": fr * source_in, "duration": fr * 25})).unwrap();
|
||||
r["clips"][0].as_u64().unwrap()
|
||||
};
|
||||
let a = place(&mut s, 0, 100);
|
||||
let b = place(&mut s, 25, 200);
|
||||
let c = place(&mut s, 50, 300);
|
||||
let lone = place(&mut s, 100, 50); // after a gap
|
||||
let p0 = preview(&mut s, b, 0);
|
||||
for frames in [-30, -1, 1, 30] {
|
||||
let p = preview(&mut s, b, frames);
|
||||
assert_eq!(p["previous"]["clip"].as_u64(), Some(a));
|
||||
assert_eq!(p["next"]["clip"].as_u64(), Some(c));
|
||||
// the previous clip's last frame and the next one's first, whatever the slip
|
||||
assert_eq!(p["previous"], p0["previous"]);
|
||||
assert_eq!(p["next"], p0["next"]);
|
||||
assert_eq!(p["previous"]["mediaTime"].as_i64(), Some(fr * (100 + 24)));
|
||||
assert_eq!(p["next"]["mediaTime"].as_i64(), Some(fr * 300));
|
||||
assert_eq!(p["in"]["mediaTime"].as_i64(), Some(fr * (200 + frames)));
|
||||
assert_eq!(p["out"]["mediaTime"].as_i64(), Some(fr * (200 + 24 + frames)));
|
||||
// the slipped clip keeps its place and length
|
||||
assert_eq!(p["in"]["time"].as_i64(), Some(fr * 25));
|
||||
assert_eq!(p["out"]["time"].as_i64(), Some(fr * 49));
|
||||
}
|
||||
// the first clip has nothing before it, the one after a gap nothing on either side
|
||||
assert!(preview(&mut s, a, 5)["previous"].is_null());
|
||||
let p = preview(&mut s, lone, 5);
|
||||
assert!(p["previous"].is_null() && p["next"].is_null());
|
||||
assert!(p["in"].is_object() && p["out"].is_object());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn slipping_the_sound_shows_its_linked_picture() {
|
||||
let (mut s, v, a) = split_edit();
|
||||
let p = preview(&mut s, a, 4);
|
||||
assert_eq!(p["clip"].as_u64(), Some(a));
|
||||
assert_eq!(p["shown"].as_u64(), Some(v));
|
||||
assert_eq!(p["video"], json!(true));
|
||||
assert_eq!(p["in"]["video"], json!(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sound_only_clips_preview_without_pictures() {
|
||||
let mut s = Session::default();
|
||||
s.execute("file.newProject", json!({"name": "Slip"})).unwrap();
|
||||
s.execute("file.newSequence", json!({"name": "Sequence", "fps": 25, "video": 1, "audio": 1, "width": 16, "height": 16})).unwrap();
|
||||
let r = s.execute("file.newOfflineFile", json!({"name": "Sound", "seconds": 4, "video": false, "audio": true})).unwrap();
|
||||
let item = r["item"].as_u64().unwrap();
|
||||
let fr = frame(&s);
|
||||
let r = s.execute("timeline.place", json!({"item": item, "track": "A1", "time": 0, "sourceIn": fr * 10, "duration": fr * 25})).unwrap();
|
||||
let a = r["clips"][0].as_u64().unwrap();
|
||||
let p = preview(&mut s, a, 3);
|
||||
assert_eq!(p["video"], json!(false));
|
||||
assert_eq!(p["in"]["video"], json!(false));
|
||||
assert_eq!(p["offsetFrames"], json!(3));
|
||||
s.execute("timeline.slip", json!({"clip": a, "deltaFrames": 3})).unwrap();
|
||||
assert_eq!(source_ins(&p), vec![(a, clip(&s, a).source_in.0)]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn speed_reverse_and_other_media_rates_show_the_committed_frames() {
|
||||
// 30 fps media in a 25 fps sequence, at 200 %, then reversed
|
||||
for reverse in [false, true] {
|
||||
let (mut s, item) = session(30, 20);
|
||||
let fr = frame(&s);
|
||||
let r = s
|
||||
.execute("timeline.place", json!({"item": item, "track": "V1", "audioTrack": "A1", "time": 0, "sourceIn": fr * 100, "duration": fr * 50}))
|
||||
.unwrap();
|
||||
let v = r["clips"][0].as_u64().unwrap();
|
||||
s.execute("timeline.select", json!({"clips": [v]})).unwrap();
|
||||
s.execute("clip.speedDuration", json!({"speed": 200, "reverse": reverse, "ripple": false})).unwrap();
|
||||
for frames in [-7, 0, 13] {
|
||||
let p = preview(&mut s, v, frames);
|
||||
s.execute("timeline.slip", json!({"clip": v, "deltaFrames": frames})).unwrap();
|
||||
let it = clip(&s, v);
|
||||
let fd = Tick(fr);
|
||||
assert_eq!(p["in"]["mediaTime"].as_i64(), Some(it.source_time_at(it.start).0), "reverse {reverse}, {frames} frames");
|
||||
assert_eq!(p["out"]["mediaTime"].as_i64(), Some(it.source_time_at(it.end() - fd).0), "reverse {reverse}, {frames} frames");
|
||||
assert_eq!(p["offsetFrames"], json!(frames));
|
||||
// the media frame on the media's own 30 fps grid
|
||||
let rate30 = filmcraft_time::FrameRate::new(30, 1);
|
||||
assert_eq!(p["in"]["mediaFrame"].as_i64(), Some(rate30.frame_at(it.source_time_at(it.start))));
|
||||
if frames != 0 {
|
||||
s.execute("edit.undo", json!({})).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_source_timecodes_follow_the_slip() {
|
||||
let (mut s, v, _) = split_edit();
|
||||
// source In frame 20 + 5 = 00:00:01:00; the picture is 70 frames long, so its Out frame is
|
||||
// 20 + 69 + 5 = 94 = 00:00:03:19
|
||||
let p = preview(&mut s, v, 5);
|
||||
assert_eq!(p["in"]["sourceTimecode"], json!("00:00:01:00"));
|
||||
assert_eq!(p["out"]["sourceTimecode"], json!("00:00:03:19"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hostile_slip_preview_params_are_errors_or_clamped_never_panics() {
|
||||
let (mut s, v, a) = split_edit();
|
||||
assert!(s.execute("timeline.slipPreview", json!({})).is_err());
|
||||
assert!(s.execute("timeline.slipPreview", json!({"clip": 999_999, "delta": 5})).is_err());
|
||||
assert!(s.execute("timeline.slipPreview", json!({"clip": "V1", "delta": 5})).is_err());
|
||||
let fr = frame(&s);
|
||||
for d in [json!({"delta": i64::MAX}), json!({"delta": i64::MIN}), json!({"deltaFrames": i64::MAX}), json!({"deltaFrames": i64::MIN}), json!({"delta": "x"})]
|
||||
{
|
||||
let mut p = d.clone();
|
||||
p["clip"] = json!(v);
|
||||
let r = s.execute("timeline.slipPreview", p).unwrap();
|
||||
let ins = source_ins(&r);
|
||||
// clamped at one end of the media or not moved, in sync
|
||||
assert_eq!(ins[0].1, ins[1].1, "{d}");
|
||||
assert!([0, fr * 20, fr * 30].contains(&ins[0].1), "{d}: {ins:?}");
|
||||
}
|
||||
let _ = a;
|
||||
}
|
||||
@@ -349,7 +349,7 @@ pub fn to_playhead(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
// ------------------------------------------------------------------ Trim Monitor
|
||||
|
||||
/// One side of the Trim Monitor: the clip and the frame shown for it.
|
||||
fn side_json(s: &Session, seq: &Sequence, clip: ClipId, outgoing: bool) -> Option<Value> {
|
||||
pub(crate) fn side_json(s: &Session, seq: &Sequence, clip: ClipId, outgoing: bool) -> Option<Value> {
|
||||
let (tid, it) = seq.find_item(clip)?;
|
||||
let rate = seq.settings.frame_rate;
|
||||
let fd = rate.frame_duration();
|
||||
|
||||
@@ -644,9 +644,9 @@ impl FrameServer {
|
||||
/// [`FrameServer::request`] at `prio` 0 for one of several pictures of the same target and
|
||||
/// size shown at once: `view` names the picture (0 is [`FrameServer::request`]'s). A frame
|
||||
/// on screen replaces only the one asked for before in its own view, so the Trim Monitor's
|
||||
/// outgoing and incoming pictures at a cut inside one take (one item, one size) don't cancel
|
||||
/// each other's decode on every refresh while each still drops the positions a trim has left
|
||||
/// behind.
|
||||
/// outgoing and incoming pictures at a cut inside one take, and the Slip Monitor's In and Out
|
||||
/// frames (one item, one size), don't cancel each other's decode on every refresh while each
|
||||
/// still drops the positions a trim or a slip drag has left behind.
|
||||
pub fn request_in_view(&self, key: FrameKey, time: Tick, scale: f32, project: &Arc<Project>, view: u32) {
|
||||
let view = view.min(SHARED_VIEW - 1);
|
||||
let catch_up = Some(Tick::from_seconds_f64(SCRUB_KEEP_S));
|
||||
|
||||
@@ -638,6 +638,11 @@
|
||||
(gap) (Lücke)
|
||||
Out: {name} Out: {name}
|
||||
In: {name} In: {name}
|
||||
Previous: {name} Vorheriger: {name}
|
||||
Next: {name} Nächster: {name}
|
||||
Slip: {offset} frame Slip: {offset} Frame
|
||||
Slip: {offset} frames Slip: {offset} Frames
|
||||
at the media limit an der Mediengrenze
|
||||
Play Around Edit (Space loops, Shift+K once) Um Schnitt herum abspielen (Leertaste in Schleife, Umschalt+K einmal)
|
||||
Trim Backward Many Weit rückwärts trimmen
|
||||
Trim Backward Rückwärts trimmen
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 45.
|
@@ -616,6 +616,11 @@
|
||||
(gap) (hueco)
|
||||
Out: {name} Salida: {name}
|
||||
In: {name} Entrada: {name}
|
||||
Previous: {name} Anterior: {name}
|
||||
Next: {name} Siguiente: {name}
|
||||
Slip: {offset} frame Desplazamiento: {offset} fotograma
|
||||
Slip: {offset} frames Desplazamiento: {offset} fotogramas
|
||||
at the media limit en el límite del medio
|
||||
Play Around Edit (Space loops, Shift+K once) Reproducir alrededor de la edición (Espacio en bucle, Mayús+K una vez)
|
||||
Trim Backward Many Recortar varios fotogramas hacia atrás
|
||||
Trim Backward Recortar hacia atrás
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 3 and column 95.
|
@@ -610,6 +610,11 @@
|
||||
(gap) (espace vide)
|
||||
Out: {name} Sortie : {name}
|
||||
In: {name} Entrée : {name}
|
||||
Previous: {name} Précédent : {name}
|
||||
Next: {name} Suivant : {name}
|
||||
Slip: {offset} frame Glissement : {offset} image
|
||||
Slip: {offset} frames Glissement : {offset} images
|
||||
at the media limit à la limite du média
|
||||
Play Around Edit (Space loops, Shift+K once) Lire autour du point de montage (Espace en boucle, Maj+K une fois)
|
||||
Trim Backward Many Rogner de plusieurs images en arrière
|
||||
Trim Backward Rogner en arrière
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 5 and column 83.
|
@@ -615,6 +615,11 @@
|
||||
(gap) (celah)
|
||||
Out: {name} Keluar: {name}
|
||||
In: {name} Masuk: {name}
|
||||
Previous: {name} Sebelumnya: {name}
|
||||
Next: {name} Berikutnya: {name}
|
||||
Slip: {offset} frame Slip: {offset} bingkai
|
||||
Slip: {offset} frames Slip: {offset} bingkai
|
||||
at the media limit di batas media
|
||||
Play Around Edit (Space loops, Shift+K once) Putar di Sekitar Edit (Space berulang, Shift+K sekali)
|
||||
Trim Backward Many Pangkas Mundur Banyak
|
||||
Trim Backward Pangkas Mundur
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 14.
|
@@ -605,6 +605,11 @@
|
||||
(gap) (spazio vuoto)
|
||||
Out: {name} Uscita: {name}
|
||||
In: {name} Entrata: {name}
|
||||
Previous: {name} Precedente: {name}
|
||||
Next: {name} Successivo: {name}
|
||||
Slip: {offset} frame Scorrimento sorgente: {offset} fotogramma
|
||||
Slip: {offset} frames Scorrimento sorgente: {offset} fotogrammi
|
||||
at the media limit al limite del media
|
||||
Play Around Edit (Space loops, Shift+K once) Riproduci attorno al taglio (Spazio in loop, Shift+K una volta)
|
||||
Trim Backward Many Rifila molto indietro
|
||||
Trim Backward Rifila indietro
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 3 and column 95.
|
@@ -618,6 +618,11 @@
|
||||
(gap) (ギャップ)
|
||||
Out: {name} アウト: {name}
|
||||
In: {name} イン: {name}
|
||||
Previous: {name} 前: {name}
|
||||
Next: {name} 次: {name}
|
||||
Slip: {offset} frame スリップ: {offset} フレーム
|
||||
Slip: {offset} frames スリップ: {offset} フレーム
|
||||
at the media limit メディアの端
|
||||
Play Around Edit (Space loops, Shift+K once) 編集点の前後を再生 (Space でループ、Shift+K で 1 回)
|
||||
Trim Backward Many 後方へ複数フレームトリム
|
||||
Trim Backward 後方へトリム
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 11 and column 59.
|
@@ -1514,6 +1514,11 @@
|
||||
In the project 프로젝트에
|
||||
In/Out Duration 시작/끝 지속 시간
|
||||
In: {name} 시작: {name}
|
||||
Previous: {name} 이전: {name}
|
||||
Next: {name} 다음: {name}
|
||||
Slip: {offset} frame 슬립: {offset}프레임
|
||||
Slip: {offset} frames 슬립: {offset}프레임
|
||||
at the media limit 미디어 경계에 도달
|
||||
Include Alpha Channel 알파 채널 포함
|
||||
Include captions on import 가져올 때 자막 포함
|
||||
Include Handles: 핸들 포함:
|
||||
|
||||
|
@@ -612,6 +612,11 @@
|
||||
(gap) (lacuna)
|
||||
Out: {name} Saída: {name}
|
||||
In: {name} Entrada: {name}
|
||||
Previous: {name} Anterior: {name}
|
||||
Next: {name} Próximo: {name}
|
||||
Slip: {offset} frame Deslizar conteúdo: {offset} quadro
|
||||
Slip: {offset} frames Deslizar conteúdo: {offset} quadros
|
||||
at the media limit no limite da mídia
|
||||
Play Around Edit (Space loops, Shift+K once) Reproduzir ao redor da edição (Espaço em loop, Shift+K uma vez)
|
||||
Trim Backward Many Aparar muitos para trás
|
||||
Trim Backward Aparar para trás
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 4.
|
@@ -591,6 +591,11 @@
|
||||
(gap) (промежуток)
|
||||
Out: {name} Выход: {name}
|
||||
In: {name} Вход: {name}
|
||||
Previous: {name} Предыдущий: {name}
|
||||
Next: {name} Следующий: {name}
|
||||
Slip: {offset} frame Скольжение: {offset} кадр
|
||||
Slip: {offset} frames Скольжение, кадров: {offset}
|
||||
at the media limit на границе медиа
|
||||
Play Around Edit (Space loops, Shift+K once) Воспроизвести вокруг склейки (пробел — цикл, Shift+K — один раз)
|
||||
Trim Backward Many Подрезать назад на несколько кадров
|
||||
Trim Backward Подрезать назад
|
||||
|
||||
|
@@ -607,6 +607,11 @@
|
||||
(gap) (间隙)
|
||||
Out: {name} 出点:{name}
|
||||
In: {name} 入点:{name}
|
||||
Previous: {name} 上一个:{name}
|
||||
Next: {name} 下一个:{name}
|
||||
Slip: {offset} frame 错动:{offset} 帧
|
||||
Slip: {offset} frames 错动:{offset} 帧
|
||||
at the media limit 已到媒体边界
|
||||
Play Around Edit (Space loops, Shift+K once) 围绕编辑点播放(空格循环,Shift+K 触发一次)
|
||||
Trim Backward Many 大幅向后修剪
|
||||
Trim Backward 向后修剪
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 3 and column 95.
|
@@ -44,6 +44,7 @@ pub mod scopes;
|
||||
pub mod sequence_settings;
|
||||
pub mod settings;
|
||||
pub mod shortcuts_dialog;
|
||||
pub mod slip_monitor;
|
||||
pub mod text;
|
||||
pub mod timecode;
|
||||
pub mod timeline;
|
||||
@@ -137,6 +138,7 @@ pub fn eta_suffix(job: &serde_json::Value) -> String {
|
||||
|
||||
pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, p: PanelKind, rect: Rect) {
|
||||
match p {
|
||||
PanelKind::Program if slip_monitor::active(app) => slip_monitor::show(app, ui, rect),
|
||||
PanelKind::Program if !app.session.state.edit_points.is_empty() => trim_monitor::show(app, ui, rect),
|
||||
PanelKind::Program => monitor::show(app, ui, rect, monitor::Which::Program),
|
||||
PanelKind::Source => monitor::show(app, ui, rect, monitor::Which::Source),
|
||||
|
||||
@@ -0,0 +1,242 @@
|
||||
//! The Slip Monitor: while the Slip tool (Y) drags a clip, the Program monitor shows the slip's
|
||||
//! four frames on a black canvas the shape of the sequence frame: the slipped clip's new first and
|
||||
//! last frames large, side by side across the canvas, with their source timecodes over them, and
|
||||
//! the previous clip's last frame and the next clip's first frame half that size above their
|
||||
//! outer corners. The large two follow the drag; the small two stay put. Below the canvas are the
|
||||
//! slip offset as a signed timecode and in frames; the Timeline shows the offset at the pointer.
|
||||
//!
|
||||
//! The frames come from [`filmcraft_engine::slip::preview`] (`timeline.slipPreview`), worked out
|
||||
//! once per change of the drag's delta ([`preview`], kept in [`Drag::Slip`]) with the clamp
|
||||
//! `timeline.slip` applies on release, so what is shown is what is committed. The project is not
|
||||
//! touched while dragging. Each picture asks the frame server for its frame in its own view
|
||||
//! ([`crate::frames::FrameServer::request_in_view`]): the newest position replaces the ones the
|
||||
//! pointer has left behind, and the nearest decoded frame stands in until it's ready, so a fast
|
||||
//! drag over long-GOP 4K media never queues up stale decodes or blocks the UI.
|
||||
//!
|
||||
//! The monitor is shown for as long as the drag lasts: releasing commits the slip, Escape drops
|
||||
//! it (#580), and either way the Program monitor is back the next frame.
|
||||
//!
|
||||
//! Automation ids: `slipMonitor.previous`, `slipMonitor.in`, `slipMonitor.out`,
|
||||
//! `slipMonitor.next`, `slipMonitor.previousTimecode`, `slipMonitor.inTimecode`,
|
||||
//! `slipMonitor.outTimecode`, `slipMonitor.nextTimecode`, `slipMonitor.offset`,
|
||||
//! `slipMonitor.offsetTimecode`.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use egui::{Align2, Color32, FontId, Painter, Pos2, Rect, Stroke, StrokeKind, pos2, vec2};
|
||||
use filmcraft_project::ClipId;
|
||||
use filmcraft_time::{Tick, TimeDisplay, format_time};
|
||||
use serde_json::Value;
|
||||
|
||||
use crate::FilmcraftApp;
|
||||
use crate::panels::timeline::Drag;
|
||||
use crate::panels::trim_monitor::{RIPPLE_RED, ROLL_YELLOW, picture, shift_text};
|
||||
use crate::theme::Tokens;
|
||||
|
||||
/// Frame server views of the four pictures (one item can fill all four: clips cut from one take).
|
||||
const VIEWS: [u32; 4] = [3, 4, 5, 6];
|
||||
const TEXTURES: [&str; 4] = ["slip-previous", "slip-in", "slip-out", "slip-next"];
|
||||
const IDS: [&str; 4] = ["slipMonitor.previous", "slipMonitor.in", "slipMonitor.out", "slipMonitor.next"];
|
||||
/// The neighbours' pictures' size relative to the slipped clip's two.
|
||||
const SMALL: f32 = 0.5;
|
||||
|
||||
/// What slipping `clip` by `delta` shows (`timeline.slipPreview`); `None` when it can't be worked
|
||||
/// out (no such clip any more, a locked track), and the Program monitor stays as it is.
|
||||
pub fn preview(app: &FilmcraftApp, clip: ClipId, delta: Tick) -> Option<Arc<Value>> {
|
||||
filmcraft_engine::slip::preview(&app.session, clip, delta).ok().map(Arc::new)
|
||||
}
|
||||
|
||||
/// The preview of the Slip drag in progress, if one is.
|
||||
fn current(app: &FilmcraftApp) -> Option<Arc<Value>> {
|
||||
match &app.tl.drag {
|
||||
Some(Drag::Slip { preview: Some(p), .. }) => Some(p.clone()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// True while a Slip drag replaces the Program monitor with the Slip Monitor.
|
||||
pub fn active(app: &FilmcraftApp) -> bool {
|
||||
current(app).is_some()
|
||||
}
|
||||
|
||||
/// The slip offset as a signed sequence timecode (`+00:00:05:20`).
|
||||
pub fn offset_timecode(app: &FilmcraftApp, info: &Value) -> String {
|
||||
let n = info["offsetFrames"].as_i64().unwrap_or(0);
|
||||
let (rate, df) = app.session.active_sequence().map(|q| (q.settings.frame_rate, q.settings.drop_frame)).unwrap_or_default();
|
||||
let tc = format_time(rate.tick_of(n.saturating_abs()), rate, df, TimeDisplay::Timecode, 48000);
|
||||
format!("{}{tc}", if n < 0 { "-" } else { "+" })
|
||||
}
|
||||
|
||||
/// The slip offset in frames, and whether the media's end holds it back ("Slip: +25 frames").
|
||||
fn offset_text(info: &Value) -> (String, bool) {
|
||||
let n = info["offsetFrames"].as_i64().unwrap_or(0);
|
||||
let offset = shift_text(n);
|
||||
let text = if n.abs() == 1 { tlf!("Slip: {offset} frame", offset) } else { tlf!("Slip: {offset} frames", offset) };
|
||||
let at_limit = info["atLimit"].as_bool().unwrap_or(false);
|
||||
if at_limit { (format!("{text} · {}", tl!("at the media limit")), true) } else { (text, false) }
|
||||
}
|
||||
|
||||
/// Where the four pictures go on a canvas `w` wide: the slipped clip's In and Out side by side
|
||||
/// across it, the neighbours at `SMALL` size above their outer corners, the group centred in
|
||||
/// `area` (scaled down when `area` is too short for it). Returns `[previous, in, out, next]`.
|
||||
fn layout(area: Rect, aspect: f32) -> [Rect; 4] {
|
||||
let mut big_w = area.width() / 2.0;
|
||||
let total_h = |w: f32| w / aspect * (1.0 + SMALL);
|
||||
if total_h(big_w) > area.height() {
|
||||
big_w = area.height() / (1.0 + SMALL) * aspect;
|
||||
}
|
||||
let big_h = big_w / aspect;
|
||||
let (small_w, small_h) = (big_w * SMALL, big_h * SMALL);
|
||||
let left = area.center().x - big_w;
|
||||
let top = area.center().y - total_h(big_w) / 2.0;
|
||||
let big_top = top + small_h;
|
||||
[
|
||||
Rect::from_min_size(pos2(left, top), vec2(small_w, small_h)),
|
||||
Rect::from_min_size(pos2(left, big_top), vec2(big_w, big_h)),
|
||||
Rect::from_min_size(pos2(left + big_w, big_top), vec2(big_w, big_h)),
|
||||
Rect::from_min_size(pos2(left + 2.0 * big_w - small_w, top), vec2(small_w, small_h)),
|
||||
]
|
||||
}
|
||||
|
||||
/// White text with a dark outline, readable over any picture. Returns its rect.
|
||||
fn overlay_text(p: &Painter, at: Pos2, anchor: Align2, text: &str, font: FontId) -> Rect {
|
||||
let shadow = Color32::from_black_alpha(200);
|
||||
for d in [vec2(-1.5, 0.0), vec2(1.5, 0.0), vec2(0.0, -1.5), vec2(0.0, 1.5), vec2(1.5, 1.5)] {
|
||||
p.text(at + d, anchor, text, font.clone(), shadow);
|
||||
}
|
||||
p.text(at, anchor, text, font, Color32::WHITE)
|
||||
}
|
||||
|
||||
/// The Slip Monitor in the Program monitor's `rect`.
|
||||
pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let Some(info) = current(app) else { return };
|
||||
let t = app.tokens;
|
||||
ui.painter().rect_filled(rect, 0.0, t.panel_bg);
|
||||
let (sw, sh) = app.session.active_sequence().map(|q| (q.settings.width.max(1) as f32, q.settings.height.max(1) as f32)).unwrap_or((16.0, 9.0));
|
||||
let aspect = sw / sh;
|
||||
|
||||
// the canvas: the sequence frame's shape, black, above a bar with the offset
|
||||
let bar_h = 34.0;
|
||||
let area = Rect::from_min_max(rect.min + vec2(8.0, 8.0), pos2(rect.max.x - 8.0, rect.max.y - bar_h));
|
||||
let s = (area.width() / sw).min(area.height() / sh).max(0.0);
|
||||
let canvas = Rect::from_center_size(area.center(), vec2(sw * s, sh * s));
|
||||
ui.painter().rect_filled(canvas, 0.0, Color32::BLACK);
|
||||
let slots = layout(canvas, aspect);
|
||||
|
||||
let sides = [&info["previous"], &info["in"], &info["out"], &info["next"]];
|
||||
let mut pics = slots;
|
||||
for (i, side) in sides.iter().enumerate() {
|
||||
let slot = slots[i];
|
||||
pics[i] = if side.is_null() {
|
||||
// no clip touches it on this side: black, as at a gap
|
||||
ui.painter().rect_stroke(slot, 0.0, Stroke::new(1.0, Color32::from_gray(48)), StrokeKind::Inside);
|
||||
ui.painter().text(slot.center(), Align2::CENTER_CENTER, tl!("(gap)"), Tokens::ui(11.0), t.text_faint);
|
||||
slot
|
||||
} else {
|
||||
picture(app, ui, slot, side, TEXTURES[i], VIEWS[i]).0
|
||||
};
|
||||
app.auto.add(IDS[i], pics[i], side["sourceTimecode"].as_str().unwrap_or(""));
|
||||
}
|
||||
|
||||
// the new source In and Out timecodes over the large pictures
|
||||
let size = (pics[1].height() * 0.11).clamp(11.0, 40.0);
|
||||
for i in [1, 2] {
|
||||
let tc = sides[i]["sourceTimecode"].as_str().unwrap_or("--:--:--:--");
|
||||
let r = overlay_text(ui.painter(), pos2(pics[i].center().x, pics[i].max.y - size * 0.6), Align2::CENTER_BOTTOM, tc, Tokens::semibold(size));
|
||||
app.auto.add(&format!("{}Timecode", IDS[i]), r, tc);
|
||||
}
|
||||
// the neighbours' timecodes, small, inside their pictures
|
||||
let small = (pics[0].height() * 0.12).clamp(9.0, 16.0);
|
||||
for (i, anchor) in [(0, Align2::LEFT_BOTTOM), (3, Align2::RIGHT_BOTTOM)] {
|
||||
let Some(tc) = sides[i]["sourceTimecode"].as_str() else { continue };
|
||||
let at = if i == 0 { pos2(pics[i].min.x + 6.0, pics[i].max.y - 4.0) } else { pos2(pics[i].max.x - 6.0, pics[i].max.y - 4.0) };
|
||||
let r = overlay_text(ui.painter(), at, anchor, tc, Tokens::ui(small));
|
||||
app.auto.add(&format!("{}Timecode", IDS[i]), r, tc);
|
||||
}
|
||||
// which clips these are, in the black space between the neighbours
|
||||
let gap = Rect::from_min_max(pos2(slots[0].max.x + 12.0, slots[0].min.y), pos2(slots[3].min.x - 12.0, slots[1].min.y));
|
||||
if gap.width() > 40.0 && gap.height() > 24.0 {
|
||||
let name = |v: &Value| v["name"].as_str().unwrap_or("").to_string();
|
||||
let (prev, slipped, next) = (name(sides[0]), name(sides[1]), name(sides[3]));
|
||||
let lines = [
|
||||
(Some(slipped).filter(|n| !n.is_empty()), Tokens::semibold(12.0), t.text),
|
||||
(Some(prev).filter(|n| !n.is_empty()).map(|name| tlf!("Previous: {name}", name)), Tokens::ui(10.5), t.text_dim),
|
||||
(Some(next).filter(|n| !n.is_empty()).map(|name| tlf!("Next: {name}", name)), Tokens::ui(10.5), t.text_dim),
|
||||
];
|
||||
let mut y = gap.center().y - 20.0;
|
||||
for (text, font, col) in lines {
|
||||
if let Some(text) = text {
|
||||
let text = elide(ui, &text, &font, gap.width());
|
||||
ui.painter().text(pos2(gap.center().x, y), Align2::CENTER_CENTER, text, font, col);
|
||||
}
|
||||
y += 17.0;
|
||||
}
|
||||
}
|
||||
|
||||
// the offset: a signed timecode (as in the monitor's time display) and in frames
|
||||
let bar = Rect::from_min_max(pos2(canvas.min.x, canvas.max.y + 4.0), pos2(canvas.max.x, rect.max.y));
|
||||
let tc = offset_timecode(app, &info);
|
||||
let r = ui.painter().text(pos2(bar.min.x + 2.0, bar.center().y), Align2::LEFT_CENTER, &tc, Tokens::semibold(14.0), t.hot_text);
|
||||
app.auto.add("slipMonitor.offsetTimecode", r, &tc);
|
||||
let (text, at_limit) = offset_text(&info);
|
||||
let r = ui.painter().text(
|
||||
pos2(bar.max.x - 2.0, bar.center().y),
|
||||
Align2::RIGHT_CENTER,
|
||||
&text,
|
||||
Tokens::semibold(13.0),
|
||||
if at_limit { RIPPLE_RED } else { ROLL_YELLOW },
|
||||
);
|
||||
app.auto.add("slipMonitor.offset", r, &text);
|
||||
}
|
||||
|
||||
/// The offset next to the pointer in the Timeline while slipping (as the Program monitor shows
|
||||
/// it), in a small tag under `at`.
|
||||
pub fn paint_timeline_offset(app: &FilmcraftApp, p: &Painter, at: Pos2) {
|
||||
let Some(info) = current(app) else { return };
|
||||
let t = app.tokens;
|
||||
let tc = offset_timecode(app, &info);
|
||||
let font = Tokens::semibold(11.0);
|
||||
let galley = p.layout_no_wrap(tc, font, t.text);
|
||||
let r = Rect::from_center_size(at + vec2(0.0, 26.0), galley.size() + vec2(12.0, 6.0));
|
||||
p.rect_filled(r, 4.0, Color32::from_black_alpha(200));
|
||||
p.rect_stroke(r, 4.0, Stroke::new(1.0, Color32::from_gray(90)), StrokeKind::Inside);
|
||||
p.galley(r.center() - galley.size() / 2.0, galley, t.text);
|
||||
}
|
||||
|
||||
/// `text` cut to fit `width` with a trailing "…".
|
||||
fn elide(ui: &egui::Ui, text: &str, font: &egui::FontId, width: f32) -> String {
|
||||
let fits = |s: &str| ui.painter().layout_no_wrap(s.to_string(), font.clone(), Color32::WHITE).size().x <= width;
|
||||
if fits(text) {
|
||||
return text.to_string();
|
||||
}
|
||||
let chars: Vec<char> = text.chars().collect();
|
||||
(0..chars.len()).rev().map(|n| format!("{}…", chars.iter().take(n).collect::<String>())).find(|s| fits(s)).unwrap_or_default()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn the_large_pair_spans_the_canvas_and_the_neighbours_sit_on_its_outer_corners() {
|
||||
let canvas = Rect::from_min_size(pos2(100.0, 50.0), vec2(1600.0, 900.0));
|
||||
let [prev, inn, out, next] = layout(canvas, 16.0 / 9.0);
|
||||
assert_eq!((inn.min.x, out.max.x), (100.0, 1700.0), "In and Out fill the width");
|
||||
assert_eq!(inn.max.x, out.min.x);
|
||||
assert!((inn.width() - 800.0).abs() < 1e-3 && (inn.height() - 450.0).abs() < 1e-3);
|
||||
assert!((prev.width() - 400.0).abs() < 1e-3 && (next.width() - 400.0).abs() < 1e-3);
|
||||
assert_eq!((prev.min.x, prev.max.y), (inn.min.x, inn.min.y), "previous on the In's top-left corner");
|
||||
assert_eq!((next.max.x, next.max.y), (out.max.x, out.min.y), "next on the Out's top-right corner");
|
||||
// the group (675 high) is centred in the 900 high canvas
|
||||
assert!((prev.min.y - (50.0 + 112.5)).abs() < 1e-3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_short_canvas_scales_the_group_down_to_fit() {
|
||||
let canvas = Rect::from_min_size(pos2(0.0, 0.0), vec2(1600.0, 300.0));
|
||||
let [prev, inn, out, _] = layout(canvas, 16.0 / 9.0);
|
||||
assert!(prev.min.y >= -1e-3 && inn.max.y <= 300.0 + 1e-3);
|
||||
assert!((inn.height() * 1.5 - 300.0).abs() < 1e-3);
|
||||
assert!(((inn.center().x + out.center().x) / 2.0 - 800.0).abs() < 1e-3, "centred");
|
||||
}
|
||||
}
|
||||
@@ -202,7 +202,11 @@ pub enum Drag {
|
||||
},
|
||||
Slip {
|
||||
clip: ClipId,
|
||||
/// The media delta `timeline.slip` gets on release (it clamps it at the media's ends).
|
||||
delta: Tick,
|
||||
/// What the Slip Monitor shows for `delta` (`timeline.slipPreview`), worked out when the
|
||||
/// delta changes; `None` when it can't be (the Program monitor then stays as it is).
|
||||
preview: Option<Arc<Value>>,
|
||||
},
|
||||
Slide {
|
||||
clip: ClipId,
|
||||
@@ -984,6 +988,32 @@ mod trim_preview_tests {
|
||||
preview_drag(&app, &seq, &mut out, &mut edited);
|
||||
assert!(edited.is_empty() && out.contains_key(&left.id));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_slip_draws_the_clip_and_its_partners_from_the_slipped_media_in_place() {
|
||||
let (mut app, seq) = demo();
|
||||
let clip = seq.video_tracks[0].items.iter().find(|i| i.link.is_some()).unwrap().clone();
|
||||
let delta = Tick(filmcraft_time::TICKS_PER_SECOND / 5);
|
||||
let preview = crate::panels::slip_monitor::preview(&app, clip.id, delta);
|
||||
let applied = Tick(preview.as_ref().unwrap()["delta"].as_i64().unwrap());
|
||||
assert_ne!(applied, Tick::ZERO, "the demo clip has media to slip into");
|
||||
app.tl.drag = Some(Drag::Slip { clip: clip.id, delta, preview });
|
||||
let (mut out, mut edited) = (HashMap::new(), HashMap::new());
|
||||
preview_drag(&app, &seq, &mut out, &mut edited);
|
||||
assert!(out.is_empty(), "nothing moves or changes length");
|
||||
let partners = filmcraft_engine::commands::with_links(&app.session, &[clip.id]);
|
||||
let sound: Vec<ClipId> = partners.iter().copied().filter(|c| seq.audio_tracks.iter().any(|t| t.item(*c).is_some())).collect();
|
||||
assert!(!sound.is_empty(), "the demo clip has linked sound");
|
||||
for c in &sound {
|
||||
let was = seq.find_item(*c).unwrap().1;
|
||||
let shown = &edited[c];
|
||||
assert_eq!((shown.start, shown.duration), (was.start, was.duration));
|
||||
assert_eq!(shown.source_in, was.source_in + applied, "the sound's waveform follows the slip");
|
||||
}
|
||||
// the picture's thumbnails would be a decode per position: they keep the clip's media
|
||||
assert!(!edited.contains_key(&clip.id));
|
||||
assert_eq!(edited.len(), sound.len());
|
||||
}
|
||||
}
|
||||
|
||||
/// #1424: dragging a clip edge must not squeeze the waveform into the new clip width. The render
|
||||
|
||||
@@ -81,6 +81,23 @@ pub(super) fn preview_drag(
|
||||
out.insert(*clip, (it.start + *delta, it.duration, None));
|
||||
}
|
||||
}
|
||||
// a slip keeps every clip where it is and shows other media in it: its sound is drawn from
|
||||
// the source In the Slip Monitor shows (the release commits it), so the waveform slides
|
||||
// under the pointer. Its waveform is cached peaks; the picture's thumbnails would be new
|
||||
// decodes for every position, so they wait for the release and the Slip Monitor shows the
|
||||
// frames.
|
||||
Drag::Slip { preview: Some(p), .. } => {
|
||||
for c in p["clips"].as_array().into_iter().flatten() {
|
||||
let (Some(id), Some(source_in)) = (c["clip"].as_u64(), c["sourceIn"].as_i64()) else { continue };
|
||||
if let Some((tid, it)) = seq.find_item(ClipId(id))
|
||||
&& seq.track(tid).is_some_and(|t| t.kind == TrackKind::Audio)
|
||||
{
|
||||
let mut e = it.clone();
|
||||
e.source_in = Tick(source_in);
|
||||
edited.insert(e.id, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -511,7 +528,7 @@ fn start_drag(
|
||||
crate::panels::timeline_volume::add_keyframe(app, seq, layout, clip, p.x);
|
||||
None
|
||||
}
|
||||
(Tool::Slip, Grab::Other(Hit::Clip { clip, .. })) => Some(Drag::Slip { clip, delta: Tick::ZERO }),
|
||||
(Tool::Slip, Grab::Other(Hit::Clip { clip, .. })) => Some(start_slip(app, ctx, resp, clip)),
|
||||
(Tool::Slide, Grab::Other(Hit::Clip { clip, .. })) => Some(Drag::Slide { clip, delta: Tick::ZERO }),
|
||||
(_, Grab::Other(Hit::Clip { clip, track, .. })) => {
|
||||
// select (shift toggles; alt selects one side of a link)
|
||||
@@ -591,6 +608,16 @@ fn start_drag(
|
||||
}
|
||||
}
|
||||
|
||||
/// A Slip tool drag on `clip`: the Slip Monitor replaces the Program monitor as soon as the drag
|
||||
/// starts, so its first four-up is worked out now.
|
||||
fn start_slip(app: &FilmcraftApp, ctx: &egui::Context, resp: &egui::Response, clip: ClipId) -> Drag {
|
||||
if resp.drag_started() {
|
||||
// the Slip Monitor takes over the Program monitor, which may be drawn already
|
||||
ctx.request_repaint();
|
||||
}
|
||||
Drag::Slip { clip, delta: Tick::ZERO, preview: crate::panels::slip_monitor::preview(app, clip, Tick::ZERO) }
|
||||
}
|
||||
|
||||
/// Track Select Forward (Backward) also selects the captions that end after (start before) `t`, so
|
||||
/// the subtitles go with the clips and stay in sync. Shift keeps to the clicked track, which has no
|
||||
/// captions, and a locked caption track keeps its captions.
|
||||
@@ -733,10 +760,19 @@ fn drag_update(app: &mut FilmcraftApp, ui: &mut egui::Ui, resp: &egui::Response,
|
||||
let delta = filmcraft_engine::commands::roll_delta(&app.session, left, right, target - l.end()).unwrap_or(target - l.end());
|
||||
Drag::Roll { left, right, delta, from }
|
||||
}),
|
||||
Drag::Slip { clip, .. } => {
|
||||
Drag::Slip { clip, delta: was, preview } => {
|
||||
let start = resp.interact_pointer_pos().map(|_| ()).and(ctx.input(|i| i.pointer.press_origin()));
|
||||
let origin = start.map(|o| layout.tick_at(o.x)).unwrap_or(t_here);
|
||||
Some(Drag::Slip { clip, delta: -(rate.snap_nearest(t_here - origin)) })
|
||||
let delta = -(rate.snap_nearest(t_here - origin));
|
||||
// the four-up follows the drag frame by frame; a pointer still within one frame keeps it
|
||||
let preview = if delta == was && preview.is_some() {
|
||||
preview
|
||||
} else {
|
||||
// the Program monitor may have been drawn already this frame: show it on the next
|
||||
ctx.request_repaint();
|
||||
crate::panels::slip_monitor::preview(app, clip, delta)
|
||||
};
|
||||
Some(Drag::Slip { clip, delta, preview })
|
||||
}
|
||||
Drag::Slide { clip, .. } => {
|
||||
let origin = ctx.input(|i| i.pointer.press_origin()).map(|o| layout.tick_at(o.x)).unwrap_or(t_here);
|
||||
@@ -807,6 +843,10 @@ fn drag_update(app: &mut FilmcraftApp, ui: &mut egui::Ui, resp: &egui::Response,
|
||||
) {
|
||||
ctx.set_cursor_icon(CursorIcon::ResizeColumn);
|
||||
}
|
||||
// a slip shows its offset at the pointer as well as in the Slip Monitor
|
||||
if matches!(app.tl.drag, Some(Drag::Slip { .. })) {
|
||||
crate::panels::slip_monitor::paint_timeline_offset(app, ui.painter(), p);
|
||||
}
|
||||
// auto-scroll when dragging near the edges
|
||||
if !matches!(app.tl.drag, Some(Drag::Pan { .. }) | Some(Drag::ZoomBar { .. }) | Some(Drag::Volume(_))) {
|
||||
let v = &mut app.ui.timeline;
|
||||
@@ -855,7 +895,7 @@ fn commit_drag(app: &mut FilmcraftApp, ctx: &egui::Context, resp: &egui::Respons
|
||||
Some(app.session.execute("clip.remix", json!({"clip": clip.0, "duration": d.0})))
|
||||
}
|
||||
Drag::Roll { left, right, delta, .. } if delta != Tick::ZERO => Some(app.session.execute("timeline.roll", json!({"left": left.0, "right": right.0, "delta": delta.0}))),
|
||||
Drag::Slip { clip, delta } if delta != Tick::ZERO => Some(app.session.execute("timeline.slip", json!({"clip": clip.0, "delta": delta.0}))),
|
||||
Drag::Slip { clip, delta, .. } if delta != Tick::ZERO => Some(app.session.execute("timeline.slip", json!({"clip": clip.0, "delta": delta.0}))),
|
||||
Drag::Slide { clip, delta } if delta != Tick::ZERO => Some(app.session.execute("timeline.slide", json!({"clip": clip.0, "delta": delta.0}))),
|
||||
Drag::Transition { id, start, duration, .. } => {
|
||||
let moved = seq.all_tracks().find_map(|tr| tr.transitions.iter().find(|x| x.id == id)).is_some_and(|x| (x.start, x.duration) != (start, duration));
|
||||
|
||||
@@ -121,18 +121,20 @@ const VIEW_OUTGOING: u32 = 1;
|
||||
const VIEW_INCOMING: u32 = 2;
|
||||
|
||||
/// Fit a w×h picture into `area`.
|
||||
fn fit(area: Rect, w: f32, h: f32) -> Rect {
|
||||
pub(crate) fn fit(area: Rect, w: f32, h: f32) -> Rect {
|
||||
let s = (area.width() / w.max(1.0)).min(area.height() / h.max(1.0));
|
||||
Rect::from_center_size(area.center(), vec2(w * s, h * s))
|
||||
}
|
||||
|
||||
/// Draw one side's frame (the clip's media at `media_time`). `view` is the picture's frame server
|
||||
/// view: the newest frame asked for in it replaces the older ones still waiting, so a trim decodes
|
||||
/// where the edit point is now without cancelling the other side's frame.
|
||||
fn picture(app: &mut FilmcraftApp, ui: &mut egui::Ui, area: Rect, side: &Value, tex_name: &str, view: u32) -> Rect {
|
||||
/// Draw one side's frame (the clip's media at `mediaTime`; a sound clip shows its name), shared
|
||||
/// with the Slip Monitor. `view` is the picture's frame server view: the newest frame asked for
|
||||
/// in it replaces the older ones still waiting, so a drag decodes where the pointer is now.
|
||||
/// Until that frame is ready the nearest decoded one before it (or the last one shown) stands in.
|
||||
/// Returns the picture's rect and whether it shows the exact frame.
|
||||
pub(crate) fn picture(app: &mut FilmcraftApp, ui: &mut egui::Ui, area: Rect, side: &Value, tex_name: &str, view: u32) -> (Rect, bool) {
|
||||
let t = app.tokens;
|
||||
let item = filmcraft_project::ItemId(side["item"].as_u64().unwrap_or(0));
|
||||
let Some(pi) = app.session.project.item(item) else { return area };
|
||||
let Some(pi) = app.session.project.item(item) else { return (area, false) };
|
||||
let size = match &pi.kind {
|
||||
ItemKind::Media(m) => m.info.video.as_ref().map(|v| (v.width, v.height)).unwrap_or((0, 0)),
|
||||
ItemKind::Sequence(s) => (s.settings.width, s.settings.height),
|
||||
@@ -143,7 +145,7 @@ fn picture(app: &mut FilmcraftApp, ui: &mut egui::Ui, area: Rect, side: &Value,
|
||||
ui.painter().rect_filled(pic, 0.0, t.monitor_bg);
|
||||
if size.0 == 0 || !side["video"].as_bool().unwrap_or(false) {
|
||||
ui.painter().text(pic.center(), Align2::CENTER_CENTER, format!("♪ {}", side["name"].as_str().unwrap_or("")), Tokens::ui(13.0), t.text_dim);
|
||||
return pic;
|
||||
return (pic, true);
|
||||
}
|
||||
let img_rect = fit(pic, size.0 as f32, size.1 as f32);
|
||||
let rate = pi.frame_rate();
|
||||
@@ -160,7 +162,9 @@ fn picture(app: &mut FilmcraftApp, ui: &mut egui::Ui, area: Rect, side: &Value,
|
||||
let project = app.session.project.clone();
|
||||
app.frames.request_in_view(key, rate.tick_of(frame), scale, &project, view);
|
||||
let ctx = ui.ctx().clone();
|
||||
let tex = if let Some(img) = app.frames.get(&key) {
|
||||
let exact = app.frames.get(&key);
|
||||
let shown = exact.is_some();
|
||||
let tex = if let Some(img) = exact {
|
||||
Some(app.texture_for(&ctx, tex_name, key, &img))
|
||||
} else {
|
||||
match app.frames.nearest(Target::Item(item), frame, size_key, rev, 48) {
|
||||
@@ -171,10 +175,10 @@ fn picture(app: &mut FilmcraftApp, ui: &mut egui::Ui, area: Rect, side: &Value,
|
||||
if let Some(tex) = tex {
|
||||
ui.painter().image(tex, img_rect, Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)), Color32::WHITE);
|
||||
}
|
||||
pic
|
||||
(pic, shown)
|
||||
}
|
||||
|
||||
fn shift_text(frames: i64) -> String {
|
||||
pub(crate) fn shift_text(frames: i64) -> String {
|
||||
if frames > 0 { format!("+{frames}") } else { frames.to_string() }
|
||||
}
|
||||
|
||||
@@ -216,7 +220,7 @@ pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
pics[i] = p;
|
||||
} else {
|
||||
let (tex, view) = if i == 0 { ("trim-outgoing", VIEW_OUTGOING) } else { ("trim-incoming", VIEW_INCOMING) };
|
||||
pics[i] = picture(app, ui, r, side, tex, view);
|
||||
pics[i] = picture(app, ui, r, side, tex, view).0;
|
||||
}
|
||||
}
|
||||
let [lp, rp] = pics;
|
||||
|
||||
@@ -68,6 +68,7 @@ mod sequence_ui;
|
||||
mod settings_menus_ui;
|
||||
mod settings_ui;
|
||||
mod shared_docking_ui;
|
||||
mod slip_monitor_ui;
|
||||
mod source_drag_ui;
|
||||
mod source_playback_ui;
|
||||
mod status_bar_ui;
|
||||
|
||||
@@ -0,0 +1,505 @@
|
||||
//! Headless UI tests of the Slip Monitor: with the Slip tool (Y), dragging a clip turns the
|
||||
//! Program monitor into the four-up slip view (previous clip's Out, the new In and Out, the next
|
||||
//! clip's In) that follows the pointer frame by frame, shows the decoded frames, and commits on
|
||||
//! release exactly what it showed; Escape drops it. The real `FilmcraftApp` under `egui_kittest`
|
||||
//! with the demo project, the pointer moving a few pixels per frame as a mouse does.
|
||||
|
||||
use std::sync::mpsc::{Sender, channel};
|
||||
|
||||
use egui::{Pos2, pos2};
|
||||
use egui_kittest::Harness;
|
||||
use filmcraft_engine::Session;
|
||||
use filmcraft_project::{ClipId, ItemId, TrackItem};
|
||||
use filmcraft_time::Tick;
|
||||
use filmcraft_ui_egui::FilmcraftApp;
|
||||
use filmcraft_ui_egui::control::ControlRequest;
|
||||
use filmcraft_ui_egui::panels::timeline::Drag;
|
||||
use filmcraft_ui_egui::state::Tool;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
struct Driver {
|
||||
harness: Harness<'static, FilmcraftApp>,
|
||||
tx: Sender<ControlRequest>,
|
||||
}
|
||||
|
||||
impl Driver {
|
||||
/// The demo project, snapping off so drags land exactly where the pointer goes; frames 1/60 s
|
||||
/// apart, as on a display.
|
||||
fn demo() -> Self {
|
||||
let mut session = Session::default();
|
||||
session.execute("file.openDemoProject", json!({})).expect("demo project");
|
||||
session.execute("sequence.snap", json!({"on": false})).expect("snapping off");
|
||||
let (tx, rx) = channel();
|
||||
let app = FilmcraftApp::new(session).with_control(rx);
|
||||
let harness = Harness::builder().with_size(egui::vec2(1600.0, 980.0)).with_step_dt(1.0 / 60.0).with_max_steps(10_000).build_eframe(move |_cc| app);
|
||||
let mut d = Driver { harness, tx };
|
||||
d.frames(4);
|
||||
d.ok("ui.elements", json!({"prefix": "timeline.clip."}));
|
||||
d
|
||||
}
|
||||
|
||||
fn frames(&mut self, n: usize) {
|
||||
for _ in 0..n {
|
||||
let ctx = self.harness.ctx.clone();
|
||||
let mut raw = std::mem::take(self.harness.input_mut());
|
||||
eframe::App::raw_input_hook(self.harness.state_mut(), &ctx, &mut raw);
|
||||
*self.harness.input_mut() = raw;
|
||||
self.harness.step();
|
||||
}
|
||||
}
|
||||
|
||||
fn call(&mut self, method: &str, params: Value) -> Value {
|
||||
let (req, reply) = ControlRequest::new(method, params.clone());
|
||||
self.tx.send(req).unwrap();
|
||||
for _ in 0..600 {
|
||||
self.frames(1);
|
||||
if let Ok(v) = reply.try_recv() {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
panic!("no reply to {method} {params}");
|
||||
}
|
||||
|
||||
fn ok(&mut self, method: &str, params: Value) -> Value {
|
||||
let v = self.call(method, params.clone());
|
||||
assert_eq!(v["ok"], json!(true), "{method} {params} failed: {v}");
|
||||
v["result"].clone()
|
||||
}
|
||||
|
||||
fn app(&self) -> &FilmcraftApp {
|
||||
self.harness.state()
|
||||
}
|
||||
|
||||
fn app_mut(&mut self) -> &mut FilmcraftApp {
|
||||
self.harness.state_mut()
|
||||
}
|
||||
|
||||
fn send(&mut self, e: egui::Event) {
|
||||
self.harness.input_mut().events.push(e);
|
||||
self.frames(1);
|
||||
}
|
||||
|
||||
fn key(&mut self, key: egui::Key) {
|
||||
self.send(egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers: Default::default() });
|
||||
self.send(egui::Event::Key { key, physical_key: None, pressed: false, repeat: false, modifiers: Default::default() });
|
||||
}
|
||||
|
||||
fn press(&mut self, at: Pos2) {
|
||||
self.send(egui::Event::PointerMoved(at));
|
||||
self.send(egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed: true, modifiers: Default::default() });
|
||||
}
|
||||
|
||||
fn move_to(&mut self, at: Pos2) {
|
||||
self.send(egui::Event::PointerMoved(at));
|
||||
}
|
||||
|
||||
fn release(&mut self, at: Pos2) {
|
||||
self.send(egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed: false, modifiers: Default::default() });
|
||||
self.frames(2);
|
||||
}
|
||||
|
||||
/// The Slip Monitor's elements (id → label) of the frame before the last.
|
||||
fn slip_elements(&self) -> Vec<(String, String)> {
|
||||
let v = serde_json::to_value(self.app().auto.query("slipMonitor.")).unwrap_or_default();
|
||||
v.as_array().into_iter().flatten().map(|e| (e["id"].as_str().unwrap_or("").to_string(), e["label"].as_str().unwrap_or("").to_string())).collect()
|
||||
}
|
||||
|
||||
/// The preview the Slip drag in progress shows.
|
||||
fn slip_preview(&self) -> Value {
|
||||
match &self.app().tl.drag {
|
||||
Some(Drag::Slip { preview: Some(p), .. }) => (**p).clone(),
|
||||
other => panic!("no slip preview: {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
fn clip(&self, id: ClipId) -> TrackItem {
|
||||
self.app().session.active_sequence().expect("sequence").find_item(id).expect("clip").1.clone()
|
||||
}
|
||||
|
||||
/// A V1 clip with clips touching both its edges and linked sound, and a point inside it.
|
||||
fn middle_clip(&mut self) -> (ClipId, Pos2) {
|
||||
let seq = self.app().session.active_sequence().expect("sequence").clone();
|
||||
let items = &seq.video_tracks[0].items;
|
||||
let it = items
|
||||
.iter()
|
||||
.find(|c| c.link.is_some() && items.iter().any(|p| p.end() == c.start) && items.iter().any(|n| n.start == c.end()))
|
||||
.expect("a V1 clip between two others")
|
||||
.clone();
|
||||
let id = format!("timeline.clip.{}", it.id.0);
|
||||
let els = self.ok("ui.elements", json!({"prefix": id}));
|
||||
let el = els.as_array().expect("elements").iter().find(|e| e["id"] == id.as_str()).unwrap_or_else(|| panic!("no {id}: {els}")).clone();
|
||||
let r: Vec<f32> = el["rect"].as_array().expect("rect").iter().map(|x| x.as_f64().expect("number") as f32).collect();
|
||||
// the clip's middle, above the lower band where a transition takes the press
|
||||
(it.id, pos2(r[0] + r[2] / 2.0, r[1] + 8.0))
|
||||
}
|
||||
|
||||
/// The media frame a side shows, on its item's own frame grid.
|
||||
fn media_frame(&self, side: &Value) -> i64 {
|
||||
let item = ItemId(side["item"].as_u64().expect("item"));
|
||||
let rate = self.app().session.project.item(item).expect("item").frame_rate();
|
||||
rate.frame_at(Tick(side["mediaTime"].as_i64().expect("mediaTime")))
|
||||
}
|
||||
|
||||
/// Step frames (the button still held) until the named picture shows `frame`, for up to 20 s.
|
||||
fn wait_for_texture(&mut self, tex: &str, frame: i64) -> bool {
|
||||
let t0 = std::time::Instant::now();
|
||||
while t0.elapsed() < std::time::Duration::from_secs(20) {
|
||||
if self.app().texture_key(tex).is_some_and(|k| k.frame == frame) {
|
||||
return true;
|
||||
}
|
||||
self.frames(1);
|
||||
std::thread::sleep(std::time::Duration::from_millis(2));
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
/// Render the window to `<target tmp>/ui-screenshots/<name>.png` (needs a GPU).
|
||||
fn screenshot(&mut self, name: &str) -> std::path::PathBuf {
|
||||
self.frames(2);
|
||||
let img = self.harness.render().expect("render");
|
||||
let png = filmcraft_ui_egui::control::encode_png(img.as_raw(), img.width(), img.height()).expect("png");
|
||||
let dir = std::path::PathBuf::from(env!("CARGO_TARGET_TMPDIR")).join("ui-screenshots");
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let path = dir.join(format!("{name}.png"));
|
||||
std::fs::write(&path, png).unwrap();
|
||||
eprintln!("screenshot: {}", path.display());
|
||||
path
|
||||
}
|
||||
}
|
||||
|
||||
fn ids(els: &[(String, String)]) -> Vec<&str> {
|
||||
els.iter().map(|(id, _)| id.as_str()).collect()
|
||||
}
|
||||
|
||||
/// The counters show the preview `p` on the next frame (the one the Timeline asks for when it
|
||||
/// changes), and the automation ids read back are the frame before the last.
|
||||
fn assert_counters_show(d: &mut Driver, p: &Value) {
|
||||
d.frames(2);
|
||||
let els = d.slip_elements();
|
||||
let label = |id: &str| els.iter().find(|(i, _)| i == id).map(|(_, l)| l.clone()).unwrap_or_default();
|
||||
assert_eq!(label("slipMonitor.inTimecode"), p["in"]["sourceTimecode"].as_str().unwrap());
|
||||
assert_eq!(label("slipMonitor.outTimecode"), p["out"]["sourceTimecode"].as_str().unwrap());
|
||||
let n = p["offsetFrames"].as_i64().unwrap();
|
||||
assert!(label("slipMonitor.offset").contains(&if n > 0 { format!("+{n}") } else { n.to_string() }), "{}", label("slipMonitor.offset"));
|
||||
}
|
||||
|
||||
/// The four pictures are decoded frames of the preview's new In and Out and of the neighbours.
|
||||
fn assert_pictures_show(d: &mut Driver, p: &Value, prev: &Value, next: &Value) {
|
||||
let (fin, fout) = (d.media_frame(&p["in"]), d.media_frame(&p["out"]));
|
||||
assert!(d.wait_for_texture("slip-in", fin), "the In picture shows media frame {fin}: {:?}", d.app().texture_key("slip-in"));
|
||||
assert!(d.wait_for_texture("slip-out", fout), "the Out picture shows media frame {fout}: {:?}", d.app().texture_key("slip-out"));
|
||||
assert!(d.wait_for_texture("slip-previous", d.media_frame(prev)));
|
||||
assert!(d.wait_for_texture("slip-next", d.media_frame(next)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dragging_with_the_slip_tool_shows_the_four_up_and_follows_the_pointer() {
|
||||
let mut d = Driver::demo();
|
||||
let (clip, at) = d.middle_clip();
|
||||
let before = d.clip(clip);
|
||||
let partners = filmcraft_engine::commands::with_links(&d.app().session, &[clip]);
|
||||
let partners_before: Vec<TrackItem> = partners.iter().map(|c| d.clip(*c)).collect();
|
||||
let undo0 = d.app().session.history.undo.len();
|
||||
d.key(egui::Key::Y);
|
||||
assert_eq!(d.app().ui.tool, Tool::Slip, "Y picks the Slip tool");
|
||||
assert!(d.slip_elements().is_empty(), "no Slip Monitor before the drag");
|
||||
|
||||
d.press(at);
|
||||
// past egui's drag threshold: the four-up is up at once (the Program monitor is drawn before
|
||||
// the Timeline, and the automation ids are the last frame's)
|
||||
d.move_to(at + egui::vec2(8.0, 0.0));
|
||||
assert!(matches!(d.app().tl.drag, Some(Drag::Slip { preview: Some(_), .. })), "the slip drag started");
|
||||
d.frames(2);
|
||||
let els = d.slip_elements();
|
||||
for id in [
|
||||
"slipMonitor.previous",
|
||||
"slipMonitor.in",
|
||||
"slipMonitor.out",
|
||||
"slipMonitor.next",
|
||||
"slipMonitor.inTimecode",
|
||||
"slipMonitor.outTimecode",
|
||||
"slipMonitor.offset",
|
||||
] {
|
||||
assert!(ids(&els).contains(&id), "{id} on screen: {els:?}");
|
||||
}
|
||||
let first = d.slip_preview();
|
||||
let (prev0, next0) = (first["previous"].clone(), first["next"].clone());
|
||||
assert!(prev0.is_object() && next0.is_object(), "the clip has neighbours: {first}");
|
||||
|
||||
// a few pixels at a time to the right, then back past the start to the left: the In and Out
|
||||
// frames and the counters follow every step; the neighbours never change
|
||||
let mut last_in = first["in"]["mediaTime"].as_i64().unwrap();
|
||||
let mut seen = std::collections::HashSet::new();
|
||||
let path: Vec<f32> = (1..=12).map(|i| 8.0 + 4.0 * i as f32).chain((1..=30).map(|i| 56.0 - 4.0 * i as f32)).collect();
|
||||
for (step, dx) in path.iter().enumerate() {
|
||||
d.move_to(at + egui::vec2(*dx, 0.0));
|
||||
let p = d.slip_preview();
|
||||
let in_t = p["in"]["mediaTime"].as_i64().unwrap();
|
||||
let out_t = p["out"]["mediaTime"].as_i64().unwrap();
|
||||
// Out − In is the clip's length: the slip moves both by one amount
|
||||
assert_eq!(out_t - in_t, first["out"]["mediaTime"].as_i64().unwrap() - first["in"]["mediaTime"].as_i64().unwrap(), "step {step}");
|
||||
if step < 12 {
|
||||
assert!(in_t <= last_in, "dragging right slips to earlier media (step {step})");
|
||||
} else {
|
||||
assert!(in_t >= last_in, "dragging left slips to later media (step {step})");
|
||||
}
|
||||
last_in = in_t;
|
||||
seen.insert(in_t);
|
||||
assert_eq!(p["previous"], prev0, "the previous clip's Out frame stays");
|
||||
assert_eq!(p["next"], next0, "the next clip's In frame stays");
|
||||
assert_counters_show(&mut d, &p);
|
||||
// nothing is edited while dragging
|
||||
assert_eq!(d.clip(clip), before);
|
||||
assert_eq!(d.app().session.history.undo.len(), undo0);
|
||||
}
|
||||
assert!(seen.len() > 10, "the In frame moved with the pointer: {seen:?}");
|
||||
|
||||
// the pictures are decoded frames of the new In and Out
|
||||
let p = d.slip_preview();
|
||||
assert_pictures_show(&mut d, &p, &prev0, &next0);
|
||||
|
||||
// release: one Slip, exactly what the monitor showed, picture and sound together; the
|
||||
// Program monitor is back
|
||||
let end = at + egui::vec2(*path.last().unwrap(), 0.0);
|
||||
d.release(end);
|
||||
assert!(d.slip_elements().is_empty(), "the Slip Monitor is gone after the release");
|
||||
assert!(d.app().tl.drag.is_none());
|
||||
assert_eq!(d.app().session.history.undo.len(), undo0 + 1, "one undo step");
|
||||
for c in p["clips"].as_array().unwrap() {
|
||||
let it = d.clip(ClipId(c["clip"].as_u64().unwrap()));
|
||||
assert_eq!(it.source_in.0, c["sourceIn"].as_i64().unwrap(), "committed as previewed");
|
||||
}
|
||||
let after = d.clip(clip);
|
||||
assert_eq!((after.start, after.duration), (before.start, before.duration), "the clip keeps its place and length");
|
||||
assert_ne!(after.source_in, before.source_in);
|
||||
let shift = after.source_in - before.source_in;
|
||||
for (c, was) in partners.iter().zip(&partners_before) {
|
||||
assert_eq!(d.clip(*c).source_in - was.source_in, shift, "linked clips slip together");
|
||||
}
|
||||
|
||||
// undo and redo
|
||||
d.ok("engine.execute", json!({"command": "edit.undo", "params": {}}));
|
||||
assert_eq!(d.clip(clip), before);
|
||||
d.ok("engine.execute", json!({"command": "edit.redo", "params": {}}));
|
||||
assert_eq!(d.clip(clip), after);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn escape_drops_the_slip_and_its_monitor() {
|
||||
let mut d = Driver::demo();
|
||||
let (clip, at) = d.middle_clip();
|
||||
let before = d.clip(clip);
|
||||
let project = d.app().session.project.clone();
|
||||
let undo0 = d.app().session.history.undo.len();
|
||||
d.key(egui::Key::Y);
|
||||
d.press(at);
|
||||
for i in 1..=10 {
|
||||
d.move_to(at + egui::vec2(6.0 * i as f32, 0.0));
|
||||
}
|
||||
assert!(!d.slip_elements().is_empty(), "the Slip Monitor is up");
|
||||
assert_ne!(d.slip_preview()["offsetFrames"], json!(0));
|
||||
d.key(egui::Key::Escape);
|
||||
d.frames(1);
|
||||
assert!(d.app().tl.drag.is_none(), "Escape ended the drag");
|
||||
assert!(d.slip_elements().is_empty(), "and closed the Slip Monitor");
|
||||
d.release(at + egui::vec2(60.0, 0.0));
|
||||
assert_eq!(d.clip(clip), before, "nothing slipped");
|
||||
assert_eq!(*d.app().session.project, *project);
|
||||
assert_eq!(d.app().session.history.undo.len(), undo0, "no undo step");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_slip_far_past_the_media_stops_at_its_end_and_commits_that() {
|
||||
let mut d = Driver::demo();
|
||||
let (clip, at) = d.middle_clip();
|
||||
d.key(egui::Key::Y);
|
||||
d.press(at);
|
||||
// far to the left: later and later media, past what the file has
|
||||
for i in 1..=40 {
|
||||
d.move_to(at - egui::vec2(25.0 * i as f32, 0.0));
|
||||
}
|
||||
let p = d.slip_preview();
|
||||
assert_eq!(p["atLimit"], json!(true), "held at the media's end: {p}");
|
||||
assert!(d.slip_elements().iter().any(|(id, l)| id == "slipMonitor.offset" && l.contains("limit")));
|
||||
d.release(at - egui::vec2(1000.0, 0.0));
|
||||
for c in p["clips"].as_array().unwrap() {
|
||||
assert_eq!(d.clip(ClipId(c["clip"].as_u64().unwrap())).source_in.0, c["sourceIn"].as_i64().unwrap());
|
||||
}
|
||||
let _ = clip;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_fast_slip_keeps_one_decode_per_picture_waiting() {
|
||||
let mut d = Driver::demo();
|
||||
let (_, at) = d.middle_clip();
|
||||
d.key(egui::Key::Y);
|
||||
d.press(at);
|
||||
// big jumps every frame: each refresh asks for new In and Out frames
|
||||
let mut most = 0;
|
||||
for i in 1..=60 {
|
||||
let dx = if i % 2 == 0 { 15.0 * i as f32 } else { -15.0 * i as f32 };
|
||||
d.move_to(at + egui::vec2(dx.clamp(-600.0, 600.0), 0.0));
|
||||
most = most.max(d.app().frames.queue_len());
|
||||
}
|
||||
// the newest position replaces the ones left behind in each picture's view: a handful of
|
||||
// jobs wait, never one per refresh
|
||||
assert!(most <= 8, "at most a few frame jobs queued while dragging fast, saw {most}");
|
||||
d.release(at);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn slip_and_trim_tools_still_edit_after_a_slip() {
|
||||
// Trim Monitor drags and ordinary trims keep working once a slip has run (the pictures share
|
||||
// `trim_monitor::picture`)
|
||||
let mut d = Driver::demo();
|
||||
let (clip, at) = d.middle_clip();
|
||||
d.key(egui::Key::Y);
|
||||
d.press(at);
|
||||
for i in 1..=6 {
|
||||
d.move_to(at + egui::vec2(5.0 * i as f32, 0.0));
|
||||
}
|
||||
d.release(at + egui::vec2(30.0, 0.0));
|
||||
d.key(egui::Key::V);
|
||||
assert_eq!(d.app().ui.tool, Tool::Selection);
|
||||
let before = d.clip(clip);
|
||||
d.ok("engine.execute", json!({"command": "timeline.trim", "params": {"clip": clip.0, "edge": "out", "deltaFrames": -3}}));
|
||||
assert_eq!(d.clip(clip).duration, before.duration - d.app().session.sequence_rate().tick_of(3));
|
||||
d.ok("engine.execute", json!({"command": "trim.selectEditPoint", "params": {"clip": clip.0, "edge": "out", "kind": "roll"}}));
|
||||
d.frames(3);
|
||||
let els = serde_json::to_value(d.app().auto.query("trimMonitor.")).unwrap_or_default();
|
||||
assert!(els.as_array().is_some_and(|a| a.iter().any(|e| e["id"] == "trimMonitor.outgoing")), "the Trim Monitor still shows");
|
||||
}
|
||||
|
||||
/// Screenshots of the Slip Monitor mid-drag, for looking at (needs a GPU):
|
||||
/// `cargo test -p filmcraft-ui-egui --test it slip_monitor_ui:: -- --ignored --nocapture`
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn slip_monitor_screenshots() {
|
||||
let mut d = Driver::demo();
|
||||
let (_, at) = d.middle_clip();
|
||||
d.screenshot("slip-before");
|
||||
d.key(egui::Key::Y);
|
||||
d.press(at);
|
||||
for (i, dx) in [40.0, -80.0].into_iter().enumerate() {
|
||||
for s in 1..=10 {
|
||||
d.move_to(at + egui::vec2(dx * s as f32 / 10.0, 0.0));
|
||||
}
|
||||
let p = d.slip_preview();
|
||||
let (fin, fout) = (d.media_frame(&p["in"]), d.media_frame(&p["out"]));
|
||||
d.wait_for_texture("slip-in", fin);
|
||||
d.wait_for_texture("slip-out", fout);
|
||||
d.screenshot(&format!("slip-dragging-{i}"));
|
||||
}
|
||||
d.release(at + egui::vec2(-80.0, 0.0));
|
||||
d.screenshot("slip-released");
|
||||
}
|
||||
|
||||
/// A 20 s 3840×2160 25 fps movie with sound in `codec` (ffmpeg's libx264 / libx265), a keyframe
|
||||
/// every `gop` frames, made once in `target/fixtures/ui-egui`; `None` without ffmpeg.
|
||||
fn movie_4k(codec: &str, gop: u32) -> Option<std::path::PathBuf> {
|
||||
let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../target/fixtures/ui-egui");
|
||||
std::fs::create_dir_all(&dir).ok()?;
|
||||
let path = dir.join(format!("slip_4k_{}_g{gop}.mp4", if codec == "libx265" { "hevc" } else { "h264" }));
|
||||
if !path.exists() {
|
||||
let ffmpeg = std::env::var_os("FILMCRAFT_FFMPEG").unwrap_or_else(|| "ffmpeg".into());
|
||||
let ok = std::process::Command::new(ffmpeg)
|
||||
.args([
|
||||
"-loglevel",
|
||||
"error",
|
||||
"-y",
|
||||
"-f",
|
||||
"lavfi",
|
||||
"-i",
|
||||
"testsrc2=size=3840x2160:rate=25:duration=20",
|
||||
"-f",
|
||||
"lavfi",
|
||||
"-i",
|
||||
"sine=frequency=440:duration=20",
|
||||
])
|
||||
.args(["-c:v", codec, "-pix_fmt", "yuv420p", "-g", &gop.to_string(), "-preset", "veryfast", "-c:a", "aac", "-shortest"])
|
||||
.arg(&path)
|
||||
.status()
|
||||
.is_ok_and(|s| s.success());
|
||||
if !ok {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
Some(path)
|
||||
}
|
||||
|
||||
/// How the Slip Monitor keeps up with long-GOP 4K H.264 and HEVC: the UI frame time while the
|
||||
/// pointer slips a clip fast (decoding is off the UI thread, so it stays a display refresh),
|
||||
/// the frame jobs waiting, and how long after the pointer stops the exact In and Out frames are
|
||||
/// on screen. Prints the numbers:
|
||||
/// `cargo test --release -p filmcraft-ui-egui --test it slip_monitor_ui::perf_ -- --ignored --nocapture`
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn perf_slip_monitor_4k_long_gop() {
|
||||
for (codec, gop) in [("libx264", 250), ("libx265", 250), ("libx264", 25), ("libx265", 25)] {
|
||||
let Some(path) = movie_4k(codec, gop) else {
|
||||
eprintln!("skipped: no ffmpeg to make the 4K fixture");
|
||||
return;
|
||||
};
|
||||
let mut session = Session::default();
|
||||
session.execute("file.newProject", json!({"name": "Slip 4K"})).unwrap();
|
||||
let r = session.execute("file.import", json!({"paths": [path.to_string_lossy()]})).unwrap();
|
||||
let item = r["items"][0].as_u64().or_else(|| r["item"].as_u64()).unwrap_or_else(|| panic!("import: {r}"));
|
||||
session.execute("file.newSequence", json!({"name": "Sequence", "fps": 25, "video": 1, "audio": 1, "width": 3840, "height": 2160})).unwrap();
|
||||
session.execute("sequence.snap", json!({"on": false})).unwrap();
|
||||
let fr = session.sequence_rate().tick_of(1).0;
|
||||
// three 4 s clips cut from the take, with handles on both sides of the middle one
|
||||
for (i, src) in [(0, 0), (1, 200), (2, 400)] {
|
||||
session
|
||||
.execute(
|
||||
"timeline.place",
|
||||
json!({"item": item, "track": "V1", "audioTrack": "A1", "time": fr * 100 * i, "sourceIn": fr * (src + 20), "duration": fr * 100}),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
let (tx, rx) = channel();
|
||||
let app = FilmcraftApp::new(session).with_control(rx);
|
||||
let harness = Harness::builder().with_size(egui::vec2(1600.0, 980.0)).with_step_dt(1.0 / 60.0).with_max_steps(100_000).build_eframe(move |_cc| app);
|
||||
let mut d = Driver { harness, tx };
|
||||
d.frames(4);
|
||||
d.ok("ui.set", json!({"timeline": {"fit": true}}));
|
||||
d.frames(10);
|
||||
let (clip, at) = d.middle_clip();
|
||||
// baseline: the Program monitor showing a frame deep in a GOP, as a seek does
|
||||
let it = d.clip(clip);
|
||||
let seek = it.start + Tick(fr * 87);
|
||||
let want = d.app().session.sequence_rate().frame_at(seek);
|
||||
d.app_mut().session.set_playhead(seek);
|
||||
let t0 = std::time::Instant::now();
|
||||
while d.app().program_picture().map(|k| k.frame) != Some(want) && t0.elapsed() < std::time::Duration::from_secs(20) {
|
||||
d.frames(1);
|
||||
std::thread::sleep(std::time::Duration::from_millis(2));
|
||||
}
|
||||
let program = t0.elapsed().as_secs_f64() * 1000.0;
|
||||
d.key(egui::Key::Y);
|
||||
d.press(at);
|
||||
let mut steps = Vec::new();
|
||||
let mut most_queued = 0;
|
||||
for i in 1..=120 {
|
||||
let dx = ((i as f32) * 0.37).sin() * 220.0;
|
||||
let t0 = std::time::Instant::now();
|
||||
d.move_to(at + egui::vec2(dx, 0.0));
|
||||
steps.push(t0.elapsed().as_secs_f64() * 1000.0);
|
||||
most_queued = most_queued.max(d.app().frames.queue_len());
|
||||
}
|
||||
steps.sort_by(f64::total_cmp);
|
||||
let p = d.slip_preview();
|
||||
let (fin, fout) = (d.media_frame(&p["in"]), d.media_frame(&p["out"]));
|
||||
let t0 = std::time::Instant::now();
|
||||
let shown = d.wait_for_texture("slip-in", fin) && d.wait_for_texture("slip-out", fout);
|
||||
let settle = t0.elapsed().as_secs_f64() * 1000.0;
|
||||
eprintln!(
|
||||
"{codec} 4K GOP {gop}: Program monitor seek {program:.0} ms; UI frame while slipping median {:.1} ms, p95 {:.1} ms, max {:.1} ms; at most {most_queued} frame jobs queued; exact In+Out on screen {settle:.0} ms after the pointer stopped ({})",
|
||||
steps[steps.len() / 2],
|
||||
steps[steps.len() * 95 / 100],
|
||||
steps[steps.len() - 1],
|
||||
if shown { "shown" } else { "NOT shown" }
|
||||
);
|
||||
assert!(shown, "{codec}: the exact frames arrive once the pointer rests");
|
||||
d.release(at);
|
||||
}
|
||||
}
|
||||
@@ -165,6 +165,18 @@ Dynamic trimming takes an explicit clock (seconds) so it is deterministic: `trim
|
||||
{direction, slow?, clock}` (J/L), `trim.tick {clock}`, `trim.shuttleStop {clock?}` (K, one undo step),
|
||||
`trim.cancelDynamic` (Esc), `trim.playAround {clock, loop?}` (Space / Shift+K).
|
||||
|
||||
**Slip Monitor** (`crates/engine/src/slip.rs`, `crates/ui-egui/src/panels/slip_monitor.rs`): while the
|
||||
Slip tool (Y) drags a clip, the Program monitor shows the slipped clip's new first and last frames
|
||||
large, side by side, with the previous clip's last frame and the next clip's first frame half size
|
||||
above their outer corners (ids `slipMonitor.previous`, `.in`, `.out`, `.next`, their `…Timecode`
|
||||
labels, `slipMonitor.offsetTimecode` (`+00:00:05:20`) and `slipMonitor.offset` (`Slip: +25 frames`)). `timeline.slipPreview
|
||||
{clip, delta|deltaFrames}` returns what `timeline.slip` with the same params would do without
|
||||
editing anything: `previous` / `in` / `out` / `next` (null where no clip touches it; each with
|
||||
`mediaTime`, `mediaFrame`, `sourceTimecode`), `shown` (the linked picture when the dragged clip is
|
||||
sound), `delta` (the slip after clamping at the media's ends), `offsetFrames`, `atLimit` and `clips`
|
||||
(each slipped clip's new `sourceIn` / `sourceOut`). Linked partners are clamped together, as
|
||||
`timeline.slip` does them.
|
||||
|
||||
**Replace With Clip**: `clip.replaceFromSource`, `clip.replaceFromSourceMatchFrame` and
|
||||
`clip.replaceFromBin {clips?, item?, keepSourceIn?}` swap the media of the clips and return
|
||||
`{clips: [ids], item, short: [{clip, shortByFrames}]}`. `short` lists the replaced clips that now
|
||||
|
||||
@@ -30,6 +30,7 @@ stays a binary of its own in `tests/`. Select one file's tests with its module p
|
||||
| Scopes and panels (M8.9 / M12.6) | `crates/scopes/src/tests.rs`, `crates/engine/src/{scopes,panels}_tests.rs`, `crates/ui-egui/tests/it/panels_ui.rs` | scope maths on generated frames (flat colours → exact histogram bins, ramps → waveform row = code value, 75 % bars → parade levels and vectorscope target cells for BT.601/709/2020, HLS hue angles, YC chroma, Clamp Signal, decimation, NaN); `scopes.read` on a colour matte (exact bins, 78.43 %) and on Bars and Tone (the six targets); metadata edits (one undo step, read-only fields refused, saved in the project), the event log (failed / disabled commands, repeats, jobs started / finished / failed / cancelled); every panel from Window ▸, the scopes' wrench menu, presets, five-scope grid, typing into a Metadata field, Timecode rows and modes, Events filter / Clear All, Progress cancel, Reference Monitor park / gang / scopes (`FILMCRAFT_UI_SNAPSHOT_DIR=<dir>` writes `panels-*.png`); `perf_scopes_at_1080p` (ignored) times each scope |
|
||||
| Keyframe navigator and Effect Controls ruler | `crates/engine/src/tests.rs` (`add_keyframe_toggles_the_keyframe_at_the_playhead`), `crates/ui-egui/tests/it/keyframes_ui.rs`, `lane_tests` in `crates/ui-egui/src/panels/effect_controls.rs` | `effects.addKeyframe` adds a keyframe at the playhead or removes the one there (the value falls back to the remaining keyframes; undo, redo, parameters that name nothing); headless: the Properties diamond turns animation on, adds and removes the keyframe at the playhead (Scale 50 % → 100 % again), its ◀ ▶ arrows and Effect Controls' step between keyframes, Crop is applied before its first keyframe; a click on the Effect Controls time ruler and a drag of the playhead's handle move the playhead, and no playhead is drawn off the clip; ruler labels are sequence timecode, and clip times, frame rates and panel widths at their limits don't panic (`FILMCRAFT_UI_SHOTS=<dir>` writes `keyframes-*.png`) |
|
||||
| Golden images | `crates/golden/tests/golden.rs` | CPU renders vs committed PNGs; GPU vs CPU on the same scenes (§3) |
|
||||
| Slip Monitor | `crates/engine/src/slip_tests.rs`, `crates/ui-egui/tests/it/slip_monitor_ui.rs`, `trim_preview_tests` in `crates/ui-egui/src/panels/timeline.rs` | `timeline.slipPreview` = what `timeline.slip` commits for every delta (linked pair at unequal media limits #529, speed 200 %, reversed, 30 fps media in a 25 fps sequence), neighbours static, no project change or undo step, hostile params; headless: Y + drag shows the four ids at once, In/Out follow every pointer step and the pictures show those decoded frames, release commits what was shown (one undo step, undo/redo), Escape leaves the project untouched, a fast drag keeps ≤ 8 frame jobs queued; `slip_monitor_screenshots` and `perf_slip_monitor_4k_long_gop` (ignored) render the view and time 4K H.264 / HEVC |
|
||||
| Engine / command | `crates/engine/src/tests.rs` | run commands on the demo project, assert the sequence, undo/redo, disabled cases |
|
||||
| Render | `crates/render/src/tests.rs` | compositing, opacity, Motion, cross dissolve midpoint, ½-res vs full, GPU plan vs reference, audio mix, audio-effect continuity |
|
||||
| Multi-camera / sync | `crates/audio-dsp/src/sync.rs`, `crates/engine/src/multicam_tests.rs`, `crates/ui-egui/tests/it/multicam_ui.rs` | audio offsets within one sample: Rust-generated multi-mic speech (gains −20…+10 dB, SNR 40/25/10/3 dB, zero-phase colouring, fractional delays, a 0 dB-SNR room with a −4 dB echo) and ffmpeg-made camera/recorder files (pink-noise bursts, independent noise; exact lags recovered); timecode (± hours) and marker sync within a frame; Merge Clips; timeline Synchronize keeps frame-aligned starts; multicam structure, angle render (PSNR vs the camera), Switch Audio mix = the angle's track, live switching from a simulated playback clock (cuts, healing, one undo step), Ctrl+N cuts, flatten (frames identical), save/load; 20 angles: paging (auto / 2×2 / 3×3), page-relative keys, absolute cameras beyond 16, a page decoding only its angles at the cell scale (recording source), Auto-Adjust scale, Selection Top Down; headless: page arrows, angle 17–20 cells, grid-only view, Edit Cameras thumbnails; `perf_grid_of_four_1080p_angles` (ignored) prints the grid cost |
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ open interaction reports (about 40 of the 188 open issues).
|
||||
|---|---|---|---|---|---|
|
||||
| Menus | 366 in-scope menu items | ~338 present (label diff, 92%) | 92% | spelling, Render and Replace, 5 workspaces | 10–20 h |
|
||||
| Keyboard | Premiere default keyboard + editor | Premiere-compatible preset (143 keyboard-only commands; 39 cloud / absent-panel keys skipped with reasons), FilmCraft / FCP / Avid presets, editor | 90% | Ctrl chords (#256 fixed), modifier hints on Windows (#270 fixed) | 5–10 h |
|
||||
| Timeline editing tools | Selection, Track Select, Ripple / Rolling / Rate Stretch, Razor, Slip / Slide, Pen, Hand, Zoom, Type | all present, trim modes, Trim Monitor, dynamic trimming | 80% | deselect in empty space (#683), gap delete (#648, #668), clip stretch (#653), new tracks by dropping (#483), Escape cancels drag (#580 fixed), delete in timeline (#680, #404) | 30–50 h |
|
||||
| Timeline editing tools | Selection, Track Select, Ripple / Rolling / Rate Stretch, Razor, Slip / Slide, Pen, Hand, Zoom, Type | all present, trim modes, Trim Monitor, four-up Slip Monitor while slipping, dynamic trimming | 80% | deselect in empty space (#683), gap delete (#648, #668), clip stretch (#653), new tracks by dropping (#483), Escape cancels drag (#580 fixed), delete in timeline (#680, #404) | 30–50 h |
|
||||
| Program monitor on-screen controls | Motion / Transform handles, mask handles, safe margins, guides, transparency grid | guides, rulers, safe margins, transparency grid, snapping, mask drawing; **no transform handles** (#639); Button Editor (+) does nothing (#431) | 55% | #639, #431 | 15–25 h |
|
||||
| Effect Controls | property rows, keyframe area with zoom, divider, graphs, eyedroppers | rows, keyframes, value / velocity graphs, eyedropper (#518); missing keyframe zoom (#641, #645), draggable divider (#643), row lines (#640), Position curves (#448) | 60% | #412, #640–#645, #448 | 15–25 h |
|
||||
| Panels and docking | 17 workspaces, dock / undock / float, drop zones | 11 workspaces, docking; rearranging windows reported missing (#493); multi-monitor floating windows (#466) | 60% | #493, #466 | 20–35 h |
|
||||
|
||||
Reference in New Issue
Block a user