EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
Merge pull request #423 from cdinhoo/codex/effect-input-control-fixes
Claude91d37dd449f7
diff --cc crates/ui-egui/src/panels/effect_controls.rsindex 99fe39e44,ae20ea857..8560392a8--- a/crates/ui-egui/src/panels/effect_controls.rs+++ b/crates/ui-egui/src/panels/effect_controls.rs@@@ -30,13 -30,24 +30,28 @@@ use crate::{EffectcraftApp, widgets}type Actions = Vec<(String, serde_json::Value)>;-const ROW: f32 = 24.0;+const ROW: f32 = 20.0;const DIAL_ROW: f32 = 64.0;+// The effect title starts at 44 pt. Each level's names sit one tree step farther in;+// reserve the same icon gutter for properties and groups so sibling names align.+const PARAM_NAME_X: f32 = 58.0;+const TREE_INDENT: f32 = 14.0;+ /// Selecting any descendant activates its owning effect without replacing the property+ /// selection used by keyframe editing, copy and delete.+ fn effect_active(g: &PropGroup, layer: effectcraft_engine::project::LayerId, selected: &[(effectcraft_engine::project::LayerId, u64)]) -> bool {+ fn contains(g: &PropGroup, uid: u64, depth: usize) -> bool {+ if g.uid == uid {+ return true;+ }+ if depth >= 16 {+ return false;+ }+ g.children.iter().any(|n| n.uid() == uid || matches!(n, Node::Group(child) if contains(child, uid, depth + 1)))+ }+ selected.iter().any(|(l, uid)| *l == layer && contains(g, *uid, 0))+ }+fn selected_layer(app: &EffectcraftApp) -> Option<Layer> {let comp = app.session.active_comp()?;let id = app.session.state.selected_layers.first()?;@@@ -160,11 -170,14 +175,15 @@@ fn prop_rowr: Rect,indent: f32,actions: &mut Actions,-) {+) -> Vec<Rect> {let t = app.tokens;+ let mut dims = vec![];let cy = r.center().y;let uid = prop.uid;+ if ui.input(|i| i.pointer.primary_pressed()) && ui.rect_contains_pointer(r) {+ let add = ui.input(|i| i.modifiers.shift || i.modifiers.command);+ actions.push(("prop.select".into(), json!({"layer": layer.id.0, "prop": uid, "add": add})));+ }let swr = Rect::from_center_size(pos2(r.min.x + indent, cy), vec2(14.0, 14.0));if !prop.static_only && !matches!(prop.ui, ParamUi::Hidden) {let resp = ui.interact(swr, egui::Id::new(("ec-sw", uid)), Sense::click());@@@ -208,9 -219,11 +227,11 @@@}_ => vx,};- let name_clip =- Rect::from_min_max(pos2(swr.max.x + 6.0, r.min.y), pos2(((r.min.x + r.width() * 0.48).max(swr.max.x + 124.0) - 4.0).min(vx - 6.0), r.max.y));+ let name_clip = Rect::from_min_max(pos2(swr.max.x + 6.0, r.min.y), pos2(vx - 6.0, r.max.y));+ app.auto.add(&format!("effectControls.prop.{uid}.name"), name_clip, &prop.name);p.with_clip_rect(name_clip.intersect(p.clip_rect())).text(pos2(swr.max.x + 6.0, cy), Align2::LEFT_CENTER, &prop.name, Tokens::ui(12.0), t.text);+ ui.interact(name_clip, egui::Id::new(("ec-prop-name", uid)), Sense::click());+ app.auto.add(&format!("effectControls.prop.{uid}.name"), name_clip, &prop.name);let merge = format!("ec-{uid}");let set =|actions: &mut Actions, v: serde_json::Value| actions.push(("prop.set".into(), json!({"layer": layer.id.0, "prop": uid, "value": v, "merge": merge})));@@@ -981,12 -984,13 +1002,13 @@@ pub fn show(app: &mut EffectcraftApp, ulet mut tops: Vec<(u64, f32)> = vec![];for (fi, g) in fx.iter().enumerate() {let GroupKind::Effect { effect } = &g.kind else { continue };- let r = Rect::from_min_size(pos2(body.min.x, y), vec2(body.width(), 26.0));+ 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 += 26.0;+ 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);- bp.rect_filled(r, 0.0, if selected { Color32::from_rgb(0x2f, 0x3a, 0x52) } else { Color32::from_rgb(0x2a, 0x2a, 0x2a) });+ let active = effect_active(g, layer.id, &app.session.state.selected_props);+ bp.rect_filled(r, 0.0, if active { Color32::from_rgb(0x2f, 0x3a, 0x52) } else { Color32::from_rgb(0x2a, 0x2a, 0x2a) });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::new(("ec-fx", g.uid)), Sense::click()).clicked() {actions.push(("effect.toggle".into(), json!({"layer": layer.id.0, "effect": g.uid})));