FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
Audio Track Mixer: mixer.meterInputOnly refuses parameters that are not an object
dotCooCoo4c3feebfcb17
diff --git a/crates/ui-egui/src/panels/mixer.rs b/crates/ui-egui/src/panels/mixer.rsindex 178070ce6..e935a3cb4 100644--- a/crates/ui-egui/src/panels/mixer.rs+++ b/crates/ui-egui/src/panels/mixer.rs@@ -232,8 +232,11 @@ pub(crate) fn open_show_hide_tracks(app: &mut FilmcraftApp, ctx: &egui::Context)}/// Meter Input(s) Only (`mixer.meterInputOnly`, `{"on":bool?}`): sets the option, or toggles it-/// without `on`.+/// without `on`. Parameters that are neither an object nor null are an error.pub(crate) fn set_meter_input_only(app: &mut FilmcraftApp, params: &Value) -> Result<Value, String> {+ if !params.is_object() && !params.is_null() {+ return Err("command parameters must be an object".into());+ }let on = match params.get("on") {None | Some(Value::Null) => !app.ui.mixer_meter_input_only,Some(v) => v.as_bool().ok_or("`on` must be true or false")?,diff --git a/crates/ui-egui/tests/it/keyboard_ui.rs b/crates/ui-egui/tests/it/keyboard_ui.rsindex ef242bb28..1155b154e 100644--- a/crates/ui-egui/tests/it/keyboard_ui.rs+++ b/crates/ui-egui/tests/it/keyboard_ui.rs@@ -306,6 +306,24 @@ fn audio_track_mixer_keys_open_show_hide_and_toggle_meter_input_only() {assert_eq!(d.app().ui.focused, filmcraft_ui_egui::dock::PanelKind::AudioTrackMixer);}+/// `mixer.meterInputOnly` refuses parameters that are not an object and leaves the option as it+/// was; null parameters toggle it.+#[test]+fn meter_input_only_refuses_parameters_that_are_not_an_object() {+ let mut d = Driver::new();+ assert!(!d.app().ui.mixer_meter_input_only);+ for params in [json!(true), json!(1), json!("on"), json!([true])] {+ let (req, reply) = ControlRequest::new("ui.menu.invoke", json!({"id": "mixer.meterInputOnly", "params": params}));+ d.tx.send(req).unwrap();+ d.frames(3);+ let response = reply.try_recv().expect("the command is answered");+ assert_eq!(response["ok"], false, "{params}: {response}");+ assert!(!d.app().ui.mixer_meter_input_only, "{params} leaves Meter Input(s) Only off");+ }+ let r = d.ok("ui.menu.invoke", json!({"id": "mixer.meterInputOnly", "params": null}));+ assert_eq!(r, json!({"meterInputOnly": true}));+}+/// 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).