Project panel: Composition Settings… in a comp's right-click menu (fixes #1058)

First in the menu, as in After Effects, and for the right-clicked comp rather than the one in the viewer: the dialog keeps the comp it edits and OK passes it to comp.settings. comp.settings with only {"comp": id} opens the dialog on that comp.
This commit is contained in:
Marco Arnulfo
2026-10-12 18:54:56 +02:00
parent 470ea7a3af
commit 7304f4c672
5 changed files with 81 additions and 2 deletions
+10
View File
@@ -271,6 +271,13 @@ fn no_params(p: &Value) -> bool {
p.as_object().is_none_or(|m| m.is_empty())
}
/// `{"comp": id}` and nothing else: Composition Settings opens on that comp instead of
/// applying no settings to it.
fn only_comp(p: &Value) -> Option<effectcraft_engine::project::ItemId> {
let m = p.as_object().filter(|m| m.len() == 1)?;
m.get("comp")?.as_u64().map(effectcraft_engine::project::ItemId)
}
/// Execute a UI or engine command by id.
pub fn invoke(app: &mut EffectcraftApp, ctx: &egui::Context, id: &str, params: Value) -> Result<Value, String> {
// Layer ▸ New ▸ Text (menu, shortcut, context menus) puts an insertion point in the centre of
@@ -647,6 +654,9 @@ pub fn invoke(app: &mut EffectcraftApp, ctx: &egui::Context, id: &str, params: V
"app.home" => app.ui.start_screen = !app.ui.start_screen,
"app.newComp" | "comp.new" if no_params(&params) => crate::panels::dialogs::open_new_comp(app),
"app.compSettings" | "comp.settings" if no_params(&params) => crate::panels::dialogs::open_comp_settings(app)?,
"app.compSettings" | "comp.settings" if only_comp(&params).is_some() => {
crate::panels::dialogs::open_comp_settings_for(app, only_comp(&params).ok_or("missing `comp`")?)?
}
"app.solidSettings" | "layer.newSolid" if no_params(&params) => crate::panels::dialogs::open_new_solid(app)?,
"keys.velocity" if no_params(&params) => crate::panels::key_dialogs::open_velocity(app)?,
"keys.interpolation" if no_params(&params) => crate::panels::key_dialogs::open_interpolation(app)?,