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
@@ -8,7 +8,7 @@ use effectcraft_project::{FootageKind, ItemId, ItemKind, Layer, LayerSource, Nod
|
||||
use effectcraft_time::Tick;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use super::layer::{color_p, index_p, insert_layer, insert_layer_at};
|
||||
use super::layer::{color_p, index_p, insert_layer, insert_layer_at, place, position_p};
|
||||
use super::{CommandSpec, b_p, bad, comp_id, f_p, has_comp, has_layers, layer_mut, layer_p, layers_p, str_p};
|
||||
use crate::{EngineError, Result, Session, cmd};
|
||||
|
||||
@@ -120,6 +120,7 @@ pub(crate) fn new_model(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let fr = comp.frame_rate;
|
||||
let start = fr.snap_nearest(f_p(p, "time").map(Tick::from_seconds_f64).unwrap_or(Tick::ZERO));
|
||||
let index = index_p(p, "layer.newModel")?;
|
||||
let position = position_p(p, "layer.newModel")?;
|
||||
let id = s.edit("New 3D Model Layer", None, |proj, st| {
|
||||
let mut l = build::layer(proj, &comp, &name, LayerSource::Model { item }, (comp.width, comp.height), None);
|
||||
let g = build::model_geometry_options(&mut Ids(&mut proj.next_id), scale, &clips);
|
||||
@@ -129,6 +130,7 @@ pub(crate) fn new_model(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
l.start_time = start;
|
||||
l.in_point = start;
|
||||
l.out_point = comp.duration.max(start + fr.frame_duration());
|
||||
place(&mut l, position);
|
||||
insert_layer_at(proj, st, cid, l, index)
|
||||
})?;
|
||||
Ok(json!({"layer": id.0, "item": item.0}))
|
||||
@@ -350,7 +352,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"3D Model Layer",
|
||||
[],
|
||||
None,
|
||||
"{item?: id or name of a 3D model footage item, path?: a .gltf, .glb or .obj file to import, name?, time? (s), index? (1-based stack position)}",
|
||||
"{item?: id or name of a 3D model footage item, path?: a .gltf, .glb or .obj file to import, name?, time? (s), index? (1-based stack position), position? ([x, y] comp px)}",
|
||||
has_comp,
|
||||
new_model
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user