M13.14: lazy project open, non-blocking UI with large projects, bench --ops
- footage.check: background footage check after File > Open (Progress panel), not an undo step - timeline: track-matte / parent menus built only while open (was O(n^2) per frame); expression-row lookup per layer; panels hold Arc<Comp> snapshots instead of deep clones - Project panel: virtualised vertical scrolling, selection reveal, thumbnails rendered off the UI thread - effectcraft-cli bench --ops (engine::perf + ui-egui::bench) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
41f672eef5
commit
8a4a2bfc52
@@ -22,7 +22,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let w = (rect.max.x - xv - 12.0).clamp(90.0, 220.0);
|
||||
let mut y = rect.min.y + 10.0;
|
||||
let st = app.session.state.content_fill.clone();
|
||||
let comp = app.session.active_comp().cloned();
|
||||
let comp = app.session.active_comp_arc();
|
||||
let layer = comp.as_ref().and_then(|c| app.session.state.selected_layers.first().and_then(|l| c.layer(*l)).cloned());
|
||||
// Fill Target.
|
||||
p.text(pos2(x0, y + 9.0), Align2::LEFT_CENTER, "Fill Target", Tokens::semibold(12.0), t.text);
|
||||
|
||||
@@ -317,7 +317,7 @@ fn prop_row(
|
||||
}
|
||||
}
|
||||
Value::Layer(l) => {
|
||||
let comp = app.session.active_comp().cloned();
|
||||
let comp = app.session.active_comp_arc();
|
||||
if let Some(comp) = comp {
|
||||
let dr = Rect::from_min_size(pos2(vx, cy - 9.0), vec2(((r.max.x - vx) * 0.55).clamp(90.0, 170.0), 18.0));
|
||||
let idx_of = |id: u64| comp.layers.iter().position(|x| x.id.0 == id);
|
||||
@@ -883,7 +883,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
return;
|
||||
};
|
||||
let Some(cid) = app.session.active_comp_id() else { return };
|
||||
let comp = app.session.project.comp(cid).cloned().unwrap_or_else(|| effectcraft_engine::project::Comp::new(1, 1, Default::default(), Default::default()));
|
||||
let comp = app.session.project.comp_arc(cid).unwrap_or_else(|| effectcraft_engine::project::Comp::new(1, 1, Default::default(), Default::default()).into());
|
||||
let comp_name = app.session.project.item(cid).map(|i| i.name.clone()).unwrap_or_default();
|
||||
let snap_project = app.session.project.clone();
|
||||
let snap_expr = app.session.expr.clone();
|
||||
|
||||
@@ -395,7 +395,7 @@ fn value_widget(app: &mut EffectcraftApp, ui: &mut egui::Ui, auto: &str, ty: Opt
|
||||
/// Revert and Push to Comp.
|
||||
fn instance(app: &mut EffectcraftApp, ui: &mut egui::Ui, actions: &mut Actions) {
|
||||
let t = app.tokens;
|
||||
let Some(comp) = app.session.active_comp().cloned() else { return };
|
||||
let Some(comp) = app.session.active_comp_arc() else { return };
|
||||
let Some(layer) = app.session.state.selected_layers.iter().filter_map(|l| comp.layer(*l)).find(|l| essential::group(l).is_some()).cloned() else { return };
|
||||
let LayerSource::Comp { item: src } = layer.source else { return };
|
||||
let Some(eg) = app.session.project.comp(src).and_then(|c| c.essential.clone()) else { return };
|
||||
|
||||
@@ -60,7 +60,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
y += 82.0;
|
||||
p.line_segment([pos2(rect.min.x + 8.0, y), pos2(rect.max.x - 8.0, y)], egui::Stroke::new(1.0, t.separator));
|
||||
y += 14.0;
|
||||
let comp = app.session.active_comp().cloned();
|
||||
let comp = app.session.active_comp_arc();
|
||||
if let Some(c) = comp {
|
||||
let sel: Vec<String> = app.session.state.selected_layers.iter().filter_map(|id| c.layer(*id)).map(|l| l.name.clone()).collect();
|
||||
let tc = crate::panels::timecode(&app.session, &c, app.session.time());
|
||||
|
||||
@@ -71,7 +71,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
app.auto.add("layerPanel.empty", rect, "Layer panel (empty)");
|
||||
return;
|
||||
};
|
||||
let comp = app.session.project.comp(cid).cloned().unwrap_or_else(|| effectcraft_engine::project::Comp::new(1, 1, Default::default(), Default::default()));
|
||||
let comp = app.session.project.comp_arc(cid).unwrap_or_else(|| effectcraft_engine::project::Comp::new(1, 1, Default::default(), Default::default()).into());
|
||||
let time = app.session.time();
|
||||
let fx_count = layer.effects().map(|f| f.groups().count()).unwrap_or(0);
|
||||
let view = app.ui.layer_view.map(|v| v.min(fx_count)).unwrap_or_else(|| default_view(&layer, app.ui.tool));
|
||||
|
||||
@@ -215,7 +215,7 @@ pub fn preview(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
}
|
||||
|
||||
// Cache bar over the preview range.
|
||||
if let Some(c) = app.session.active_comp().cloned() {
|
||||
if let Some(c) = app.session.active_comp_arc() {
|
||||
let cid = app.session.active_comp_id().map(|i| i.0).unwrap_or(0);
|
||||
let scale = app.viewer_shown.as_ref().map(|(_, k)| k.scale).unwrap_or(1000);
|
||||
let pl = match app.playback.plan.filter(|_| app.playback.playing) {
|
||||
@@ -431,7 +431,7 @@ pub fn history(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
pub fn markers(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let t = app.tokens;
|
||||
let p = ui.painter().with_clip_rect(rect);
|
||||
let Some(c) = app.session.active_comp().cloned() else { return };
|
||||
let Some(c) = app.session.active_comp_arc() else { return };
|
||||
let mut y = rect.min.y + 8.0;
|
||||
if c.markers.is_empty() {
|
||||
p.text(rect.center(), Align2::CENTER_CENTER, "No composition markers", Tokens::ui(12.0), t.text_faint);
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
//! 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.
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use effectcraft_engine::project::{Item, ItemId, ItemKind};
|
||||
use egui::{Align2, Color32, Rect, Sense, Stroke, pos2, vec2};
|
||||
use serde_json::json;
|
||||
@@ -102,41 +104,69 @@ pub fn drop_folder(project: &effectcraft_engine::project::Project, row: Option<I
|
||||
if it.is_folder() { Some(it.id) } else { it.parent }
|
||||
}
|
||||
|
||||
/// A thumbnail being rendered off the UI thread: (revision, result slot).
|
||||
type PendingThumb = (u64, Arc<Mutex<Option<Option<(u32, u32, Vec<u8>)>>>>);
|
||||
|
||||
/// Thumbnail of a comp (its current time) or footage (first frame), cached per item/revision.
|
||||
/// Rendered on a background thread (inline on wasm32): until the new one lands the previous
|
||||
/// thumbnail stays up, so selecting a big comp or editing it never stalls the panel.
|
||||
fn thumbnail(app: &EffectcraftApp, ctx: &egui::Context, it: &Item) -> Option<egui::TextureHandle> {
|
||||
let key = egui::Id::new(("proj-thumb", it.id.0));
|
||||
let pkey = egui::Id::new(("proj-thumb-pending", it.id.0));
|
||||
let rev = app.session.revision;
|
||||
if let Some((r, tex)) = ctx.data(|d| d.get_temp::<(u64, egui::TextureHandle)>(key))
|
||||
&& r == rev
|
||||
{
|
||||
return Some(tex);
|
||||
}
|
||||
let (w, h, px) = match &it.kind {
|
||||
ItemKind::Comp(_) => {
|
||||
let t = app.session.state.times.get(&it.id).copied().unwrap_or_default();
|
||||
app.session.render_rgba8(it.id, t, 192).ok()?
|
||||
}
|
||||
ItemKind::Footage(f) if f.has_video => {
|
||||
let img = app.session.footage.frame(it.id, f, effectcraft_engine::time::Tick(0))?;
|
||||
// Point-sample down to at most 192 px on the long side.
|
||||
let step = (img.width.max(img.height) as f32 / 192.0).ceil().max(1.0) as u32;
|
||||
let (w, h) = (img.width.div_ceil(step), img.height.div_ceil(step));
|
||||
let full = img.to_rgba8();
|
||||
let mut px = Vec::with_capacity((w * h * 4) as usize);
|
||||
for y in 0..h {
|
||||
for x in 0..w {
|
||||
let i = (((y * step) * img.width + x * step) * 4) as usize;
|
||||
px.extend_from_slice(&full[i..i + 4]);
|
||||
let cached: Option<(u64, egui::TextureHandle)> = ctx.data(|d| d.get_temp(key));
|
||||
let mut tex = cached.as_ref().map(|(_, t)| t.clone());
|
||||
let have = cached.as_ref().map(|(r, _)| *r);
|
||||
// A finished render: upload it.
|
||||
let pending: Option<PendingThumb> = ctx.data(|d| d.get_temp(pkey));
|
||||
if let Some((prev, slot)) = &pending {
|
||||
let done = slot.lock().ok().and_then(|mut s| s.take());
|
||||
match done {
|
||||
Some(Some((w, h, px))) => {
|
||||
let ci = egui::ColorImage::from_rgba_unmultiplied([w as usize, h as usize], &px);
|
||||
let t = ctx.load_texture(format!("proj-thumb-{}", it.id.0), ci, egui::TextureOptions::LINEAR);
|
||||
ctx.data_mut(|d| {
|
||||
d.insert_temp(key, (*prev, t.clone()));
|
||||
d.remove::<PendingThumb>(pkey);
|
||||
});
|
||||
tex = Some(t);
|
||||
if *prev == rev {
|
||||
return tex;
|
||||
}
|
||||
}
|
||||
(w, h, px)
|
||||
Some(None) => {
|
||||
ctx.data_mut(|d| d.remove::<PendingThumb>(pkey));
|
||||
return tex;
|
||||
}
|
||||
None => {
|
||||
ctx.request_repaint_after(std::time::Duration::from_millis(50));
|
||||
return tex;
|
||||
}
|
||||
}
|
||||
_ => return None,
|
||||
};
|
||||
let ci = egui::ColorImage::from_rgba_unmultiplied([w as usize, h as usize], &px);
|
||||
let tex = ctx.load_texture(format!("proj-thumb-{}", it.id.0), ci, egui::TextureOptions::LINEAR);
|
||||
ctx.data_mut(|d| d.insert_temp(key, (rev, tex.clone())));
|
||||
Some(tex)
|
||||
}
|
||||
if have == Some(rev) {
|
||||
return tex;
|
||||
}
|
||||
let t = app.session.state.times.get(&it.id).copied().unwrap_or_default();
|
||||
let job = app.session.thumbnail_job(it.id, t, 192)?;
|
||||
let slot: Arc<Mutex<Option<Option<(u32, u32, Vec<u8>)>>>> = Arc::default();
|
||||
if cfg!(target_arch = "wasm32") {
|
||||
*slot.lock().ok()? = Some(job());
|
||||
} else {
|
||||
let s = slot.clone();
|
||||
let spawned = std::thread::Builder::new().name("proj-thumb".into()).spawn(move || {
|
||||
let r = job();
|
||||
if let Ok(mut s) = s.lock() {
|
||||
*s = Some(r);
|
||||
}
|
||||
});
|
||||
if spawned.is_err() {
|
||||
return tex;
|
||||
}
|
||||
}
|
||||
ctx.data_mut(|d| d.insert_temp::<PendingThumb>(pkey, (rev, slot)));
|
||||
ctx.request_repaint();
|
||||
tex
|
||||
}
|
||||
|
||||
fn fit(r: Rect, w: f32, h: f32) -> Rect {
|
||||
@@ -290,7 +320,6 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
app.ui.project_hscroll = (hscroll + sresp.drag_delta().x * overflow / (track.width() - tw).max(1.0)).clamp(0.0, overflow);
|
||||
}
|
||||
}
|
||||
let mut y = list.min.y;
|
||||
let query = app.ui.project_search.to_lowercase();
|
||||
let mut rows: Vec<(ItemId, usize)> = vec![];
|
||||
fn walk(app: &EffectcraftApp, folder: Option<ItemId>, depth: usize, q: &str, out: &mut Vec<(ItemId, usize)>) {
|
||||
@@ -324,8 +353,48 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let hover_y = ctx.pointer_hover_pos().filter(|p| list.contains(*p)).map(|p| p.y);
|
||||
let mut drop_row: Option<ItemId> = None;
|
||||
let mut actions: Vec<(String, serde_json::Value)> = vec![];
|
||||
for (i, (id, depth)) in rows.iter().enumerate() {
|
||||
let Some(it) = app.session.project.item(*id).cloned() else { continue };
|
||||
// Vertical scrolling: only the rows in view are drawn (and registered), so a project with
|
||||
// thousands of items costs what one screenful does.
|
||||
let content_h = rows.len() as f32 * ROW_H;
|
||||
let max_scroll = (content_h - list.height() + ROW_H).max(0.0);
|
||||
if ui.rect_contains_pointer(list) {
|
||||
let (dy, shift) = ui.input(|i| (i.smooth_scroll_delta.y, i.modifiers.shift));
|
||||
if !shift && dy != 0.0 {
|
||||
app.ui.project_scroll -= dy;
|
||||
}
|
||||
}
|
||||
// A selection made elsewhere (a command, an agent, the viewer) scrolls into view.
|
||||
let sel_key = egui::Id::new("proj-sel-seen");
|
||||
let sel_now = app.session.state.project_selection.last().map(|i| i.0);
|
||||
if ctx.data(|d| d.get_temp::<Option<u64>>(sel_key)) != Some(sel_now) {
|
||||
ctx.data_mut(|d| d.insert_temp(sel_key, sel_now));
|
||||
if let Some(row) = sel_now.and_then(|s| rows.iter().position(|(id, _)| id.0 == s)) {
|
||||
let top = row as f32 * ROW_H;
|
||||
if top < app.ui.project_scroll {
|
||||
app.ui.project_scroll = top;
|
||||
} else if top + ROW_H > app.ui.project_scroll + list.height() {
|
||||
app.ui.project_scroll = top + ROW_H - list.height();
|
||||
}
|
||||
}
|
||||
}
|
||||
app.ui.project_scroll = app.ui.project_scroll.clamp(0.0, max_scroll);
|
||||
let scroll = app.ui.project_scroll;
|
||||
if max_scroll > 0.0 {
|
||||
let track = Rect::from_min_max(pos2(rect.max.x - 6.0, list.min.y + 1.0), pos2(rect.max.x - 2.0, list.max.y - 7.0));
|
||||
let th = (track.height() * list.height() / content_h).clamp(16.0, track.height());
|
||||
let thumb = Rect::from_min_size(pos2(track.min.x, track.min.y + (track.height() - th) * (scroll / max_scroll)), vec2(track.width(), th));
|
||||
let vresp = ui.interact(track.expand2(vec2(2.0, 0.0)), egui::Id::new("proj-vscroll"), Sense::drag());
|
||||
p.rect_filled(thumb, 2.0, if vresp.hovered() || vresp.dragged() { t.text_dim } else { t.text_faint });
|
||||
app.auto.add("project.vscroll", track, &format!("{scroll}/{max_scroll}"));
|
||||
if vresp.dragged() {
|
||||
app.ui.project_scroll = (scroll + vresp.drag_delta().y * max_scroll / (track.height() - th).max(1.0)).clamp(0.0, max_scroll);
|
||||
}
|
||||
}
|
||||
let first = ((scroll / ROW_H).floor() as usize).min(rows.len());
|
||||
let mut y = list.min.y - (scroll - first as f32 * ROW_H);
|
||||
let project = app.session.project.clone();
|
||||
for (i, (id, depth)) in rows.iter().enumerate().skip(first) {
|
||||
let Some(it) = project.item(*id) else { continue };
|
||||
let r = Rect::from_min_size(pos2(list.min.x, y), vec2(list.width(), ROW_H));
|
||||
y += ROW_H;
|
||||
if r.min.y > list.max.y {
|
||||
@@ -355,7 +424,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
}
|
||||
app.auto.add(&format!("project.item.{}.twirl", id.0), tw, &it.name);
|
||||
}
|
||||
icons::paint(&lp, Rect::from_center_size(pos2(x0 + 18.0, r.center().y), vec2(14.0, 14.0)), item_icon(&it), t.text_dim);
|
||||
icons::paint(&lp, Rect::from_center_size(pos2(x0 + 18.0, r.center().y), vec2(14.0, 14.0)), item_icon(it), t.text_dim);
|
||||
// Proxy indicator: filled = the proxy is used, hollow = set but off. Click to switch.
|
||||
if let Some(px) = it.proxy.as_ref() {
|
||||
let pr = Rect::from_center_size(pos2(x0 + 4.0, r.center().y), vec2(9.0, 9.0));
|
||||
@@ -437,10 +506,10 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let cp = lp.with_clip_rect(cell);
|
||||
let txt = match *key {
|
||||
"type" => it.type_name().to_string(),
|
||||
"size" => file_size(&it).map(fmt_size).unwrap_or_default(),
|
||||
"size" => file_size(it).map(fmt_size).unwrap_or_default(),
|
||||
"duration" => it.duration().map(|d| fmt_dur(d.seconds(), it.frame_rate().map(|r| r.as_f64()).unwrap_or(30.0))).unwrap_or_default(),
|
||||
"fps" => it.frame_rate().map(|f| format!("{:.2}", f.as_f64())).unwrap_or_default(),
|
||||
"path" => file_path(&it).to_string(),
|
||||
"path" => file_path(it).to_string(),
|
||||
"comment" => {
|
||||
let cr = Rect::from_min_size(pos2(*cx - 2.0, r.min.y + 2.0), vec2(*w, r.height() - 4.0));
|
||||
if cell_edit(app, ui, &mut actions, "comment", cr) {
|
||||
|
||||
@@ -60,7 +60,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let t = app.tokens;
|
||||
let p = ui.painter().with_clip_rect(rect);
|
||||
let ctx = ui.ctx().clone();
|
||||
let comp = app.session.active_comp().cloned();
|
||||
let comp = app.session.active_comp_arc();
|
||||
let layer = comp.as_ref().and_then(|c| app.session.state.selected_layers.first().and_then(|id| c.layer(*id)).cloned());
|
||||
let (Some(comp), Some(cid), Some(layer)) = (comp, app.session.active_comp_id(), layer) else {
|
||||
p.text(rect.center(), Align2::CENTER_CENTER, "Select a layer to see its properties", Tokens::ui(12.0), t.text_faint);
|
||||
|
||||
@@ -75,15 +75,23 @@ fn row_height(row: &Row, rh: f32) -> f32 {
|
||||
/// Insert an expression editor row after every property that has an expression.
|
||||
fn with_expr_rows(rows: Vec<Row>, comp: &Comp, closed: &std::collections::BTreeSet<u64>) -> Vec<Row> {
|
||||
let mut out = Vec::with_capacity(rows.len());
|
||||
// Rows come grouped by layer: look each layer up once (a linear search per property row
|
||||
// made twirling open many layers of a big comp quadratic).
|
||||
let mut cur: Option<&Layer> = None;
|
||||
for r in rows {
|
||||
let extra = match r.kind {
|
||||
RowKind::Prop { uid } if !closed.contains(&uid) => comp.layer(r.layer).and_then(|l| l.props.find(uid)).and_then(|p| p.expr.as_ref()).map(|e| Row {
|
||||
let mut extra = None;
|
||||
if let RowKind::Prop { uid } = r.kind
|
||||
&& !closed.contains(&uid)
|
||||
{
|
||||
if cur.is_none_or(|l| l.id != r.layer) {
|
||||
cur = comp.layer(r.layer);
|
||||
}
|
||||
extra = cur.and_then(|l| l.props.find(uid)).and_then(|p| p.expr.as_ref()).map(|e| Row {
|
||||
layer: r.layer,
|
||||
depth: r.depth,
|
||||
kind: RowKind::Expr { uid, lines: e.text.lines().count().max(1) },
|
||||
}),
|
||||
_ => None,
|
||||
};
|
||||
});
|
||||
}
|
||||
out.push(r);
|
||||
out.extend(extra);
|
||||
}
|
||||
@@ -336,7 +344,7 @@ fn tl_map_id() -> egui::Id {
|
||||
/// Zoom the time ruler around the CTI.
|
||||
pub fn zoom(app: &mut EffectcraftApp, ctx: &egui::Context, k: f64) {
|
||||
let Some((x0, w)) = ctx.data(|d| d.get_temp::<(f32, f32)>(egui::Id::new("timeline-graph-area"))) else { return };
|
||||
let comp = app.session.active_comp().cloned();
|
||||
let comp = app.session.active_comp_arc();
|
||||
let Some(comp) = comp else { return };
|
||||
let fit = (w as f64 - 20.0) / comp.duration.seconds().max(0.01);
|
||||
let pps = app.ui.timeline.pps.unwrap_or(fit);
|
||||
@@ -731,7 +739,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
ui.painter().text(rect.center(), Align2::CENTER_CENTER, "(no composition)", Tokens::ui(12.0), t.text_faint);
|
||||
return;
|
||||
};
|
||||
let Some(comp) = app.session.project.comp(cid).cloned() else { return };
|
||||
let Some(comp) = app.session.project.comp_arc(cid) else { return };
|
||||
let p = ui.painter().clone();
|
||||
let time = app.session.time();
|
||||
let fr = comp.frame_rate;
|
||||
@@ -1294,14 +1302,19 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
if tresp.clicked() {
|
||||
widgets::open_popup(ui, pop);
|
||||
}
|
||||
// The menu lists every layer: built only while it is open (per visible row
|
||||
// it made a big comp's timeline quadratic).
|
||||
let mut opts = vec!["No Track Matte".to_string(), "-".to_string()];
|
||||
let candidates: Vec<&Layer> = comp.layers.iter().filter(|l| l.id != layer.id && l.source.is_av()).collect();
|
||||
for l in &candidates {
|
||||
opts.push(format!("{}. {}", idx_of(l.id), l.name));
|
||||
}
|
||||
opts.push("-".into());
|
||||
for k in MatteKind::ALL {
|
||||
opts.push(k.label().into());
|
||||
let mut candidates: Vec<&Layer> = vec![];
|
||||
if widgets::popup_is_open(ui, pop) {
|
||||
for (i, l) in comp.layers.iter().enumerate().filter(|(_, l)| l.id != layer.id && l.source.is_av()) {
|
||||
opts.push(format!("{}. {}", i + 1, l.name));
|
||||
candidates.push(l);
|
||||
}
|
||||
opts.push("-".into());
|
||||
for k in MatteKind::ALL {
|
||||
opts.push(k.label().into());
|
||||
}
|
||||
}
|
||||
if let Some(i) = widgets::popup_menu(ui, pop, mr.left_bottom(), &opts, None) {
|
||||
if i == 0 {
|
||||
@@ -1340,9 +1353,14 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
if presp.clicked() {
|
||||
widgets::open_popup(ui, pop);
|
||||
}
|
||||
let cands: Vec<&Layer> = comp.layers.iter().filter(|l| l.id != layer.id).collect();
|
||||
let mut cands: Vec<&Layer> = vec![];
|
||||
let mut popts = vec!["None".to_string(), "-".to_string()];
|
||||
popts.extend(cands.iter().map(|l| format!("{}. {}", idx_of(l.id), l.name)));
|
||||
if widgets::popup_is_open(ui, pop) {
|
||||
for (i, l) in comp.layers.iter().enumerate().filter(|(_, l)| l.id != layer.id) {
|
||||
popts.push(format!("{}. {}", i + 1, l.name));
|
||||
cands.push(l);
|
||||
}
|
||||
}
|
||||
if let Some(i) = widgets::popup_menu(ui, pop, pr_rect.left_bottom(), &popts, None) {
|
||||
let par = if i == 0 { serde_json::Value::Null } else { json!(cands[i - 2].id.0) };
|
||||
actions.push(("layer.setParent".into(), json!({"layers": [layer.id.0], "parent": par})));
|
||||
@@ -1839,7 +1857,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
// Alt-drag the first or last key of a selected group: scale the group in time.
|
||||
if kresp.drag_started()
|
||||
&& ui.input(|i| i.modifiers.alt)
|
||||
&& let Some(c) = app.session.active_comp().cloned()
|
||||
&& let Some(c) = app.session.active_comp_arc()
|
||||
{
|
||||
super::graph_tools::alt_scale_begin(app, &ctx, &c, ct.seconds());
|
||||
}
|
||||
@@ -1889,7 +1907,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
}
|
||||
}
|
||||
// Alt-drag key group scaling (follows the pointer until release).
|
||||
if let Some(c) = app.session.active_comp().cloned() {
|
||||
if let Some(c) = app.session.active_comp_arc() {
|
||||
super::graph_tools::alt_scale_update(app, &ctx, &c, tm, &mut actions);
|
||||
}
|
||||
// Graph editor.
|
||||
|
||||
@@ -152,7 +152,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
run(app, &ctx, "track.stabilize", src_p.clone());
|
||||
}
|
||||
y += 34.0;
|
||||
let Some(comp) = app.session.active_comp().cloned() else {
|
||||
let Some(comp) = app.session.active_comp_arc() else {
|
||||
p.text(pos2(x0, y + 8.0), Align2::LEFT_CENTER, "Open a composition to track motion.", Tokens::ui(12.0), t.text_faint);
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -327,7 +327,7 @@ fn aux_views(
|
||||
/// (its comp and 3D view stay put whatever comp is active). Returns the main viewer's rectangle.
|
||||
fn locked_pane(app: &mut EffectcraftApp, ui: &mut egui::Ui, full: Rect, bg: Color32) -> Rect {
|
||||
let Some(lv) = app.session.state.locked_viewer else { return full };
|
||||
let Some(comp) = app.session.project.comp(lv.comp).cloned() else { return full };
|
||||
let Some(comp) = app.session.project.comp_arc(lv.comp) else { return full };
|
||||
let name = app.session.project.item(lv.comp).map(|i| i.name.clone()).unwrap_or_default();
|
||||
let gap = 2.0;
|
||||
let mid = full.center().x;
|
||||
@@ -410,7 +410,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
empty_state(app, ui, rect);
|
||||
return;
|
||||
};
|
||||
let comp = app.session.project.comp(cid).cloned().unwrap_or_else(|| effectcraft_engine::project::Comp::new(1920, 1080, Default::default(), Tick::ZERO));
|
||||
let comp = app.session.project.comp_arc(cid).unwrap_or_else(|| effectcraft_engine::project::Comp::new(1920, 1080, Default::default(), Tick::ZERO).into());
|
||||
let comp_name = app.session.project.item(cid).map(|i| i.name.clone()).unwrap_or_default();
|
||||
let p = ui.painter().clone();
|
||||
VIEW_CAM.with(|c| c.set(app.session.view_camera(cid)));
|
||||
@@ -1628,7 +1628,7 @@ fn create_shape(app: &mut EffectcraftApp, tool: Tool, a: [f64; 2], b: [f64; 2],
|
||||
&& matches!(kind, "rect" | "ellipse")
|
||||
{
|
||||
// Mask in layer space: invert the layer transform.
|
||||
let comp = app.session.active_comp().cloned();
|
||||
let comp = app.session.active_comp_arc();
|
||||
if let Some(comp) = comp {
|
||||
let ectx = EvalCtx {
|
||||
project: &app.session.project,
|
||||
|
||||
Reference in New Issue
Block a user