The Composition viewer ignored drags from other panels. Now, as in After Effects: - A Project item dropped on the viewer becomes a layer centred where it lands (above the selected layer, like any new layer); while dragging, the viewer is outlined and the layer's frame follows the pointer. - Media Browser files do the same; files dropped from the OS file manager do too when the platform reports where the pointer is during the drag (otherwise they import as before). - An effect from Effects & Presets goes on the layer under the pointer, which is outlined while dragging. layer.addItem and layer.newModel take `position` ([x, y] comp px). file.import takes `addToComp` with `time`, `index` and `position`; mediaBrowser.import shares it (file::add_to_comp): layered files go in as their comps, the comp they were dropped in stays open, and items that can't be layers are reported in `errors`. viewer::layer_at is the hit test pick() and the drop share. Tests: ui_drag_drop.rs (project item and effect dropped on the viewer) and imported_files_go_into_the_comp_where_they_were_dropped (engine). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
78f49e09ab
commit
8ef1a28bc4
@@ -104,20 +104,14 @@ fn browser_import(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if !browser(s)?.fetch(&list, p) {
|
||||
return Ok(json!({"pending": true, "paths": list}));
|
||||
}
|
||||
let r = s.execute("file.import", json!({"paths": paths}))?;
|
||||
// Add to the active comp (drag into the timeline).
|
||||
if b_p(p, "addToComp").unwrap_or(false)
|
||||
&& s.active_comp_id().is_some()
|
||||
&& let Some(items) = r.get("items").and_then(Value::as_array)
|
||||
let target = s.active_comp_id();
|
||||
let mut r = s.execute("file.import", json!({"paths": paths}))?;
|
||||
// Dragged into the Timeline or the Composition viewer: into the comp, where they were dropped.
|
||||
let errors = super::file::add_to_comp(s, &r, target, p);
|
||||
if !errors.is_empty()
|
||||
&& let Some(e) = r.get_mut("errors").and_then(Value::as_array_mut)
|
||||
{
|
||||
// Where a drop put them (`time`, `index`): one under the other.
|
||||
for (k, it) in items.iter().enumerate() {
|
||||
let mut add = json!({"item": it, "time": p.get("time")});
|
||||
if let Some(i) = p.get("index").and_then(Value::as_u64) {
|
||||
add["index"] = json!(i.saturating_add(k as u64));
|
||||
}
|
||||
s.execute("layer.addItem", add)?;
|
||||
}
|
||||
e.extend(errors.into_iter().map(Value::from));
|
||||
}
|
||||
Ok(r)
|
||||
}
|
||||
@@ -243,7 +237,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Import",
|
||||
[],
|
||||
None,
|
||||
"{paths, addToComp?, time?, index? (where the layers go, as in layer.addItem)}",
|
||||
"{paths, addToComp?, time?, index?, position? (where the layers go, as in layer.addItem)}",
|
||||
browser_enabled,
|
||||
browser_import
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user