mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-14 11:17:12 -04:00
Time: in Frames style a typed number is a frame count (#610 follow-up)
parse_timecode reads bare digits as timecode pairs, so 00100 went to frame 30 (1 s) instead of frame 100. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QiAJeFttZp83Fh7YuzAR5f
This commit is contained in:
2 files changed
+20
-8
No files matched your search
@@ -43,12 +43,17 @@ pub fn parse_display_time(s: &Session, comp: &Comp, text: &str, current: i64) ->
|
||||
let relative = text.trim().starts_with('+') || text.trim().starts_with('-');
|
||||
if relative {
|
||||
Ok(parsed)
|
||||
} else if st.time_display == TimeDisplayStyle::Frames
|
||||
&& let Ok(frame) = text.trim().parse::<i64>()
|
||||
{
|
||||
// Displayed digits are a plain frame count (00100 is frame 100, not 1 s) plus
|
||||
// Start Numbering Frames At.
|
||||
Ok(frame.saturating_sub(st.frame_start))
|
||||
} else if st.time_display == TimeDisplayStyle::Frames {
|
||||
// Displayed digits are composition frame plus Start Numbering Frames At.
|
||||
Ok(parsed - st.frame_start)
|
||||
Ok(parsed.saturating_sub(st.frame_start))
|
||||
} else {
|
||||
// Displayed timecode includes the composition Start Timecode offset.
|
||||
Ok(parsed - fr.frame_at(comp.display_start))
|
||||
Ok(parsed.saturating_sub(fr.frame_at(comp.display_start)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,11 +413,7 @@ fn time_set_snaps_to_the_nearest_frame_and_ae_timecode() {
|
||||
#[test]
|
||||
fn time_set_keeps_the_frame_shown_in_the_current_time_field() {
|
||||
let mut s = Session::default();
|
||||
s.execute(
|
||||
"comp.new",
|
||||
json!({"name": "Example", "width": 64, "height": 64, "frameRate": 30, "duration": 0.6, "startTimecode": "0:00:00:05"}),
|
||||
)
|
||||
.unwrap();
|
||||
s.execute("comp.new", json!({"name": "Example", "width": 64, "height": 64, "frameRate": 30, "duration": 0.6, "startTimecode": "0:00:00:05"})).unwrap();
|
||||
let r = s.execute("time.set", json!({"frame": 0})).unwrap();
|
||||
assert_eq!(r["display"], "0:00:00:05");
|
||||
let r = s.execute("time.set", json!({"timecode": "0:00:00:05"})).unwrap();
|
||||
@@ -433,6 +429,17 @@ fn time_set_keeps_the_frame_shown_in_the_current_time_field() {
|
||||
assert_eq!(r["frame"], 13);
|
||||
}
|
||||
|
||||
/// Frames display style: typed digits are a frame count, so 00100 is frame 100, not 1 s (#530).
|
||||
#[test]
|
||||
fn time_set_reads_frames_style_digits_as_a_frame_count() {
|
||||
let mut s = Session::default();
|
||||
s.execute("comp.new", json!({"name": "Long", "width": 64, "height": 64, "frameRate": 30, "duration": 10})).unwrap();
|
||||
s.execute("file.projectSettings", json!({"timeDisplay": "frames"})).unwrap();
|
||||
let r = s.execute("time.set", json!({"timecode": "00100"})).unwrap();
|
||||
assert_eq!(r["frame"], 100);
|
||||
assert_eq!(r["display"], "00100");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn separate_dimensions_split_and_rejoin() {
|
||||
let (mut s, l) = setup();
|
||||
|
||||
Reference in new issue
Block a user