Timeline: Project items land where they are dropped (#89)
A Project item (or Media Browser file) dropped in the Timeline always went above the selected layer, starting where new layers start. Now, as in After Effects, a line shows where it goes in the stack (above the first layer row whose middle is below the pointer, else below the last), and over the time graph a marker with a timecode tag shows its In point, which follows the pointer (frame-snapped) or, with Shift, the current time. The layer reorder drag shares the insertion logic. layer.addItem and layer.newModel take `index` (1-based stack position); mediaBrowser.import passes `time` and `index` on, one layer under the other. Tests: project_items_land_where_they_are_dropped_in_the_timeline (ui_drag_drop.rs, real pointer drags: outline, time graph, Shift, below the last layer) and add_item_at_a_stack_index_and_time (engine). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9e619d2893
commit
1a0940d50a
@@ -47,6 +47,27 @@ fn demo_layer_cache_is_transparent() {
|
||||
}
|
||||
}
|
||||
|
||||
/// `layer.addItem` puts the layer at `index` (1-based) in the stack and starts it at `time`, as a
|
||||
/// drop in the Timeline does (#89).
|
||||
#[test]
|
||||
fn add_item_at_a_stack_index_and_time() {
|
||||
let mut s = Session::default();
|
||||
let clip = s.execute("comp.new", json!({"name": "Clip", "width": 16, "height": 16, "frameRate": 30, "duration": 1})).unwrap()["comp"].as_u64().unwrap();
|
||||
s.execute("comp.new", json!({"name": "Main", "width": 32, "height": 32, "frameRate": 30, "duration": 4})).unwrap();
|
||||
for name in ["C", "B", "A"] {
|
||||
s.execute("layer.newSolid", json!({"name": name})).unwrap();
|
||||
}
|
||||
let names = |s: &Session| s.active_comp().unwrap().layers.iter().map(|l| l.name.clone()).collect::<Vec<_>>();
|
||||
s.execute("layer.addItem", json!({"item": clip, "index": 2, "time": 1.01})).unwrap();
|
||||
assert_eq!(names(&s), ["A", "Clip", "B", "C"]);
|
||||
let l = &s.active_comp().unwrap().layers[1];
|
||||
assert_eq!(l.in_point, effectcraft_time::Tick::from_seconds_f64(1.0), "on the nearest frame");
|
||||
// Past the bottom: the bottom.
|
||||
s.execute("layer.addItem", json!({"item": clip, "index": 99})).unwrap();
|
||||
assert_eq!(names(&s).last().map(String::as_str), Some("Clip 2"));
|
||||
assert!(s.execute("layer.addItem", json!({"item": clip, "index": 0})).is_err(), "1-based");
|
||||
}
|
||||
|
||||
/// Audio, Lock and Shy don't change pixels: toggling them keeps the cached layers (#103).
|
||||
#[test]
|
||||
fn audio_lock_and_shy_keep_cached_layers() {
|
||||
|
||||
Reference in New Issue
Block a user