FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
fix(masks): hide the mask handles while the clip is not selected (fixes #1341)
Marco Arnulfodadbfe0bf8db
diff --git a/crates/ui-egui/src/panels/masks.rs b/crates/ui-egui/src/panels/masks.rsindex c741a1d3c..61ea2b0f5 100644--- a/crates/ui-egui/src/panels/masks.rs+++ b/crates/ui-egui/src/panels/masks.rs@@ -225,13 +225,18 @@ fn inside(pts: &[Vec2], p: Vec2) -> bool {w != 0}-/// Mask editing on the Program monitor (selected mask) and the pen tool.+/// Mask editing on the Program monitor (selected mask, while its clip is selected, as for the+/// transform box) and the pen tool.pub fn monitor_overlay(app: &mut FilmcraftApp, ui: &mut egui::Ui, pic: Rect, frame: (u32, u32)) {if app.ui.mask_pen.is_some() {pen_overlay(app, ui, pic, frame);return;}let Some(sel) = app.session.state.selected_mask else { return };+ // (the mask stays selected: its handles come back with its clip, #1341)+ if !app.session.state.selection.contains(&sel.clip) {+ return;+ }let Some(seq) = app.session.active_sequence() else { return };let ph = app.session.playhead();let Some((_, it)) = seq.find_item(sel.clip) else { return };diff --git a/crates/ui-egui/tests/masks_ui.rs b/crates/ui-egui/tests/masks_ui.rsindex 813d9eac1..cb39219ca 100644--- a/crates/ui-egui/tests/masks_ui.rs+++ b/crates/ui-egui/tests/masks_ui.rs@@ -77,6 +77,10 @@ impl Driver {self.ok("ui.drag", json!({"from": {"x": x, "y": y}, "to": {"x": x + dx, "y": y + dy}, "steps": 6}));self.frames(2);}+ fn has(&mut self, id: &str) -> bool {+ let v = self.ok("ui.elements", json!({"prefix": id}));+ v.as_array().is_some_and(|a| a.iter().any(|e| e["id"] == id))+ }fn masks(&mut self) -> Vec<Value> {self.exec("masks.list", json!({}))["masks"].as_array().unwrap().clone()}@@ -216,6 +220,33 @@ fn create_and_edit_masks_on_the_monitor() {d.shot("mask-tracked");}+/// The selected mask's outline and handles are drawn on the Program monitor only while its clip+/// is selected, as Motion's box is: selecting another clip, or none, hides them (#1341).+#[test]+fn mask_handles_follow_the_clip_selection() {+ let mut d = Driver::demo();+ let seq = d.exec("sequence.inspect", json!({}));+ let items = seq["video"][0]["items"].as_array().unwrap().clone();+ let (id, start, dur) = (items[0]["clip"].as_u64().unwrap(), items[0]["start"].as_i64().unwrap(), items[0]["duration"].as_i64().unwrap());+ let other = items[1]["clip"].as_u64().unwrap();+ d.exec("playhead.set", json!({"time": start + dur / 2}));+ d.exec("timeline.select", json!({"clips": [id]}));+ d.exec("masks.add", json!({"clip": id, "effect": "opacity", "shape": "ellipse"}));+ d.frames(3);+ assert!(d.has("program.mask.vertex.0"), "handles of the selected clip's mask");+ d.shot("mask-clip-selected");+ for clips in [json!([other]), json!([])] {+ d.exec("timeline.select", json!({"clips": clips}));+ d.frames(3);+ assert!(!d.has("program.mask.vertex.0"), "no handles with {clips} selected");+ assert!(!d.has("program.mask.body"), "no outline with {clips} selected");+ d.shot(&format!("mask-clip-deselected-{}", clips.as_array().map_or(0, Vec::len)));+ }+ d.exec("timeline.select", json!({"clips": [id]}));+ d.frames(3);+ assert!(d.has("program.mask.vertex.0"), "the handles come back with the clip");+}+/// Shift held while placing pen points snaps each new segment to 45° steps from the previous/// point; a Shift-drag also constrains the Bézier handle it pulls out (#853).#[test]