Project panel: items dropped on New Composition make a comp (#227)

Dragging Project items onto the Create a new Composition button at the
bottom of the Project panel did nothing. As in After Effects, the
button now takes the drop and runs File > New Comp from Selection with
the dragged items (the selection when the dragged item is in it): one
item becomes a comp of its size, frame rate and duration holding it,
and several open the New Composition from Selection dialog. The button
is outlined while items are dragged over it.

Test: project_items_dropped_on_new_comp_make_a_composition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bflatastic
2026-10-08 12:59:40 +07:00
co-authored by Claude Opus 5.5
parent fab6dedd7c
commit 6b95b7a182
2 changed files with 47 additions and 2 deletions
+18 -2
View File
@@ -2,8 +2,9 @@
//! search, item list with columns (Name, Label, then the visible optional columns: Type, Size,
//! Media Duration, Frame Rate, File Path, Comment — shown or hidden from the header's context
//! menu), folders (drag items into and out of them), renaming (Enter, or double-click the name),
//! the label colour picker, and the bottom bar (interpret, new folder, new comp, bit depth,
//! delete). Edits are `project.*` engine commands, so they are undoable.
//! the label colour picker, and the bottom bar (interpret, new folder, new comp: click, or drop
//! items on it for a comp from them, bit depth, delete). Edits are engine commands, so they are
//! undoable.
use std::sync::{Arc, Mutex};
@@ -699,6 +700,21 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
_ => app.ui.status = "Interpret Footage: select a footage item".into(),
}
}
// Items dropped on Create a new Composition: New Comp from Selection with them (After
// Effects; several items ask how in its dialog).
if id == "newComp"
&& let Some(DragPayload::Item(iid)) = egui::DragAndDrop::payload::<DragPayload>(&ctx).as_deref()
&& ui.rect_contains_pointer(r)
{
p.rect_stroke(r, 4.0, Stroke::new(2.0, t.accent), egui::StrokeKind::Inside);
if ctx.input(|i| i.pointer.any_released()) {
if !app.session.state.project_selection.contains(&ItemId(*iid)) {
app.session.state.project_selection = vec![ItemId(*iid)];
}
actions.push(("file.newCompFromSelection".into(), json!({})));
egui::DragAndDrop::clear_payload(&ctx);
}
}
x += 26.0;
}
let depth = app.session.project.settings.bit_depth.label();