EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
Merge remote-tracking branch 'origin/main' into pr
midasdfed1f65ba375f
diff --cc ROADMAP.mdindex 40f3c5a5f,1ce9d9bb2..79d99dcc7--- a/ROADMAP.md+++ b/ROADMAP.md@@@ -117,11 -117,9 +117,14 @@@ Come tell us what matters most to you o## Progress log+ - 2026-10-28: A shape layer's Rectangle and Ellipse Size get the Constrain Proportions chain+ that Scale has, so a circle stays a circle while its size is typed, scrubbed or keyed; it+ starts off, so existing shapes behave as before (#2489).+- 2026-10-22: Localization: the panel/dialog catalogs gain 303 rows in Japanese, Simplified+ Chinese and Traditional Chinese — panel tabs, form and dialog labels, panel context menus,+ tracker/graph/text-panel controls, File-panel footers and credits. Japanese is 1,624 of+ ≈ 4,200 interface strings (39%); the Chinese panel catalogs hold 998 rows each, and+ Simplified Chinese is 46% with its 306 effect names.- 2026-10-16: Convert To Bezier Path turns a shape layer's Rectangle, Ellipse or Polystarpath into an editable Path 1 with the same geometry, as After Effects does; it used toapply to mask RotoBezier only, so a parametric shape path could not be converted at alldiff --cc crates/ui-egui/src/panels/graph.rsindex b46ce8821,24df22616..a82285f62--- a/crates/ui-egui/src/panels/graph.rs+++ b/crates/ui-egui/src/panels/graph.rs@@@ -240,23 -240,20 +240,22 @@@ impl ButtonBar/// at `y`: draws it, registers it for automation and advances the bar. Once a button does not fit/// (or a previous one overflowed), the button goes to the "»" menu instead and only the id the/// menu picked reports a click. Returns whether this button was chosen.- fn text_button(- app: &mut EffectcraftApp,- ui: &mut egui::Ui,- p: &egui::Painter,- bar: &mut ButtonBar,- y: f32,- label: &str,+ /// One bar button for [`text_button`]: label, lit state, automation id and tooltip.+ struct BarBtn<'a> {+ label: &'a str,on: bool,- id: &str,- tip: &str,- ) -> bool {+ id: &'a str,+ tip: &'a str,+ }++ fn text_button(app: &mut EffectcraftApp, ui: &mut egui::Ui, p: &egui::Painter, bar: &mut ButtonBar, y: f32, btn: BarBtn) -> bool {+ let BarBtn { label, on, id, tip } = btn;let t = app.tokens;- let w = p.layout_no_wrap(label.to_string(), Tokens::ui(11.0), t.text).size().x + 14.0;+ let (shown, shown_tip) = (crate::i18n::tr(label), crate::i18n::tr(tip));+ let w = p.layout_no_wrap(shown.to_string(), Tokens::ui(11.0), t.text).size().x + 14.0;// Once one button overflows, the rest follow it into the menu (they keep their order).if !bar.hidden.is_empty() || bar.x + w > bar.limit {+ // The menu translates these English labels when it draws them; automation keeps them.bar.hidden.push((id.to_string(), label.to_string(), on, tip.to_string()));return bar.chosen.as_deref() == Some(id);}diff --cc crates/ui-egui/src/panels/project.rsindex 17861fc00,1944f333f..6367acb0b--- a/crates/ui-egui/src/panels/project.rs+++ b/crates/ui-egui/src/panels/project.rs@@@ -553,19 -566,361 +566,361 @@@ fn draw_header(app: &mut EffectcraftApp}column_menu(app, &resp);}- let hresp = ui.interact(Rect::from_min_max(pos2(x, hdr.min.y), hdr.max), egui::Id::unique("proj-hdr-rest"), Sense::CLICK);+ let hresp = ui.interact(Rect::from_min_max(pos2(end_x, hdr.min.y), hdr.max), egui::Id::unique("proj-hdr-rest"), Sense::CLICK);column_menu(app, &hresp);app.auto.add("project.columns", hdr, "Columns (right-click to show or hide)");- // Rows.- let footer_h = 28.0;- let list = Rect::from_min_max(pos2(rect.min.x, hdr.max.y), pos2(rect.max.x, rect.max.y - footer_h));- let lp = p.with_clip_rect(list);- // The list's empty area (under the rows and the scroll bar, which take their own clicks):- // a click deselects, a drag draws a selection box, a double-click imports, as in After- // Effects (File ▸ Import ▸ File...).- // Not a Tab stop: the keyboard reaches the rows, and nothing else here takes a key.- let empty = ui.interact(list, egui::Id::unique("proj-empty"), Sense::CLICK | Sense::DRAG);- app.auto.add("project.empty", list, "Double-click to import files; drag to select items; right-click for project actions");+ }++ /// An item row's context menu: Composition Settings, Delete, Rename, Duplicate, labels and the+ /// footage commands.+ fn item_menu(+ app: &mut EffectcraftApp,+ ui: &mut egui::Ui,+ ctx: &egui::Context,+ it: &effectcraft_engine::project::Item,+ id: ItemId,+ selected: bool,+ actions: &mut Vec<(String, serde_json::Value)>,+ ) {+ let t = app.tokens;+ let footage = matches!(it.kind, ItemKind::Footage(_));+ // First on a comp, as in After Effects; for this comp, not the viewer's (#1058).+ if matches!(it.kind, ItemKind::Comp(_)) && ui.button(crate::i18n::tr("Composition Settings…")).clicked() {+ actions.push(("comp.settings".into(), json!({"comp": id.0})));+ ui.close();+ }+ if ui.button(crate::i18n::tr("Delete")).clicked() {+ actions.push(("project.delete".into(), json!({"items": targets(app, id, selected)})));+ ui.close();+ }+ if matches!(it.kind, ItemKind::Comp(_)) && ui.button(crate::i18n::tr("Open Composition")).clicked() {+ actions.push(("comp.open".into(), json!({"comp": id.0})));+ ui.close();+ }+ if ui.button(crate::i18n::tr("Rename")).clicked() {+ ctx.data_mut(|d| d.insert_temp::<Editing>(edit_id(), (id.0, "name".into(), it.name.clone())));+ ui.close();+ }+ let duplicate_items = targets(app, id, selected);+ // Like Edit > Duplicate: folders disable the whole operation, including mixed selections.+ let can_duplicate = !duplicate_items.is_empty() && duplicate_items.iter().all(|id| app.session.project.item(ItemId(*id)).is_some_and(|i| !i.is_folder()));+ let mut duplicate = egui::Button::new(crate::i18n::tr("Duplicate"));+ if let Some(shortcut) = app.session.shortcuts().shortcut_of("edit.duplicate", &serde_json::Value::Null) {+ duplicate = duplicate.shortcut_text(crate::menus::shortcut_text(shortcut));+ }+ let response = ui.add_enabled(can_duplicate, duplicate);+ app.auto.add("project.context.duplicate", response.rect, "Duplicate");+ if response.clicked() {+ actions.push(("project.duplicate".into(), json!({"items": duplicate_items})));+ ui.close();+ }+ if it.parent.is_some() && ui.button(crate::i18n::tr("Move to Project Root")).clicked() {+ actions.push(("project.move".into(), json!({"items": targets(app, id, selected), "folder": null})));+ ui.close();+ }+ if !it.is_folder() && ui.button(crate::i18n::tr("Add to Composition")).clicked() {+ actions.push(("layer.addItem".into(), json!({"item": id.0})));+ ui.close();+ }+ // File ▸ New Comp from Selection on the selection (the right-clicked row joins it+ // above): several items ask how in its dialog, as in After Effects (#360).+ if ui.button(crate::i18n::tr("New Comp from Selection")).clicked() {+ actions.push(("file.newCompFromSelection".into(), json!({})));+ ui.close();+ }+ // File ▸ Replace Footage ▸ With Precomposition: every layer using the item uses a+ // new composition holding it instead. The label says how many layers that changes.+ let uses: usize = app.session.project.item_users(id).iter().map(|(_, n)| n).sum();+ let label = match uses {+ 0 => crate::i18n::tr("Replace with Precomposition").to_owned(),+ 1 => format!("{} ({})", crate::i18n::tr("Replace with Precomposition"), crate::i18n::tr("used once")),+ n => format!("{} ({})", crate::i18n::tr("Replace with Precomposition"), crate::i18n::tr_args("used {} times", &[&n])),+ };+ if (footage || matches!(it.kind, ItemKind::Solid(_))) && ui.button(label).clicked() {+ actions.push(("file.replaceWithPrecomp".into(), json!({"item": id.0})));+ ui.close();+ }+ ui.separator();+ ui.menu_button(crate::i18n::tr("Label"), |ui| {+ for l in Label::ALL {+ if widgets::label_entry(ui, l, &app.session.prefs.label_name(l), l == it.label, &t).clicked() {+ actions.push(("project.setLabel".into(), json!({"items": targets(app, id, selected), "label": label_index(l)})));+ ui.close();+ }+ }+ });+ // Footage: the File menu's footage commands (Interpret Footage, Replace Footage…).+ if footage {+ let mut chosen = None;+ crate::menus::submenu_at(app, ui, &["File", "Interpret Footage"], &mut chosen);+ crate::menus::submenu_at(app, ui, &["File", "Replace Footage"], &mut chosen);+ crate::menus::entry_for(app, ui, "file.reloadFootage", &mut chosen);+ crate::menus::entry_for(app, ui, "file.revealInFinder", &mut chosen);+ actions.extend(chosen);+ }+ }++ /// The inline rename / comment field over `cell` when it is item `id`'s `field` being edited;+ /// returns whether it took the cell.+ fn cell_edit(+ app: &mut EffectcraftApp,+ ui: &mut egui::Ui,+ actions: &mut Vec<(String, serde_json::Value)>,+ editing: &Option<Editing>,+ id: u64,+ field: &str,+ cell: Rect,+ ) -> bool {+ let ctx = ui.ctx().clone();+ let Some((eid, ef, mut buf)) = editing.clone().filter(|(e, f, _)| *e == id && f == field) else { return false };+ let mut child = ui.new_child(egui::UiBuilder::new().max_rect(cell));+ // The field keeps Tab (egui would move the keyboard to the next widget, where Enter no+ // longer renames, #881): Tab commits like Enter and gives the keyboard back to the panel.+ let filter = egui::EventFilter { tab: true, horizontal_arrows: true, vertical_arrows: true, ..Default::default() };+ let resp = child.add(egui::TextEdit::singleline(&mut buf).desired_width(cell.width()).font(Tokens::ui(12.0)).event_filter(filter));+ app.auto.add(&format!("project.item.{}.{field}Edit", id), cell, field);+ let tab = resp.has_focus() && ctx.input(|i| i.key_pressed(egui::Key::Tab));+ if tab {+ resp.surrender_focus();+ }+ if resp.lost_focus() || tab {+ ctx.data_mut(|d| d.remove::<Editing>(edit_id()));+ if !ctx.input(|i| i.key_pressed(egui::Key::Escape)) {+ let (cmd, params) = if ef == "name" {+ ("project.rename", json!({"item": eid, "name": buf}))+ } else {+ ("project.setComment", json!({"items": [eid], "comment": buf}))+ };+ actions.push((cmd.into(), params));+ }+ } else {+ widgets::keep_focus(&ctx, &resp, &buf);+ ctx.data_mut(|d| d.insert_temp::<Editing>(edit_id(), (eid, ef, buf)));+ }+ true+ }++ /// A click on item `id`'s row: plain selects it, Shift extends from the anchor and Cmd toggles.+ fn select_click(app: &mut EffectcraftApp, ui: &egui::Ui, ctx: &egui::Context, id: ItemId, rows: &[(ItemId, usize)]) {+ let m = ui.input(|i| i.modifiers);+ let anchor_key = anchor_id();+ ctx.data_mut(|d| d.insert_temp(cursor_id(), id));+ let anchor = ctx.data(|d| d.get_temp::<ItemId>(anchor_key)).or_else(|| app.session.state.project_selection.first().copied());+ if m.shift+ && let Some(a) = anchor.and_then(|a| rows.iter().position(|(i, _)| *i == a))+ {+ let b = rows.iter().position(|(i, _)| *i == id).unwrap_or(a);+ app.session.state.project_selection = rows.get(a.min(b)..=a.max(b)).unwrap_or_default().iter().map(|(i, _)| *i).collect();+ } else if m.command {+ if app.session.state.project_selection.contains(&id) {+ app.session.state.project_selection.retain(|i| *i != id);+ } else {+ app.session.state.project_selection.push(id);+ }+ ctx.data_mut(|d| d.insert_temp(anchor_key, id));+ } else {+ app.session.state.project_selection = vec![id];+ ctx.data_mut(|d| d.insert_temp(anchor_key, id));+ }+ }++ /// Double-click opens the item, as in After Effects: a comp in its Timeline and the viewer, a+ /// folder toggles, footage (not data) and solids open in the Footage panel.+ fn open_item(app: &mut EffectcraftApp, it: &effectcraft_engine::project::Item, id: ItemId, actions: &mut Vec<(String, serde_json::Value)>) {+ match &it.kind {+ ItemKind::Comp(_) => actions.push(("comp.open".into(), json!({"comp": id.0}))),+ ItemKind::Folder if !app.ui.project_open_folders.remove(&id.0) => {+ app.ui.project_open_folders.insert(id.0);+ }+ // Footage (not data) and solids open in the Footage panel.+ ItemKind::Footage(f) if f.kind != effectcraft_engine::project::FootageKind::Data => actions.push(("footage.open".into(), json!({"item": id.0}))),+ ItemKind::Solid(_) => actions.push(("footage.open".into(), json!({"item": id.0}))),+ _ => {}+ }+ }++ /// What the pointer is doing over the list: the item being dragged, the row under it, whether it+ /// is over the list at all.+ struct DropState {+ dragging: Option<u64>,+ row: Option<ItemId>,+ hovering: bool,+ }++ /// Dragging an item or files over the list: drop outlines, moving items into folders, importing+ /// files and the drag ghost.+ fn drop_targets(app: &mut EffectcraftApp, ctx: &egui::Context, lp: &egui::Painter, list: Rect, ds: DropState, actions: &mut Vec<(String, serde_json::Value)>) {+ let t = app.tokens;+ let DropState { dragging, row, hovering } = ds;+ // Dropping a dragged item on the list: into the folder under the pointer (or the folder of+ // the item under it), or the project root below the rows.+ if let Some(iid) = dragging+ && hovering+ {+ if row.is_none() {+ lp.rect_stroke(list.shrink(1.0), 0.0, Stroke::new(1.0, t.accent.gamma_multiply(0.6)), egui::StrokeKind::Inside);+ }+ if ctx.input(|i| i.pointer.any_released()) && row != Some(ItemId(iid)) {+ let folder = drop_folder(&app.session.project, row);+ let cur = app.session.project.item(ItemId(iid)).and_then(|i| i.parent);+ if folder != cur {+ let moving: Vec<u64> = if app.session.state.project_selection.contains(&ItemId(iid)) {+ app.session.state.project_selection.iter().map(|i| i.0).collect()+ } else {+ vec![iid]+ };+ actions.push(("project.move".into(), json!({"items": moving, "folder": folder.map(|f| f.0)})));+ if let Some(f) = folder {+ app.ui.project_open_folders.insert(f.0);+ }+ }+ egui::DragAndDrop::clear_payload(ctx);+ }+ }+ // Files dragged from the Media Browser: import.+ if let Some(DragPayload::Files(paths)) = egui::DragAndDrop::payload::<DragPayload>(ctx).as_deref()+ && hovering+ {+ lp.rect_stroke(list.shrink(1.0), 0.0, Stroke::new(1.0, t.accent.gamma_multiply(0.6)), egui::StrokeKind::Inside);+ if ctx.input(|i| i.pointer.any_released()) {+ actions.push(("mediaBrowser.import".into(), json!({"paths": paths})));+ egui::DragAndDrop::clear_payload(ctx);+ }+ }+ // Drag ghost.+ if let Some(DragPayload::Item(iid)) = egui::DragAndDrop::payload::<DragPayload>(ctx).as_deref()+ && let Some(pos) = ctx.pointer_hover_pos()+ && let Some(it) = app.session.project.item(ItemId(*iid))+ {+ let painter = ctx.layer_painter(egui::LayerId::new(egui::Order::Tooltip, egui::Id::unique("dnd-ghost")));+ let g = painter.layout_no_wrap(it.name.clone(), Tokens::ui(12.0), t.text);+ let r = Rect::from_min_size(pos + vec2(12.0, 8.0), g.size() + vec2(16.0, 8.0));+ painter.rect_filled(r, 4.0, Color32::from_rgba_premultiplied(40, 40, 40, 230));+ painter.galley(r.min + vec2(8.0, 4.0), g, t.text);+ }+ }++ /// The footer: Interpret Footage, New Folder, New Composition, the colour depth and the trash.+ fn footer(app: &mut EffectcraftApp, ui: &mut egui::Ui, p: &egui::Painter, foot: Rect, actions: &mut Vec<(String, serde_json::Value)>) {+ let t = app.tokens;+ let ctx = ui.ctx().clone();+ p.line_segment([foot.left_top(), foot.right_top()], Stroke::new(1.0, t.separator));+ let mut x = foot.min.x + 8.0;+ for (icon, id, tip) in [+ (Icon::Gear, "interpret", "Interpret Footage"),+ (Icon::NewFolder, "newFolder", "Create a new Folder"),+ (Icon::NewComp, "newComp", "Create a new Composition"),+ ] {+ let r = Rect::from_min_size(pos2(x, foot.min.y + 3.0), vec2(22.0, 22.0));- let resp = widgets::icon_button(ui, r, icon, false, &t, egui::Id::unique(("pfoot", id))).on_hover_text(tip);++ let resp = widgets::icon_button(ui, r, icon, false, &t, egui::Id::unique(("pfoot", id))).on_hover_text(crate::i18n::tr(tip));+ app.auto.add(&format!("project.{id}"), r, tip);+ resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, crate::i18n::tr(tip)));+ if resp.clicked() {+ let footage =+ app.session.state.project_selection.first().and_then(|i| app.session.project.item(*i)).is_some_and(|i| matches!(i.kind, ItemKind::Footage(_)));+ match id {+ "newComp" => crate::panels::dialogs::open_new_comp(app),+ "newFolder" => actions.push(("project.newFolder".into(), json!({}))),+ _ if footage => actions.push(("file.interpretFootage".into(), json!({}))),+ _ => 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();+ let dr = Rect::from_min_size(pos2(x + 4.0, foot.min.y + 5.0), vec2(48.0, 18.0));+ let dresp = ui.interact(dr, egui::Id::unique("bpc"), Sense::click());+ p.text(dr.center(), Align2::CENTER_CENTER, depth, Tokens::ui(11.5), if dresp.hovered() { t.text } else { t.text_dim });+ app.auto.add("project.bitDepth", dr, depth);+ dresp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, crate::i18n::tr_args("Project color depth: {}", &[&depth])));+ // Click cycles 8/16/32 bpc; Alt-click opens Project Settings (as in After Effects).+ if dresp.clicked() {+ if ui.input(|i| i.modifiers.alt) {+ actions.push(("file.projectSettings".into(), json!({})));+ } else {+ actions.push(("file.cycleBitDepth".into(), json!({})));+ }+ }+ dresp.on_hover_text(crate::i18n::tr("Project color depth: click to cycle 8/16/32 bpc, Alt-click for Project Settings"));+ let tr = Rect::from_min_size(pos2(foot.max.x - 30.0, foot.min.y + 3.0), vec2(22.0, 22.0));+ let trash =+ widgets::icon_button(ui, tr, Icon::Trash, false, &t, egui::Id::unique("ptrash")).on_hover_text(crate::i18n::tr("Delete selected project items"));+ trash.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, crate::i18n::tr("Delete selected project items")));+ if trash.clicked() && !app.session.state.project_selection.is_empty() {+ actions.push(("project.delete".into(), json!({})));+ }+ app.auto.add("project.delete", tr, "Delete");+ }++ /// The optional columns of a row (type, size, duration, fps, path, comment). Returns the comment+ /// cell's response so its clicks select the row and open its context menu.+ fn optional_cells(+ app: &mut EffectcraftApp,+ ui: &mut egui::Ui,+ g: &RowGeom,+ it: &effectcraft_engine::project::Item,+ cl: &Columns,+ editing: &Option<Editing>,+ actions: &mut Vec<(String, serde_json::Value)>,+ ) -> Option<egui::Response> {+ let t = app.tokens;+ let ctx = ui.ctx().clone();+ let RowGeom { lp, list, r, .. } = *g;+ let mut extra = None;+ for (key, _, cx, w) in cl.cols.iter().skip(2) {+ let cell = cl.opt_clip(Rect::from_min_size(pos2(*cx, r.min.y), vec2(*w, r.height())).intersect(list));+ if cell.width() <= 0.0 {+ continue;+ }+ 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(),+ "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(),+ "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, actions, editing, it.id.0, "comment", cr) {+ continue;+ }+ let cresp = ui.interact(cell, egui::Id::unique(("pcomment", it.id.0)), Sense::CLICK);+ app.auto.add(&format!("project.item.{}.comment", it.id.0), cell, &it.comment);+ cresp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Unknown, true, crate::i18n::tr_args("Comment of {}: {}", &[&it.name, &it.comment])));+ if cresp.double_clicked() {+ ctx.data_mut(|d| d.insert_temp::<Editing>(edit_id(), (it.id.0, "comment".into(), it.comment.clone())));+ } else {+ // Other clicks select the row and open its context menu.+ extra = Some(cresp);+ }+ it.comment.clone()+ }+ _ => String::new(),+ };+ let align = if *key == "fps" { Align2::RIGHT_CENTER } else { Align2::LEFT_CENTER };+ let tx = if *key == "fps" { cx + w - 6.0 } else { *cx };+ cp.text(pos2(tx, r.center().y), align, txt, Tokens::ui(11.5), t.text_dim);+ }+ extra+ }++ /// Shift+wheel / trackpad over the list scrolls the optional columns sideways.+ fn hscroll_wheel(app: &mut EffectcraftApp, ui: &egui::Ui, list: Rect, overflow: f32) {if overflow > 0.0 && ui.rect_contains_pointer(list) {let (dx, dy, shift) = ui.input(|i| (i.smooth_scroll_delta.x, i.smooth_scroll_delta.y, i.modifiers.shift));let d = if dx.abs() > 0.0 {