665bfac0b339
panel.rs
use super::common::{Actions, PARAM_NAME_X, ROW, effect_active, prune_lock, shown_layer, shown_layer_id};
use super::editors::{curves_editor, editor_height, histogram_only, levels_editor, object_matte_editor, roto_editor, warp_editor};
use super::rows::{FxScope, group_rows, toggle_closed};
use super::{Align2, Color32, EffectcraftApp, EvalCtx, GroupKind, Icon, Layer, PropGroup, Rect, Sense, Stroke, Tokens, json, pos2, vec2, widgets};
use crate::dock::{PanelKind, WorkspaceExt as _};
/// Plain arrows in Effect Controls, as in After Effects, before their layer nudge runs: Right /
/// Left expand / collapse the selected effects, and Down / Up select the next / previous effect
/// in the stacking order, from the lowest / highest selected one, stopping at the last / first.
/// Only while Effect Controls has the focus and is on screen: the front tab of its frame, drawn
/// last frame (a maximized frame hides every other frame and every floating window), not behind
/// Home. Only the effect headers selected on the layer the panel shows (the locked one when it is
/// locked) count: with none the arrows still nudge.
pub(crate) fn handle_arrow_key(app: &mut EffectcraftApp, ctx: &egui::Context, key: egui::Key) -> bool {
use egui::Key::{ArrowDown, ArrowLeft, ArrowRight, ArrowUp};
let panel = PanelKind::EffectControls;
if app.ui.focused != panel
|| app.ui.start_screen
|| app.session.state.text_edit.is_some()
|| !app.ui.dock.is_visible(panel)
|| !app.dock_rects.iter().any(|(p, _)| *p == panel)
|| !matches!(key, ArrowLeft | ArrowRight | ArrowUp | ArrowDown)
{
return false;
}
let Some(layer_id) = shown_layer_id(app) else { return false };
let Some(effects) = app.session.active_comp().and_then(|c| c.layer(layer_id)).and_then(|l| l.effects()) else { return false };
let headers: Vec<u64> = effects.groups().filter(|g| matches!(&g.kind, GroupKind::Effect { .. })).map(|g| g.uid).collect();
let selected = &app.session.state.selected_props;
let picked: Vec<usize> = headers.iter().enumerate().filter(|(_, u)| selected.contains(&(layer_id, **u))).map(|(i, _)| i).collect();
let (Some(&top), Some(&bottom)) = (picked.first(), picked.last()) else { return false };
match key {
ArrowUp | ArrowDown => {
// Clamped at the ends, where the key still doesn't nudge the layer.
let to = if key == ArrowUp { top.saturating_sub(1) } else { bottom.saturating_add(1).min(headers.len().saturating_sub(1)) };
if let Some(&uid) = headers.get(to) {
// A selection, as a click on the header makes it: no undo step.
app.session.state.selected_props = vec![(layer_id, uid)];
reveal_effect(ctx, uid);
}
}
_ => {
for uid in picked.iter().filter_map(|i| headers.get(*i)) {
if key == ArrowLeft {
app.ui.fx_closed.insert(*uid);
} else {
app.ui.fx_closed.remove(uid);
}
}
}
}
true
}
/// The effect header the next Effect Controls pass scrolls into view.
fn reveal_id() -> egui::Id {
egui::Id::unique("ec-reveal")
}
/// Scroll Effect Controls so effect `uid`'s header is in view, once it has been laid out.
fn reveal_effect(ctx: &egui::Context, uid: u64) {
ctx.data_mut(|d| d.insert_temp(reveal_id(), uid));
ctx.request_repaint();
}
// ---------------------------------------------------------------------------------------------
/// Open the rename field on effect `uid` (Enter with the effect selected). It takes the keyboard,
/// its whole name selected, the pass it is first drawn.
pub fn start_rename(ctx: &egui::Context, uid: u64, name: &str) {
let id = egui::Id::unique(("ec-rename", uid));
ctx.data_mut(|d| {
d.insert_temp(id, name.to_string());
d.insert_temp(id.with("start"), true);
});
}
/// Where an effect header's parts sit, for its rename field.
struct EffectHdr<'a> {
g: &'a PropGroup,
shown: &'a str,
r: Rect,
tw: Rect,
reset: Rect,
rename_id: egui::Id,
layer_id: u64,
}
/// The effect header's name field while renaming: Enter or blur commits, Escape cancels.
fn rename_field(app: &mut EffectcraftApp, ui: &mut egui::Ui, h: &EffectHdr, mut value: String, actions: &mut Actions) {
let EffectHdr { g, shown, r, tw, reset, rename_id, layer_id } = *h;
let ctx = ui.ctx().clone();
let name_rect = Rect::from_min_max(pos2(tw.max.x + 6.0, r.min.y + 2.0), pos2(reset.min.x - 6.0, r.max.y - 2.0));
// The field opens with the name the header draws (in the interface language), however it
// was opened, so committing it untouched is not a rename.
let opening = ctx.data_mut(|d| d.remove_temp::<bool>(rename_id.with("start"))).is_some();
if opening {
value = shown.to_string();
}
let response = ui.put(name_rect, egui::TextEdit::singleline(&mut value).id(rename_id.with("field")).font(Tokens::semibold(12.0)));
app.auto.add(&format!("effectControls.effect.{}.nameEdit", g.uid), name_rect, "Effect name");
// Focus the field the frame it first exists, its whole name selected so typing replaces it:
// focusing an id not yet on screen leaves the accessibility tree with a focus it doesn't
// contain. The Enter that opened it (it is drawn in that pass) doesn't also commit it.
if opening {
widgets::select_all(&ctx, response.id, &value);
response.request_focus();
ctx.data_mut(|d| d.insert_temp(rename_id, value));
return;
}
// Escape cancels. egui drops the field's focus on Escape in the same frame, so the
// key is checked on the focus being lost as well as held.
let escape = (response.has_focus() || response.lost_focus()) && ui.input(|i| i.key_pressed(egui::Key::Escape));
let commit = response.lost_focus() || (response.has_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter)));
if escape || commit {
ctx.data_mut(|d| d.remove::<String>(rename_id));
// The field opens with the drawn name, so committing it unchanged is not a rename.
if !escape && !value.trim().is_empty() && value != shown {
actions.push(("prop.renameGroup".into(), json!({"layer": layer_id, "prop": g.uid, "name": value})));
}
} else {
ctx.data_mut(|d| d.insert_temp(rename_id, value));
}
}
struct EditorCx<'a> {
bp: &'a egui::Painter,
layer: &'a Layer,
ectx: &'a EvalCtx<'a>,
}
/// An effect's custom editor (curves, levels, roto...), or the histogram-only fallback.
fn effect_editor(app: &mut EffectcraftApp, ui: &mut egui::Ui, cx: &EditorCx, g: &PropGroup, er: Rect, actions: &mut Actions) {
let GroupKind::Effect { effect } = &g.kind else { return };
match effect.as_str() {
"ec.color.curves" => curves_editor(app, ui, cx.bp, cx.layer, g, cx.ectx, er, actions),
effectcraft_engine::effects::warp_stab::ID => warp_editor(app, ui, cx.bp, cx.layer, g, er, actions),
effectcraft_engine::effects::camera_tracker::ID => crate::panels::camera_tracker_ui::editor(app, ui, cx.bp, cx.layer, g, er, actions),
effectcraft_engine::effects::roto::ID => roto_editor(app, ui, cx.bp, cx.layer, g, er, actions),
effectcraft_engine::effects::object_matte::ID => object_matte_editor(app, ui, cx.bp, cx.layer, g, er, actions),
"ec.color.levels" | "ec.color.levelsic" => levels_editor(app, ui, cx.bp, cx.layer, g, effect, cx.ectx, er, actions),
crate::panels::fx_editors::GLOW | crate::panels::fx_editors::RESHAPE | crate::panels::fx_editors::EXTRACTOR => {
crate::panels::fx_editors::header_editor(app, ui, cx.bp, cx.layer, g, effect, cx.ectx, er, actions)
}
_ => histogram_only(app, ui, cx.bp, g, er),
}
}
struct ReorderDrag<'a> {
tops: &'a [(u64, f32)],
y: f32,
du: u64,
drag_id: egui::Id,
layer_id: u64,
}
/// Drag an effect header to reorder: the insertion line between headers, and the drop.
fn reorder_drag(ctx: &egui::Context, bp: &egui::Painter, body: Rect, t: &Tokens, st: &ReorderDrag, actions: &mut Actions) {
let ReorderDrag { tops, y, du, drag_id, layer_id } = *st;
if let Some(pos) = ctx.pointer_interact_pos() {
let slot = tops.iter().position(|(_, ty)| pos.y < *ty + (ROW + 2.0) / 2.0).unwrap_or(tops.len());
let ly = tops.get(slot).map(|(_, ty)| *ty).unwrap_or(y - 4.0);
bp.line_segment([pos2(body.min.x + 4.0, ly), pos2(body.max.x - 4.0, ly)], Stroke::new(2.0, t.accent));
if ctx.input(|i| i.pointer.any_released()) {
if let Some(from) = tops.iter().position(|(u, _)| *u == du) {
let to = if slot > from { slot - 1 } else { slot };
if to != from {
actions.push(("effect.reorder".into(), json!({"layer": layer_id, "effect": du, "index": to + 1})));
}
}
ctx.data_mut(|d| d.remove::<u64>(drag_id));
}
}
if !ctx.input(|i| i.pointer.any_down()) {
ctx.data_mut(|d| d.remove::<u64>(drag_id));
}
}
/// Drop effects and animation presets here.
fn drop_payload(ui: &egui::Ui, rect: Rect, p: &egui::Painter, t: &Tokens, layer_id: u64, actions: &mut Actions) {
let ctx = ui.ctx().clone();
if let Some(payload) = egui::DragAndDrop::payload::<crate::panels::DragPayload>(&ctx)
&& ui.rect_contains_pointer(rect)
&& let Some((id, params)) = match payload.as_ref() {
crate::panels::DragPayload::Effect(e) => Some(("effect.apply", json!({"effect": e, "layers": [layer_id]}))),
crate::panels::DragPayload::Preset { preset, .. } => Some(preset.apply_to(layer_id)),
_ => None,
}
{
p.rect_stroke(rect, 0.0, Stroke::new(2.0, t.accent), egui::StrokeKind::Inside);
if ctx.input(|i| i.pointer.any_released()) {
actions.push((id.into(), params));
egui::DragAndDrop::clear_payload(&ctx);
}
}
}
/// A plug-in effect whose last render failed (an effect helper that stopped, ...): a warning sign
/// at `at`, after the effect's name, with the message on hover. The frame shows the input as is.
fn render_error_mark(app: &mut EffectcraftApp, ui: &mut egui::Ui, bp: &egui::Painter, effect: &str, g: &PropGroup, at: egui::Pos2) {
let Some(err) = effectcraft_engine::effects::plugin::plugin_error(effect) else { return };
let wr = bp.text(at, Align2::LEFT_CENTER, "⚠", Tokens::semibold(12.0), app.tokens.warning);
let resp = ui.interact(wr.expand(2.0), egui::Id::unique(("ec-fx-error", g.uid)), Sense::hover());
app.auto.add(&format!("effectControls.effect.{}.error", g.uid), wr, &err);
resp.on_hover_text(err);
ui.ctx().request_repaint_after(std::time::Duration::from_millis(500));
}
fn about_button(app: &mut EffectcraftApp, ui: &mut egui::Ui, bp: &egui::Painter, t: &Tokens, effect: &str, g: &PropGroup, r: Rect) {
// About…: the effect's name and category (AE's About dialog).
let about = Rect::from_min_size(pos2(r.max.x - 50.0, r.center().y - 9.0), vec2(44.0, 18.0));
let aresp = ui.interact(about, egui::Id::unique(("ec-about", g.uid)), Sense::click());
bp.text(about.center(), Align2::CENTER_CENTER, crate::i18n::tr("About..."), Tokens::ui(11.5), if aresp.hovered() { t.hot_text } else { t.text_dim });
app.auto.add(&format!("effectControls.effect.{}.about", g.uid), about, "About");
let apop = egui::Id::unique(("ec-about-pop", g.uid));
if aresp.clicked() {
widgets::open_popup(ui, apop);
}
if let Some(spec) = effectcraft_engine::effects::find(effect) {
let lines = vec![
crate::i18n::effects::name(spec.id, spec.name),
format!("Category: {}", crate::i18n::effects::category(spec.category)),
"EffectCraft built-in effect (MIT OR Apache-2.0)".to_string(),
];
let _ = widgets::popup_menu(ui, apop, about.left_bottom(), &lines, None);
}
}
/// The Effect Controls panel for the selected layer (or the layer the panel is locked to, see
/// `common::shown_layer_id`): a header with the comp and layer names, then
/// one header per effect (Fx toggle, twirl, rename, Reset, About, label bar, reorder drag and its
/// right-click menu) followed by that effect's custom editor and its property rows. Dragging
/// effects or presets onto the panel applies them; a right-click on empty space opens the Effect
/// menu. The rows read from a snapshot of the project, and every edit is queued and run through
/// [`crate::menus::invoke`], with failures reported in `app.ui.status`.
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();
// A locked layer that was deleted unlocks the panel, which then follows the selection.
prune_lock(app);
let Some(layer) = shown_layer(app) else {
p.text(rect.center(), Align2::CENTER_CENTER, crate::i18n::tr("Select a layer to see its effects"), Tokens::ui(12.0), t.text_faint);
return;
};
let Some(cid) = app.session.active_comp_id() else { return };
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();
let ectx = EvalCtx {
project: &snap_project,
comp_id: cid,
comp: &comp,
time: app.session.time(),
expr: snap_expr.as_deref(),
footage: None,
property_overrides: &[],
media_overrides: &[],
reads: None,
};
let hdr = Rect::from_min_size(rect.min, vec2(rect.width(), 24.0));
p.text(pos2(hdr.min.x + 10.0, hdr.center().y), Align2::LEFT_CENTER, format!("{} • {}", comp_name, layer.name), Tokens::ui(11.5), t.text_dim);
p.line_segment([hdr.left_bottom(), hdr.right_bottom()], Stroke::new(1.0, t.separator));
let body = Rect::from_min_max(pos2(rect.min.x, hdr.max.y), rect.max);
let scroll = widgets::PanelScroll::begin(ui, egui::Id::unique("ec-scroll"), body);
let body = scroll.content;
let mut y = body.min.y + 4.0 - scroll.offset;
let mut actions: Actions = vec![];
let bp = p.with_clip_rect(body);
let fx: Vec<PropGroup> = layer.effects().map(|f| f.groups().cloned().collect()).unwrap_or_default();
if fx.is_empty() {
bp.text(
pos2(body.center().x, body.min.y + 40.0),
Align2::CENTER_CENTER,
crate::i18n::tr("No effects. Drag one from Effects & Presets."),
Tokens::ui(12.0),
t.text_faint,
);
}
// Clicking empty space deselects the effects.
let bg = ui.interact(body, egui::Id::unique("ec-bg"), Sense::click());
if bg.clicked() {
app.session.state.selected_props.retain(|(l, u)| !(*l == layer.id && fx.iter().any(|g| effect_active(g, layer.id, &[(*l, *u)]))));
}
let has_clip = !app.session.state.effect_clipboard.is_empty();
let drag_id = egui::Id::unique("ec-drag-effect");
let dragging: Option<u64> = ctx.data(|d| d.get_temp(drag_id));
// Header tops, for drag-to-reorder.
let mut tops: Vec<(u64, f32)> = vec![];
for (fi, g) in fx.iter().enumerate() {
let GroupKind::Effect { effect } = &g.kind else { continue };
// The header draws the effect's name in the interface language; the automation labels
// below keep the property tree's name, which is the registry's English name (#821).
let shown = crate::i18n::effects::group(effect, &g.name);
let r = Rect::from_min_size(pos2(body.min.x, y), vec2(body.width(), ROW + 2.0));
tops.push((g.uid, r.min.y));
y += ROW + 2.0;
let open = !app.ui.fx_closed.contains(&g.uid);
let selected = app.session.state.selected_props.iter().any(|(l, u)| *l == layer.id && *u == g.uid);
let active = effect_active(g, layer.id, &app.session.state.selected_props);
bp.rect_filled(r, 0.0, if active { t.fx_header_active } else { t.fx_header });
// The effect's colour label (26.5): a bar on the header's left edge.
if let Some(lab) = g.label.filter(|l| *l != effectcraft_engine::color::Label::None) {
let [lr, lg, lb] = app.session.prefs.label_rgb(lab);
bp.rect_filled(Rect::from_min_size(r.min, vec2(4.0, r.height())), 0.0, Color32::from_rgb(lr, lg, lb));
app.auto.add(
&format!("effectControls.effect.{}.label", g.uid),
Rect::from_min_size(r.min, vec2(4.0, r.height())),
&app.session.prefs.label_name(lab),
);
}
let fxr = Rect::from_center_size(pos2(r.min.x + 14.0, r.center().y), vec2(16.0, 16.0));
if widgets::icon_toggle(ui, fxr, Icon::Fx, g.enabled, &t, egui::Id::unique(("ec-fx", g.uid)), Sense::click()).clicked() {
actions.push(("effect.toggle".into(), json!({"layer": layer.id.0, "effect": g.uid})));
}
app.auto.add(&format!("effectControls.effect.{}.fx", g.uid), fxr, &g.name);
let tw = Rect::from_center_size(pos2(r.min.x + 32.0, r.center().y), vec2(12.0, 12.0));
if widgets::twirl(ui, tw, open, egui::Id::unique(("ec-tw", g.uid)), &t).clicked() {
toggle_closed(app, g, open, ui.input(|i| i.modifiers.alt || i.modifiers.command));
}
app.auto.add(&format!("effectControls.effect.{}.twirl", g.uid), tw, &g.name);
let rename_id = egui::Id::unique(("ec-rename", g.uid));
let editing: Option<String> = ctx.data(|d| d.get_temp(rename_id));
let reset = Rect::from_min_size(pos2(r.max.x - 96.0, r.center().y - 9.0), vec2(40.0, 18.0));
let hdr_cx = EffectHdr { g, shown: &shown, r, tw, reset, rename_id, layer_id: layer.id.0 };
if let Some(value) = editing.as_ref().cloned() {
rename_field(app, ui, &hdr_cx, value, &mut actions);
} else {
let name = bp.text(pos2(tw.max.x + 6.0, r.center().y), Align2::LEFT_CENTER, &shown, Tokens::semibold(12.0), t.text);
app.auto.add(&format!("effectControls.effect.{}.name", g.uid), name, &g.name);
render_error_mark(app, ui, &bp, effect, g, pos2(name.max.x + 8.0, r.center().y));
}
let rresp = ui.interact(reset, egui::Id::unique(("ec-reset", g.uid)), Sense::click());
bp.text(reset.center(), Align2::CENTER_CENTER, crate::i18n::tr("Reset"), Tokens::ui(11.5), if rresp.hovered() { t.hot_text } else { t.text_dim });
app.auto.add(&format!("effectControls.effect.{}.reset", g.uid), reset, "Reset");
if rresp.clicked() {
actions.push(("effect.reset".into(), json!({"layer": layer.id.0, "effect": g.uid})));
}
about_button(app, ui, &bp, &t, effect, g, r);
let hresp = ui.interact(
Rect::from_min_max(pos2(tw.max.x, r.min.y), pos2(reset.min.x - 4.0, r.max.y)),
egui::Id::unique(("ec-hdr", g.uid)),
if editing.is_some() { Sense::hover() } else { Sense::click_and_drag() },
);
if hresp.double_clicked() {
ctx.data_mut(|d| d.insert_temp(rename_id, shown.clone()));
ctx.data_mut(|d| d.insert_temp(rename_id.with("start"), true));
}
hresp.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, true, active, &shown));
app.auto.add(&format!("effectControls.effect.{}", g.uid), r, &g.name);
if hresp.clicked() || hresp.drag_started() || hresp.secondary_clicked() {
let (shift, command) = ui.input(|i| (i.modifiers.shift, i.modifiers.command));
if shift && hresp.clicked() {
// A range from the last effect picked, which stays the end the next range starts from.
let from = app.session.state.selected_props.iter().rev().find_map(|(l, u)| fx.iter().position(|f| *l == layer.id && f.uid == *u));
let from = from.unwrap_or(fi);
let range = fx.iter().enumerate().filter(|(i, _)| (from.min(fi)..=from.max(fi)).contains(i));
let mut picked: Vec<_> = range.filter(|(i, _)| *i != from).map(|(_, f)| (layer.id, f.uid)).collect();
picked.extend(fx.get(from).map(|f| (layer.id, f.uid)));
app.session.state.selected_props = picked;
} else if command && hresp.clicked() {
if selected {
app.session.state.selected_props.retain(|(l, u)| !(*l == layer.id && *u == g.uid));
} else {
app.session.state.selected_props.push((layer.id, g.uid));
}
} else if !selected || hresp.clicked() {
app.session.state.selected_props = vec![(layer.id, g.uid)];
}
}
if hresp.drag_started() {
ctx.data_mut(|d| d.insert_temp(drag_id, g.uid));
}
crate::widgets::context_menu(&hresp, |ui| {
let lid = layer.id.0;
let mut picked_label: Option<usize> = None;
let mut item = |ui: &mut egui::Ui, label: &str, enabled: bool, cmd: &str, params: serde_json::Value| {
if ui.add_enabled(enabled, egui::Button::new(crate::i18n::context_item(cmd, ¶ms, label))).clicked() {
actions.push((cmd.into(), params));
ui.close();
}
};
item(ui, "Copy", true, "effect.copy", json!({"layer": lid, "effect": g.uid}));
item(ui, "Paste", has_clip, "effect.paste", json!({"layers": [lid]}));
item(ui, "Duplicate", true, "effect.duplicate", json!({"layer": lid, "effect": g.uid}));
if ui.button(crate::i18n::tr("Rename")).clicked() {
ctx.data_mut(|d| d.insert_temp(rename_id, shown.clone()));
ctx.data_mut(|d| d.insert_temp(rename_id.with("start"), true));
ui.close();
}
ui.separator();
ui.menu_button(crate::i18n::tr("Label"), |ui| {
let cur = g.label.unwrap_or(effectcraft_engine::color::Label::None);
for (i, l) in effectcraft_engine::color::Label::ALL.into_iter().enumerate() {
if widgets::label_entry(ui, l, &app.session.prefs.label_name(l), l == cur, &t).clicked() {
picked_label = Some(i);
ui.close();
}
}
});
item(ui, "Reset", true, "effect.reset", json!({"layer": lid, "effect": g.uid}));
item(ui, "Remove", true, "effect.remove", json!({"layer": lid, "effect": g.uid}));
ui.separator();
item(ui, "Move Up", fi > 0, "effect.reorder", json!({"layer": lid, "effect": g.uid, "index": fi.max(1)}));
item(ui, "Move Down", fi + 1 < fx.len(), "effect.reorder", json!({"layer": lid, "effect": g.uid, "index": fi + 2}));
if let Some(i) = picked_label {
actions.push(("effect.setLabel".into(), json!({"layer": lid, "effect": g.uid, "label": i})));
}
});
// What the effect can't render as asked (an OCIO config it can't read, transforms it
// passes through), under its name.
if let Some(w) = effectcraft_engine::effects::warning(g, &mut |pr| ectx.value(&layer, pr)) {
let galley = bp.layout(format!("⚠ {w}"), Tokens::ui(11.0), t.warning, (body.width() - 20.0).max(60.0));
let wr = Rect::from_min_size(pos2(body.min.x + 10.0, y + 3.0), galley.size());
bp.galley(wr.min, galley, t.warning);
app.auto.add(&format!("effectControls.effect.{}.warning", g.uid), wr, &w);
y += wr.height() + 6.0;
}
if open {
let eh = editor_height(effect, g, body.width());
if eh > 0.0 {
let er = Rect::from_min_size(pos2(body.min.x, y), vec2(body.width(), eh));
y += eh;
if er.max.y >= body.min.y && er.min.y <= body.max.y {
// Curves, Levels and other custom editors do not use prop_row.
// Clicking their controls must activate the owner as well.
if ui.input(|i| i.pointer.primary_pressed()) && ui.rect_contains_pointer(er) {
actions.push(("prop.select".into(), json!({"layer":layer.id.0,"prop":g.uid})));
}
effect_editor(app, ui, &EditorCx { bp: &bp, layer: &layer, ectx: &ectx }, g, er, &mut actions);
}
}
let scope = FxScope { effect: effect.as_str(), root: g, path: String::new() };
group_rows(app, ui, &bp, &layer, g, &ectx, body, &mut y, 0, &scope, &mut actions);
if effect == "ec.color.tint" {
let r = Rect::from_min_size(pos2(body.min.x + PARAM_NAME_X, y + 2.0), vec2(120.0, ROW));
let label = crate::i18n::tr("Swap Colors");
let resp = widgets::text_button(ui, r, label, false, &t, egui::Id::unique(("ec-tint-swap", g.uid)));
app.auto.add_response(&format!("effectControls.effect.{}.swapColors", g.uid), &resp, label);
if resp.clicked() {
actions.push(("prop.select".into(), json!({"layer": layer.id.0, "prop": g.uid})));
actions.push(("effect.swapTintColors".into(), json!({"layer": layer.id.0, "effect": g.uid})));
}
y += ROW + 4.0;
}
}
y += 4.0;
}
if let Some(du) = dragging {
reorder_drag(&ctx, &bp, body, &t, &ReorderDrag { tops: &tops, y, du, drag_id, layer_id: layer.id.0 }, &mut actions);
}
// Right-click anywhere a control has no menu of its own: the Effect menu, which applies to
// the selected layers (After Effects). Drawn after the rows, whose menus open first.
let menu_id = bg.id.with("effect-menu");
let open = ui.input(|i| i.pointer.secondary_clicked())
&& ui.rect_contains_pointer(body)
&& (!egui::Popup::is_any_open(&ctx) || egui::Popup::is_id_open(&ctx, menu_id));
egui::Popup::context_menu(&bg).style(crate::widgets::menu_style).id(menu_id).open_memory(open.then_some(egui::SetOpenCommand::Bool(true))).show(|ui| {
ui.set_min_width(200.0);
actions.extend(crate::menus::menu_contents(app, ui, "Effect"));
});
let content_h = y + scroll.offset - body.min.y;
let offset = scroll.offset;
scroll.end(ui, &mut app.auto, "effectControls.scroll", content_h, &t);
// Up / Down picked an effect: bring its header into view from the next pass (after `end`,
// which stores this pass's offset).
if let Some(uid) = ctx.data_mut(|d| d.remove_temp::<u64>(reveal_id()))
&& let Some(&(_, top)) = tops.iter().find(|(u, _)| *u == uid)
{
// (With the 4-point gap above it: the panel starts with one and every effect ends with one.)
let top = top - body.min.y + offset;
widgets::PanelScroll::reveal(&ctx, egui::Id::unique("ec-scroll"), top - 4.0, top + ROW + 2.0, body.height());
ctx.request_repaint();
}
drop_payload(ui, rect, &p, &t, layer.id.0, &mut actions);
if ui.input(|i| i.pointer.primary_down()) && actions.iter().any(|(id, _)| id == "prop.set") {
app.ui.viewer.property_interacting = true;
ctx.request_repaint();
}
for (id, params) in actions {
if let Err(e) = crate::menus::invoke(app, &ctx, &id, params) {
app.ui.status = e;
}
}
}
No file is open. Choose one in the tree, or press Ctrl+O (⌘O on a Mac) to find one by name.
Syntax highlighting could not load. The unmodified read-only text remains available above.