mirror of
https://github.com/storytold/effectcraft.git
synced 2026-11-28 09:09:39 +01:00
#3808: Interpret Footage keeps main's results for targets that aren't footage
`file.interpretFootage` resolves its items as before and skips what isn't footage, so an explicit missing id, composition or solid succeeds and changes nothing again, and a script setting a solid's mainSource.conformFrameRate doesn't throw. The dialog still opens on the first item `interpretation_targets` gives, which is the first footage the command changes, and opens no dialog when that is none. Tests pin Main's result for those targets, Proxy's existing error, and the script setter on a solid.
This commit is contained in:
1 parent
5af43b67b5
commit
337a6ba677
4 files changed
+47
-19
No files matched your search
@@ -61,8 +61,8 @@ fn items_p(s: &Session, p: &Value) -> Vec<ItemId> {
|
||||
|
||||
/// The items `file.interpretFootage` changes for parameters `p` (with `proxy`, the items whose
|
||||
/// proxy `file.interpretProxy` changes): `items`/`item`, else the selection, keeping only
|
||||
/// footage (items with a proxy). The Interpret Footage dialog shows the first one, so OK
|
||||
/// writes its settings back to the footage they came from.
|
||||
/// footage (items with a proxy), as the commands skip the rest. The Interpret Footage dialog
|
||||
/// shows the first one, so OK writes its settings back to the footage they came from.
|
||||
pub fn interpretation_targets(s: &Session, p: &Value, proxy: bool) -> Vec<ItemId> {
|
||||
if proxy {
|
||||
return super::proxy::proxied(s, p);
|
||||
@@ -1020,7 +1020,7 @@ pub(crate) fn guess_alpha(s: &Session, item: ItemId, f: &Footage) -> Option<(Alp
|
||||
}
|
||||
|
||||
fn interpret(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let items = interpretation_targets(s, p, false);
|
||||
let items = items_p(s, p);
|
||||
if items.is_empty() {
|
||||
return Err(bad("file.interpretFootage", "select footage"));
|
||||
}
|
||||
|
||||
@@ -319,7 +319,8 @@ fn interpret_proxy_settings_apply_to_the_proxy() {
|
||||
/// What both Interpret Footage commands change, and what their dialog shows first: `items` in
|
||||
/// order, else `item`, else the Project selection (for Main, the selected layers' footage when no
|
||||
/// footage is selected), keeping footage only, or for Proxy only items with a proxy. A missing or
|
||||
/// other item is no target, so the command reports that there is nothing to interpret.
|
||||
/// other item is no target: Main skips it and changes nothing, Proxy reports that nothing named
|
||||
/// has a proxy.
|
||||
#[test]
|
||||
fn interpretation_targets_follow_the_parameters_then_the_selection() {
|
||||
let mut s = session();
|
||||
@@ -358,19 +359,24 @@ fn interpretation_targets_follow_the_parameters_then_the_selection() {
|
||||
assert_eq!(t(&s, json!({}), false), [c]);
|
||||
s.state.project_selection = vec![comp];
|
||||
assert_eq!(t(&s, json!({}), false), [c], "a selected composition is no footage");
|
||||
// The commands change nothing when nothing is a target.
|
||||
// Nothing named is a target: Main succeeds and changes nothing (scripts set a solid's
|
||||
// mainSource.conformFrameRate through it), Proxy refuses. Named with footage, only the
|
||||
// footage changes.
|
||||
s.execute("layer.newSolid", json!({"color": "#ff0000"})).unwrap();
|
||||
let solid = s.project.items.values().find(|i| matches!(i.kind, ItemKind::Solid(_))).unwrap().id;
|
||||
let before = s.project.clone();
|
||||
for (command, params) in [
|
||||
("file.interpretFootage", json!({"item": 999, "loop": 2})),
|
||||
("file.interpretFootage", json!({"item": comp.0, "loop": 2})),
|
||||
("file.interpretProxy", json!({"item": 999, "loop": 2})),
|
||||
("file.interpretProxy", json!({"item": a.0, "loop": 2})),
|
||||
] {
|
||||
let e = s.execute(command, params.clone()).unwrap_err().to_string();
|
||||
let usual = if command == "file.interpretProxy" { "no proxy" } else { "select footage" };
|
||||
assert!(e.contains(usual), "{command} {params}: {e}");
|
||||
for params in [json!({"item": 999, "loop": 2}), json!({"item": comp.0, "loop": 2}), json!({"items": [solid.0, 999], "loop": 2})] {
|
||||
assert_eq!(s.execute("file.interpretFootage", params.clone()).unwrap(), json!({"items": []}), "{params}");
|
||||
}
|
||||
for params in [json!({"item": 999, "loop": 2}), json!({"item": a.0, "loop": 2}), json!({"item": solid.0, "loop": 2})] {
|
||||
let e = s.execute("file.interpretProxy", params.clone()).unwrap_err().to_string();
|
||||
assert!(e.contains("no proxy"), "{params}: {e}");
|
||||
}
|
||||
assert_eq!(*s.project, *before);
|
||||
let r = s.execute("file.interpretFootage", json!({"items": [solid.0, b.0], "loop": 2})).unwrap();
|
||||
assert_eq!(r["items"].as_array().map(|a| a.iter().map(|i| i["item"].clone()).collect::<Vec<_>>()), Some(vec![json!(b.0)]), "{r}");
|
||||
let ItemKind::Footage(f) = &s.project.item(b).unwrap().kind else { panic!("not footage") };
|
||||
assert_eq!(f.loop_count, 2);
|
||||
}
|
||||
|
||||
/// Use Proxy switches only the targets that have a proxy, and the first of those decides which
|
||||
|
||||
@@ -1197,6 +1197,20 @@ fn import_options_sequence_picks_one_still_or_the_run() {
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
/// A solid's mainSource has no frame rate to conform: setting conformFrameRate leaves the solid
|
||||
/// as it was, without an error.
|
||||
#[test]
|
||||
fn conform_rate_of_a_solid_changes_nothing() {
|
||||
let mut s = session();
|
||||
let o = ok(
|
||||
&mut s,
|
||||
r#"var c = app.project.items.addComp("C", 64, 36, 1, 1, 24); var l = c.layers.addSolid([1, 0, 0], "Red", 64, 36, 1);
|
||||
var before = JSON.stringify(l.source.mainSource.__info()); l.source.mainSource.conformFrameRate = 12;
|
||||
[String(l.source.mainSource), l.source.mainSource.conformFrameRate, JSON.stringify(l.source.mainSource.__info()) === before]"#,
|
||||
);
|
||||
assert_eq!(o.result, json!(["[object SolidSource]", 0, true]));
|
||||
}
|
||||
|
||||
/// #813: FootageItem proxies, replaceWithSequence and mainSource.conformFrameRate.
|
||||
#[test]
|
||||
fn footage_proxies_sequences_and_conform_rate() {
|
||||
|
||||
@@ -1342,7 +1342,8 @@ mod tests {
|
||||
|
||||
/// Interpret Footage named at an item it can't change (missing, not footage, or for Proxy
|
||||
/// without a proxy) doesn't open on the selected footage: as with nothing selected, the
|
||||
/// command runs and reports that there is nothing to interpret, and nothing changes.
|
||||
/// command runs with the parameters given, and nothing changes. Main skips what isn't
|
||||
/// footage and succeeds; Proxy reports that nothing named has a proxy.
|
||||
#[test]
|
||||
fn interpret_footage_named_at_no_footage_opens_no_dialog() {
|
||||
for command in ["file.interpretFootage", "file.interpretProxy"] {
|
||||
@@ -1351,20 +1352,27 @@ mod tests {
|
||||
let ctx = egui::Context::default();
|
||||
app.session.execute("comp.new", json!({"name": "Comp", "width": 4, "height": 4, "frameRate": 24, "duration": 1})).unwrap();
|
||||
let comp = app.session.active_comp_id().unwrap();
|
||||
app.session.execute("layer.newSolid", json!({"color": "#ff0000"})).unwrap();
|
||||
let solid = app.session.project.items.values().find(|i| matches!(i.kind, effectcraft_engine::project::ItemKind::Solid(_))).unwrap().id;
|
||||
// Footage without a proxy.
|
||||
let kind = app.session.project.item(a).unwrap().kind.clone();
|
||||
let plain = std::sync::Arc::make_mut(&mut app.session.project).add_item("plain.mov", Default::default(), None, kind);
|
||||
app.session.state.project_selection = vec![a];
|
||||
let mut invalid = vec![json!({"item": 999}), json!({"items": [999]}), json!({"item": comp.0})];
|
||||
let mut invalid = vec![json!({"item": 999}), json!({"items": [999]}), json!({"item": comp.0}), json!({"item": solid.0})];
|
||||
if proxy {
|
||||
invalid.push(json!({"item": plain.0}));
|
||||
}
|
||||
let before = app.session.project.clone();
|
||||
for params in invalid {
|
||||
let e = crate::menus::invoke(&mut app, &ctx, command, params.clone()).unwrap_err();
|
||||
let r = crate::menus::invoke(&mut app, &ctx, command, params.clone());
|
||||
assert!(app.dialog.is_none(), "{command}: {params}");
|
||||
assert!(e.contains(if proxy { "no proxy" } else { "select footage" }), "{command}: {params}: {e}");
|
||||
assert_eq!(app.ui.status, e, "the status line says why");
|
||||
if proxy {
|
||||
let e = r.unwrap_err();
|
||||
assert!(e.contains("no proxy"), "{command}: {params}: {e}");
|
||||
assert_eq!(app.ui.status, e, "the status line says why");
|
||||
} else {
|
||||
assert_eq!(r, Ok(json!({"items": []})), "{command}: {params}");
|
||||
}
|
||||
}
|
||||
assert_eq!(*app.session.project, *before);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user