Masks and Project panel: selecting a mask selects its points; linked Mask Feather; selection box (#203)

- Selecting a mask in the Timeline (its row or Mask Path), or a shape's
  Path, selects all its points, so dragging one in the viewer moves the
  whole mask, as in After Effects. Delete still removes the mask, and
  selecting another property deselects the points.
- Mask Feather has the chain link (Constrain Proportions, on by
  default, Alt edits one value) and no longer takes negative values;
  Scale's link shows as a toggle too.
- Dragging in the Project panel's empty area draws a selection box
  (Shift / Cmd adds); a click there deselects.

Tests: selecting_a_mask_selects_its_points,
mask_feather_values_are_linked_and_not_negative,
dragging_in_the_empty_area_box_selects_items.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gnTnH3Jmk5zr4tMq1Mc9f
This commit is contained in:
Claude
2026-10-07 22:13:19 +00:00
parent b26f55a775
commit b4d2d58eeb
8 changed files with 208 additions and 18 deletions
+39 -3
View File
@@ -323,9 +323,10 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
let list = Rect::from_min_max(pos2(rect.min.x, hdr.max.y), pos2(rect.max.x, rect.max.y - footer_h));
let lp = p.with_clip_rect(list);
// The list's empty area (under the rows and the scroll bar, which take their own clicks):
// a double-click imports, as in After Effects (File ▸ Import ▸ File...).
let empty = ui.interact(list, egui::Id::new("proj-empty"), Sense::click());
app.auto.add("project.empty", list, "Double-click to import files");
// a click deselects, a drag draws a selection box, a double-click imports, as in After
// Effects (File ▸ Import ▸ File...).
let empty = ui.interact(list, egui::Id::new("proj-empty"), Sense::click_and_drag());
app.auto.add("project.empty", list, "Double-click to import files; drag to select items");
if overflow > 0.0 && ui.rect_contains_pointer(list) {
let (dx, dy, shift) = ui.input(|i| (i.smooth_scroll_delta.x, i.smooth_scroll_delta.y, i.modifiers.shift));
let d = if dx.abs() > 0.0 {
@@ -718,6 +719,41 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
if empty.double_clicked() {
actions.push(("file.import".into(), json!({})));
}
// Selection box over the rows it touches (#203); Shift or Cmd/Ctrl adds to the selection.
let adding = ui.input(|i| i.modifiers.shift || i.modifiers.command);
if empty.clicked() && !adding {
app.session.state.project_selection.clear();
}
let box_id = egui::Id::new("proj-marquee");
if let (Some(start), Some(end)) = (ctx.input(|i| i.pointer.press_origin()), empty.interact_pointer_pos())
&& empty.dragged()
{
let b = Rect::from_two_pos(start, end).intersect(list);
lp.rect_filled(b, 0.0, t.accent.gamma_multiply(0.12));
lp.rect_stroke(b, 0.0, Stroke::new(1.0, t.accent), egui::StrokeKind::Inside);
ctx.data_mut(|d| d.insert_temp(box_id, b));
}
if empty.drag_stopped()
&& let Some(b) = ctx.data(|d| d.get_temp::<Rect>(box_id))
{
ctx.data_mut(|d| d.remove::<Rect>(box_id));
// Rows sit at fixed heights from the top of the scrolled list.
let top = list.min.y - app.ui.project_scroll;
let picked = rows.iter().enumerate().filter(|(i, _)| {
let y = top + *i as f32 * ROW_H;
y < b.max.y && y + ROW_H > b.min.y
});
let picked: Vec<ItemId> = picked.map(|(_, (id, _))| *id).collect();
let sel = &mut app.session.state.project_selection;
if !adding {
sel.clear();
}
for id in picked {
if !sel.contains(&id) {
sel.push(id);
}
}
}
for (id, params) in actions {
if let Err(e) = crate::menus::invoke(app, &ctx, &id, params) {
app.ui.status = e;
+43 -9
View File
@@ -2882,6 +2882,26 @@ fn fmt_num(v: f64, d: usize) -> String {
format!("{v:.d$}")
}
/// Linked values after component `d` of `c` became `v`: the others scale by the same ratio
/// (Constrain Proportions); from 0 the others that are 0 too follow the value.
fn constrained(c: &[f64], d: usize, v: f64) -> Vec<f64> {
let Some(&old) = c.get(d) else { return c.to_vec() };
c.iter()
.enumerate()
.map(|(e, &x)| {
if e == d {
v
} else if old.abs() > 1e-9 {
x * v / old
} else if x.abs() <= 1e-9 {
v
} else {
x
}
})
.collect()
}
/// Inline value editor for a property row; pushes `prop.set` actions.
fn value_editor(
app: &mut EffectcraftApp,
@@ -2929,21 +2949,35 @@ fn value_editor(
let c = value.components();
let n = if prop.shown_dims > 0 && !(is_3d && c.len() == 3) { prop.shown_dims as usize } else { c.len() };
let pct = matches!(prop.ui, ParamUi::Percent);
// Mask Feather: two linked values, never negative (as in After Effects, #203).
let feather = prop.match_id == "feather" && layer.props.parent_of(uid).is_some_and(|g| matches!(g.kind, GroupKind::Mask { .. }));
let range = if feather { (0.0, 1e9) } else { (-1e9, 1e9) };
// Scale and Mask Feather: the chain link (Constrain Proportions, on by default).
let linkable = feather || (pct && prop.match_id == "scale");
let linked = linkable && !app.ui.timeline.unlinked.contains(&uid);
if linkable {
let lr = Rect::from_center_size(pos2(x + 7.0, at.y), vec2(14.0, 14.0));
let resp = ui.interact(lr, egui::Id::new(("tl-link", uid)), Sense::click()).on_hover_text("Constrain Proportions");
icons::paint(p, lr, Icon::Link, if linked { t.accent } else { t.text_faint });
app.auto.add(&format!("timeline.prop.{uid}.link"), lr, "Constrain Proportions");
if resp.clicked() && !app.ui.timeline.unlinked.remove(&uid) {
app.ui.timeline.unlinked.insert(uid);
}
x += 18.0;
}
for d in 0..n.min(c.len()) {
let suffix = if pct && d + 1 == n { "%" } else { "" };
let (r, nv, _) =
widgets::hot_number_at(ui, pos2(x, y), egui::Id::new(("v", uid, d)), c[d], if pct { 0.5 } else { 1.0 }, (-1e9, 1e9), 1, suffix, &t);
let (r, nv, _) = widgets::hot_number_at(ui, pos2(x, y), egui::Id::new(("v", uid, d)), c[d], if pct { 0.5 } else { 1.0 }, range, 1, suffix, &t);
app.auto.add(&format!("timeline.prop.{uid}.value.{d}"), r, &prop.name);
if let Some(nv) = nv {
let mut nc = c.clone();
if pct && prop.match_id == "scale" && !ui.input(|i| i.modifiers.alt) {
// Constrain proportions (AE's chain link, on by default).
let k = if c[d].abs() > 1e-9 { nv / c[d] } else { 1.0 };
for e in 0..n {
nc[e] = if e == d { nv } else { c[e] * k };
// Alt edits one value of a linked pair.
let shown = if linked && !ui.input(|i| i.modifiers.alt) { n.min(c.len()) } else { 1 };
let from = if shown == 1 { d } else { 0 };
for (e, v) in constrained(c.get(from..from + shown).unwrap_or_default(), d - from, nv).into_iter().enumerate() {
if let Some(slot) = nc.get_mut(from + e) {
*slot = v;
}
} else {
nc[d] = nv;
}
set(actions, json!(nc));
}
+5
View File
@@ -413,6 +413,10 @@ pub struct TimelineState {
/// Properties whose inline expression editor is collapsed.
#[serde(default)]
pub expr_closed: BTreeSet<u64>,
/// Scale and Mask Feather properties whose chain link (Constrain Proportions, on by default)
/// was turned off.
#[serde(default)]
pub unlinked: BTreeSet<u64>,
/// Visible optional columns (column header right-click ▸ Columns): `av`, `keys`, `label`,
/// `num`, `comment`, `switches`, `parent`, `in`, `out`, `duration`, `stretch`. The name
/// column is always shown; Modes follows `show_modes` (F4).
@@ -458,6 +462,7 @@ impl Default for TimelineState {
graph_reference: false,
graph_transform_box: true,
expr_closed: BTreeSet::new(),
unlinked: BTreeSet::new(),
columns: default_tl_columns(),
source_name: false,
}