mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-25 10:36:56 -06:00
Problem: effect colour labels (26.5) were drawn only on the Effect Controls header; the Timeline's effect rows looked unlabelled. Fix: an effect group row in the Timeline paints the label colour as a 4 px bar on its left edge (same look as the Effect Controls header) and registers `timeline.group.<uid>.label` with the label's name for agents. Docs: gaps.md row 21 and ui-parity.md updated. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
46 lines
2.3 KiB
Rust
46 lines
2.3 KiB
Rust
//! An effect's colour label (26.5) shows on its Timeline row as well as in Effect Controls.
|
|
|
|
use effectcraft_engine::Session;
|
|
use effectcraft_engine::project::LayerId;
|
|
use effectcraft_ui_egui::EffectcraftApp;
|
|
use effectcraft_ui_egui::dock::PanelKind;
|
|
use egui::vec2;
|
|
use egui_kittest::Harness;
|
|
use serde_json::json;
|
|
|
|
fn harness() -> (Harness<'static, EffectcraftApp>, u64, u64) {
|
|
let mut s = Session::default();
|
|
s.execute("comp.new", json!({"name": "Main", "width": 320, "height": 180, "frameRate": 30, "duration": 4})).unwrap();
|
|
let layer = s.execute("layer.newSolid", json!({"name": "A", "color": "#406080"})).unwrap()["layer"].as_u64().unwrap();
|
|
let fx = s.execute("effect.apply", json!({"layers": [layer], "effect": "ec.blur.gaussian"})).unwrap()["effects"][0].as_u64().unwrap();
|
|
s.state.selected_layers = vec![LayerId(layer)];
|
|
s.state.selected_props = vec![(LayerId(layer), fx)];
|
|
let mut app = EffectcraftApp::new(s);
|
|
app.show_panel(PanelKind::Timeline);
|
|
app.ui.timeline.open_layers.insert(layer);
|
|
let effects = app.session.active_comp().and_then(|c| c.layer(LayerId(layer))).and_then(|l| l.props.sub("effects")).map(|g| g.uid);
|
|
app.ui.timeline.open_groups.extend(effects);
|
|
let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_eframe(|_| app);
|
|
h.run_steps(4);
|
|
(h, layer, fx)
|
|
}
|
|
|
|
/// The label bar appears on the effect's row once the effect has a label, carries the label's
|
|
/// name for agents, and goes away when the label is cleared.
|
|
#[test]
|
|
fn the_effect_row_wears_its_colour_label() {
|
|
let (mut h, layer, fx) = harness();
|
|
let id = format!("timeline.group.{fx}.label");
|
|
assert!(h.state().auto.find(&format!("timeline.group.{fx}.fx")).is_some(), "the effect's row is on screen");
|
|
assert!(h.state().auto.find(&id).is_none(), "an unlabelled effect has no bar");
|
|
|
|
h.state_mut().session.execute("effect.setLabel", json!({"layer": layer, "effect": fx, "label": "Blue"})).unwrap();
|
|
h.run_steps(3);
|
|
let blue = h.state().session.prefs.label_name(effectcraft_engine::color::Label::Blue);
|
|
assert_eq!(h.state().auto.find(&id).map(|e| e.label.clone()), Some(blue));
|
|
|
|
h.state_mut().session.execute("effect.setLabel", json!({"layer": layer, "effect": fx, "label": 0})).unwrap();
|
|
h.run_steps(3);
|
|
assert!(h.state().auto.find(&id).is_none(), "clearing the label removes the bar");
|
|
}
|