Merge pull request #1017 from marcoarnulfo/feat/layer-context-add-marker
# Conflicts: # crates/ui-egui/tests/ui_blank_context_menus.rs
This commit is contained in:
@@ -259,3 +259,32 @@ fn timeline_layer_context_menu_has_the_effects_submenu_and_applies_an_effect() {
|
||||
.unwrap_or_default();
|
||||
assert_eq!(names, ["Gaussian Blur"]);
|
||||
}
|
||||
|
||||
/// #976: a layer's context menu has After Effects' Markers ▸ Add Marker, which marks the layer that
|
||||
/// was right-clicked (not the one selected before, and not the composition) at the current time.
|
||||
#[test]
|
||||
fn layer_context_menu_adds_a_layer_marker() {
|
||||
let mut h = harness();
|
||||
let solid = |h: &mut Harness<'_, EffectcraftApp>, name: &str| -> u64 {
|
||||
h.state_mut().session.execute("layer.newSolid", json!({"name": name, "color": "#406080"})).unwrap()["layer"].as_u64().unwrap()
|
||||
};
|
||||
let (below, top) = (solid(&mut h, "Below"), solid(&mut h, "Top"));
|
||||
h.state_mut().session.execute("layer.select", json!({"layers": [below]})).unwrap();
|
||||
h.state_mut().session.execute("time.set", json!({"time": 1.5})).unwrap();
|
||||
h.run_steps(3);
|
||||
let r = rect(&h, &format!("timeline.layer.{top}.row"));
|
||||
right_click(&mut h, pos2(r.min.x + 210.0, r.center().y));
|
||||
h.get_by_label("Markers ⏵").click();
|
||||
h.run_steps(3);
|
||||
snapshot(&mut h, "layer-markers");
|
||||
h.get_by_label("Add Marker").click();
|
||||
h.run_steps(3);
|
||||
let now = h.state().session.time().seconds();
|
||||
let comp = h.state().session.active_comp().unwrap();
|
||||
let markers = |id: u64| -> Vec<f64> { comp.layer(effectcraft_engine::project::LayerId(id)).unwrap().markers.iter().map(|m| m.time.seconds()).collect() };
|
||||
assert_eq!(markers(top), vec![now]);
|
||||
assert!((now - 1.5).abs() < 0.01, "at the current time: {now}");
|
||||
assert!(markers(below).is_empty(), "{:?}", markers(below));
|
||||
assert!(comp.markers.is_empty(), "no composition marker");
|
||||
assert_eq!(h.state().session.history.undo.last().map(|u| u.0.as_str()), Some("Add Marker"));
|
||||
}
|
||||
|
||||
@@ -356,13 +356,38 @@ fn dragging_out_of_the_marker_bin_adds_a_comp_marker() {
|
||||
assert_eq!(markers(&h), vec![13.0]);
|
||||
let history = &h.state().session.history.undo;
|
||||
assert_eq!((history.len(), history.last().map(|u| u.0.as_str())), (undo + 1, Some("Add Marker")), "one undo step");
|
||||
// Numpad * (it arrives as text): Add Marker at the current time.
|
||||
// Numpad * (it arrives as text) with no layer selected: Add Marker at the current time.
|
||||
h.state_mut().session.execute("edit.deselectAll", json!({})).unwrap();
|
||||
h.state_mut().session.execute("time.set", json!({"time": 20.0})).unwrap();
|
||||
h.event(Event::Text("*".into()));
|
||||
h.run_steps(2);
|
||||
assert_eq!(markers(&h), vec![13.0, 20.0]);
|
||||
}
|
||||
|
||||
/// #976: as in After Effects, Numpad * marks the selected layers at the current time; only with
|
||||
/// no layer selected does it add a composition marker.
|
||||
#[test]
|
||||
fn numpad_star_marks_the_selected_layer() {
|
||||
let (mut h, layer) = harness();
|
||||
let comp_markers =
|
||||
|h: &Harness<'_, EffectcraftApp>| -> Vec<f64> { h.state().session.active_comp().unwrap().markers.iter().map(|m| m.time.seconds()).collect() };
|
||||
let layer_markers = |h: &Harness<'_, EffectcraftApp>| -> Vec<f64> {
|
||||
let comp = h.state().session.active_comp().unwrap();
|
||||
comp.layer(effectcraft_engine::project::LayerId(layer)).unwrap().markers.iter().map(|m| m.time.seconds()).collect()
|
||||
};
|
||||
let star = |h: &mut Harness<'_, EffectcraftApp>, time: f64| {
|
||||
h.state_mut().session.execute("time.set", json!({"time": time})).unwrap();
|
||||
h.event(Event::Text("*".into()));
|
||||
h.run_steps(2);
|
||||
};
|
||||
h.state_mut().session.execute("layer.select", json!({"layers": [layer]})).unwrap();
|
||||
star(&mut h, 2.0);
|
||||
assert_eq!((layer_markers(&h), comp_markers(&h)), (vec![2.0], vec![]));
|
||||
h.state_mut().session.execute("edit.deselectAll", json!({})).unwrap();
|
||||
star(&mut h, 3.0);
|
||||
assert_eq!((layer_markers(&h), comp_markers(&h)), (vec![2.0], vec![3.0]));
|
||||
}
|
||||
|
||||
/// #468: zoomed in, a CTI scrub held past the right end of the ruler scrolls the timeline (the
|
||||
/// CTI rides the edge), past the left end scrolls it back; during playback the view pages to
|
||||
/// keep the CTI in sight.
|
||||
|
||||
Reference in New Issue
Block a user