Tint: Swap Colors (#963) (#1060)

Squash of #1060 by @RavoxX, without the docs/images screenshots (kept out of the repo).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jannik Wappler
2026-10-13 04:33:43 -04:00
committed by Brandon Thomas
co-authored by Claude Opus 5.5
parent 9aabb5da4f
commit 1765dc53df
6 changed files with 186 additions and 2 deletions
@@ -135,6 +135,40 @@ fn effect_controls_widgets_register_automation_ids() {
assert!(ids(&h).contains(&pt_id), "effect point control shown for the selected effect");
}
#[test]
fn tint_swap_button_targets_its_instance_and_undoes_both_colors() {
let mut s = Session::default();
s.execute("comp.new", json!({"width": 640, "height": 360, "frameRate": 30, "duration": 5})).unwrap();
let lid = s.execute("layer.newSolid", json!({"color": "#000000"})).unwrap()["layer"].as_u64().unwrap();
let first = s.execute("effect.apply", json!({"effect": "Tint"})).unwrap()["effects"][0].as_u64().unwrap();
let target = s.execute("effect.apply", json!({"effect": "Tint"})).unwrap()["effects"][0].as_u64().unwrap();
let blur = s.execute("effect.apply", json!({"effect": "Gaussian Blur"})).unwrap()["effects"][0].as_u64().unwrap();
let mut app = EffectcraftApp::new(s);
app.show_panel(PanelKind::EffectControls);
let mut h = Harness::builder().with_size(egui::vec2(1700.0, 1100.0)).build_eframe(|_| app);
h.run_steps(4);
let id = format!("effectControls.effect.{target}.swapColors");
let rect = h.state().auto.find(&id).unwrap().rect;
assert!(ids(&h).contains(&format!("effectControls.effect.{first}.swapColors")));
assert!(!ids(&h).contains(&format!("effectControls.effect.{blur}.swapColors")));
let n = h.state().session.history.undo.len();
click(&mut h, egui::pos2(rect[0] + rect[2] / 2.0, rect[1] + rect[3] / 2.0));
let l = layer(&h.state().session, lid);
let g = l.props.find_group(target).unwrap();
assert_eq!(g.prop("black").unwrap().value, KV::Color([1.0; 4]));
assert_eq!(g.prop("white").unwrap().value, KV::Color([0.0, 0.0, 0.0, 1.0]));
assert_eq!(l.props.find_group(first).unwrap().prop("black").unwrap().value, KV::Color([0.0, 0.0, 0.0, 1.0]));
assert_eq!(h.state().session.history.undo.len(), n + 1);
assert_eq!(h.state().session.state.selected_props, vec![(LayerId(lid), target)]);
assert!(h.state_mut().session.undo());
let l = layer(&h.state().session, lid);
assert_eq!(l.props.find_group(target).unwrap().prop("black").unwrap().value, KV::Color([0.0, 0.0, 0.0, 1.0]));
assert_eq!(l.props.find_group(target).unwrap().prop("white").unwrap().value, KV::Color([1.0; 4]));
h.state_mut().ui.fx_closed.insert(target);
h.run_steps(2);
assert!(!h.state().auto.elements.iter().any(|e| e.id == id));
}
#[test]
fn crosshair_and_eyedropper_pick_from_the_viewer() {
let (app, x) = app();