From f178286192fd04f0eb7d0c0cfd3c02b0873e74a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Mon, 26 Oct 2026 07:14:03 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20UI=20pass:=20proxies=20off=20by?= =?UTF-8?q?=20default,=20picture-only=20fullscreen,=20hover=20submenus,=20?= =?UTF-8?q?level=20in=20the=20volume=20slider?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Proxies: "Make them on import" now defaults to off (pref file and fresh sessions); the switches say "proxies" so a search finds them. - Fullscreen: a button at the transport's right end; fullscreen draws only the picture and the transport band; Escape leaves it. - Context menu: Clip label and Fit are hover submenus like Adjust and Compound; moving between two ▸ rows switches the open submenu. A right-click inside a selection makes the clicked clip the anchor, so Equalizer no longer refuses on a linked video half; Alt+4 on a video clip opens the EQ on its linked audio. - Volume: the live output level rides inside the slider's fill instead of as separate bars beside it. - Hover hints: label and key chips share one centre line, even padding; undo steps read as verbs ("Undo Enable/disable clip"), clearer wording. - Resize while playing: the picture restart waits until the size has held still for 200 ms instead of reseeking every 8 px. - Ripple trim of a start edge no longer trips the lane's overlap check. - Tests: no longer pinned to one ffmpeg's exact bitrates/offsets; the .edith probe test writes its own project; overflow fixes in test helpers. --- crates/app/src/export_ui.rs | 4 +- crates/app/src/keymap.rs | 8 +- crates/app/src/main.rs | 13 +- crates/app/src/menus.rs | 22 ++- crates/app/src/player/actions.rs | 21 ++- crates/app/src/player/bins.rs | 3 +- crates/app/src/player/cards.rs | 9 + crates/app/src/player/library.rs | 10 +- crates/app/src/player/markers.rs | 3 +- crates/app/src/player/timeline_edit.rs | 28 ++-- crates/app/src/render.rs | 26 +++ crates/app/src/tests/left.rs | 6 +- crates/app/src/tests/media.rs | 14 +- crates/app/src/tests/nocycle.rs | 2 +- crates/app/src/timeline_math.rs | 11 ++ crates/app/src/ui/bench_stance/clip.rs | 2 +- crates/app/src/ui/dock_stance.rs | 8 +- crates/app/src/ui/overlays.rs | 209 ++++++++++++++---------- crates/app/src/ui/popup.rs | 2 +- crates/app/src/ui/settings_stance.rs | 8 +- crates/app/src/ui/stance.rs | 52 +++--- crates/app/src/ui/timeband_stance.rs | 116 ++++++------- crates/app/src/ui/widgets.rs | 22 ++- crates/engine/src/playback.rs | 8 +- crates/engine/src/project.rs | 6 +- crates/engine/tests/it/audio_streams.rs | 16 +- crates/engine/tests/it/bitrate.rs | 41 ++++- crates/engine/tests/it/display_unit.rs | 10 +- crates/engine/tests/it/saveload.rs | 8 +- crates/engine/tests/it/voice_audio.rs | 2 +- crates/mcp/src/tools/listen.rs | 2 +- crates/mcp/src/tools/media.rs | 23 ++- 32 files changed, 444 insertions(+), 271 deletions(-) diff --git a/crates/app/src/export_ui.rs b/crates/app/src/export_ui.rs index 0f9813e..9fc8601 100644 --- a/crates/app/src/export_ui.rs +++ b/crates/app/src/export_ui.rs @@ -536,7 +536,7 @@ pub(crate) fn encoder_label(seat: EncoderSeat) -> &'static str { pub(crate) fn encoder_note(seat: EncoderSeat) -> &'static str { match seat { EncoderSeat::Auto => "GPU encoder if any", - EncoderSeat::Hardware => "GPU encoder or refuse", + EncoderSeat::Hardware => "GPU encoder or fail", EncoderSeat::Software => "software encoder, always", } } @@ -572,7 +572,7 @@ pub(crate) fn encoder_choices(current: EncoderSeat) -> Vec { #[allow(dead_code)] pub(crate) fn av1_hw_warning(format: Format, seat: EncoderSeat) -> Option<&'static str> { (seat == EncoderSeat::Hardware && matches!(format, Format::Av1 | Format::Av1Mp4)) - .then_some("AV1 on the GPU reset this machine's driver once — Software is the safe seat") + .then_some("AV1 on the GPU reset this machine's driver once — Software is the safe choice") } /// How a rendition is named where a person reads it: the panel button, the diff --git a/crates/app/src/keymap.rs b/crates/app/src/keymap.rs index 9c84d8f..a3574ed 100644 --- a/crates/app/src/keymap.rs +++ b/crates/app/src/keymap.rs @@ -812,8 +812,8 @@ impl ActionId { ActionId::TransitionPushDown => "Push down", ActionId::TransitionZoom => "Zoom", ActionId::Reverse => "Reverse clip", - ActionId::ClipEnabled => "Enabled", - ActionId::ClipLabel => "Label", + ActionId::ClipEnabled => "Clip enabled", + ActionId::ClipLabel => "Clip label", ActionId::NewSolid => "Solid colour", ActionId::NewGradient => "Gradient", ActionId::NewCountdown => "Countdown", @@ -838,8 +838,8 @@ impl ActionId { ActionId::CompareSide => "Compare: side by side", ActionId::AutoColour => "Auto colour", ActionId::SaveLook => "Save colour as look\u{2026}", - ActionId::ToggleProxies => "Use editing copies", - ActionId::ToggleAutoProxies => "Editing copies on import", + ActionId::ToggleProxies => "Use proxies for playback", + ActionId::ToggleAutoProxies => "Make proxies on import", ActionId::Theme => "Theme…", ActionId::AccentColour => "Accent colour…", ActionId::Fullscreen => "Fullscreen", diff --git a/crates/app/src/main.rs b/crates/app/src/main.rs index 40aa319..d5ad00b 100644 --- a/crates/app/src/main.rs +++ b/crates/app/src/main.rs @@ -315,9 +315,9 @@ struct Player { ledger_readout: Rc>>, /// Where the status bar's toast text paints: its width is how much of the message fits. toast_text: Rc>>, - /// The clip menu's Adjust row has the pointer: the 150 ms timer opens the - /// submenu only if it still does. - adjust_hot: bool, + /// The clip menu's submenu row (Adjust, Compound, Label or Fit) the pointer is on, if any: + /// its 150 ms timer opens that submenu only if it is still the one under the pointer. + sub_hot: Sub, /// Where the pointer came onto the Adjust row, and the submenu's near edge /// `(x, top, bottom)` (written while drawing): together the "safe triangle" /// a diagonal move toward the submenu may cross without closing it. @@ -1203,6 +1203,10 @@ struct Player { /// closed) cannot have the new session's frame written under the old name /// ([`Player::session_swapped`]). shot_pending: Option<(u64, String, String)>, + /// The viewer size a playing picture was last asked for, and when it first + /// asked for it: a resize is applied only once it has held still for + /// `VIEW_SETTLE` ([`Player::push_view_size`]). `None` while paused. + view_seen: Option<((u32, u32), Instant)>, /// The active session's identity, for the above: bumped by every door that /// swaps `session` or `preview_session`. session_gen: u64, @@ -1534,7 +1538,7 @@ fn main() { menu_sub2: None, ledger_readout: Rc::default(), toast_text: Rc::default(), - adjust_hot: false, + sub_hot: Sub::Closed, adjust_aim: None, adjust_sub: Cell::new(None), picker: None, @@ -1770,6 +1774,7 @@ fn main() { viz_wheel: Rc::default(), picture_box: Rc::default(), shot_pending: None, + view_seen: None, session_gen: 0, // Nothing heard yet: the first pump seeds it off the session // it serves. diff --git a/crates/app/src/menus.rs b/crates/app/src/menus.rs index 0f7cd0f..15f0864 100644 --- a/crates/app/src/menus.rs +++ b/crates/app/src/menus.rs @@ -56,11 +56,22 @@ pub(crate) struct ContextMenu { pub(crate) on: MenuOn, pub(crate) at: Point, pub(crate) details: bool, - /// A submenu is out beside the plate: "Adjust" (the card openers), or "Compound" when - /// [`ContextMenu::compound`] says so. One at a time. - pub(crate) adjust: bool, - /// The submenu that is out is "Compound" (nest, break apart, open), not "Adjust". - pub(crate) compound: bool, + /// The submenu out beside the plate, if any. One at a time. + pub(crate) sub: Sub, +} + +/// Which submenu of a clip menu is out beside the plate. +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub(crate) enum Sub { + Closed, + /// The card openers. + Adjust, + /// Nest, break apart, open, flatten. + Compound, + /// The colour list of the clip. + Label, + /// The fit policies of the clip. + Fit, } /// An open library menu: which row it was opened on -- the file and the stream, @@ -535,7 +546,6 @@ pub(crate) fn adjust_item(action: ActionId) -> bool { | ActionId::Reframe | ActionId::TrackMask | ActionId::Speed - | ActionId::Fit ) } diff --git a/crates/app/src/player/actions.rs b/crates/app/src/player/actions.rs index b9aa552..7a0adcd 100644 --- a/crates/app/src/player/actions.rs +++ b/crates/app/src/player/actions.rs @@ -11,8 +11,19 @@ use crate::*; pub(crate) fn step_name(action: ActionId) -> Option<&'static str> { let name = match action { ActionId::Undo | ActionId::Redo => return None, - ActionId::ClipEnabled => "Clip enabled", - ActionId::ClipLabel => "Clip label", + ActionId::ClipEnabled => "Enable/disable clip", + ActionId::ClipLabel => "Set clip label", + ActionId::NewSolid => "Add solid colour", + ActionId::NewGradient => "Add gradient", + ActionId::NewCountdown => "Add countdown", + ActionId::NewBars => "Add colour bars", + ActionId::NewTone => "Add tone", + ActionId::NewBarsAndTone => "Add bars and tone", + ActionId::NewAdjustment => "Add adjustment layer", + ActionId::NewRectangle => "Add rectangle shape", + ActionId::NewEllipse => "Add ellipse shape", + ActionId::NewLine => "Add line shape", + ActionId::NewArrow => "Add arrow shape", _ => action.label().trim_end_matches('\u{2026}'), }; (name.chars().count() < 30).then_some(name) @@ -312,6 +323,9 @@ impl Player { // claimed the key, so it empties every selection the timeline // holds -- clips, a picked gap, a title and a caption -- and the // Clip tab goes back to what it shows with nothing picked. + // In player fullscreen Escape leaves it first, the way every video player does; the + // picks stay where they are until the next Escape. + ActionId::Deselect if self.player_fullscreen => self.run_action(ActionId::Fullscreen, window, cx), ActionId::Deselect => self.clear_picks(cx), // A picked gap is what Delete closes (DESIGN §7); a clip mark or // nothing at all falls through to the clip path as before. @@ -1644,7 +1658,8 @@ mod tests { assert_eq!(step_name(ActionId::Color), Some("Colour")); assert_eq!(step_name(ActionId::AddMarker), Some("Add marker")); assert_eq!(step_name(ActionId::Delete), Some("Delete")); - assert_eq!(step_name(ActionId::ClipEnabled), Some("Clip enabled")); + assert_eq!(step_name(ActionId::ClipEnabled), Some("Enable/disable clip")); + assert_eq!(step_name(ActionId::NewTone), Some("Add tone")); assert_eq!(step_name(ActionId::Undo), None); assert_eq!(step_name(ActionId::Redo), None); for action in ActionId::ALL { diff --git a/crates/app/src/player/bins.rs b/crates/app/src/player/bins.rs index f4bd528..6d13f30 100644 --- a/crates/app/src/player/bins.rs +++ b/crates/app/src/player/bins.rs @@ -154,8 +154,7 @@ impl Player { on: MenuOn::Bin, at, details: false, - adjust: false, - compound: false, + sub: Sub::Closed, }); cx.notify(); } diff --git a/crates/app/src/player/cards.rs b/crates/app/src/player/cards.rs index a95bbea..cf82702 100644 --- a/crates/app/src/player/cards.rs +++ b/crates/app/src/player/cards.rs @@ -3789,6 +3789,15 @@ impl Player { } _ => self.selected.anchor(), }; + // A video clip's sound is its linked audio half, so Alt+4 on a picked film opens on that. + let anchor = match anchor { + Some((lane, idx)) if lane.kind == LaneKind::Video => self + .linked_partners((lane, idx)) + .into_iter() + .find(|(l, _)| l.kind == LaneKind::Audio) + .or(anchor), + _ => anchor, + }; let refusal = match (anchor, &self.session) { (_, None) => Some("No timeline — no file open".to_string()), (None, _) => Some(format!( diff --git a/crates/app/src/player/library.rs b/crates/app/src/player/library.rs index 964da73..c427947 100644 --- a/crates/app/src/player/library.rs +++ b/crates/app/src/player/library.rs @@ -72,13 +72,13 @@ pub(crate) fn auto_proxies_pref_path() -> PathBuf { crate::keymap::Keymap::config_path().with_file_name("auto-proxies") } -/// `On` unless the file says `off`; missing, unreadable or garbled all read as -/// `On`, the same default the field has always started at -- a preference -/// file is not the user's work, so a bad one is worth no message at startup. +/// `Off` unless the file says `on`; missing, unreadable or garbled all read as +/// `Off`, the same as [`load_proxies_pref`] -- a preference file is not the +/// user's work, so a bad one is worth no message at startup. pub(crate) fn load_auto_proxies_pref() -> bool { match std::fs::read_to_string(auto_proxies_pref_path()) { - Ok(text) => text.trim() != "off", - Err(_) => true, + Ok(text) => text.trim() == "on", + Err(_) => false, } } diff --git a/crates/app/src/player/markers.rs b/crates/app/src/player/markers.rs index 2c1f72e..7a77ebc 100644 --- a/crates/app/src/player/markers.rs +++ b/crates/app/src/player/markers.rs @@ -183,8 +183,7 @@ impl Player { on: MenuOn::Marker, at, details: false, - adjust: false, - compound: false, + sub: Sub::Closed, }); cx.notify(); } diff --git a/crates/app/src/player/timeline_edit.rs b/crates/app/src/player/timeline_edit.rs index 7fc8aed..d6ec765 100644 --- a/crates/app/src/player/timeline_edit.rs +++ b/crates/app/src/player/timeline_edit.rs @@ -1555,7 +1555,12 @@ impl Player { if !self.menu_allowed() { return; } - if !self.selected.contains((lane, idx)) { + if self.selected.contains((lane, idx)) { + // Kept, but this clip becomes the anchor: Equalizer, Speed and the other + // one-clip items read the anchor, and inside a linked pair it could be the + // other half -- the video one, which the equalizer then refused. + self.selected.promote((lane, idx)); + } else { self.select((lane, idx), cx); } self.context_menu = Some(ContextMenu { @@ -1563,8 +1568,7 @@ impl Player { on: MenuOn::Clip(idx), at, details: false, - adjust: false, - compound: false, + sub: Sub::Closed, }); cx.notify(); } @@ -1588,8 +1592,7 @@ impl Player { on: MenuOn::Gap(start, frames), at, details: false, - adjust: false, - compound: false, + sub: Sub::Closed, }); cx.notify(); } @@ -1613,8 +1616,7 @@ impl Player { on: MenuOn::Bench, at, details: false, - adjust: false, - compound: false, + sub: Sub::Closed, }); cx.notify(); } @@ -1633,8 +1635,7 @@ impl Player { on: MenuOn::Empty, at, details: false, - adjust: false, - compound: false, + sub: Sub::Closed, }); cx.notify(); } @@ -1655,8 +1656,7 @@ impl Player { on: MenuOn::Viewer, at, details: false, - adjust: false, - compound: false, + sub: Sub::Closed, }); cx.notify(); } @@ -1676,8 +1676,7 @@ impl Player { on: MenuOn::SeqTab, at, details: false, - adjust: false, - compound: false, + sub: Sub::Closed, }); cx.notify(); } @@ -1695,8 +1694,7 @@ impl Player { on: MenuOn::Head, at, details: false, - adjust: false, - compound: false, + sub: Sub::Closed, }); cx.notify(); } diff --git a/crates/app/src/render.rs b/crates/app/src/render.rs index 7360e76..fda584a 100644 --- a/crates/app/src/render.rs +++ b/crates/app/src/render.rs @@ -181,6 +181,12 @@ impl Player { } } +/// How long a viewer size must hold still while playing before the picture is +/// restarted for it. Each restart stalls the picture until the new stream +/// refills, so a window being dragged (a step every few pixels) is applied +/// once the drag rests instead of on every step. +const VIEW_SETTLE: std::time::Duration = std::time::Duration::from_millis(200); + impl Player { /// Tells the active session where the picture actually lands, in device /// pixels, so its seats can paint at that size instead of the project's @@ -223,6 +229,26 @@ impl Player { let w = (f32::from(fitted.size.width) * scale).round() as u32; let h = (f32::from(fitted.size.height) * scale).round() as u32; let (w, h) = self.viewer_target((w, h), native, playing); + // Playing: a size that is still moving is held back until it has rested + // for VIEW_SETTLE, since every apply restarts the picture. Paused, a frame + // is cheap and must be sharp, so the size is applied at once. + let settled = if !playing { + self.view_seen = None; + true + } else { + match self.view_seen { + Some((size, since)) if size == (w, h) => since.elapsed() >= VIEW_SETTLE, + _ => { + self.view_seen = Some(((w, h), Instant::now())); + false + } + } + }; + if !settled { + // The loop keeps turning while playing; asked again in case it does not. + window.request_animation_frame(); + return; + } let Some(session) = self.active_session_mut() else { return; }; diff --git a/crates/app/src/tests/left.rs b/crates/app/src/tests/left.rs index 92965e0..143408d 100644 --- a/crates/app/src/tests/left.rs +++ b/crates/app/src/tests/left.rs @@ -12,10 +12,10 @@ fn eq_numbers_read_the_way_the_card_shows_them() { } #[test] -fn the_library_menu_says_editing_copy_not_proxy() { +fn the_proxy_switches_say_proxy_so_a_search_finds_them() { assert_eq!(RowItem::Proxy.label(), "Make editing copy"); - assert!(!keymap::ActionId::ToggleProxies.label().to_lowercase().contains("proxies")); - assert!(!keymap::ActionId::ToggleAutoProxies.label().to_lowercase().contains("proxies")); + assert!(keymap::ActionId::ToggleProxies.label().to_lowercase().contains("proxies")); + assert!(keymap::ActionId::ToggleAutoProxies.label().to_lowercase().contains("proxies")); } #[test] diff --git a/crates/app/src/tests/media.rs b/crates/app/src/tests/media.rs index cdd3a41..ad25405 100644 --- a/crates/app/src/tests/media.rs +++ b/crates/app/src/tests/media.rs @@ -1296,9 +1296,9 @@ fn the_subtitle_card_sizes_outlines_and_offsets_are_bounded() { /// call the same claim it makes about Proxies: a project's own line always /// beats this one once one is open ([`engine::edith::Document::auto_proxy`]), /// but with nothing open (or nothing saved since the flip) this is what a -/// relaunch reads instead of the field's hardcoded `true`. +/// relaunch reads instead of the hardcoded Off. #[test] -fn the_auto_proxies_default_round_trips_through_its_own_config_file_or_falls_back_to_on() { +fn the_auto_proxies_default_round_trips_through_its_own_config_file_or_falls_back_to_off() { let _config_env = config_env_lock(); let dir = std::env::temp_dir().join(format!( @@ -1314,8 +1314,8 @@ fn the_auto_proxies_default_round_trips_through_its_own_config_file_or_falls_bac // path. crate::keymap::set_test_config_home(Some(dir.clone())); - // Nothing written yet: On, the field's own long-standing default. - assert!(load_auto_proxies_pref(), "a missing file must read as On"); + // Nothing written yet: Off, the default. + assert!(!load_auto_proxies_pref(), "a missing file must read as Off"); save_auto_proxies_pref(false).unwrap(); assert!(!load_auto_proxies_pref(), "off must round-trip"); @@ -1326,12 +1326,12 @@ fn the_auto_proxies_default_round_trips_through_its_own_config_file_or_falls_bac "on must round-trip too, not just off" ); - // Garbled bytes -- a stray edit, or a future dialect -- read as On rather + // Garbled bytes -- a stray edit, or a future dialect -- read as Off rather // than failing a startup on someone else's edit of the file. std::fs::write(auto_proxies_pref_path(), "not on or off\n").unwrap(); assert!( - load_auto_proxies_pref(), - "unreadable content must fall back to On" + !load_auto_proxies_pref(), + "unreadable content must fall back to Off" ); crate::keymap::set_test_config_home(None); diff --git a/crates/app/src/tests/nocycle.rs b/crates/app/src/tests/nocycle.rs index ba3aef2..9e33eb5 100644 --- a/crates/app/src/tests/nocycle.rs +++ b/crates/app/src/tests/nocycle.rs @@ -58,7 +58,7 @@ fn the_rows_that_became_lists_say_so_in_their_labels() { assert_eq!(ActionId::Fit.label(), "Fit to frame…"); assert_eq!(ActionId::KeyEasing.label(), "Key easing…"); assert_eq!(ActionId::SpeedRampFastSlowFast.label(), "Speed ramp fast-slow-fast"); - assert_eq!(ActionId::ToggleProxies.label(), "Use editing copies"); + assert_eq!(ActionId::ToggleProxies.label(), "Use proxies for playback"); } #[test] diff --git a/crates/app/src/timeline_math.rs b/crates/app/src/timeline_math.rs index 1a98a1f..7459b73 100644 --- a/crates/app/src/timeline_math.rs +++ b/crates/app/src/timeline_math.rs @@ -141,6 +141,17 @@ impl Selection { self.picks.last().copied() } + /// Moves `pick`, already one of the selection's, to the end, so it becomes + /// the [`Self::anchor`] while every other pick stays: a right-click inside a + /// selection keeps it, and the menu's one-clip items still act on the clip + /// the hand named. + pub(crate) fn promote(&mut self, pick: (Lane, usize)) { + if let Some(at) = self.picks.iter().position(|p| *p == pick) { + let pick = self.picks.remove(at); + self.picks.push(pick); + } + } + /// Whether `pick` is one of the selection's -- the question a right-click /// asks before it decides whether the menu is about the selection or /// about the clip under it. diff --git a/crates/app/src/ui/bench_stance/clip.rs b/crates/app/src/ui/bench_stance/clip.rs index 6710542..3d60ec5 100644 --- a/crates/app/src/ui/bench_stance/clip.rs +++ b/crates/app/src/ui/bench_stance/clip.rs @@ -1217,7 +1217,7 @@ pub(crate) fn hover_hint_text(zone: HoverZone, shift: bool, alt: bool) -> &'stat "Shift-drag: change which part of the clip plays \u{00b7} add Alt to slide" } (HoverZone::Body, true, true) => { - "Shift+Alt-drag: slide, neighbours give and take" + "Shift+Alt-drag: slide; neighbouring clips absorb the change" } (HoverZone::Body, false, true) => "Alt-drag: move with snapping off", } diff --git a/crates/app/src/ui/dock_stance.rs b/crates/app/src/ui/dock_stance.rs index d074587..b86f3b9 100644 --- a/crates/app/src/ui/dock_stance.rs +++ b/crates/app/src/ui/dock_stance.rs @@ -1737,8 +1737,7 @@ fn opens_dock_menu( on: MenuOn::Dock, at: event.position, details: false, - adjust: false, - compound: false, + sub: Sub::Closed, }); cx.notify(); }) @@ -2168,8 +2167,7 @@ fn sources_tab( on: MenuOn::Dock, at, details: false, - adjust: false, - compound: false, + sub: Sub::Closed, }); cx.notify(); })), @@ -2186,7 +2184,7 @@ fn sources_tab( div() .id("dock-which") .flex_none() - .tooltip(crate::ui::widgets::tip_hover("Which media", "", None)) + .tooltip(crate::ui::widgets::tip_hover("Show all media or favourites only", "", None)) .child(kit::segmented( "dock-which-seg", &[Segment::text("All"), Segment::text("Favourites")], diff --git a/crates/app/src/ui/overlays.rs b/crates/app/src/ui/overlays.rs index 9a91ce7..5d6ca35 100644 --- a/crates/app/src/ui/overlays.rs +++ b/crates/app/src/ui/overlays.rs @@ -170,6 +170,9 @@ impl Player { let mut sub_rows: Vec = Vec::new(); let mut sub_measure: Vec<(String, String)> = Vec::new(); let mut adjust_at: Option = None; + // Where the Clip label and Fit to frame rows sit, each opening its own submenu. + let mut label_at: Option = None; + let mut fit_at: Option = None; let mut comp_rows: Vec = Vec::new(); let mut comp_measure: Vec<(String, String)> = Vec::new(); let mut rows: Vec = Vec::new(); @@ -299,63 +302,71 @@ impl Player { let (comp_list, main_list): (Vec, Vec) = rest.into_iter().partition(|a| fold && crate::menus::compound_item(*a)); let has_comp = !comp_list.is_empty(); + // Whether a row of the main list opens a choice submenu (Clip label, Fit to frame). + let has_pick = fold + && idx.is_some() + && main_list.iter().any(|a| matches!(a, ActionId::ClipLabel | ActionId::Fit)); + // A ▸ row that opens the submenu `which` beside itself. Hovering it opens that + // submenu after ADJUST_HOVER, a click at once. Each row tracks its own hot state + // (`sub_hot`), so resting on another ▸ row after the first has opened switches it. let sub_row = |rows: &mut Vec, measure: &mut Vec<(String, String)>, - which: bool, + which: Sub, + (name, icon): (&'static str, Option), + enabled: bool, cx: &mut Context| { - let name = if which { "Compound" } else { "Adjust" }; + let id: usize = match which { + Sub::Compound => 901, + Sub::Label => 902, + Sub::Fit => 903, + Sub::Adjust | Sub::Closed => 900, + }; measure.push((name.into(), "▸".into())); rows.push( - popup_row_icon( - ("menu", 900usize + usize::from(which)), - name, - "▸", - Some(false), - Some(if which { - crate::ui::icons::Icon::Layers - } else { - crate::ui::icons::Icon::SlidersHorizontal - }), - None, - ) - .on_hover(cx.listener(move |this, on: &bool, window, cx| { - this.adjust_hot = *on; - if !*on { - return; - } - // Where the pointer came onto the row: the apex of - // the safe triangle toward the submenu. - this.adjust_aim = Some(window.mouse_position()); - if this.context_menu.is_some_and(|m| !m.adjust || m.compound != which) { - // Hover intent: opens once the pointer has - // rested on the row for a moment, so a - // pointer crossing it does not flash the - // submenu. - cx.spawn(async move |this, cx| { - cx.background_executor().timer(ADJUST_HOVER).await; - let _ = this.update(cx, |this, cx| { - if this.adjust_hot - && let Some(m) = &mut this.context_menu - && (!m.adjust || m.compound != which) - { - m.adjust = true; - m.compound = which; - cx.notify(); - } - }); - }) - .detach(); - } - })) + popup_row_icon(("menu", id), name, "▸", Some(false), icon, None) + .when(enabled, |d| { + d.on_hover(cx.listener(move |this, on: &bool, window, cx| { + if !*on { + if this.sub_hot == which { + this.sub_hot = Sub::Closed; + } + return; + } + this.sub_hot = which; + // Where the pointer came onto the row: the apex of + // the safe triangle toward the submenu. + this.adjust_aim = Some(window.mouse_position()); + if this.context_menu.is_some_and(|m| m.sub != which) { + // Hover intent: opens once the pointer has + // rested on the row for a moment, so a + // pointer crossing it does not flash the + // submenu. + cx.spawn(async move |this, cx| { + cx.background_executor().timer(ADJUST_HOVER).await; + let _ = this.update(cx, |this, cx| { + if this.sub_hot == which + && let Some(m) = &mut this.context_menu + && m.sub != which + { + m.sub = which; + cx.notify(); + } + }); + }) + .detach(); + } + })) + }) // A click opens it at once and never shuts it: the // hover may have opened it a moment before. - .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { - if let Some(m) = &mut this.context_menu { - m.adjust = true; - m.compound = which; - } - cx.notify(); - })) + .when(enabled, |d| { + d.on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { + if let Some(m) = &mut this.context_menu { + m.sub = which; + } + cx.notify(); + })) + }) .into_any_element(), ); }; @@ -366,9 +377,9 @@ impl Player { adjust_at: &mut Option, cx: &mut Context| { *adjust_at = Some(rows.len()); - sub_row(rows, measure, false, cx); + sub_row(rows, measure, Sub::Adjust, ("Adjust", Some(crate::ui::icons::Icon::SlidersHorizontal)), true, cx); if has_comp { - sub_row(rows, measure, true, cx); + sub_row(rows, measure, Sub::Compound, ("Compound", Some(crate::ui::icons::Icon::Layers)), true, cx); } }; // 0: the plate; 1: the Adjust submenu; 2: the Compound submenu. @@ -404,6 +415,22 @@ impl Player { // rather than printing a stroke that would do nothing. let refusal = enable(action, ctx.clone()); let enabled = refusal.yes(); + // Clip label and Fit to frame are ▸ rows like Adjust: the list they + // offer hangs beside the row, and the row itself runs nothing. + if let (true, Some(_), ActionId::ClipLabel | ActionId::Fit) = (fold, idx, action) { + let (which, name) = match action { + ActionId::Fit => { + fit_at = Some(rows.len()); + (Sub::Fit, "Fit to frame") + } + _ => { + label_at = Some(rows.len()); + (Sub::Label, "Clip label") + } + }; + sub_row(rows, measure, which, (name, crate::menus::icon(action)), enabled, cx); + continue; + } // The one item that is not about this clip says so, and says it // here rather than in the registry: the stroke is global too, // but its row in the keys menu is not sitting on a clip. @@ -422,7 +449,8 @@ impl Player { ActionId::ToggleSnap => { format!("Snap — {}", if self.snap { "on" } else { "off" }) } - ActionId::ClipLabel => "Label".to_string(), + // A ▸ row in this menu, not a dialog: no ellipsis on its label. + ActionId::Fit => "Fit to frame".to_string(), // Plain words for the three that read as jargon; the action ids stay. ActionId::LoopTrim => "Loop while trimming".to_string(), ActionId::Dissolve => "Blend into next clip".to_string(), @@ -447,10 +475,7 @@ impl Player { | ActionId::NewTitle => format!("New {}", full.to_lowercase()), _ => full.to_string(), }; - let hint = match action { - ActionId::ClipLabel | ActionId::Fit => "▸".to_string(), - _ => shortcut(&self.keymap, action), - }; + let hint = shortcut(&self.keymap, action); // A switch wears the menu's ✓ when on, the bar's own style. let check = match (action, menu.on) { (ActionId::ClipEnabled, _) => Some({ @@ -472,7 +497,7 @@ impl Player { crate::menus::icon(action), refusal.why(), ) - .when(!is_sub && has_sub, |d| { + .when(!is_sub && (has_sub || has_pick), |d| { d.on_hover(cx.listener(|this, on: &bool, window, cx| { // Another row under the pointer closes the // submenu -- unless the pointer is crossing @@ -488,10 +513,10 @@ impl Player { }; if let Some(m) = &mut this.context_menu && *on - && m.adjust + && m.sub != Sub::Closed && !toward { - m.adjust = false; + m.sub = Sub::Closed; cx.notify(); } })) @@ -505,28 +530,11 @@ impl Player { d.cursor_pointer() .hover(|s| s.bg(rgba(crate::ui::theme::WASH_HOVER))) .on_click(cx.listener( - move |this, event: &ClickEvent, window, cx| { + move |this, _: &ClickEvent, window, cx| { // Closed first: the action moves the very // indices this menu is holding. this.context_menu = None; - // The one item that is a *choice* and not a - // doing: four policies, so the pointer gets - // the list of them on this clip rather than - // the next one stepped to behind the click. - // The stroke still steps -- same door. - if let (ActionId::ClipLabel, Some(idx)) = (action, idx) { - this.open_picker( - Pick::Label(menu.lane, idx), - event.position(), - cx, - ); - } else if let (ActionId::Fit, Some(idx)) = (action, idx) { - this.open_picker( - Pick::Fit(menu.lane, idx), - event.position(), - cx, - ); - } else if let (MenuOn::Head, Some(size)) = + if let (MenuOn::Head, Some(size)) = (menu.on, crate::ui::bench_stance::TrackSize::of_action(action)) { // A header's own height: this track only, not every track. @@ -610,10 +618,20 @@ impl Player { let h = MENU_PAD * 2. + list_h; let pw = popup_w(measure.iter().map(|(l, h)| (l.as_str(), h.as_str())), true); let (x, y) = menu_at_w(menu_above(at, viewport, floor, h), viewport, pw, h); - // The submenu that is out: Adjust's, or Compound's. - let (sub_rows, sub_measure, sub_at) = match menu.compound { - true => (comp_rows, comp_measure, adjust_at.map(|a| a + 1)), - false => (sub_rows, sub_measure, adjust_at), + // The submenu that is out, and the row it hangs from: Adjust's, Compound's, or a + // choice list (Clip label, Fit to frame) built from the picker's own rows. + let (sub_rows, sub_measure, sub_at) = match (menu.sub, idx) { + (Sub::Adjust, _) => (sub_rows, sub_measure, adjust_at), + (Sub::Compound, _) => (comp_rows, comp_measure, adjust_at.map(|a| a + 1)), + (Sub::Label, Some(idx)) => { + let (rows, measure) = self.choice_sub_rows(Pick::Label(menu.lane, idx), cx); + (rows, measure, label_at) + } + (Sub::Fit, Some(idx)) => { + let (rows, measure) = self.choice_sub_rows(Pick::Fit(menu.lane, idx), cx); + (rows, measure, fit_at) + } + _ => (Vec::new(), Vec::new(), None), }; // The submenu's near edge, for the safe triangle (see `adjust_sub`). self.adjust_sub.set(match sub_rows.is_empty() { @@ -689,9 +707,9 @@ impl Player { .children(rows), ), ) - // The Adjust submenu, beside the plate at its row; on the left + // The open submenu, beside the plate at its row; on the left // of it where the right edge has no room. - .children((menu.adjust && !sub_rows.is_empty()).then(|| { + .children((!sub_rows.is_empty()).then(|| { let sw = popup_w( sub_measure.iter().map(|(l, h)| (l.as_str(), h.as_str())), true, @@ -715,6 +733,27 @@ impl Player { ) } + /// The rows of a clip menu's choice submenu: the list the picker shows for `of` + /// ([`Player::choices`]), each row picking through [`Player::choose`] and closing the menu. + fn choice_sub_rows(&self, of: Pick, cx: &mut Context) -> (Vec, Vec<(String, String)>) { + let mut rows: Vec = Vec::new(); + let mut measure: Vec<(String, String)> = Vec::new(); + for (n, (choice, label, detail, picked)) in self.choices(of).into_iter().enumerate() { + measure.push((label.to_string(), detail.to_string())); + rows.push( + popup_row(("menu-choice", n), label, detail, Some(picked), None) + .cursor_pointer() + .hover(|s| s.bg(rgba(crate::ui::theme::WASH_HOVER))) + .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { + this.context_menu = None; + this.choose(choice, cx); + })) + .into_any_element(), + ); + } + (rows, measure) + } + /// The open choice list: every value of one enumerated setting at once, the /// one in force marked, and a click on any of them picks *that* one -- what /// a button stepping one value on per click could never say. Built on the diff --git a/crates/app/src/ui/popup.rs b/crates/app/src/ui/popup.rs index eac48be..a3708d7 100644 --- a/crates/app/src/ui/popup.rs +++ b/crates/app/src/ui/popup.rs @@ -475,7 +475,7 @@ mod tests { .filter(|a| !crate::menus::adjust_item(**a) && !crate::menus::compound_item(**a)) .count() + 3; // Adjust, Compound and Properties - assert!(top <= 19, "{top} rows"); + assert!(top <= 20, "{top} rows"); let view = size(px(1280.), px(720.)); let list_h = crate::oracle::menu_rows_h(top + 1, view); let h = MENU_PAD * 2. + list_h; diff --git a/crates/app/src/ui/settings_stance.rs b/crates/app/src/ui/settings_stance.rs index 1f941c1..cfddc49 100644 --- a/crates/app/src/ui/settings_stance.rs +++ b/crates/app/src/ui/settings_stance.rs @@ -642,7 +642,7 @@ fn project_section(player: &Player, cx: &mut Context) -> impl IntoElemen // ([`Player::proxy_tail`], its own separator dropped). .child(choice_row( "settings-proxies", - "Editing copies", + "Editing copies (proxies)", "Lighter copies for smooth playback; export always uses the originals", chord_of(player, ActionId::ToggleProxies), { @@ -694,7 +694,7 @@ fn still_row(player: &Player, cx: &mut Context) -> impl IntoElement { .tooltip(crate::ui::widgets::tip_hover( "Still image length", "", - Some("how long a picture or title card is placed for when it is dropped on the timeline; clips already placed keep theirs"), + Some("How long a picture or title card lasts when it is dropped on the timeline; clips already placed keep theirs"), )) .child( div() @@ -924,7 +924,7 @@ fn vivid_row(player: &Player, cx: &mut Context) -> impl IntoElement { .tooltip(crate::ui::widgets::overlay_tip_hover( "Vivid", "", - Some("How strong the accent colour is: 0 is a faint tint, 50 the colours as designed, 100 bold."), + Some("How strong the accent colour is: 0 is a faint tint, 50 keeps the colours as designed, 100 bold."), )) .child(slider_row_inline( SliderRow { @@ -2046,7 +2046,7 @@ mod tests { // (label, tail, row); the key lives in the tooltip, the column is empty. let rows: [(&str, &str, ChoiceRow); 3] = [ ("When HDR plays on a normal screen", "", ChoiceRow::Tone), - ("Editing copies", "100%", ChoiceRow::Proxies), + ("Editing copies (proxies)", "100%", ChoiceRow::Proxies), (" Make them on import", "", ChoiceRow::AutoProxies), ]; for (label, tail, row) in rows { diff --git a/crates/app/src/ui/stance.rs b/crates/app/src/ui/stance.rs index 00a7288..195ec73 100644 --- a/crates/app/src/ui/stance.rs +++ b/crates/app/src/ui/stance.rs @@ -1412,6 +1412,9 @@ pub(crate) fn render( // disagree here either. let dock_w = player.split_px(Split::Dock, window_size); let bench_h = player.split_px(Split::Bench, window_size); + // Player fullscreen (F11, `ActionId::Fullscreen`): the picture and the transport band only. + // Only the children below change; the root keeps its handlers and focus. + let fullscreen = player.player_fullscreen; div() .id("stance-room") // Inter is the default face for any text that sets no role of its own. @@ -1451,7 +1454,7 @@ pub(crate) fn render( if let (Some(m), "left" | "right") = (this.context_menu.as_mut(), key) && matches!(m.on, MenuOn::Clip(_)) { - m.adjust = key == "right"; + m.sub = if key == "right" { Sub::Adjust } else { Sub::Closed }; cx.notify(); return; } @@ -1937,9 +1940,9 @@ pub(crate) fn render( .size_full() // The menu bar is laid over the top rows (`menubar::bar`, absolute), so // the room starts below it. - .pt(px(MENU_BAR_H)) + .pt(px(if fullscreen { 0. } else { MENU_BAR_H })) .flex() - .bg(rgb(DARK_CANVAS())) + .bg(rgb(if fullscreen { 0x000000 } else { DARK_CANVAS() })) .children(hitmap::frame()) .child(mouse_exit_listener(cx)) .child( @@ -1954,15 +1957,20 @@ pub(crate) fn render( .min_w(px(0.)) .flex() .flex_col() - .child(screen(player, position, window, cx)) + // Fullscreen stands the picture up alone (the same builder the + // darkroom's screen uses), with the time band under it. + .when(fullscreen, |el| el.child(player.picture_area(position, window, cx))) + .when(!fullscreen, |el| el.child(screen(player, position, window, cx))) .child(time_band(player, position, cx)) - .child(divider( - Split::Bench, - player.split_drag == Some(Split::Bench), - cx, - )) - .child(bench(player, bench_h, window, cx)) - .child(ledger(player, cx)) + .when(!fullscreen, |el| { + el.child(divider( + Split::Bench, + player.split_drag == Some(Split::Bench), + cx, + )) + .child(bench(player, bench_h, window, cx)) + .child(ledger(player, cx)) + }) // A maximized clip param card (EQ/Colour/Transform/Speed/ // Silence/Mix/Subtitle style) escapes the dock to mount here // instead, the same window-space `stance-centre` context @@ -1975,7 +1983,7 @@ pub(crate) fn render( // same seven functions stay mounted in the dock // (`dock_stance::clip_tab`'s own `.when(!card_maximized, ...)` // guard keeps this from ever double-mounting one). - .when(player.card_maximized, |el| { + .when(player.card_maximized && !fullscreen, |el| { el.children(player.eq_card(window_size, cx)) .children(player.color_card(window_size, cx)) .children(player.transform_card(window_size, cx)) @@ -1990,12 +1998,14 @@ pub(crate) fn render( .children(player.subtitle_style_card(window_size, cx)) }), ) - .child(divider( - Split::Dock, - player.split_drag == Some(Split::Dock), - cx, - )) - .child(dock(player, dock_w, window_size, window, cx)) + .when(!fullscreen, |el| { + el.child(divider( + Split::Dock, + player.split_drag == Some(Split::Dock), + cx, + )) + .child(dock(player, dock_w, window_size, window, cx)) + }) // All three hanging menus (DESIGN §9: "verbs of the thing under the // cursor") mount on the ROOT, and none of them inside // `stance-centre`. Their anchors are *window* coordinates -- a @@ -2013,8 +2023,10 @@ pub(crate) fn render( // menu, then the open list last so it floats over whichever row set it. // The menu bar sits over the room's top edge and its click-away under // the root's own menus; its dropdown is deferred, so it paints over both. - .child(menubar::bar(player, f32::from(viewport.width), f32::from(viewport.height), cx)) - .children(menubar::backdrop(player, cx)) + .when(!fullscreen, |el| { + el.child(menubar::bar(player, f32::from(viewport.width), f32::from(viewport.height), cx)) + .children(menubar::backdrop(player, cx)) + }) .children(player.context_card(viewport, cx)) .children(player.library_card(viewport, cx)) .children(player.picker_card(viewport, cx)) diff --git a/crates/app/src/ui/timeband_stance.rs b/crates/app/src/ui/timeband_stance.rs index f0d6939..ed4e436 100644 --- a/crates/app/src/ui/timeband_stance.rs +++ b/crates/app/src/ui/timeband_stance.rs @@ -1,7 +1,7 @@ //! The transport band's own content (REDESIGN §3.3, DESIGN.md §6.3): the //! timecode on the left, icon-only transport controls centred (go to start, //! frame back, play, frame forward, go to end, loop), then mute, the volume -//! slider and the level meter on the right. Words and keys live in the +//! slider, the level meter and fullscreen on the right. Words and keys live in the //! tooltips only. The trim deltas show only while a loop-trim roll is armed. //! The band is 44px tall. The overview strip sits above the ruler //! (`ui/bench_stance/overview.rs`); Export lives on the menu bar @@ -137,6 +137,7 @@ fn volume_slider(player: &Player, cx: &mut Context) -> impl IntoElement let t = crate::ui::theme::tokens(); let fill = if player.volume.muted { t.ink3 } else { t.accent }; let half = VOLUME_THUMB / 2.; + let level = master_level(player); div() .id("stance-volume") .flex_none() @@ -147,7 +148,7 @@ fn volume_slider(player: &Player, cx: &mut Context) -> impl IntoElement .tooltip(crate::ui::widgets::tip_hover( "Volume", "", - Some(&format!("{}%", player.volume.percent())), + Some(&format!("{}% \u{b7} the bright part is the sound playing now", player.volume.percent())), )) .on_mouse_down( MouseButton::Left, @@ -174,10 +175,26 @@ fn volume_slider(player: &Player, cx: &mut Context) -> impl IntoElement .bg(rgb(t.e3)) .child( div() + .relative() .h_full() .w(relative(player.volume.along())) .rounded(px(2.)) - .bg(rgb(fill)), + // Playing, the set level dims to a bed and the live level + // rides inside it; at rest it is the plain fill. + .map(|d| match level { + Some(_) => d.bg(rgba((fill << 8) | 0x55)), + None => d.bg(rgb(fill)), + }) + .children(level.map(|(frac, hot, clipped)| { + let ink = if clipped { + crate::ui::theme::STATUS_ERROR() + } else if hot { + crate::ui::theme::STATUS_WARNING() + } else { + fill + }; + div().absolute().left_0().top_0().h_full().w(relative(frac)).rounded(px(2.)).bg(rgb(ink)) + })), ), ) .child( @@ -223,70 +240,21 @@ fn icon_tip(player: &Player, action: ActionId) -> TipFn { } } -/// The master level meter's length on the band, in px. -const METER_W: f32 = 32.; - -/// The stereo master level meter before the volume: two 4px bars (left over right), each to its -/// level with a 1px marker at its held peak, warning-coloured within 1 dB of full scale, and a -/// clip lamp at the right end that stays lit for a few seconds after a peak reached 0 dBFS. The -/// lamp's slot is always there, so a clip moves nothing. Read through [`Player::master_reading`] -/// (at most 30 times a second, from the engine's own stereo peaks, so the mix card's meters do not -/// compete with it). -fn level_meter(player: &Player) -> impl IntoElement { +/// The live output level for the volume slider's track, while sound is moving: how far along the +/// set level the louder side reaches (0..1 of the fill), and whether it is within 1 dB of full +/// scale or clipped. Read through [`Player::master_reading`] (at most 30 times a second, from the +/// engine's own stereo peaks, so the mix card's meters do not compete with it). The level lives +/// inside the slider rather than as bars beside it: a second little control next to the volume +/// read as noise, and inside the fill it says what the meter is for at a glance. +fn master_level(player: &Player) -> Option<(f32, bool, bool)> { use crate::player::cards::METER_FLOOR_DB; - let now = std::time::Instant::now(); - let (meters, clipped) = player.master_reading(now); - let frac = |db: f32| ((db - METER_FLOOR_DB) / -METER_FLOOR_DB).clamp(0., 1.); - let bar = |side: usize| { - let meter = Some(meters[side]); - let level = meter.map_or(0., |m| frac(m.level_db)); - let hold = meter.map_or(0., |m| frac(m.hold_db)); - let hot = meter.is_some_and(|m| m.level_db >= -1.); - div() - .flex_none() - .relative() - .w_full() - .h(px(4.)) - .rounded(px(2.)) - // The raised plate, not the panel: the band is panel-coloured, and a - // bed the band's own colour would vanish at rest. - .bg(rgb(DARK_RAISED())) - .child(div().h_full().w(relative(level)).rounded(px(2.)).bg(rgb( - if hot { STATUS_WARNING() } else { ACCENT_PRIMARY() }, - ))) - .when(hold > 0., |d| { - d.child( - div() - .absolute() - .top_0() - .h_full() - .w(px(1.)) - .left(relative(hold)) - .bg(rgb(INK1())), - ) - }) - }; - div() - .id("stance-tb-meter") - .flex_none() - .flex() - .items_center() - .gap(px(3.)) - .w(px(METER_W)) - .tooltip(crate::ui::widgets::tip_hover( - "Master level, left over right. The lamp lights on a clipped peak.", - "", - None, - )) - .child(div().flex_1().flex().flex_col().gap(px(1.)).child(bar(0)).child(bar(1))) - .child( - div() - .flex_none() - .w(px(3.)) - .h(px(9.)) - .rounded(px(1.5)) - .bg(rgb(if clipped { STATUS_ERROR() } else { DARK_RAISED() })), - ) + if !player.session.as_ref().is_some_and(|s| s.is_playing()) || player.volume.muted { + return None; + } + let (meters, clipped) = player.master_reading(std::time::Instant::now()); + let db = meters[0].level_db.max(meters[1].level_db); + let frac = ((db - METER_FLOOR_DB) / -METER_FLOOR_DB).clamp(0., 1.); + Some((frac, db >= -1., clipped)) } /// The timecode on the transport (REDESIGN §3.3): the `timecode` role, digits in @@ -383,7 +351,8 @@ fn play_button(player: &Player, cx: &mut Context) -> impl IntoElement { } /// The width of the timecode cluster and of the volume cluster: equal, so the -/// transport between them sits on the column's centre. +/// transport between them sits on the column's centre. The tail (Mute, volume, +/// Fullscreen, with 4px gaps) is 168px, inside it. const SIDE_W: f32 = 184.; /// The whole band, left to right: the timecode, the transport centred in the @@ -397,7 +366,6 @@ pub(crate) fn render( use crate::ui::icons::Icon; let tc = timecode(player.hero_position(position), player.active_fps()); let band_w = BAND_W.with(Rc::clone); - let wide = column_w() >= 900.; // Go to time retypes the timecode in place; a click on it opens that. let timecode_cell = match player.time_edit.clone() { Some(field) => timecode_field(&field).into_any_element(), @@ -465,8 +433,16 @@ pub(crate) fn render( cx, )) .child(volume_slider(player, cx)) - // The meter is the first thing to go when the column narrows. - .when(wide, |d| d.child(level_meter(player))), + // Fullscreen closes the row at its right end, as video players do: the same + // icon button as the transport's, dispatching `ActionId::Fullscreen` through `act`. + .child(icon_button( + "stance-tb-fullscreen", + player, + Icon::Scan, + ActionId::Fullscreen, + player.player_fullscreen, + cx, + )), ) } diff --git a/crates/app/src/ui/widgets.rs b/crates/app/src/ui/widgets.rs index ce39ccb..8d6f026 100644 --- a/crates/app/src/ui/widgets.rs +++ b/crates/app/src/ui/widgets.rs @@ -534,17 +534,20 @@ fn tip_boxed(plate: Div, w: f32, window: Option<&Window>) -> Div { } } +/// One line of a hover plate: the keycap's height, so a label and its chips share a line box +/// and the text centres on the chips. +const TIP_LINE_PX: f32 = 18.; + /// DESIGN §2.5 and §4.5: a tooltip is a floating plate, so it is a panel with a /// hairline, a 6px radius and the one shadow the room uses for floating plates -/// (menus, the palette, sheets, toasts). Padded 8px down and 10px across. +/// (menus, the palette, sheets, toasts). Padded 10px on every side. fn tip_plate() -> Div { crate::ui::kit::plate(6.) .flex() .flex_none() .flex_col() .gap(px(4.)) - .px(px(10.)) - .py(px(8.)) + .p(px(10.)) } /// A plain prose tooltip ([`Tip`], [`OverlayTip`]): one line in ink1 on the @@ -560,7 +563,7 @@ fn tip_text(text: &SharedString, window: Option<&Window>) -> Div { .font(name.font) .text_size(name.size) .text_color(rgb(INK1())) - .children(lines.into_iter().map(|l| div().whitespace_nowrap().child(l))), + .children(lines.into_iter().map(|l| div().h(px(TIP_LINE_PX)).line_height(px(TIP_LINE_PX)).whitespace_nowrap().child(l))), w, window, ) @@ -576,6 +579,10 @@ fn tip_card(parts: &TipParts, window: Option<&Window>) -> Div { let last = name_lines.pop().unwrap_or_default(); let ink = |l: String, c: u32| { div() + .h(px(TIP_LINE_PX)) + .line_height(px(TIP_LINE_PX)) + .flex() + .items_center() .whitespace_nowrap() .font(name.font.clone()) .text_size(name.size) @@ -588,9 +595,10 @@ fn tip_card(parts: &TipParts, window: Option<&Window>) -> Div { .children(name_lines.iter().cloned().map(|l| ink(l, INK1()))) .child( div() + .h(px(TIP_LINE_PX)) .flex() .flex_row() - .items_baseline() + .items_center() .gap(px(8.)) .child(ink(last.clone(), INK1())) .when_some(parts.key.clone(), |row, text| { @@ -623,6 +631,10 @@ fn tip_card(parts: &TipParts, window: Option<&Window>) -> Div { .map(|l| { let l = l.clone(); div() + .h(px(TIP_LINE_PX)) + .line_height(px(TIP_LINE_PX)) + .flex() + .items_center() .whitespace_nowrap() .font(name.font.clone()) .text_size(name.size) diff --git a/crates/engine/src/playback.rs b/crates/engine/src/playback.rs index e1048f8..fb1ade1 100644 --- a/crates/engine/src/playback.rs +++ b/crates/engine/src/playback.rs @@ -1013,7 +1013,7 @@ impl PlaybackSession { drop_late: false, // A file just opened is a project nobody has picked stand-ins for. proxies: false, - auto_proxies: true, + auto_proxies: false, encoder_seat: crate::export::EncoderSeat::default(), sample_rate: None, }) @@ -1109,7 +1109,7 @@ impl PlaybackSession { priming: false, drop_late: false, proxies: false, - auto_proxies: true, + auto_proxies: false, encoder_seat: crate::export::EncoderSeat::default(), sample_rate: None, }) @@ -1238,7 +1238,7 @@ impl PlaybackSession { drop_late: false, // A file just opened is a project nobody has picked stand-ins for. proxies: false, - auto_proxies: true, + auto_proxies: false, encoder_seat: crate::export::EncoderSeat::default(), sample_rate: None, }) @@ -1365,7 +1365,7 @@ impl PlaybackSession { drop_late: false, // A file just opened is a project nobody has picked stand-ins for. proxies: false, - auto_proxies: true, + auto_proxies: false, encoder_seat: crate::export::EncoderSeat::default(), sample_rate: None, }) diff --git a/crates/engine/src/project.rs b/crates/engine/src/project.rs index 4a08ac3..84c1997 100644 --- a/crates/engine/src/project.rs +++ b/crates/engine/src/project.rs @@ -2329,7 +2329,7 @@ impl ProjectSettings { encoder_seat: crate::export::EncoderSeat::default(), sample_rate: None, proxies: false, - auto_proxies: true, + auto_proxies: false, tone: crate::tonemap::Preset::default(), limiter: Limiter::default(), caption_style: crate::captionanim::CaptionStyle::default(), @@ -8857,8 +8857,10 @@ impl Project { // hole between it and what it was cut from closes behind it. let g = i64::from(new_start) - i64::from(old_start); if g != 0 { - shift_behind(&mut self.lanes[l], old_end, -g); + // Back in place first: `shift_behind` checks the whole lane, and the clip + // still starting at the trimmed head would overlap what moves up. self.lanes[l].clips[i].start = old_start; + shift_behind(&mut self.lanes[l], old_end, -g); } } Edge::End => { diff --git a/crates/engine/tests/it/audio_streams.rs b/crates/engine/tests/it/audio_streams.rs index f997ccd..5398a77 100644 --- a/crates/engine/tests/it/audio_streams.rs +++ b/crates/engine/tests/it/audio_streams.rs @@ -55,8 +55,22 @@ fn zero_crossings(samples: &[f32]) -> usize { #[test] fn probe_streams_lists_every_audio_track_in_file_order() { let streams = AudioSession::probe_streams(asset(MULTI)).expect("probes"); + // The bitrates are the encoder's output, and the fixtures are regenerated + // with whatever ffmpeg is installed, so each is held to within 5 % of the + // value it was last measured at rather than to the exact figure. The rest + // of every row is compared exactly below. + let mut shape = streams.clone(); + for (s, want) in shape.iter_mut().zip([128_372u64, 62_612, 193_928]) { + let got = s.bitrate.expect("a bitrate"); + assert!( + got.abs_diff(want) * 20 <= want, + "stream {}: bitrate {got} is more than 5% from {want}", + s.index + ); + s.bitrate = Some(want); + } assert_eq!( - streams, + shape, vec![ StreamInfo { index: 0, diff --git a/crates/engine/tests/it/bitrate.rs b/crates/engine/tests/it/bitrate.rs index 226b46b..24f7fe6 100644 --- a/crates/engine/tests/it/bitrate.rs +++ b/crates/engine/tests/it/bitrate.rs @@ -170,14 +170,40 @@ fn a_stream_the_container_states_is_stated_and_no_stream_is_invented() { } } +/// The picture's bits per second as `ffprobe` reads it off the file: the video +/// packets' bytes over `format=duration`, both taken from the file and neither +/// from the probe under test. +fn ffprobe_picture_bps(name: &str) -> u64 { + let run = |entries: &[&str]| { + let out = std::process::Command::new("ffprobe") + .args(["-v", "error"]) + .args(entries) + .arg(asset(name)) + .output() + .expect("ffprobe runs"); + String::from_utf8(out.stdout).expect("ffprobe prints utf-8") + }; + let bytes: u64 = run(&["-select_streams", "v", "-show_entries", "packet=size", "-of", "csv=p=0"]) + .lines() + .filter(|l| !l.trim().is_empty()) + .map(|l| l.trim().parse::().expect("a packet size")) + .sum(); + let secs: f64 = run(&["-show_entries", "format=duration", "-of", "csv=p=0"]) + .trim() + .parse() + .expect("a duration"); + (bytes as f64 * 8.0 / secs).round() as u64 +} + #[test] fn a_matroska_states_its_sound_too_and_its_picture_is_unchanged() { // Both mkv fixtures carry `-c:a aac -b:a 128k` (`gen_fixtures.sh:158,223`), // so an absent audio row here is a missing measurement, not a silent file -- // and a film library is overwhelmingly Matroska, so this is the common case. // - // The video numbers are pinned so that adding the sound track to the walk - // cannot move the picture. The numerator is the one `ffprobe + // The picture is checked against what ffprobe reads from the file itself, + // so that adding the sound track to the walk cannot move it, and so that + // the fixtures can be regenerated without this test caring. The numerator is the one `ffprobe // -select_streams v -show_entries packet=size` sums independently -- 716 834 // bytes for test_av1.mkv. The denominator is `Info.Duration`, **2.023 s**, // not the picture's own 2.000 s: the AAC track outlasts the last frame by @@ -185,10 +211,17 @@ fn a_matroska_states_its_sound_too_and_its_picture_is_unchanged() { // These were 2_867_336 / 2_086_260 while the divisor was the video track, // i.e. 1.1 % high, which is the same defect the lopsided fixture shows at // 30x. - for (name, video_bps) in [("test_av1.mkv", 2_834_736), ("test_hevc.mkv", 2_062_540)] { + for name in ["test_av1.mkv", "test_hevc.mkv"] { let rate = probe_bitrate(&asset(name)); no_field_is_zero(name, rate); - assert_eq!(rate.video, Some(video_bps), "{name}: picture moved"); + // A tenth of a percent is the probe's integer rounding and nothing + // more. The 1.1 % divisor error this guards against is well outside it. + let expected = ffprobe_picture_bps(name); + let video = rate.video.unwrap_or_else(|| panic!("{name}: no picture rate")); + assert!( + video.abs_diff(expected) * 1000 <= expected, + "{name}: picture moved: {video} bps, ffprobe reads {expected}" + ); let audio = rate .audio .unwrap_or_else(|| panic!("{name}: no audio rate, and it has a 128k AAC track")); diff --git a/crates/engine/tests/it/display_unit.rs b/crates/engine/tests/it/display_unit.rs index accd38d..1ed9d55 100644 --- a/crates/engine/tests/it/display_unit.rs +++ b/crates/engine/tests/it/display_unit.rs @@ -121,7 +121,10 @@ fn video_unit_3(dar_width: u16, dar_height: u16, coded_width: u16, coded_height: ) } -fn with_video_element(source: &Path, into: &Path, element: &str) { +/// Patches the `Video` element into a copy of `source` and returns the byte +/// offset it was written at, found by scanning the source rather than +/// assumed, since the offset depends on the muxer's layout. +fn with_video_element(source: &Path, into: &Path, element: &str) -> usize { let from = hex(VIDEO_UNIT_3); let to = hex(element); assert_eq!( @@ -139,6 +142,7 @@ fn with_video_element(source: &Path, into: &Path, element: &str) { let mut patched = bytes.clone(); patched[at..at + from.len()].copy_from_slice(&to); std::fs::write(into, patched).expect("write the patched fixture"); + at } fn hex(text: &str) -> Vec { @@ -166,7 +170,7 @@ fn reduced(aspect: PixelAspect) -> (u32, u32) { fn a_display_unit_of_zero_states_the_stretch_in_pixels() { let scratch = Scratch::new("pixels"); let unit0 = scratch.path("display_unit0.mkv"); - with_video_element(&asset("test_anamorphic.mkv"), &unit0, VIDEO_UNIT_0); + let aimed_at = with_video_element(&asset("test_anamorphic.mkv"), &unit0, VIDEO_UNIT_0); // The patch landed, and it landed on a file the demuxer opens. let patched = std::fs::read(&unit0).expect("read back the patched fixture"); @@ -181,7 +185,7 @@ fn a_display_unit_of_zero_states_the_stretch_in_pixels() { patched .windows(wanted.len()) .position(|window| window == wanted), - Some(369), + Some(aimed_at), "the DisplayUnit-0 element is where it was aimed" ); diff --git a/crates/engine/tests/it/saveload.rs b/crates/engine/tests/it/saveload.rs index b12e7a8..b28674d 100644 --- a/crates/engine/tests/it/saveload.rs +++ b/crates/engine/tests/it/saveload.rs @@ -100,18 +100,14 @@ fn a_picked_audio_stream_lands_saves_and_comes_back() { /// Both stand-in switches through the front door: what the picture is cut on /// and whether an import makes one at all are two settings, saved and reopened -/// as the pair they are -- and a session that was never told keeps making them, -/// which is what every project did before there was a switch. +/// as the pair they are -- and a fresh session makes none until it is told to. #[test] fn both_proxy_switches_survive_a_save_and_a_reopen() { let dir = scratch("proxyswitches"); let media = copy_in(&dir, "test_av.mp4"); let mut session = PlaybackSession::open(&media).expect("open the fixture"); session.set_gain(0.0); - assert!( - session.auto_proxies(), - "a fresh project makes them by itself" - ); + assert!(!session.auto_proxies(), "a fresh project makes none by itself"); assert!(!session.proxies(), "and is cut on the film itself"); session.set_proxies(true); diff --git a/crates/engine/tests/it/voice_audio.rs b/crates/engine/tests/it/voice_audio.rs index 8d8fd22..fda4896 100644 --- a/crates/engine/tests/it/voice_audio.rs +++ b/crates/engine/tests/it/voice_audio.rs @@ -55,7 +55,7 @@ fn clip(source: usize, frames: u32) -> Clip { fn noise(i: usize, rms: f32) -> f32 { let mut sum = 0.0f32; for k in 0..4u64 { - let mut x = (i as u64).wrapping_mul(0x9E37_79B9_7F4A_7C15).wrapping_add(k * 0xD1B5_4A32_D192_ED03); + let mut x = (i as u64).wrapping_mul(0x9E37_79B9_7F4A_7C15).wrapping_add(k.wrapping_mul(0xD1B5_4A32_D192_ED03)); x ^= x >> 29; x = x.wrapping_mul(0xBF58_476D_1CE4_E5B9); x ^= x >> 32; diff --git a/crates/mcp/src/tools/listen.rs b/crates/mcp/src/tools/listen.rs index 52e27cb..d33b732 100644 --- a/crates/mcp/src/tools/listen.rs +++ b/crates/mcp/src/tools/listen.rs @@ -4196,7 +4196,7 @@ mod tests { assert!(!fix.is_error, "{}", fix.text); let scope = [Lane::new(LaneKind::Video, 1)]; assert_eq!(srv.session.as_ref().unwrap().gap_count(scope[0]), 1, "the fixture leaves a one-frame hole"); - let cut = cut_spans(&mut srv, &[(100, 2)], false, "sliver", &scope, &json!({}), false).expect("a cut"); + let cut = cut_spans(&mut srv, &[(100, 102)], false, "sliver", &scope, &json!({}), false).expect("a cut"); assert!(cut.ripple.contains("closed 1 hole(s) under 4f on V2"), "{}", cut.ripple); assert_eq!(srv.session.as_ref().unwrap().gap_count(scope[0]), 0, "{}", cut.ripple); } diff --git a/crates/mcp/src/tools/media.rs b/crates/mcp/src/tools/media.rs index deefb46..a421740 100644 --- a/crates/mcp/src/tools/media.rs +++ b/crates/mcp/src/tools/media.rs @@ -2491,20 +2491,35 @@ mod agreement_tests { #[test] fn an_edith_project_is_named_as_one_in_probe_and_import() { quiet(); - let row = probe_one(&asset("test_h264.edith")); + // A real project, saved by the tools into the test's own dir, so no fixture is needed on disk. + let td = TestDir::new("edith-project"); + let project = td.path().join("test_h264.edith"); + let tools = crate::server::tools(); + let mut maker = Server::new(); + let mut run = |name: &str, args: Value| { + let tool = tools.iter().find(|t| t.name == name).expect("tool"); + (tool.run)(&mut maker, &args) + }; + assert!(!run("project_new", json!({"path": project, "resolution": "1280x720"})).is_error); + let media = vec![asset("test_h264.mkv").display().to_string()]; + assert!(!run("media_import", json!({"paths": media})).is_error); + let saved = run("project_save", json!({})); + assert!(!saved.is_error, "{}", saved.text); + let path_arg = json!({"paths": [project.display().to_string()]}); + + let row = probe_one(&project); let line = row_line(&row); assert_eq!(line, "test_h264.edith · an edith project (open it with project_open)"); assert!(!line.contains("error"), "{line}"); assert!(!line.contains("truncated"), "{line}"); // Not a failed probe: the reply is not an error, and the row carries no error. - let probed = probe(&mut Server::new(), &json!({"paths": [asset("test_h264.edith").display().to_string()]})); + let probed = probe(&mut Server::new(), &path_arg); assert!(!probed.is_error, "{}", probed.text); assert_eq!(probed.text, line); assert_eq!(row_json(&row)["error"], json!(null)); - let td = TestDir::new("edith-import"); let mut server = Server::new(); server.session = Some(PlaybackSession::empty(1280, 720, 30.0).unwrap()); - let imported = import(&mut server, &json!({"paths": [asset("test_h264.edith").display().to_string()]})); + let imported = import(&mut server, &path_arg); assert!(imported.is_error, "{}", imported.text); assert!( imported.text.contains("test_h264.edith is an edith project, not media: open it with project_open"),