Roto Brush: Cmd/Ctrl-drag resizes the brush, and the tool options show its Diameter (#509)

Cause: the Roto Brush and Refine Edge diameters live in the editor state and
the roto.options command sets them, but the UI never did: the Layer panel
only painted strokes and the bottom bar only set the view mode, so the brush
size could not be changed.

Fix, as in After Effects: Cmd-drag (Ctrl-drag on Windows and Linux) in the
Layer panel resizes the active brush (Roto Brush or Refine Edge) without
painting. The circle stays at the press point, its edge follows the pointer,
and the size is shown while dragging. The tools bar shows a Diameter field
(header.roto.diameter) while a Roto Brush tool is active. Both go through
roto.options, and the next stroke uses the new radius. Diameter is in all
four interface catalogs.

Test: roto_brush_ctrl_drag_resizes_the_brush (a 20 px Cmd/Ctrl-drag makes a
40 px brush and paints nothing, the next stroke's radius is half of it, and
the Diameter field is registered).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QiAJeFttZp83Fh7YuzAR5f
(cherry picked from commit b4183c28eea34ba097d7a16153b84fcf7aeea045)
This commit is contained in:
Claude
2026-10-10 19:48:25 +00:00
parent 3ba43b20c7
commit 1bea11c9f1
4 changed files with 90 additions and 0 deletions
+37
View File
@@ -1837,3 +1837,40 @@ fn full_resolution_frames_wider_than_the_texture_limit_fit() {
assert!(full(&mut h), "the full-size frame is shown (and stays readable): {:?}", h.state().ui.viewer.res);
assert_eq!(h.state().viewer_texture_size(), Some([800, 134]), "2400×400 averaged by 3");
}
/// #509: ⌘/Ctrl-drag in the Layer panel resizes the Roto Brush (as in After Effects) without
/// painting, the next stroke uses the new size, and the tool options show the Diameter.
#[test]
fn roto_brush_ctrl_drag_resizes_the_brush() {
let mut h = harness();
let id = h.state().session.active_comp().unwrap().layers.iter().find(|l| l.name == "Box").unwrap().id.0;
h.state_mut().session.execute("layer.select", json!({"layers": [id]})).unwrap();
h.state_mut().ui.layer_panel = Some(id);
h.state_mut().show_panel(effectcraft_ui_egui::dock::PanelKind::Layer);
h.state_mut().ui.tool = Tool::RotoBrush;
h.run_steps(3);
assert!(h.state().auto.find("header.roto.diameter").is_some(), "the Diameter field");
let canvas = rect(&h, "layerPanel.canvas");
let zoom = canvas.width() / 80.0;
let c = canvas.center();
h.input_mut().events.push(Event::ModifiersChanged(egui::Modifiers::COMMAND));
drag(&mut h, c, c + vec2(20.0 * zoom, 0.0));
h.input_mut().events.push(Event::ModifiersChanged(egui::Modifiers::NONE));
h.run_steps(2);
let dia = h.state().session.state.roto.diameter;
assert!((dia - 40.0).abs() <= 1.0, "a 20 px drag makes a 40 px brush: {dia}");
let strokes = |h: &Harness<'_, EffectcraftApp>| {
let l = h.state().session.active_comp().unwrap().layer(LayerId(id)).unwrap().clone();
let roto = effectcraft_engine::effects::roto::ID;
let g = l
.effects()
.and_then(|fx| fx.groups().find(|g| matches!(&g.kind, effectcraft_engine::project::GroupKind::Effect { effect } if effect == roto)).cloned());
g.map(|g| effectcraft_engine::effects::roto::data(&effectcraft_engine::effects::flatten_params(&g, &mut |p| p.value.clone())).strokes.clone())
.unwrap_or_default()
};
assert!(strokes(&h).is_empty(), "resizing paints nothing");
drag(&mut h, c - vec2(10.0 * zoom, 0.0), c + vec2(10.0 * zoom, 0.0));
let s = strokes(&h);
assert_eq!(s.len(), 1);
assert!((s[0].radius - dia / 2.0).abs() < 1e-6, "{} vs {dia}", s[0].radius);
}