FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
Merge remote-tracking branch 'origin/main' into fix-256
Brandon Thomasa739ffea84e3
diff --cc crates/ui-egui/tests/keyboard_ui.rsindex dfc4324c8,2fe5dac50..036606320--- a/crates/ui-egui/tests/keyboard_ui.rs+++ b/crates/ui-egui/tests/keyboard_ui.rs@@@ -180,43 -180,20 +180,61 @@@ fn new_keys_work_in_the_app()assert_eq!(d.app().ui.program.zoom, None);}+/// Off macOS the menus show `Ctrl+…`, so that is what agents send: a `Ctrl` chord through+/// `ui.key` (and `ctrl` in `ui.click` modifiers) must act like the physical key, which egui-winit+/// reports as `ctrl` + `command`. Bindings are written `Cmd+…`, so this failed to match (#245).+#[cfg(not(target_os = "macos"))]+#[test]+fn ctrl_chords_fire_shortcuts_off_macos() {+ let mut d = Driver::new();+ let seq = d.exec("sequence.inspect", json!({}));+ let second = &seq["video"][0]["items"].as_array().unwrap()[1];+ let (clip, start) = (second["clip"].as_u64().unwrap(), second["start"].as_i64().unwrap());+ let start_of = |d: &mut Driver| {+ d.exec("sequence.inspect", json!({}))["video"][0]["items"]+ .as_array()+ .unwrap()+ .iter()+ .find(|i| i["clip"].as_u64() == Some(clip))+ .map(|i| i["start"].as_i64().unwrap())+ .unwrap()+ };+ d.exec("playhead.set", json!({"time": start + 1_000_000_000}));+ d.focus("Timeline");+ d.key("D");+ assert!(d.app().session.state.selection.iter().any(|c| c.0 == clip));+ // Ctrl+Right nudges one frame right, like Cmd+Right; Ctrl+Z undoes it+ let rate = d.app().session.sequence_rate();+ d.key("Ctrl+Right");+ assert_eq!(start_of(&mut d), start + rate.tick_of(1).0, "Ctrl+Right nudges");+ d.key("Ctrl+Z");+ assert_eq!(start_of(&mut d), start, "Ctrl+Z undoes");+ // the same chord spelt with the modifier flag+ d.ok("ui.key", json!({"key": "Right", "ctrl": true}));+ d.frames(3);+ assert_eq!(start_of(&mut d), start + rate.tick_of(1).0, "`ctrl: true` nudges");+ d.ok("ui.key", json!({"key": "Z", "ctrl": true}));+ d.frames(3);+ assert_eq!(start_of(&mut d), start, "`ctrl: true` undoes");+ // and the bare key still does not+ d.key("Z");+ assert_eq!(start_of(&mut d), start);+}+++ #[test]+ fn delete_key_clears_the_selected_timeline_clip() {+ // #243: on Windows and Linux keyboards Delete is the forward-delete key; with the Timeline+ // focused it ran Project ▸ Clear (nothing selected there), so the clip stayed.+ let mut d = Driver::new();+ let items = |d: &mut Driver| d.exec("sequence.inspect", json!({}))["video"][0]["items"].as_array().unwrap().clone();+ let second = items(&mut d)[1].clone();+ let (clip, start) = (second["clip"].as_u64().unwrap(), second["start"].as_i64().unwrap());+ d.exec("playhead.set", json!({"time": start + 1_000_000_000}));+ d.focus("Timeline");+ d.key("D");+ assert!(d.app().session.state.selection.iter().any(|c| c.0 == clip), "D selects the clip under the playhead");+ d.key("Delete");+ assert!(!items(&mut d).iter().any(|i| i["clip"].as_u64() == Some(clip)), "Delete removed the selected clip");+ d.key("Cmd+Z");+ assert!(items(&mut d).iter().any(|i| i["clip"].as_u64() == Some(clip)), "and undo brings it back");+ }diff --cc docs/control-protocol.mdindex 6b92c3e61,69cf62d5c..5ee024345--- a/docs/control-protocol.md+++ b/docs/control-protocol.md@@@ -34,8 -34,8 +34,8 @@@ Methods (handlers in `crates/ui-egui/sr| `ui.click` / `ui.move` | `{id}` or `{x,y}`, `button`, `count`, `modifiers` | synthetic pointer input || `ui.drag` | `{from, to, steps, modifiers}` | press–move–release || `ui.scroll` | `{id|x,y, dx, dy, modifiers}` | wheel / trackpad |-| `ui.key` / `ui.type` | `{key}` (`Cmd+K`, `Space`…) / `{text}` | keyboard |+| `ui.key` / `ui.type` | `{key}` (`Cmd+K`, `Space`…; off macOS `Ctrl+K` is the same key) / `{text}` | keyboard |- | `ui.timeline.hit` / `ui.timeline.locate` | `{x,y}` / `{clip, edge?}` | timeline hit-testing |+ | `ui.timeline.hit` / `ui.timeline.locate` | `{x,y,modifiers?}` / `{clip, edge?}` | timeline hit-testing. `hit` reports a clip's `edge` (`In`/`Out`) within 7 px of it (a third of a narrow clip); just left of a cut that is the left clip's Out, from the cut rightwards the right clip's In. `kind` is the trim a press of the current tool with `modifiers` starts there (`trim`, `ripple`, `roll`, `rateStretch`, `remix`), or null || `ui.playback` | `{action: play|stop|toggle, speed?}` | || `ui.screenshot` | `{path?, panel?}` | PNG of the window or one panel; fails after 10 s when no frame is presented (window hidden, display asleep) || `ui.resize`, `ui.focus`, `app.quit` | | `ui.focus` is the only request that activates the app and takes keyboard focus |