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
+26
View File
@@ -168,6 +168,32 @@ pub fn interact(
let sign = if kind == "bg" || kind == "refineErase" { "−" } else { "+" };
painter.text(hp, Align2::CENTER_CENTER, sign, Tokens::semibold(12.0), col);
}
// ⌘/Ctrl-drag resizes the brush (After Effects): the circle stays at the press point and its
// edge follows the pointer. No stroke is painted.
let rid = egui::Id::new("layer-panel-roto-resize");
if resp.drag_started()
&& mods.command
&& let Some(pos) = ui.input(|i| i.pointer.press_origin()).or(resp.interact_pointer_pos())
{
ctx.data_mut(|d| d.insert_temp(rid, pos));
}
if let Some(origin) = ctx.data(|d| d.get_temp::<Pos2>(rid)) {
if let Some(pos) = resp.interact_pointer_pos()
&& zoom > 0.0
{
let dia = (2.0 * f64::from(origin.distance(pos)) / zoom).clamp(1.0, 5000.0).round();
let key = if refine { "refineDiameter" } else { "diameter" };
if let Err(e) = app.session.execute("roto.options", json!({key: dia})) {
app.ui.status = e.to_string();
}
painter.circle_stroke(origin, (dia * 0.5 * zoom) as f32, Stroke::new(1.5, col));
painter.text(origin + vec2(0.0, -14.0), Align2::CENTER_BOTTOM, format!("{dia:.0} px"), Tokens::ui(11.0), col);
}
if resp.drag_stopped() || !resp.dragged() {
ctx.data_mut(|d| d.remove::<Pos2>(rid));
}
return true;
}
let did = egui::Id::new("layer-panel-roto-drag");
if resp.drag_started()
&& let Some(pos) = ui.input(|i| i.pointer.press_origin()).or(resp.interact_pointer_pos())