Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

Audio Track Mixer: Show/Hide Tracks and Meter Input(s) Only are commands with Premiere's keys

dotCooCoobfe27ca1f809
diff --git a/crates/engine/src/keyboard_tests.rs b/crates/engine/src/keyboard_tests.rs
index 4e6ff2fdf..47a749b83 100644
--- a/crates/engine/src/keyboard_tests.rs
+++ b/crates/engine/src/keyboard_tests.rs
@@ -67,7 +67,7 @@ fn premiere_engine_entries_exist() {
// UI-owned ids (tools, transport, panels…) are checked by the ui-egui keyboard test
let ui_prefixes =
["tool.", "playback.", "window.", "view.", "app.", "help.", "mode.", "multicam.", "projectPanel.", "textPanel.", "panel.", "mediaBrowser."];
- let ui_ids = ["timeline.expandAllTracks", "timeline.minimizeAllTracks", "graphics.beginTextEditing"];
+ let ui_ids = ["timeline.expandAllTracks", "timeline.minimizeAllTracks", "graphics.beginTextEditing", "mixer.showHideTracks", "mixer.meterInputOnly"];
for (id, _, _) in presets::premiere() {
if id.starts_with("timeline.") && (id.contains("Height") || id.contains("Screen")) || ui_ids.contains(&id) {
continue;
diff --git a/crates/engine/src/shortcut_presets.rs b/crates/engine/src/shortcut_presets.rs
index 0fe87fe33..19e514d68 100644
--- a/crates/engine/src/shortcut_presets.rs
+++ b/crates/engine/src/shortcut_presets.rs
@@ -353,6 +353,8 @@ pub const PREMIERE_PANEL: &[Entry] = &[
("captions.merge", "Alt+M", "Text"),
("captions.split", "Alt+S", "Text"),
("playback.loop", "Cmd+L", "Audio Track Mixer"),
+ ("mixer.showHideTracks", "Cmd+Alt+T", "Audio Track Mixer"),
+ ("mixer.meterInputOnly", "Ctrl+Shift+I", "Audio Track Mixer"),
("playback.toggle", "Space", "Metadata"),
("playback.loop", "Cmd+L", "Metadata"),
("mediaBrowser.openInSource", "Shift+O", "Media Browser"),
diff --git a/crates/ui-egui/src/panels/keyboard.rs b/crates/ui-egui/src/panels/keyboard.rs
index bdf744196..82c50ee9c 100644
--- a/crates/ui-egui/src/panels/keyboard.rs
+++ b/crates/ui-egui/src/panels/keyboard.rs
@@ -18,6 +18,7 @@
//! | `timeline.nextScreen` / `timeline.prevScreen` | Show Next / Previous Screen | PageDown / PageUp (Timeline) |
//! | `projectPanel.*` | Project panel: List / Icon / Toggle View, Hover Scrub, thumbnail size, Move / Extend Selection | (Project) |
//! | `textPanel.*` | Text panel transcript: word / line / segment navigation and selection, Delete, Ripple Delete, Show Program Transcript | (Text) |
+//! | `mixer.showHideTracks` / `mixer.meterInputOnly` | Audio Track Mixer: Show/Hide Tracks / Meter Input(s) Only | Cmd+Alt+T / Ctrl+Shift+I (Audio Track Mixer) |
//! | `graphics.beginTextEditing` | Begin Text Editing for a Graphic Layer | Cmd+Alt+' |
//! | `help.filmcraftHelp` | Help (Premiere Help…) | F1 |
//! | `app.quit` | Quit | Cmd+Q |
@@ -127,6 +128,8 @@ pub const COMMANDS: &[UiCommand] = &[
uic!("textPanel.delete", "Delete", [], None),
uic!("textPanel.rippleDelete", "Ripple Delete", [], None),
uic!("textPanel.showProgramTranscript", "Show Program Transcript", [], None),
+ uic!("mixer.showHideTracks", "Show/Hide Tracks…", [], None),
+ uic!("mixer.meterInputOnly", "Meter Input(s) Only", [], None),
uic!("graphics.beginTextEditing", "Begin Text Editing for a Graphic Layer", [], Some("Cmd+Alt+'")),
uic!("help.filmcraftHelp", "FilmCraft Help…", ["Help"], Some("F1")),
uic!("app.quit", "Quit FilmCraft", [], Some("Cmd+Q")),
@@ -208,6 +211,8 @@ pub fn route(app: &mut FilmcraftApp, ctx: &egui::Context, id: &str, params: &Val
tv.target_scroll = (tv.target_scroll + d).max(0.0);
Ok(json!({"scroll": tv.target_scroll}))
}
+ "mixer.showHideTracks" => Ok(crate::panels::mixer::open_show_hide_tracks(app, ctx)),
+ "mixer.meterInputOnly" => crate::panels::mixer::set_meter_input_only(app, params),
"graphics.beginTextEditing" => begin_text_editing(app),
"help.filmcraftHelp" => {
crate::links::open(app, ctx, HELP_URL);
diff --git a/crates/ui-egui/src/panels/mixer.rs b/crates/ui-egui/src/panels/mixer.rs
index aea3b830e..db7900caf 100644
--- a/crates/ui-egui/src/panels/mixer.rs
+++ b/crates/ui-egui/src/panels/mixer.rs
@@ -17,7 +17,8 @@
//! listening square (`mixer.A1.pan51`, drag; double-click: front centre) with Center % and LFE
//! controls (`mixer.A1.pan51.center`, `mixer.A1.pan51.lfe`). Meters show one bar per channel
//! (six for 5.1 strips). The panel menu (`mixer.menu`) holds Show/Hide Tracks (`mixer.menu.showHide`,
-//! then `mixer.showHide.<A1|S1>` per strip) and Meter Input(s) Only (`mixer.menu.meterInputOnly`).
+//! then `mixer.showHide.<A1|S1>` per strip) and Meter Input(s) Only (`mixer.menu.meterInputOnly`),
+//! which are also the commands `mixer.showHideTracks` and `mixer.meterInputOnly`.
use std::collections::HashMap;
@@ -211,6 +212,35 @@ fn targets(seq: &Sequence, id: TrackId) -> Vec<&Track> {
// ------------------------------------------------------------------------------------- track mixer
+/// Egui memory key of the open Show/Hide Tracks dialog.
+const SHOW_HIDE_TRACKS_OPEN: &str = "mixer-show-hide-open";
+
+/// The key the Audio Track Mixer menu shows for `id`: its Audio Track Mixer binding, else its
+/// application-wide one; empty when it has neither.
+fn panel_key(app: &FilmcraftApp, id: &str) -> String {
+ let bindings = app.session.shortcuts.for_command(id);
+ let b = bindings.iter().find(|b| b.panel.as_deref() == Some("Audio Track Mixer")).or_else(|| bindings.iter().find(|b| b.panel.is_none()));
+ b.map(|b| crate::menus::shortcut_text(&b.keys)).unwrap_or_default()
+}
+
+/// Show/Hide Tracks… (`mixer.showHideTracks`): shows the Audio Track Mixer and opens its dialog.
+pub(crate) fn open_show_hide_tracks(app: &mut FilmcraftApp, ctx: &egui::Context) -> Value {
+ app.show_panel(crate::dock::PanelKind::AudioTrackMixer);
+ ctx.data_mut(|d| d.insert_temp(egui::Id::new(SHOW_HIDE_TRACKS_OPEN), true));
+ json!({"dialog": "showHideTracks"})
+}
+
+/// Meter Input(s) Only (`mixer.meterInputOnly`, `{"on":bool?}`): sets the option, or toggles it
+/// without `on`.
+pub(crate) fn set_meter_input_only(app: &mut FilmcraftApp, params: &Value) -> Result<Value, String> {
+ 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")?,
+ };
+ app.ui.mixer_meter_input_only = on;
+ Ok(json!({"meterInputOnly": on}))
+}
+
pub fn track_mixer(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
let t = app.tokens;
// Keep the immutable project snapshot alive while UI commands mutate the session.
@@ -237,16 +267,17 @@ pub fn track_mixer(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
let mresp = ui.interact(menu_r, egui::Id::new("mixer-menu"), Sense::click()).on_hover_text(tl!("Audio Track Mixer menu"));
icons::paint(ui.painter(), menu_r.shrink(2.0), Icon::Hamburger, if mresp.hovered() { t.tab_text_active } else { t.icon });
app.auto.add("mixer.menu", menu_r, "Audio Track Mixer menu");
- let show_hide_id = egui::Id::new("mixer-show-hide-open");
+ let show_hide_id = egui::Id::new(SHOW_HIDE_TRACKS_OPEN);
let mut show_hide: bool = ui.data(|d| d.get_temp(show_hide_id)).unwrap_or(false);
+ let (show_hide_key, meter_input_key) = (panel_key(app, "mixer.showHideTracks"), panel_key(app, "mixer.meterInputOnly"));
egui::Popup::menu(&mresp).show(|ui| {
- let r = ui.button(tl!("Show/Hide Tracks…"));
+ let r = ui.add(egui::Button::new(tl!("Show/Hide Tracks…")).shortcut_text(show_hide_key));
app.auto.add("mixer.menu.showHide", r.rect, "Show/Hide Tracks…");
if r.clicked() {
show_hide = true;
}
let on = app.ui.mixer_meter_input_only;
- let r = ui.selectable_label(on, tl!("Meter Input(s) Only"));
+ let r = ui.add(egui::Button::selectable(on, tl!("Meter Input(s) Only")).shortcut_text(meter_input_key));
app.auto.add("mixer.menu.meterInputOnly", r.rect, "Meter Input(s) Only");
if r.clicked() {
app.ui.mixer_meter_input_only = !on;
diff --git a/crates/ui-egui/tests/it/keyboard_ui.rs b/crates/ui-egui/tests/it/keyboard_ui.rs
index e0147f1d1..57e2e7d6e 100644
--- a/crates/ui-egui/tests/it/keyboard_ui.rs
+++ b/crates/ui-egui/tests/it/keyboard_ui.rs
@@ -125,7 +125,15 @@ fn premiere_table_has_no_dangling_ids_or_new_conflicts() {
}
}
// the Premiere preset binds every new command that Premiere has a key for
- for id in ["timeline.selectClipAtPlayhead", "file.exportFrame", "window.maximizeFrame", "timeline.nudgeRight", "clip.volumeUp"] {
+ for id in [
+ "timeline.selectClipAtPlayhead",
+ "file.exportFrame",
+ "window.maximizeFrame",
+ "timeline.nudgeRight",
+ "clip.volumeUp",
+ "mixer.showHideTracks",
+ "mixer.meterInputOnly",
+ ] {
assert!(!s.shortcuts.for_command(id).is_empty(), "{id} has no key in the Premiere preset");
}
}
@@ -206,6 +214,35 @@ fn new_keys_work_in_the_app() {
assert_eq!(d.app().ui.program.zoom, None);
}
+/// The Audio Track Mixer's Show/Hide Tracks (Cmd+Alt+T) and Meter Input(s) Only (Ctrl+Shift+I)
+/// keys with the mixer focused, and the two commands run from another panel.
+#[test]
+fn audio_track_mixer_keys_open_show_hide_and_toggle_meter_input_only() {
+ let mut d = Driver::new();
+ d.ok("ui.set", json!({"workspace": "Audio"}));
+ d.focus("AudioTrackMixer");
+ let dialog = |d: &mut Driver| !d.ok("ui.elements", json!({"prefix": "mixer.showHide.A1"})).as_array().unwrap().is_empty();
+ assert!(!dialog(&mut d));
+ d.key("Cmd+Alt+T");
+ assert!(dialog(&mut d), "Cmd+Alt+T opens Show/Hide Tracks");
+ d.ok("ui.click", json!({"id": "mixer.showHide.ok"}));
+ d.frames(2);
+ assert!(!dialog(&mut d), "OK closes it");
+ assert!(!d.app().ui.mixer_meter_input_only);
+ d.key("Ctrl+Shift+I");
+ assert!(d.app().ui.mixer_meter_input_only, "Ctrl+Shift+I turns Meter Input(s) Only on");
+ d.key("Ctrl+Shift+I");
+ assert!(!d.app().ui.mixer_meter_input_only, "and off again");
+ // the commands, from anywhere: Show/Hide Tracks brings the mixer forward
+ d.focus("Timeline");
+ let r = d.ok("ui.menu.invoke", json!({"id": "mixer.meterInputOnly", "params": {"on": true}}));
+ assert_eq!(r, json!({"meterInputOnly": true}));
+ d.ok("ui.menu.invoke", json!({"id": "mixer.showHideTracks"}));
+ d.frames(2);
+ assert!(dialog(&mut d), "mixer.showHideTracks opens the dialog");
+ assert_eq!(d.app().ui.focused, filmcraft_ui_egui::dock::PanelKind::AudioTrackMixer);
+}
+
/// 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).
diff --git a/docs/keyboard.md b/docs/keyboard.md
index 487d4df12..7ecca2857 100644
--- a/docs/keyboard.md
+++ b/docs/keyboard.md
@@ -40,7 +40,9 @@ Existing commands that only lacked their Premiere key were added to the table to
Project, Import from Media Browser, Get Media File Properties, Paste Attributes, Find, Edit
Original, Make Subclip, Audio Channels, the Graphics New Layer / Arrange / Select Layer commands,
Program monitor Show Rulers / Show Guides / Snap / Lock Guides, New Bin From Selection, Paste and
-Paste Insert in the Timeline, the Audio Track Mixer Loop).
+Paste Insert in the Timeline, the Audio Track Mixer Loop). The Audio Track Mixer menu's
+Show/Hide Tracks… and Meter Input(s) Only are the commands `mixer.showHideTracks` and
+`mixer.meterInputOnly`, on Cmd+Alt+T and Ctrl+Shift+I with the Audio Track Mixer focused.
FilmCraft Default keeps its own keys where they differ (Shift+E is Clip ▸ Enable there, so Export
Frame has no default key; the Premiere preset moves Shift+E to Export Frame and Enable to ⇧⌘E).
@@ -54,7 +56,6 @@ Frame has no default key; the Premiere preset moves Shift+E to Export Frame and
| Change Draw Mode (⌥⌘L) | Premiere's shape draw modes for the Pen/shape tools; FilmCraft's shape tools have no draw modes. |
| Production panel: New Project, New Folder, Close Project, Make a Copy, Move Selection Home/End/Page Up/Page Down, Move To Trash, Open Project, Zoom In/Out (12 keys) | Productions (shared multi-project folders) are not implemented; there is no Production panel. |
| Search panel: Open in Source Monitor (⇧O) | No separate Search panel; Open Search (⇧⌘F) focuses the Project panel search. |
-| Audio Track Mixer: Show/Hide Tracks… (⌥⌘T), Meter Input(s) Only (⌃⇧I) | The mixer has no track visibility dialog and no input metering (no hardware input recording). |
| Effect Controls: Remove Selected Effect (Delete), Loop During Audio-Only Playback (⌘L) | Effect Controls has no effect selection state and no audio-only playback mode; effects are removed from their context menu or `effects.remove`. |
| Effects panel: New Custom Bin (⌘/), Delete Custom Item (Delete) | The Effects panel has no custom bins (effect presets live in the Presets bin). |
| Media Browser: Select Directory List / Select Media List (⇧← / ⇧→) | The directory tree and media list take no separate keyboard focus. |