From 9a27ee6922d4c6d6d6656d18dbe44845ceffa655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 21 Aug 2026 17:49:12 +0300 Subject: [PATCH] fix: format Darkroom integration --- crates/app/src/audio_cards.rs | 13 +- crates/app/src/eq_ui.rs | 11 +- crates/app/src/export_ui.rs | 30 ++- crates/app/src/importing.rs | 20 +- crates/app/src/main.rs | 10 +- crates/app/src/notices.rs | 5 +- crates/app/src/oracle.rs | 13 +- crates/app/src/player/actions.rs | 11 +- crates/app/src/player/cards.rs | 45 +++-- crates/app/src/player/export.rs | 23 ++- crates/app/src/player/library.rs | 63 +++++-- crates/app/src/player/timeline_edit.rs | 192 +++++++++++++------ crates/app/src/player/transport.rs | 27 ++- crates/app/src/player/view.rs | 34 +++- crates/app/src/render.rs | 25 ++- crates/app/src/subs.rs | 16 +- crates/app/src/tests/cards.rs | 8 +- crates/app/src/tests/editing.rs | 93 +++++++--- crates/app/src/tests/layout.rs | 248 +++++++++++++++++++------ crates/app/src/tests/media.rs | 126 +++++++++---- crates/app/src/tests/mod.rs | 113 ++++++----- crates/app/src/tests/view.rs | 49 +++-- crates/app/src/timeline_math.rs | 72 +++---- crates/app/src/transport.rs | 11 +- crates/app/src/ui/bench_stance.rs | 35 ++-- crates/app/src/ui/dock_stance.rs | 6 +- crates/app/src/ui/inspector.rs | 14 +- crates/app/src/ui/library.rs | 168 +++++++++-------- crates/app/src/ui/overlays.rs | 128 +++++++------ crates/app/src/ui/preview.rs | 12 +- crates/app/src/ui/settings_stance.rs | 29 ++- crates/app/src/ui/theme.rs | 64 +++++-- crates/app/src/ui/timeband_stance.rs | 84 +++++++-- crates/app/src/ui/timeline.rs | 104 ++++++----- crates/app/src/ui/toolbar.rs | 13 +- crates/app/src/ui/widgets.rs | 18 +- 36 files changed, 1277 insertions(+), 656 deletions(-) diff --git a/crates/app/src/audio_cards.rs b/crates/app/src/audio_cards.rs index a006656..e38aac0 100644 --- a/crates/app/src/audio_cards.rs +++ b/crates/app/src/audio_cards.rs @@ -131,7 +131,11 @@ pub(crate) const EQ_GRAPH_MAX_H: f32 = 320.; /// pixels, an actually taller curve with more room per decibel and per /// decade. pub(crate) fn eq_graph_h(maximized: bool) -> f32 { - if maximized { EQ_GRAPH_MAX_H } else { EQ_GRAPH_H } + if maximized { + EQ_GRAPH_MAX_H + } else { + EQ_GRAPH_H + } } /// How wide the equalizer card is allowed to get. It is the one card that is a @@ -225,7 +229,11 @@ mod eq_graph_maximize_tests { /// clamp is a layout-time panic, not a compile-time one). #[test] fn maximized_graph_floor_matches_docked_and_never_exceeds_its_own_ceiling() { - assert_eq!(eq_graph_h(false), EQ_GRAPH_H, "docked height must be the floor maximized also uses"); + assert_eq!( + eq_graph_h(false), + EQ_GRAPH_H, + "docked height must be the floor maximized also uses" + ); assert!(EQ_GRAPH_H <= EQ_GRAPH_MAX_H); } } @@ -247,7 +255,6 @@ mod eq_tick_end_w_tests { } } - /// How many played samples one spectrum frame is transformed from. A power of /// two ([`fft`] is radix-2) and the whole of the engine's tap: 1024 at 48 kHz /// is a 47 Hz bin, fine enough that the bass end is a shape and short enough diff --git a/crates/app/src/eq_ui.rs b/crates/app/src/eq_ui.rs index a452d81..e610452 100644 --- a/crates/app/src/eq_ui.rs +++ b/crates/app/src/eq_ui.rs @@ -224,8 +224,7 @@ pub(crate) fn eq_curve(params: EqParams, sample_rate: u32) -> impl IntoElement { let along = step as f32 / EQ_CURVE_STEPS as f32; point( o.x + s.width * along, - o.y + s.height - * eq_y(of.response_db(eq_freq(along), sample_rate)), + o.y + s.height * eq_y(of.response_db(eq_freq(along), sample_rate)), ) }) .collect() @@ -233,11 +232,9 @@ pub(crate) fn eq_curve(params: EqParams, sample_rate: u32) -> impl IntoElement { // One thread per band, first, so the sum is drawn over them. for band in ¶ms.bands { let mut bell = PathBuilder::stroke(px(1.)); - for (step, at) in line(&EqParams { - bands: vec![*band], - }) - .into_iter() - .enumerate() + for (step, at) in line(&EqParams { bands: vec![*band] }) + .into_iter() + .enumerate() { match step { 0 => bell.move_to(at), diff --git a/crates/app/src/export_ui.rs b/crates/app/src/export_ui.rs index 6ca6bd0..a130398 100644 --- a/crates/app/src/export_ui.rs +++ b/crates/app/src/export_ui.rs @@ -607,7 +607,12 @@ pub(crate) fn fps_choices(current: f64, native: f64) -> Vec { /// The fit list's rows: all four policies against the canvas they place a /// picture on, since the word alone ("fill") says nothing about the size it is /// filling -- which is the very thing the notice says after a stroke. -pub(crate) fn fit_choices(lane: Lane, idx: usize, current: FitPolicy, (w, h): (u32, u32)) -> Vec { +pub(crate) fn fit_choices( + lane: Lane, + idx: usize, + current: FitPolicy, + (w, h): (u32, u32), +) -> Vec { FITS.into_iter() .map(|fit| { ( @@ -688,9 +693,8 @@ pub(crate) fn encoder_choices(current: EncoderSeat) -> Vec { /// risk is theirs to be told about. `None` for every other pair, which is what /// keeps this from becoming a row nobody reads. 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", - ) + (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") } /// How a rendition is named where a person reads it: the panel button, the @@ -746,7 +750,11 @@ pub(crate) fn next_resolution(current: (u32, u32), native: (u32, u32)) -> (u32, /// sound will be, or that there is none. Every field here is one `ffprobe` /// reads back off the finished file, so the line is checkable rather than a /// promise. -pub(crate) fn summary_head(format: Format, picture: Option<((u32, u32), f64)>, audio: &str) -> String { +pub(crate) fn summary_head( + format: Format, + picture: Option<((u32, u32), f64)>, + audio: &str, +) -> String { let line = match picture.filter(|_| format.has_video()) { Some(((w, h), fps)) => { format!("{} · {w}x{h} · {} fps", format_line(format), fps_label(fps)) @@ -759,7 +767,12 @@ pub(crate) fn summary_head(format: Format, picture: Option<((u32, u32), f64)>, a /// The second: where it lands, roughly how big, and what will encode the /// picture -- the seat as the probe found it (`…` until it lands, never a /// guess), which is what the running export then names on its progress line. -pub(crate) fn summary_tail(path: &Path, bytes: Option, seat: Option<&'static str>, video: bool) -> String { +pub(crate) fn summary_tail( + path: &Path, + bytes: Option, + seat: Option<&'static str>, + video: bool, +) -> String { let size = bytes.map_or_else(String::new, |bytes| format!("≈ {}", size_label(bytes))); let seat = match (video, seat) { (true, Some(seat)) => seat, @@ -967,7 +980,10 @@ impl NumberEdit { /// and stays inside the range, because a step is a walk through the legal /// numbers rather than a way out of them. pub(crate) fn step(&mut self, by: i32) { - let at = self.text.parse::().unwrap_or(MBPS_MIN as i32 - by.signum()); + let at = self + .text + .parse::() + .unwrap_or(MBPS_MIN as i32 - by.signum()); self.text = (at + by) .clamp(MBPS_MIN as i32, MBPS_MAX as i32) .to_string(); diff --git a/crates/app/src/importing.rs b/crates/app/src/importing.rs index bcbf5c0..84c385c 100644 --- a/crates/app/src/importing.rs +++ b/crates/app/src/importing.rs @@ -12,7 +12,8 @@ pub(crate) enum LibraryTab { Text, } -pub(crate) const LIBRARY_TABS: [LibraryTab; 3] = [LibraryTab::Media, LibraryTab::Audio, LibraryTab::Text]; +pub(crate) const LIBRARY_TABS: [LibraryTab; 3] = + [LibraryTab::Media, LibraryTab::Audio, LibraryTab::Text]; impl LibraryTab { pub(crate) fn label(self) -> &'static str { @@ -208,7 +209,10 @@ impl SilenceScan { /// when the mark actually moves -- [`Import::poll`]'s contract, over a /// number instead of a stage. pub(crate) fn poll(&mut self) -> f32 { - let scanned = self.progress.scanned.load(std::sync::atomic::Ordering::Relaxed); + let scanned = self + .progress + .scanned + .load(std::sync::atomic::Ordering::Relaxed); if scanned != self.seen { self.seen = scanned; self.since = Instant::now(); @@ -392,7 +396,12 @@ pub(crate) fn full_scan_key(path: &Path, stream: usize) -> ScanKey { /// numbers the on-demand scan would have. Empty past the end of what the /// background read has landed so far -- a scan still running answers with /// what it has, same as [`SilenceScan`]'s own cancel does. -pub(crate) fn slice_whole_levels(whole: &[f32], fps: f64, in_frame: u32, out_frame: u32) -> Vec { +pub(crate) fn slice_whole_levels( + whole: &[f32], + fps: f64, + in_frame: u32, + out_frame: u32, +) -> Vec { if !(fps.is_finite() && fps > 0.) { return Vec::new(); } @@ -411,7 +420,10 @@ pub(crate) fn slice_whole_levels(whole: &[f32], fps: f64, in_frame: u32, out_fra /// ([`Player::cache_media`]). One function so `Player::open_silence`'s plan /// and `Player::scan_silences`' lookup share the one contract for what /// "cached" means, instead of two copies that could drift. -pub(crate) fn silence_cached(levels: &std::collections::HashMap>>, key: &ScanKey) -> bool { +pub(crate) fn silence_cached( + levels: &std::collections::HashMap>>, + key: &ScanKey, +) -> bool { levels.contains_key(key) || levels.contains_key(&full_scan_key(&key.0, key.1)) } diff --git a/crates/app/src/main.rs b/crates/app/src/main.rs index a53dd70..e6c458c 100644 --- a/crates/app/src/main.rs +++ b/crates/app/src/main.rs @@ -36,9 +36,9 @@ pub(crate) use menus::*; pub(crate) use render::escape_leaves_player_fullscreen; // The Contain letterbox, shared with the subtitle picture overlay // (ui/preview.rs) so both draw the same fitted rect the same way. -pub(crate) use render::letterboxed_image; pub(crate) use notices::*; pub(crate) use oracle::*; +pub(crate) use render::letterboxed_image; pub(crate) use subs::*; pub(crate) use timeline_math::*; pub(crate) use transform_ui::*; @@ -72,10 +72,10 @@ use engine::{Clip, Codec, ExportHandle, Frame, MediaBitrate, PlaybackSession}; use gpui::{ AnyElement, App, Application, Bounds, ClickEvent, Context, Corners, CursorStyle, Div, DragMoveEvent, FocusHandle, KeyDownEvent, KeyUpEvent, MouseButton, MouseDownEvent, - MouseExitEvent, MouseMoveEvent, MouseUpEvent, PathBuilder, Pixels, Point, RenderImage, ScrollDelta, - ScrollHandle, ScrollWheelEvent, SharedString, Size, Stateful, TextAlign, TitlebarOptions, - Window, WindowBounds, WindowOptions, canvas, div, point, prelude::*, px, relative, rgb, rgba, - size, + MouseExitEvent, MouseMoveEvent, MouseUpEvent, PathBuilder, Pixels, Point, RenderImage, + ScrollDelta, ScrollHandle, ScrollWheelEvent, SharedString, Size, Stateful, TextAlign, + TitlebarOptions, Window, WindowBounds, WindowOptions, canvas, div, point, prelude::*, px, + relative, rgb, rgba, size, }; struct Player { diff --git a/crates/app/src/notices.rs b/crates/app/src/notices.rs index 7368200..560f10d 100644 --- a/crates/app/src/notices.rs +++ b/crates/app/src/notices.rs @@ -22,7 +22,10 @@ pub(crate) const NOTICE_MIN_W: f32 = 180.; /// without a window: dedupe against the back, a ceiling, oldest out first -- /// except an export's own outcome, which jumps to the front. [`Player::notify_user`] /// is the door every message comes through; this is what the door does. -pub(crate) fn push_notice(notices: &mut std::collections::VecDeque, message: SharedString) { +pub(crate) fn push_notice( + notices: &mut std::collections::VecDeque, + message: SharedString, +) { // A repeat of what is already at the back is dropped -- holding a key that // refuses would otherwise fill the queue with one sentence, and the count on // the bar would be a count of how long the key was held. diff --git a/crates/app/src/oracle.rs b/crates/app/src/oracle.rs index 3bb489c..2f69371 100644 --- a/crates/app/src/oracle.rs +++ b/crates/app/src/oracle.rs @@ -107,7 +107,10 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable { // the exporting card owns (`Player::open_settings`, one card at a time), // so a permission this oracle granted here would be a permission nobody // could ever observe. It is refused below, with every other card. - if action == ActionId::Theme || action == ActionId::Fullscreen || action == ActionId::SubtitleStyle { + if action == ActionId::Theme + || action == ActionId::Fullscreen + || action == ActionId::SubtitleStyle + { return Enable::Yes; } if action == ActionId::Settings { @@ -198,7 +201,9 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable { // filters samples, and a video clip has none of its own here: the sound // is the audio lane's, clip for clip. ActionId::Equalizer => match ctx.clip { - Some((_, lane)) if lane.kind != LaneKind::Audio => Enable::Hidden("this clip is picture"), + Some((_, lane)) if lane.kind != LaneKind::Audio => { + Enable::Hidden("this clip is picture") + } _ => Enable::Yes, }, // A grade is a picture setting and an audio clip has no picture. A fit @@ -252,9 +257,7 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable { // question, like the regroup above. ActionId::Detach => match (ctx.clip, ctx.caption) { (Some((clip, _)), _) if clip.link.is_none() => Enable::No("this clip is not grouped"), - (None, true) if ctx.caption_link.is_none() => { - Enable::No("this caption is not grouped") - } + (None, true) if ctx.caption_link.is_none() => Enable::No("this caption is not grouped"), _ => Enable::Yes, }, // The manual group: a *selection* of placements, at most one per lane. diff --git a/crates/app/src/player/actions.rs b/crates/app/src/player/actions.rs index c54d0df..cc02bb9 100644 --- a/crates/app/src/player/actions.rs +++ b/crates/app/src/player/actions.rs @@ -318,8 +318,8 @@ impl Player { return Ctx::default(); }; let on = on.or(self.selected.anchor()); - let clip = on - .and_then(|(lane, idx)| session.lane_clips(lane).get(idx).map(|clip| (*clip, lane))); + let clip = + on.and_then(|(lane, idx)| session.lane_clips(lane).get(idx).map(|clip| (*clip, lane))); let caption = on.is_some_and(|(lane, idx)| { lane.kind == LaneKind::Subtitle && idx < session.sub_lane(lane).len() }); @@ -340,7 +340,12 @@ impl Player { // The same pair read in the other index space: a subtitle lane's // own, where the box that was clicked is a caption. caption, - caption_link: caption.then(|| on.and_then(|(lane, idx)| session.sub_lane(lane).get(idx)).and_then(|s| s.link)).flatten(), + caption_link: caption + .then(|| { + on.and_then(|(lane, idx)| session.sub_lane(lane).get(idx)) + .and_then(|s| s.link) + }) + .flatten(), image: clip.is_some_and(|(clip, _)| { session .sources() diff --git a/crates/app/src/player/cards.rs b/crates/app/src/player/cards.rs index ee92a9a..8fa32bb 100644 --- a/crates/app/src/player/cards.rs +++ b/crates/app/src/player/cards.rs @@ -69,8 +69,11 @@ impl Player { // timeline yet to cut at it. self.pending_settings.1 = Some(fps); self.notify_user( - format!("PROJECT: {} fps — takes effect on the next file opened", fps_label(fps)) - .into(), + format!( + "PROJECT: {} fps — takes effect on the next file opened", + fps_label(fps) + ) + .into(), ); } cx.notify(); @@ -84,7 +87,9 @@ impl Player { /// seek, an edit, a reopen), not the stream already playing /// ([`engine::PlaybackSession::set_sample_rate`]). pub(crate) fn apply_sample_rate(&mut self, rate: Option, cx: &mut Context) { - let label = |rate: Option| rate.map_or("the source's own rate".to_string(), |r| format!("{r} Hz")); + let label = |rate: Option| { + rate.map_or("the source's own rate".to_string(), |r| format!("{r} Hz")) + }; if let Some(session) = &mut self.session { session.set_sample_rate(rate); self.notify_user( @@ -97,8 +102,11 @@ impl Player { } else { self.pending_settings.2 = rate; self.notify_user( - format!("PROJECT SOUND: {} — takes effect on the next file opened", label(rate)) - .into(), + format!( + "PROJECT SOUND: {} — takes effect on the next file opened", + label(rate) + ) + .into(), ); } cx.notify(); @@ -450,7 +458,12 @@ impl Player { /// Both writes: `live` is the one that takes no undo step, which is what /// every sample *inside* a drag goes through -- /// [`write_color`](Self::write_color)'s own rule. - pub(crate) fn write_transform(&mut self, params: TransformParams, live: bool, cx: &mut Context) { + pub(crate) fn write_transform( + &mut self, + params: TransformParams, + live: bool, + cx: &mut Context, + ) { self.pending_transform = None; let Some((lane, idx)) = self.transform_open else { return; @@ -904,7 +917,11 @@ impl Player { if let Err(e) = save_subtitle_style(self.sub_family.as_deref(), self.sub_text) { let path = subtitle_style_path(); self.notify_user( - format!("SUBTITLE STYLE COULD NOT BE KEPT — {} — {e}", path.display()).into(), + format!( + "SUBTITLE STYLE COULD NOT BE KEPT — {} — {e}", + path.display() + ) + .into(), ); } cx.notify(); @@ -1336,11 +1353,8 @@ impl Player { // card opens on that; one in no group has no sound to equalize and // falls to the lane refusal below, in the words it always used. let anchor = match (self.selected.anchor(), self.session.as_ref()) { - (Some((lane, idx)), Some(session)) - if lane.kind == LaneKind::Subtitle => - { - caption_media_half(session, (lane, idx), LaneKind::Audio) - .or(self.selected.anchor()) + (Some((lane, idx)), Some(session)) if lane.kind == LaneKind::Subtitle => { + caption_media_half(session, (lane, idx), LaneKind::Audio).or(self.selected.anchor()) } _ => self.selected.anchor(), }; @@ -1499,7 +1513,12 @@ impl Player { /// missing from the darkroom for. Returns `true` when a card was open /// and ate the key, the caller's cue to `cx.notify()` and stop exactly /// where each of these branches used to `return` inline. - pub(crate) fn param_card_key(&mut self, key: &str, shift: bool, cx: &mut Context) -> bool { + pub(crate) fn param_card_key( + &mut self, + key: &str, + shift: bool, + cx: &mut Context, + ) -> bool { // The one chord every param card answers to, wherever the pointer // toggle sits in `dark_card_head` -- mouse and key reach the same // switch (DESIGN's repeated "some options are only reachable via diff --git a/crates/app/src/player/export.rs b/crates/app/src/player/export.rs index ec319c7..0d64b31 100644 --- a/crates/app/src/player/export.rs +++ b/crates/app/src/player/export.rs @@ -109,7 +109,9 @@ impl Player { engine::decode::DecodeSession::open_range(&path, 0, 1).ok()?; let frame = rx.recv().ok()?; let buf = image::RgbaImage::from_raw(frame.width, frame.height, frame.bgra)?; - Some(std::sync::Arc::new(RenderImage::new(vec![image::Frame::new(buf)]))) + Some(std::sync::Arc::new(RenderImage::new(vec![ + image::Frame::new(buf), + ]))) } }); cx.spawn(async move |this, cx| { @@ -250,7 +252,12 @@ impl Player { let scan = cx.background_executor().spawn({ let (path, stream, progress) = (key.0.clone(), key.1, Arc::clone(&progress)); async move { - engine::silence::levels_with_progress(&path, stream, (0., f64::INFINITY), &progress) + engine::silence::levels_with_progress( + &path, + stream, + (0., f64::INFINITY), + &progress, + ) } }); cx.spawn(async move |this, cx| { @@ -299,8 +306,7 @@ impl Player { let Some(session) = &self.session else { return; }; - let settings = - export_settings( + let settings = export_settings( self.quality, self.custom_mbps, self.format, @@ -338,9 +344,9 @@ impl Player { return; } self.export_seat = Some((key.0.clone(), key.1, key.2.clone(), None)); - let probed = cx.background_executor().spawn(async move { - engine::export::planned_seats(&project, &meta, &settings) - }); + let probed = cx + .background_executor() + .spawn(async move { engine::export::planned_seats(&project, &meta, &settings) }); cx.spawn(async move |this, cx| { let probed = probed.await; this.update(cx, |this, cx| { @@ -676,8 +682,7 @@ impl Player { if self.export.is_some() { return; } - let mut settings = - export_settings( + let mut settings = export_settings( self.quality, self.custom_mbps, self.format, diff --git a/crates/app/src/player/library.rs b/crates/app/src/player/library.rs index bb5f917..1061652 100644 --- a/crates/app/src/player/library.rs +++ b/crates/app/src/player/library.rs @@ -153,7 +153,8 @@ impl Player { // in the way of a re-add starting a fresh one // ([`Player::cache_media`]'s dedupe reads presence here). if let Some(scan) = self.silence_bg.remove(&(path.to_path_buf(), stream)) { - scan.cancel.store(true, std::sync::atomic::Ordering::Relaxed); + scan.cancel + .store(true, std::sync::atomic::Ordering::Relaxed); } // The picked row may be the one that just went, and the engine // reseeks, so this owes the flag reset like every other edit. @@ -332,7 +333,8 @@ impl Player { // empty (`Player::cache_media`'s spawn checks this flag before it // inserts). for scan in self.silence_bg.values() { - scan.cancel.store(true, std::sync::atomic::Ordering::Relaxed); + scan.cancel + .store(true, std::sync::atomic::Ordering::Relaxed); } self.silence_bg.clear(); // Every gesture in flight, dropped for `reset_after_reseek`'s reason @@ -383,7 +385,10 @@ impl Player { // The timeline would otherwise keep playing under the preview -- two // soundtracks at once -- so it is paused here and resumed on the way // out only if this is what paused it ([`Player::close_preview`]). - self.preview_playing = self.session.as_ref().is_some_and(PlaybackSession::is_playing); + self.preview_playing = self + .session + .as_ref() + .is_some_and(PlaybackSession::is_playing); if let Some(session) = self.session.as_mut() { session.pause(); } @@ -396,8 +401,11 @@ impl Player { session.play(); self.preview_session = Some(session); self.notify_user( - format!("PREVIEWING {} — not on the timeline; esc stops it", file_name(path)) - .into(), + format!( + "PREVIEWING {} — not on the timeline; esc stops it", + file_name(path) + ) + .into(), ); } Err(e) => self.notify_user(format!("PREVIEW FAILED: {e}").into()), @@ -890,7 +898,11 @@ impl Player { if let Err(e) = save_proxies_pref(on) { let path = proxies_pref_path(); self.notify_user( - format!("PROXIES DEFAULT COULD NOT BE KEPT — {} — {e}", path.display()).into(), + format!( + "PROXIES DEFAULT COULD NOT BE KEPT — {} — {e}", + path.display() + ) + .into(), ); } self.notify_user(text.into()); @@ -931,7 +943,11 @@ impl Player { if let Err(e) = save_auto_proxies_pref(on) { let path = auto_proxies_pref_path(); self.notify_user( - format!("AUTO PROXIES DEFAULT COULD NOT BE KEPT — {} — {e}", path.display()).into(), + format!( + "AUTO PROXIES DEFAULT COULD NOT BE KEPT — {} — {e}", + path.display() + ) + .into(), ); } self.notify_user(text.into()); @@ -987,7 +1003,12 @@ impl Player { /// The export guard again, and not for the caller's sake: an export can /// have started during the seconds the worker was reading, and a drop /// during an export has always been a silent no-op. - pub(crate) fn take_import(&mut self, path: &std::path::Path, landed: Landed, cx: &mut Context) { + pub(crate) fn take_import( + &mut self, + path: &std::path::Path, + landed: Landed, + cx: &mut Context, + ) { if self.exporting().is_some() { return; } @@ -1310,7 +1331,12 @@ impl Player { /// off the worker that read the file ([`read_ahead`]), like every other /// door's do, and what is left here is the push. The engine dedupes by /// (file, track), so the same `.srt` twice is one row and says so. - pub(crate) fn take_subtitles(&mut self, path: &std::path::Path, subs: Subs, cx: &mut Context) { + pub(crate) fn take_subtitles( + &mut self, + path: &std::path::Path, + subs: Subs, + cx: &mut Context, + ) { let added = self .session .as_mut() @@ -1330,10 +1356,7 @@ impl Player { cx: &mut Context, ) { let text = match added { - Some(Ok(0)) => format!( - "{}'s subtitles are in the palette already", - file_name(path) - ), + Some(Ok(0)) => format!("{}'s subtitles are in the palette already", file_name(path)), // Where they are and what to do with them: the tracks are in the // palette and nothing is placed until one is dragged onto an S // track, which is the whole of what this door does. @@ -1608,8 +1631,12 @@ impl Player { /// their own. fn recovery_offer(project_path: &Path) -> Option { let sidecar = Self::autosave_path(project_path)?; - let project_mtime = std::fs::metadata(project_path).and_then(|m| m.modified()).ok()?; - let sidecar_mtime = std::fs::metadata(&sidecar).and_then(|m| m.modified()).ok()?; + let project_mtime = std::fs::metadata(project_path) + .and_then(|m| m.modified()) + .ok()?; + let sidecar_mtime = std::fs::metadata(&sidecar) + .and_then(|m| m.modified()) + .ok()?; (sidecar_mtime > project_mtime).then_some(sidecar) } @@ -1650,7 +1677,11 @@ impl Player { /// write is not something a person can do anything about right now, and a /// modal over it would be worse than the risk it is guarding against. fn autosave_tick(&mut self, cx: &mut Context) { - if !Self::autosave_gate(self.autosave_armed, self.autosave_dirty, self.exporting().is_some()) { + if !Self::autosave_gate( + self.autosave_armed, + self.autosave_dirty, + self.exporting().is_some(), + ) { return; } let now = Instant::now(); diff --git a/crates/app/src/player/timeline_edit.rs b/crates/app/src/player/timeline_edit.rs index 45dfb02..61693d9 100644 --- a/crates/app/src/player/timeline_edit.rs +++ b/crates/app/src/player/timeline_edit.rs @@ -150,13 +150,11 @@ impl Player { self.notify_user(format!("NOT GROUPED — {e}").into()); } } - None => { - self.notify_user( - "NOTHING TO GROUP WITH — no clip on another track covers exactly these \ + None => self.notify_user( + "NOTHING TO GROUP WITH — no clip on another track covers exactly these \ frames; ctrl-click the clips to group instead" - .into(), - ) - } + .into(), + ), }, (None, ..) => {} } @@ -184,10 +182,12 @@ impl Player { // A caption carrying a group id is a member, and a member goes the // way its group goes -- the engine's own door decides how much of // that is media (and so a reseek) and how much is a lift. - let grouped = self - .session - .as_ref() - .is_some_and(|session| session.sub_lane(lane).get(idx).is_some_and(|s| s.link.is_some())); + let grouped = self.session.as_ref().is_some_and(|session| { + session + .sub_lane(lane) + .get(idx) + .is_some_and(|s| s.link.is_some()) + }); match grouped { true => { if self @@ -310,7 +310,14 @@ impl Player { /// nothing is said about it. The engine reseeks, so all this owes is the /// flag reset -- and the selection, whose index was that lane's own and now /// names a different clip there. - pub(crate) fn move_clip(&mut self, from: Lane, idx: usize, to: Lane, x: Pixels, cx: &mut Context) { + pub(crate) fn move_clip( + &mut self, + from: Lane, + idx: usize, + to: Lane, + x: Pixels, + cx: &mut Context, + ) { if self.exporting().is_some() { return; } @@ -343,27 +350,23 @@ impl Player { // front-end already knows: a lane's kind, and where the clip was. // Everything else that could refuse (a clip that is not there) // cannot be dragged. - false if from.kind != to.kind => { - self.notify_user( - format!( - "NOT ON {} — that is a {kind} clip; drop it on a {lanes} lane", - to.label() - ) - .into(), + false if from.kind != to.kind => self.notify_user( + format!( + "NOT ON {} — that is a {kind} clip; drop it on a {lanes} lane", + to.label() ) - } + .into(), + ), // Picked up and put back down where it was: a click, and a click // says nothing. false if from == to && start == was => {} - false => { - self.notify_user( - format!( - "NOT MOVED — another clip already covers those frames on {}", - to.label() - ) - .into(), + false => self.notify_user( + format!( + "NOT MOVED — another clip already covers those frames on {}", + to.label() ) - } + .into(), + ), } cx.notify(); } @@ -472,7 +475,11 @@ impl Player { /// during the gesture -- an undo, another drop -- moves the indices gpui /// froze into the payload. pub(crate) fn dragged_sub(&self, drag: &SubDrag) -> Option { - live_idx(self.session.as_ref()?.sub_lane(drag.lane), drag.idx, drag.sub) + live_idx( + self.session.as_ref()?.sub_lane(drag.lane), + drag.idx, + drag.sub, + ) } /// A placed caption let go at window `x` over subtitle lane `to`: it lands @@ -604,7 +611,10 @@ impl Player { lane.label(), old.label() ), - None => format!("{} IS SHOWN — its captions are over the picture", lane.label()), + None => format!( + "{} IS SHOWN — its captions are over the picture", + lane.label() + ), }; self.notify_user(text.into()); cx.notify(); @@ -644,7 +654,13 @@ impl Player { /// over: [`Player::preview_ghost`]'s twin, refused for any lane that is not a /// subtitle lane -- which is the answer [`Project::move_sub`] gives at the /// release. - pub(crate) fn preview_ghost_sub(&mut self, drag: &SubDrag, to: Lane, x: Pixels, cx: &mut Context) { + pub(crate) fn preview_ghost_sub( + &mut self, + drag: &SubDrag, + to: Lane, + x: Pixels, + cx: &mut Context, + ) { let (start, _) = self.sub_drop_frame(drag.sub, x); let ghost = Ghost { lane: to, @@ -659,7 +675,13 @@ impl Player { /// The same for a palette row on its way down: it lands at the frame it is /// let go on ([`Player::place_frame`]) and is as long as the whole track it /// names. - pub(crate) fn preview_ghost_pick(&mut self, track: usize, to: Lane, x: Pixels, cx: &mut Context) { + pub(crate) fn preview_ghost_pick( + &mut self, + track: usize, + to: Lane, + x: Pixels, + cx: &mut Context, + ) { let ghost = Ghost { lane: to, start: self.place_frame(x).0, @@ -683,7 +705,12 @@ impl Player { /// the scroll clamp pins the bed's right edge to the duration, and the /// pointer has no pixel past it. The upgrade is to let the scroll clamp /// leave a screen of empty bed after the end, the way every NLE does. - pub(crate) fn drop_frame(&self, from: Lane, idx: usize, x: Pixels) -> Option<(u32, Option)> { + pub(crate) fn drop_frame( + &self, + from: Lane, + idx: usize, + x: Pixels, + ) -> Option<(u32, Option)> { let clip = self.session.as_ref()?.lane_clips(from).get(idx).copied()?; let marks = self.snap_targets(Some((from, idx))); Some(landing( @@ -727,7 +754,13 @@ impl Player { /// [`Player::drop_frame`] will commit, worked out on every move of the drag, /// so what the eye was promised is where the release puts it. A pointer that /// has wandered off the bed promises nothing. - pub(crate) fn preview_drop(&mut self, from: Lane, idx: usize, x: Pixels, cx: &mut Context) { + pub(crate) fn preview_drop( + &mut self, + from: Lane, + idx: usize, + x: Pixels, + cx: &mut Context, + ) { let cue = self.drop_frame(from, idx, x).and_then(|(_, cue)| cue); self.set_cue(cue, x, cx); } @@ -746,7 +779,13 @@ impl Player { /// are one answer -- and its own length at this zoom. A lane of the other /// kind refuses the drop ([`Project::move_clip`]), and the shadow says so /// before the release does. - pub(crate) fn preview_ghost(&mut self, drag: &ClipDrag, to: Lane, x: Pixels, cx: &mut Context) { + pub(crate) fn preview_ghost( + &mut self, + drag: &ClipDrag, + to: Lane, + x: Pixels, + cx: &mut Context, + ) { let ghost = self .dragged(drag) .and_then(|idx| self.drop_frame(drag.lane, idx, x)) @@ -802,7 +841,13 @@ impl Player { /// width -- the length the library row already reports. A file this lane /// cannot hold ([`lane_refuses`]) is tinted as refused, which is the answer /// the release would give in words. - pub(crate) fn preview_ghost_asset(&mut self, path: &Path, to: Lane, x: Pixels, cx: &mut Context) { + pub(crate) fn preview_ghost_asset( + &mut self, + path: &Path, + to: Lane, + x: Pixels, + cx: &mut Context, + ) { let ghost = Ghost { lane: to, start: self.place_frame(x).0, @@ -974,7 +1019,8 @@ impl Player { .get(clip.source) .and_then(|entry| self.syncs.get(&entry.path)) .is_some_and(|keys| { - keys.binary_search(&(clip.in_frame + (now - clip.start))).is_ok() + keys.binary_search(&(clip.in_frame + (now - clip.start))) + .is_ok() }) }) }) @@ -1022,7 +1068,13 @@ impl Player { /// one of the clips a ctrl-click selection already holds keeps that /// selection, so the menu's Group is about the whole of it. A right-click /// anywhere else is the single mark, exactly as a left press is. - pub(crate) fn open_menu(&mut self, lane: Lane, idx: usize, at: Point, cx: &mut Context) { + pub(crate) fn open_menu( + &mut self, + lane: Lane, + idx: usize, + at: Point, + cx: &mut Context, + ) { if self.modal() { return; } @@ -1041,7 +1093,14 @@ impl Player { /// Opens the same menu on the gap under the pointer instead of a clip -- /// the empty-bench-space door to [`Player::close_gap`]. Nothing is /// selected: a gap owns no clip to select, unlike [`Player::open_menu`]. - pub(crate) fn open_gap_menu(&mut self, lane: Lane, start: u32, frames: u32, at: Point, cx: &mut Context) { + pub(crate) fn open_gap_menu( + &mut self, + lane: Lane, + start: u32, + frames: u32, + at: Point, + cx: &mut Context, + ) { if self.modal() { return; } @@ -1063,7 +1122,13 @@ impl Player { /// of step with each other, which no lane's own gap is worth. A take /// whose gap does not match on its other lane is refused in words, not /// silence ([`engine::Project::gap_take_scope`]). - pub(crate) fn close_gap(&mut self, lane: Lane, start: u32, frames: u32, cx: &mut Context) { + pub(crate) fn close_gap( + &mut self, + lane: Lane, + start: u32, + frames: u32, + cx: &mut Context, + ) { let Some(session) = self.session.as_mut() else { return; }; @@ -1268,10 +1333,7 @@ impl Player { /// and not with the one that would have been there unzoomed. The one /// question a trim, a grab and a drop all ask. pub(crate) fn frame_under(&self, x: Pixels) -> u32 { - frame_at( - self.scale.time_at(px_along(x, self.ruler.get())), - self.fps, - ) + frame_at(self.scale.time_at(px_along(x, self.ruler.get())), self.fps) } /// The release: the whole drag reaches the engine as one edit, so it is one @@ -1388,10 +1450,13 @@ impl Player { return; }; self.mark_dirty(); - let set = self.session.as_mut().is_some_and(|session| match fade.is_in { - true => session.set_fade_in(fade.lane, fade.idx, fade.to), - false => session.set_fade_out(fade.lane, fade.idx, fade.to), - }); + let set = self + .session + .as_mut() + .is_some_and(|session| match fade.is_in { + true => session.set_fade_in(fade.lane, fade.idx, fade.to), + false => session.set_fade_out(fade.lane, fade.idx, fade.to), + }); if set { cx.notify(); } @@ -1426,7 +1491,9 @@ impl Player { [a, b] if a.0 == b.0 && a.1.abs_diff(b.1) == 1 => Some((a.0, a.1.min(b.1))), _ => self.selected.anchor(), }) else { - self.notify_user("NOTHING TO CROSSFADE — select an audio clip that has a neighbour".into()); + self.notify_user( + "NOTHING TO CROSSFADE — select an audio clip that has a neighbour".into(), + ); cx.notify(); return; }; @@ -1456,7 +1523,9 @@ impl Player { [a, b] if a.0 == b.0 && a.1.abs_diff(b.1) == 1 => Some((a.0, a.1.min(b.1))), _ => self.selected.anchor(), }) else { - self.notify_user("NOTHING TO DISSOLVE — select a video clip that has a neighbour".into()); + self.notify_user( + "NOTHING TO DISSOLVE — select a video clip that has a neighbour".into(), + ); cx.notify(); return; }; @@ -1465,7 +1534,11 @@ impl Player { return; }; let removing = session.transition_out_of(lane, idx) > 0; - let frames = if removing { 0 } else { self.fps.round().max(1.) as u32 }; + let frames = if removing { + 0 + } else { + self.fps.round().max(1.) as u32 + }; if !session.set_transition_out(lane, idx, frames) { self.notify_user( "NOTHING TO DISSOLVE — it takes two video clips sitting end to end on one lane" @@ -1489,10 +1562,14 @@ impl Player { }) else { return clip; }; - let to = self.followed(trim, (lane, idx), match trim.edge { - Edge::Start => clip.start, - Edge::End => clip.end(), - }); + let to = self.followed( + trim, + (lane, idx), + match trim.edge { + Edge::Start => clip.start, + Edge::End => clip.end(), + }, + ); let still = self.session.as_ref().is_some_and(|session| { session .sources() @@ -1507,9 +1584,10 @@ impl Player { /// caption in the dragged group follows by the same delta, against its own /// walls. pub(crate) fn trimmed_sub(&self, lane: Lane, idx: usize, sub: SubClip) -> SubClip { - let Some(trim) = self.trim.filter(|t| { - (t.lane, t.idx) == (lane, idx) || (t.link.is_some() && t.link == sub.link) - }) else { + let Some(trim) = self + .trim + .filter(|t| (t.lane, t.idx) == (lane, idx) || (t.link.is_some() && t.link == sub.link)) + else { return sub; }; let to = self.followed( diff --git a/crates/app/src/player/transport.rs b/crates/app/src/player/transport.rs index c52c510..2926681 100644 --- a/crates/app/src/player/transport.rs +++ b/crates/app/src/player/transport.rs @@ -51,8 +51,7 @@ impl Player { // seen without a manual replay after every nudge. Checked off the // engine's own clock, not a frame counter this pump keeps -- the // same `now()` [`Player::step`] reads. - if session.is_playing() - && should_loop_restart(frame_at(session.now(), fps), self.loop_trim) + if session.is_playing() && should_loop_restart(frame_at(session.now(), fps), self.loop_trim) { let start = self.loop_trim.map_or(0, |(lo, _)| lo); session.seek(f64::from(start) / fps); @@ -456,10 +455,22 @@ mod tests { /// otherwise silently stop covering). #[test] fn the_loop_restarts_only_on_the_crossing_with_loop_on() { - assert!(crosses_into_loop(Transport::Playing, Transport::Ended, true)); - assert!(!crosses_into_loop(Transport::Playing, Transport::Ended, false)); + assert!(crosses_into_loop( + Transport::Playing, + Transport::Ended, + true + )); + assert!(!crosses_into_loop( + Transport::Playing, + Transport::Ended, + false + )); assert!(!crosses_into_loop(Transport::Ended, Transport::Ended, true)); - assert!(!crosses_into_loop(Transport::Ended, Transport::Playing, true)); + assert!(!crosses_into_loop( + Transport::Ended, + Transport::Playing, + true + )); } /// `loop_restart_frame` picks the seek target the crossing above plays @@ -493,7 +504,11 @@ mod tests { let loop_trim = Some((30, 60)); let armed = loop_on || loop_trim.is_some(); assert!(armed, "loop_trim alone must arm the crossing"); - assert!(crosses_into_loop(Transport::Playing, Transport::Ended, armed)); + assert!(crosses_into_loop( + Transport::Playing, + Transport::Ended, + armed + )); assert_eq!(loop_restart_frame(loop_on, loop_trim), Some(30)); } diff --git a/crates/app/src/player/view.rs b/crates/app/src/player/view.rs index b070fb4..9ac4eaf 100644 --- a/crates/app/src/player/view.rs +++ b/crates/app/src/player/view.rs @@ -170,7 +170,13 @@ impl Player { /// One clip's fit policy set, whichever asked: the stroke that steps to the /// next one and the list that names one outright come through here, so they /// cannot differ in what they do or in what they say they did. - pub(crate) fn apply_fit(&mut self, lane: Lane, idx: usize, fit: FitPolicy, cx: &mut Context) { + pub(crate) fn apply_fit( + &mut self, + lane: Lane, + idx: usize, + fit: FitPolicy, + cx: &mut Context, + ) { if let Some(session) = &mut self.session && session.set_fit(lane, idx, fit) { @@ -247,8 +253,12 @@ impl Player { if view.bed <= 0. || view.duration <= 0. { return; } - let (thumb_x, thumb_w) = - scroll_thumb(view.bed, view.duration, view.scale.start.max(0.), view.span()); + let (thumb_x, thumb_w) = scroll_thumb( + view.bed, + view.duration, + view.scale.start.max(0.), + view.span(), + ); let at = px_along(x, self.scroll_track.get()); let grab = match (thumb_x..thumb_x + thumb_w).contains(&at) { true => at - thumb_x, @@ -263,11 +273,13 @@ impl Player { // leaves is always a real place inside it -- at the thumb's floor // width as much as anywhere else. false => { - let start = f64::from((at - thumb_w / 2.).max(0.)) - / f64::from(view.bed.max(1.)) + let start = f64::from((at - thumb_w / 2.).max(0.)) / f64::from(view.bed.max(1.)) * view.duration; self.scale = View { - scale: Scale { start, ..view.scale }, + scale: Scale { + start, + ..view.scale + }, ..view } .settled(); @@ -297,7 +309,10 @@ impl Player { // is the clamp's to hold, exactly as every scrollbar's is. let start = f64::from((at - grab).max(0.)) / f64::from(view.bed.max(1.)) * view.duration; self.scale = View { - scale: Scale { start, ..view.scale }, + scale: Scale { + start, + ..view.scale + }, ..view } .settled(); @@ -335,9 +350,8 @@ impl Player { // the track by [`lanes_thumb`], so the grab this leaves is always // a real place inside it. false => { - let to = self.lanes_taken( - (at - thumb_h / 2.).max(0.) / (track - thumb_h).max(1.) * max, - ); + let to = + self.lanes_taken((at - thumb_h / 2.).max(0.) / (track - thumb_h).max(1.) * max); self.lanes_scroll .set_offset(point(self.lanes_scroll.offset().x, px(-to))); thumb_h / 2. diff --git a/crates/app/src/render.rs b/crates/app/src/render.rs index 79d791d..7de0a68 100644 --- a/crates/app/src/render.rs +++ b/crates/app/src/render.rs @@ -9,7 +9,11 @@ use crate::*; /// not a card drawn over it, so it goes before a menu close or a preview /// close gets a look at the same key. See the call site in [`Player::render`] /// for the deliberate order this buys with a preview open underneath. -pub(crate) fn escape_leaves_player_fullscreen(key: &str, ctrl: bool, player_fullscreen: bool) -> bool { +pub(crate) fn escape_leaves_player_fullscreen( + key: &str, + ctrl: bool, + player_fullscreen: bool, +) -> bool { key == ESCAPE && !ctrl && player_fullscreen } @@ -99,8 +103,7 @@ impl Player { // broken -- so it says what it wants instead. The window // is already the drop target. .or_else(|| { - (self.active_session().is_none()) - .then(|| empty_hint().into_any_element()) + (self.active_session().is_none()).then(|| empty_hint().into_any_element()) }), ) // After the picture, so the plate is drawn over it rather than @@ -374,7 +377,11 @@ impl Render for Player { // legacy "Add at playhead" button's pointer one, live only // where a row is actually picked so a bare enter elsewhere // keeps meaning whatever it already means below. - if key == "enter" && this.dock_src_active && this.selected_asset.is_some() && this.exporting().is_none() { + if key == "enter" + && this.dock_src_active + && this.selected_asset.is_some() + && this.exporting().is_none() + { if let Some((path, stream)) = this.selected_asset.clone() { this.insert_source(&path, stream, None, None, cx); } @@ -657,10 +664,12 @@ impl Render for Player { .flex_1() .min_h(px(0.)) .flex() - .child(self.library( - self.split_px(Split::Library, window.viewport_size()), - cx, - )) + .child( + self.library( + self.split_px(Split::Library, window.viewport_size()), + cx, + ), + ) // The seams, one per pair of regions: what a hand // drags to give a panel more room and its // neighbour less ([`divider`]). diff --git a/crates/app/src/subs.rs b/crates/app/src/subs.rs index bb09d35..6008276 100644 --- a/crates/app/src/subs.rs +++ b/crates/app/src/subs.rs @@ -168,7 +168,11 @@ pub(crate) fn open_ahead( /// import into, which fills the library instead. One function because they are /// one read -- the engine's two doors differ by which lanes come up empty /// ([`engine::PlaybackSession::open_library`]), not by what they walk. -pub(crate) fn open_whole(path: &std::path::Path, place: bool, stage: &std::sync::atomic::AtomicU8) -> Landed { +pub(crate) fn open_whole( + path: &std::path::Path, + place: bool, + stage: &std::sync::atomic::AtomicU8, +) -> Landed { use std::sync::atomic::Ordering::Relaxed; let opened = match place { true => PlaybackSession::open(path), @@ -270,7 +274,10 @@ pub(crate) fn walk_subtitles(path: &std::path::Path) -> Subs { /// this runs on the worker ([`open_ahead`]), never the render thread; an /// import splits the two halves across the hop instead ([`read_ahead`] walks, /// [`subtitle_tail`] pushes). -pub(crate) fn subtitle_notice(session: &mut PlaybackSession, path: &std::path::Path) -> Option { +pub(crate) fn subtitle_notice( + session: &mut PlaybackSession, + path: &std::path::Path, +) -> Option { subtitle_tail(session, walk_subtitles(path)) } @@ -606,7 +613,10 @@ pub(crate) fn sub_pick_after_removal(picked: usize, removed: usize, left: usize) picked.min(left.saturating_sub(1)) } -pub(crate) fn sub_pick_name(tracks: &[engine::subtitle::SubtitleTrack], track: usize) -> Option { +pub(crate) fn sub_pick_name( + tracks: &[engine::subtitle::SubtitleTrack], + track: usize, +) -> Option { subtitle_rows(tracks).into_iter().find_map(|group| { let row = group.rows.iter().find(|row| row.track == track)?; let track = match group.rows.len() > 1 { diff --git a/crates/app/src/tests/cards.rs b/crates/app/src/tests/cards.rs index 3fbaa97..55a6017 100644 --- a/crates/app/src/tests/cards.rs +++ b/crates/app/src/tests/cards.rs @@ -2009,6 +2009,8 @@ fn a_maximized_card_can_never_rise_above_the_picture_no_matter_the_bench_height( /// invent. #[test] fn a_maximized_card_reopens_exactly_as_left_across_a_restart() { + let _config_env = config_env_lock(); + let dir = std::env::temp_dir().join(format!( "edith-test-maximized-{}-{}", std::process::id(), @@ -2018,8 +2020,8 @@ fn a_maximized_card_reopens_exactly_as_left_across_a_restart() { .as_nanos() )); std::fs::create_dir_all(&dir).unwrap(); - // Scoped to this test alone, the same reasoning `tests/media.rs`'s own - // XDG_CONFIG_HOME mutation gives: nothing else reads this file. + // `config_env_lock` serializes every test that changes this process-wide + // path. unsafe { std::env::set_var("XDG_CONFIG_HOME", &dir) }; // Nothing written yet: the default (not maximized), not a crash on a @@ -2073,6 +2075,8 @@ fn darkroom_preview_mounts_stop_and_drag_scrub() { && preview.contains("this.preview_scrub_to(event.position.x, true, cx)"), "the mounted preview scrub no longer starts its drag-and-seek gesture" ); +} + /// Source management must stay reachable in the Darkroom itself: per-row /// stand-in control/progress, pointer Add-at-playhead alongside its `↵` chord, /// and the three legacy source questions as dock filters. The test reads the diff --git a/crates/app/src/tests/editing.rs b/crates/app/src/tests/editing.rs index f8cc08d..b8a8763 100644 --- a/crates/app/src/tests/editing.rs +++ b/crates/app/src/tests/editing.rs @@ -80,8 +80,7 @@ fn an_import_adds_a_row_at_its_own_length_and_leaves_the_lanes_alone() { /// an export. #[test] fn a_song_opens_the_window_by_itself() { - let mut session = - PlaybackSession::open(asset("test_tone.mp3")).expect("a song is a timeline"); + let mut session = PlaybackSession::open(asset("test_tone.mp3")).expect("a song is a timeline"); session.set_gain(0.0); // The source's own path, which is the canonical one a row carries. let path = session.sources()[0].path.clone(); @@ -345,11 +344,13 @@ fn a_caption_is_deleted_by_the_same_row_and_stroke_every_box_is() { ); // ...and the same reading with a clip under it is the clip menu, untouched: // the flag is off wherever a `Clip` was clicked. - assert!(menu_items(Ctx { - timeline: true, - ..Ctx::default() - }) - .contains(&ActionId::Cut)); + assert!( + menu_items(Ctx { + timeline: true, + ..Ctx::default() + }) + .contains(&ActionId::Cut) + ); } /// A timeline with a subtitle palette and an empty subtitle lane: what a @@ -383,7 +384,9 @@ fn one_second(start: u32) -> SubClip { fn a_refused_caption_drop_leaves_the_mark_where_it_was() { use crate::sub_mark; let (mut session, lane) = with_subtitle_lane(); - session.place_sub(lane, 0, one_second(0)).expect("A goes down"); + session + .place_sub(lane, 0, one_second(0)) + .expect("A goes down"); session .place_sub(lane, 60, one_second(0)) .expect("B goes down after it"); @@ -517,8 +520,14 @@ fn a_caption_anchor_names_the_media_half_of_its_group() { .place_sub(lane, 0, one_second(0)) .expect("the caption goes down"); // Ungrouped: no pictures and no sound behind the words. - assert_eq!(caption_media_half(&session, (lane, 0), LaneKind::Video), None); - assert_eq!(caption_media_half(&session, (lane, 0), LaneKind::Audio), None); + assert_eq!( + caption_media_half(&session, (lane, 0), LaneKind::Video), + None + ); + assert_eq!( + caption_media_half(&session, (lane, 0), LaneKind::Audio), + None + ); // Grouped with the take -- whose sound rides along unasked -- both halves // answer by lane and index. session @@ -601,7 +610,9 @@ fn the_playhead_actions_still_work_with_a_caption_marked() { // And the edits themselves, on a timeline holding a placed caption: the // split at the playhead and the rejoin at the seam it leaves. let (mut session, lane) = with_subtitle_lane(); - session.place_sub(lane, 0, one_second(0)).expect("it goes down"); + session + .place_sub(lane, 0, one_second(0)) + .expect("it goes down"); let clips = session.lane_clips(Lane::V1).len(); assert!(session.cut_at(2.0), "the playhead splits the clip under it"); assert_eq!(session.lane_clips(Lane::V1).len(), clips + 1); @@ -665,7 +676,10 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() { ..clip }; assert_eq!(slow.frames(), 240, "a quarter speed is four times as long"); - assert!(offered(&slow, v1, ActionId::Cut, 34), "34 is a source frame"); + assert!( + offered(&slow, v1, ActionId::Cut, 34), + "34 is a source frame" + ); assert!(!offered(&slow, v1, ActionId::Cut, 35)); assert_eq!( on(&slow, v1, ActionId::Cut, 35).why(), @@ -785,7 +799,10 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() { assert!(on(&clip, lane, action, 60).why().is_some()); } assert!(matches!(on(&clip, v1, ActionId::Cut, 30), Enable::No(_))); - assert!(matches!(on(&clip, v1, ActionId::Regroup, 60), Enable::No(_))); + assert!(matches!( + on(&clip, v1, ActionId::Regroup, 60), + Enable::No(_) + )); assert!(matches!(on(&clip, v1, ActionId::Detach, 0), Enable::No(_))); // Every refusal says something, and says it short enough to sit in the // menu's right-hand column beside a label -- the still's included, which @@ -943,7 +960,10 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() { // for it, never the card that grows. let items = MENU_ITEMS.len() + 1; // Properties let floor = size(px(640.), px(360.)); - assert!(MENU_PAD * 2. + menu_rows_h(items, floor) <= 360., "too tall"); + assert!( + MENU_PAD * 2. + menu_rows_h(items, floor) <= 360., + "too tall" + ); assert!( menu_rows_h(items, floor) / MENU_ROW_H >= 12., "too few items visible to scan on the smallest window" @@ -1093,11 +1113,16 @@ fn a_menu_offers_only_what_applies_and_is_drawn_inside_the_window() { assert!(row_enable(RowItem::RemoveWithClips, placed).yes()); let unplaced = row_items(live); assert!(unplaced.contains(&RowItem::Remove) && !unplaced.contains(&RowItem::RemoveWithClips)); - assert!(!row_enable( - RowItem::RemoveWithClips, - RowCtx { exporting: true, ..placed } - ) - .yes()); + assert!( + !row_enable( + RowItem::RemoveWithClips, + RowCtx { + exporting: true, + ..placed + } + ) + .yes() + ); assert!(!row_enable(RowItem::Add, RowCtx::default()).yes()); // Every refusal is short enough to sit in the hint column beside its // label, the clip menu's rule. @@ -1288,7 +1313,10 @@ fn a_clip_box_is_never_narrower_than_its_target() { pps: 0.1, start: 0., }; - assert!(far.width_px(2.) < 1., "the fixture is not zoomed out enough"); + assert!( + far.width_px(2.) < 1., + "the fixture is not zoomed out enough" + ); assert_eq!(clip_width(far.width_px(2.)), HIT_MIN); // Zero is the floor's own case: a clip trimmed to nothing, and the // width a lane draws before its first frame is measured. @@ -1378,8 +1406,7 @@ fn group_reaches_the_sound_before_a_video_layer_over_it() { let file = dir.join("lanes.edith"); session.save_project(&file).expect("save the project"); let text = std::fs::read_to_string(&file).expect("read it back"); - let (sound, rest): (Vec<&str>, Vec<&str>) = - text.lines().partition(|l| l.starts_with("audio ")); + let (sound, rest): (Vec<&str>, Vec<&str>) = text.lines().partition(|l| l.starts_with("audio ")); std::fs::write( &file, format!("{}\n{}\n", rest.join("\n"), sound.join("\n")), @@ -1479,8 +1506,7 @@ fn adding_a_row_drops_the_whole_source_in_at_the_playhead() { // The same door with a *second audio stream* of a file already there: // a new source entry, the same picture, and the row that was dragged // is what plays. This is the whole user-facing point of the slice. - let mut session = - PlaybackSession::open(asset("test_multilang.mp4")).expect("open the fixture"); + let mut session = PlaybackSession::open(asset("test_multilang.mp4")).expect("open the fixture"); session.set_gain(0.0); let path = session.sources()[0].path.clone(); let frames = session.file_frames(&path); @@ -1920,7 +1946,8 @@ fn a_grouped_clip_on_an_added_lane_closes_its_hole_with_its_caption() { "its grouped caption went with it, not left as an orphan" ); assert_eq!( - session.sub_lane(sub_lane)[0].start, 30, + session.sub_lane(sub_lane)[0].start, + 30, "and the hole under it closed: the caption after it slid up" ); } @@ -2106,7 +2133,11 @@ fn nudge_edge_moves_one_frame_and_clamps_to_the_room() { assert_eq!(nudge_edge(50, 1, 0, 100), 51); assert_eq!(nudge_edge(50, -1, 0, 100), 49); assert_eq!(nudge_edge(0, -1, 0, 100), 0, "the room's own floor holds"); - assert_eq!(nudge_edge(100, 1, 0, 100), 100, "the room's own ceiling holds"); + assert_eq!( + nudge_edge(100, 1, 0, 100), + 100, + "the room's own ceiling holds" + ); // A 4px-wide clip's room can be one frame wide: still clamps, never // panics on the narrow end. assert_eq!(nudge_edge(5, 1, 5, 5), 5); @@ -2119,8 +2150,14 @@ fn should_loop_restart_only_at_the_windows_far_edge() { use crate::timeline_math::should_loop_restart; assert!(!should_loop_restart(40, Some((30, 60)))); assert!(should_loop_restart(60, Some((30, 60)))); - assert!(should_loop_restart(61, Some((30, 60))), "past it restarts too"); - assert!(!should_loop_restart(60, None), "loop-trim off restarts nothing"); + assert!( + should_loop_restart(61, Some((30, 60))), + "past it restarts too" + ); + assert!( + !should_loop_restart(60, None), + "loop-trim off restarts nothing" + ); } /// The paused-then-started repro this predicate was blamed for and cleared diff --git a/crates/app/src/tests/layout.rs b/crates/app/src/tests/layout.rs index a3b1638..bbd6192 100644 --- a/crates/app/src/tests/layout.rs +++ b/crates/app/src/tests/layout.rs @@ -102,7 +102,10 @@ fn no_colour_is_written_outside_the_theme() { .lines() .filter(|l| l.contains("rgb(0x") || l.contains("rgba(0x")) .collect(); - assert!(stray.is_empty(), "colour written outside the theme: {stray:?}"); + assert!( + stray.is_empty(), + "colour written outside the theme: {stray:?}" + ); } /// The literal-grep above is blind to a hue arriving through a theme @@ -127,7 +130,10 @@ fn an_alpha_carrying_role_never_reaches_rgb() { (hex.len() == 8 && !hex.ends_with("ff")).then_some(name.trim()) }) .collect(); - assert!(alpha_roles.len() >= 8, "the theme's alpha-carrying roles moved; this scan is blind"); + assert!( + alpha_roles.len() >= 8, + "the theme's alpha-carrying roles moved; this scan is blind" + ); let source = ui_source(); let mut misuses = Vec::new(); @@ -136,7 +142,10 @@ fn an_alpha_carrying_role_never_reaches_rgb() { misuses.push(*role); } } - assert!(misuses.is_empty(), "alpha-carrying role(s) reaching rgb() instead of rgba(): {misuses:?}"); + assert!( + misuses.is_empty(), + "alpha-carrying role(s) reaching rgb() instead of rgba(): {misuses:?}" + ); } /// "It scrolls" is not "it can be found": at the 640x360 floor the timeline @@ -145,7 +154,6 @@ fn an_alpha_carrying_role_never_reaches_rgb() { /// being scrolled, or it is an instruction nobody can carry out. #[test] fn the_line_about_what_is_below_the_fold_counts_what_is_still_below_it() { - // The timeline is a region and not the window: its chrome -- the // scrollbar strip's row included, which is the larger of the two the // zoom can leave in it -- and one whole lane fit the share it may take @@ -199,7 +207,10 @@ fn a_second_message_queues_behind_the_first_instead_of_erasing_it() { push_notice(&mut q, "NOTHING ADDED — no video stream".into()); push_notice(&mut q, "NOTHING ADDED — the file is not there".into()); assert_eq!(q.len(), 2); - assert_eq!(q.front().map(|n: &gpui::SharedString| n.as_ref()), Some("NOTHING ADDED — no video stream")); + assert_eq!( + q.front().map(|n: &gpui::SharedString| n.as_ref()), + Some("NOTHING ADDED — no video stream") + ); // A held key that refuses says its one sentence once: the count on the // bar is a count of messages, not of how long the key was held. @@ -212,7 +223,10 @@ fn a_second_message_queues_behind_the_first_instead_of_erasing_it() { push_notice(&mut q, format!("SCAN FAILED: {i}").into()); } assert_eq!(q.len(), NOTICES_MAX); - assert_eq!(q.back().map(|n: &gpui::SharedString| n.as_ref()), Some("SCAN FAILED: 10")); + assert_eq!( + q.back().map(|n: &gpui::SharedString| n.as_ref()), + Some("SCAN FAILED: 10") + ); // Answering the bar brings the next one up, oldest first. let front = q.pop_front(); @@ -225,7 +239,10 @@ fn a_second_message_queues_behind_the_first_instead_of_erasing_it() { #[test] fn an_export_outcome_jumps_the_queue() { let mut q = std::collections::VecDeque::new(); - push_notice(&mut q, "PROXY READY for a.mp4 — Proxies on cuts on it".into()); + push_notice( + &mut q, + "PROXY READY for a.mp4 — Proxies on cuts on it".into(), + ); push_notice(&mut q, "SUBTITLES b.srt — 1 track(s) in the palette".into()); push_notice(&mut q, format!("{EXPORT_DONE}out.mp4").into()); assert_eq!(q.len(), 3); @@ -237,7 +254,10 @@ fn an_export_outcome_jumps_the_queue() { // A failed export is the same class: the outcome, whichever it was. let mut q = std::collections::VecDeque::new(); - push_notice(&mut q, "PROXY READY for a.mp4 — Proxies on cuts on it".into()); + push_notice( + &mut q, + "PROXY READY for a.mp4 — Proxies on cuts on it".into(), + ); push_notice(&mut q, "EXPORT FAILED: disk full".into()); assert_eq!( q.front().map(|n: &gpui::SharedString| n.as_ref()), @@ -250,8 +270,14 @@ fn an_export_outcome_jumps_the_queue() { #[test] fn a_message_wears_the_colour_its_own_words_say() { assert_eq!(notice_tone("SCAN FAILED: no audio"), STATUS_ERROR()); - assert_eq!(notice_tone(&format!("{EXPORT_DONE}out.mp4")), STATUS_SUCCESS()); - assert_eq!(notice_tone("NOTHING DETACHED — not grouped"), STATUS_WARNING()); + assert_eq!( + notice_tone(&format!("{EXPORT_DONE}out.mp4")), + STATUS_SUCCESS() + ); + assert_eq!( + notice_tone("NOTHING DETACHED — not grouped"), + STATUS_WARNING() + ); assert_eq!(notice_tone("SNAP ON"), ACCENT_PRIMARY()); } @@ -267,7 +293,12 @@ fn an_inspector_section_occludes_no_timeline() { // leave this rule reading a file the render is no longer in. let render = source_from("impl Render for Player"); for card in [ - "eq_card", "color_card", "speed_card", "silence_card", "mix_card", "subtitle_style_card", + "eq_card", + "color_card", + "speed_card", + "silence_card", + "mix_card", + "subtitle_style_card", ] { assert!( inspector.contains(&format!("self.{card}(")), @@ -394,8 +425,8 @@ fn a_lane_row_is_a_fixed_header_and_a_bed_that_can_be_hit() { /// a hand can hold, and never off the ends. #[test] fn the_scroll_thumb_is_the_visible_share_at_its_own_place() { - use crate::scroll_thumb; use crate::SCROLL_THUMB_MIN; + use crate::scroll_thumb; // Nothing to scroll: the strip fills and says so. assert_eq!(scroll_thumb(400., 10., 0., 12.), (0., 400.)); @@ -469,10 +500,7 @@ fn the_scroll_strip_row_comes_and_goes_with_the_zoom() { // had: the region grows by the strip's row when it appears, by // exactly the row the lanes would otherwise lose to it. assert_eq!(timeline_h(2, scroll) - timeline_fixed_h(scroll), lanes_h(2)); - assert_eq!( - timeline_h(6, scroll) - timeline_fixed_h(scroll), - lanes_h(6) - ); + assert_eq!(timeline_h(6, scroll) - timeline_fixed_h(scroll), lanes_h(6)); // ...and the floor keeps a whole lane standing under the line, on // either face of the zoom boundary. let floor = split_size(Split::Timeline, Some(0.), 2, window, scroll); @@ -507,8 +535,8 @@ fn the_scroll_strip_row_comes_and_goes_with_the_zoom() { /// on the track, the time axis's own thumb turned through a right angle. #[test] fn the_lane_thumb_is_the_visible_share_of_the_stack() { - use crate::lanes_thumb; use crate::SCROLL_THUMB_MIN; + use crate::lanes_thumb; // Whole stack on screen: the track fills and there is nothing to scroll. assert_eq!(lanes_thumb(200., 104., 200., 0.), (0., 200.)); @@ -1152,7 +1180,10 @@ fn the_card_names_the_subtitle_it_leaves_off_and_counts_them_when_it_cannot() { // What the engine answers about the one pick that reached it, and what // this side knows about the row that did not. let named = subtitle_plan("[ASS] → embedded".to_string(), &two, &[0]); - assert_eq!(named, "[ASS] → embedded; [ASS] [FOR DUB] — in the palette, on no track"); + assert_eq!( + named, + "[ASS] → embedded; [ASS] [FOR DUB] — in the palette, on no track" + ); assert!( named.chars().count() <= SUB_PLAN_CHARS, "two tracks fit the value box: {named}" @@ -1439,8 +1470,14 @@ fn a_subtitle_group_header_is_never_gated_on_window_height() { .find("subtitle-group-head") .expect("no id on the group header"); let block = &timeline[head_at..(head_at + 2400).min(timeline.len())]; - assert!(block.contains("sub_folded.remove"), "no fold-open path: {block}"); - assert!(block.contains("sub_folded.insert"), "no fold-shut path: {block}"); + assert!( + block.contains("sub_folded.remove"), + "no fold-open path: {block}" + ); + assert!( + block.contains("sub_folded.insert"), + "no fold-shut path: {block}" + ); assert!( block.contains("\"1 track\"") || block.contains("tracks"), "the header does not say how many tracks it holds: {block}" @@ -1765,7 +1802,10 @@ fn a_dragged_divider_stops_before_either_panel_disappears() { // timeline's answer is stated for both of its faces: the timeline fits // the bed with nothing to scroll to, and zoomed in past that line the // strip's row joins the furniture. - assert_eq!(split_size(Split::Library, None, 2, window, false), library_w(1280.)); + assert_eq!( + split_size(Split::Library, None, 2, window, false), + library_w(1280.) + ); assert_eq!( split_size(Split::Inspector, None, 2, window, false), inspector_w(1280.) @@ -1779,8 +1819,14 @@ fn a_dragged_divider_stops_before_either_panel_disappears() { timeline_h(2, true).min(720. * TIMELINE_SHARE) ); // Dragged, it is what the hand asked for... - assert_eq!(split_size(Split::Library, Some(300.), 2, window, false), 300.); - assert_eq!(split_size(Split::Timeline, Some(300.), 2, window, false), 300.); + assert_eq!( + split_size(Split::Library, Some(300.), 2, window, false), + 300. + ); + assert_eq!( + split_size(Split::Timeline, Some(300.), 2, window, false), + 300. + ); // ...and never past either end of it. assert_eq!( split_size(Split::Library, Some(0.), 2, window, false), @@ -1824,7 +1870,10 @@ fn a_dragged_divider_stops_before_either_panel_disappears() { ); // A size dragged with one track and kept while a second arrives is raised // to the new floor as it is read, not silently drawn under it. - assert_eq!(split_size(Split::Timeline, Some(126.), 2, window, true), floor); + assert_eq!( + split_size(Split::Timeline, Some(126.), 2, window, true), + floor + ); // And the floor still fits the share the shortest window gives the region. assert!(floor <= 360. * TIMELINE_SHARE, "{floor} px will not fit"); assert_eq!( @@ -1866,7 +1915,9 @@ fn a_dragged_divider_stops_before_either_panel_disappears() { #[test] fn the_darkroom_seams_stop_before_either_side_disappears() { use crate::ui::theme::INSPECTOR_MIN_W; - use crate::{BENCH_MIN_H, SIDE_MAX_FRAC, SPLIT_W, Split, split_bounds, split_drag_size, split_size}; + use crate::{ + BENCH_MIN_H, SIDE_MAX_FRAC, SPLIT_W, Split, split_bounds, split_drag_size, split_size, + }; use gpui::{point, px, size}; let window = size(px(1280.), px(720.)); @@ -1935,7 +1986,10 @@ fn both_default_lanes_fit_the_bench_at_its_floor() { // row (`layout::LEDGER_SEAM_CLEARANCE`) so the last lane's own last pixel // never shares a row with the ledger's border, which lands here as // `avail` being a touch over the two-rows-plus-gap tight fit. - assert!(h >= LANE_MIN_H, "the floor should give both lanes at least their own minimum ({h} < {LANE_MIN_H})"); + assert!( + h >= LANE_MIN_H, + "the floor should give both lanes at least their own minimum ({h} < {LANE_MIN_H})" + ); let content = 2. * h + ROW_GAP; assert!( content <= avail + 1e-4, @@ -2061,7 +2115,9 @@ fn the_notice_plate_cannot_reach_the_bench_at_any_height() { #[test] fn the_notice_plate_declares_a_bounded_wrapping_text_layout() { let stance = src_text("ui/stance.rs"); - let notice_start = stance.find("fn notice_plate(").expect("notice plate moved or renamed"); + let notice_start = stance + .find("fn notice_plate(") + .expect("notice plate moved or renamed"); let notice_end = stance[notice_start..] .find("\n/// Thin strip") .map(|end| notice_start + end) @@ -2078,7 +2134,6 @@ fn the_notice_plate_declares_a_bounded_wrapping_text_layout() { ); } - /// A round trip through the file: what is saved is what the next load reads /// back, one seam touched and the other left at its default -- a scratch /// path, not the real config, the same isolation `keymap::tests`' own @@ -2198,12 +2253,20 @@ fn the_stance_renders_its_six_regions_in_the_documented_order() { // Defined in order is not composed in order -- `render()` has to call // them in it too, or the geometry above is dead prose. - let render_body = - &stance[stance.find("pub(crate) fn render(").expect("the stance's entry point")..]; + let render_body = &stance[stance + .find("pub(crate) fn render(") + .expect("the stance's entry point")..]; // Open paren only, no close: DESIGN §12 steps 3 and 4 hand most of the // regions player/window state to read, so their call sites carry // arguments now. Order is what this asserts, not arity. - let calls = ["spine(", "screen(", "time_band(", "bench(", "ledger(", "dock("]; + let calls = [ + "spine(", + "screen(", + "time_band(", + "bench(", + "ledger(", + "dock(", + ]; let composed: Vec = calls .iter() .map(|c| { @@ -2320,7 +2383,10 @@ fn every_darkroom_menu_sizes_its_list_against_the_floor_room_not_the_raw_viewpor call -- every darkroom menu must clamp both its anchor and its \ list room together" ); - assert!(sizings > 0, "{file} no longer opens any menu -- update this guard"); + assert!( + sizings > 0, + "{file} no longer opens any menu -- update this guard" + ); } } @@ -2338,10 +2404,19 @@ fn every_darkroom_menu_sizes_its_list_against_the_floor_room_not_the_raw_viewpor #[test] fn settings_project_and_editor_sections_open_disjoint_doors() { let source = src_text("ui/settings_stance.rs"); - let project_start = source.find("fn project_section(").expect("the project section"); - let editor_start = source.find("fn editor_section(").expect("the editor section"); - let render_start = source.find("pub(crate) fn render(").expect("the page's render fn"); - assert!(project_start < editor_start && editor_start < render_start, "the three fns moved; this scan is blind"); + let project_start = source + .find("fn project_section(") + .expect("the project section"); + let editor_start = source + .find("fn editor_section(") + .expect("the editor section"); + let render_start = source + .find("pub(crate) fn render(") + .expect("the page's render fn"); + assert!( + project_start < editor_start && editor_start < render_start, + "the three fns moved; this scan is blind" + ); let project_body = &source[project_start..editor_start]; let editor_body = &source[editor_start..render_start]; @@ -2354,7 +2429,10 @@ fn settings_project_and_editor_sections_open_disjoint_doors() { // every picker. let editor_no_theme = editor_body.replace("open_picker(Pick::Theme", ""); for door in ["open_picker(", "open_mix("] { - assert!(project_body.contains(door), "PROJECT section no longer opens {door} -- update this guard"); + assert!( + project_body.contains(door), + "PROJECT section no longer opens {door} -- update this guard" + ); assert!( !editor_no_theme.contains(door), "EDITOR section opens {door}, a project-file door -- that value belongs in PROJECT, not here" @@ -2364,8 +2442,15 @@ fn settings_project_and_editor_sections_open_disjoint_doors() { editor_body.contains("open_picker(Pick::Theme"), "the palette row left EDITOR -- it is a ~/.config preference, not a project value" ); - for door in ["toggle_proxies(", "toggle_auto_proxies(", "open_subtitle_style("] { - assert!(editor_body.contains(door), "EDITOR section no longer opens {door} -- update this guard"); + for door in [ + "toggle_proxies(", + "toggle_auto_proxies(", + "open_subtitle_style(", + ] { + assert!( + editor_body.contains(door), + "EDITOR section no longer opens {door} -- update this guard" + ); assert!( !project_body.contains(door), "PROJECT section opens {door}, an editor-only door -- that value belongs in EDITOR, not here" @@ -2375,9 +2460,19 @@ fn settings_project_and_editor_sections_open_disjoint_doors() { // through an opener, which is the one place a config-file write (the // subtitle style card's Save, this window's next project load) is // allowed to live. - for path_fn in ["dock_stance::config_path", "theme::config_path", "Keymap::config_path"] { - assert!(!project_body.contains(path_fn), "PROJECT section touches {path_fn} directly"); - assert!(!editor_body.contains(path_fn), "EDITOR section touches {path_fn} directly"); + for path_fn in [ + "dock_stance::config_path", + "theme::config_path", + "Keymap::config_path", + ] { + assert!( + !project_body.contains(path_fn), + "PROJECT section touches {path_fn} directly" + ); + assert!( + !editor_body.contains(path_fn), + "EDITOR section touches {path_fn} directly" + ); } } @@ -2395,9 +2490,16 @@ fn settings_row_hints_naming_config_edith_have_a_matching_pref_pair() { let source = src_text("ui/settings_stance.rs"); let library = src_text("player/library.rs"); // (row id, the stem its pref functions are named after) - for (row_id, stem) in [("settings-proxies", "proxies"), ("settings-auto-proxies", "auto_proxies")] { - let row_start = source.find(&format!("\"{row_id}\"")).unwrap_or_else(|| panic!("{row_id} row moved or renamed -- update this guard")); - let row_end = source[row_start..].find(",\n ))").map_or(source.len(), |i| row_start + i); + for (row_id, stem) in [ + ("settings-proxies", "proxies"), + ("settings-auto-proxies", "auto_proxies"), + ] { + let row_start = source + .find(&format!("\"{row_id}\"")) + .unwrap_or_else(|| panic!("{row_id} row moved or renamed -- update this guard")); + let row_end = source[row_start..] + .find(",\n ))") + .map_or(source.len(), |i| row_start + i); let row_text = &source[row_start..row_end]; if !row_text.contains("~/.config/edith") { continue; @@ -2422,10 +2524,18 @@ fn settings_row_hints_naming_config_edith_have_a_matching_pref_pair() { #[test] fn settings_project_rows_have_no_bare_noun_placeholder() { let source = src_text("ui/settings_stance.rs"); - let project_start = source.find("fn project_section(").expect("the project section"); - let editor_start = source.find("fn editor_section(").expect("the editor section"); + let project_start = source + .find("fn project_section(") + .expect("the project section"); + let editor_start = source + .find("fn editor_section(") + .expect("the editor section"); let project_body = &source[project_start..editor_start]; - for placeholder in ["\"Size\".to_string()", "\"Rate\".to_string()", "\"HDR\".to_string()"] { + for placeholder in [ + "\"Size\".to_string()", + "\"Rate\".to_string()", + "\"HDR\".to_string()", + ] { assert!( !project_body.contains(placeholder), "a PROJECT row fell back to the bare noun {placeholder} -- it reads as a value with no project open" @@ -2442,28 +2552,50 @@ fn settings_project_rows_have_no_bare_noun_placeholder() { #[test] fn hdr_reference_rows_read_content_light_and_use_the_established_empty_state() { let source = src_text("ui/settings_stance.rs"); - let project_start = source.find("fn project_section(").expect("the project section"); - let editor_start = source.find("fn editor_section(").expect("the editor section"); + let project_start = source + .find("fn project_section(") + .expect("the project section"); + let editor_start = source + .find("fn editor_section(") + .expect("the editor section"); let project_body = &source[project_start..editor_start]; - assert!(project_body.contains("settings-hdr-reference"), "the HDR reference row is missing"); - assert!(project_body.contains("settings-content-light"), "the content-light row is missing"); + assert!( + project_body.contains("settings-hdr-reference"), + "the HDR reference row is missing" + ); + assert!( + project_body.contains("settings-content-light"), + "the content-light row is missing" + ); // Reads the real declared numbers, not an invented default or a fixed // string standing in for one. for field in ["mastering_max", "max_cll", "max_fall"] { - assert!(project_body.contains(field), "the HDR reference rows do not read ContentLight::{field}"); + assert!( + project_body.contains(field), + "the HDR reference rows do not read ContentLight::{field}" + ); } // No override field exists on the engine side to write one into, so the // row must never claim a picker/opener the way every other PROJECT row // does -- it is built with `row_static`, not `row`/`row_ink`. - assert!(project_body.contains("row_static(\n \"settings-hdr-reference\""), "the HDR reference row must be read-only (row_static), not a picker"); - assert!(project_body.contains("row_static(\n \"settings-content-light\""), "the content-light row must be read-only (row_static), not a picker"); + assert!( + project_body.contains("row_static(\n \"settings-hdr-reference\""), + "the HDR reference row must be read-only (row_static), not a picker" + ); + assert!( + project_body.contains("row_static(\n \"settings-content-light\""), + "the content-light row must be read-only (row_static), not a picker" + ); // The established empty state: a bare "—" reused, never a second idiom // ("N/A", "None", "Unknown"...) invented for the same absence. - assert!(project_body.contains("\"—\".to_string()"), "the HDR reference rows must reuse the page's own empty-state dash"); + assert!( + project_body.contains("\"—\".to_string()"), + "the HDR reference rows must reuse the page's own empty-state dash" + ); } /// The parity class this user has reported four separate times: "some /// options are only reachable via keyboard shortcut". A source scan (this @@ -2558,7 +2690,9 @@ fn darkroom_bench_wires_transition_controls_and_lane_drop_cue() { } let lane = &bench[bench.find("fn lane_row(").expect("the lane renderer") - ..bench.find("pub(crate) fn render(").expect("the bench renderer")]; + ..bench + .find("pub(crate) fn render(") + .expect("the bench renderer")]; for needle in [ "this.preview_lane_drop(event.drag(cx).0, lane, cx)", "this.forget_lane_drop(lane, cx)", diff --git a/crates/app/src/tests/media.rs b/crates/app/src/tests/media.rs index 0f79725..a7424dc 100644 --- a/crates/app/src/tests/media.rs +++ b/crates/app/src/tests/media.rs @@ -2,10 +2,12 @@ //! command line, the scans, the codecs offered, and the subtitles found. use super::*; +use crate::player::library::{ + auto_proxies_pref_path, load_auto_proxies_pref, save_auto_proxies_pref, +}; use crate::subs::{ - load_subtitle_style, save_subtitle_style, sub_line_h_for, subtitle_style_path, SUB_SIZE_RANGE, + SUB_SIZE_RANGE, load_subtitle_style, save_subtitle_style, sub_line_h_for, subtitle_style_path, }; -use crate::player::library::{auto_proxies_pref_path, load_auto_proxies_pref, save_auto_proxies_pref}; use crate::ui::preview::{bgra_to_rgba, screenshot_path}; /// The import line's own state machine, driven the way a repaint drives @@ -160,7 +162,11 @@ fn a_bar_wide_sweep_writes_once_per_frame_delivered() { } // The release, whatever the worker is doing. written.extend(stash.take()); - assert_eq!(written, vec![0, 9, 19, 29, 39], "one write per frame landed"); + assert_eq!( + written, + vec![0, 9, 19, 29, 39], + "one write per frame landed" + ); } /// The one value a gesture may never lose: where the hand let go. The @@ -293,7 +299,10 @@ fn a_second_film_does_not_cost_the_first_one_its_levels() { assert_eq!(scan_plan(false, Some(&a), &half), ScanPlan::Start); // ...and the seconds asked for are the clip's, at the project's rate. assert_eq!(source_secs(&half, 30.), (0., 50.)); - assert_eq!(source_secs(&(half.0.clone(), 0, 900, 1500), 30.), (30., 50.)); + assert_eq!( + source_secs(&(half.0.clone(), 0, 900, 1500), 30.), + (30., 50.) + ); // A rate that is not one reads the file rather than nothing. assert_eq!(source_secs(&half, 0.), (0., f64::INFINITY)); } @@ -307,7 +316,8 @@ fn a_second_film_does_not_cost_the_first_one_its_levels() { #[test] fn a_warm_whole_source_scan_answers_the_card_for_every_clip_cut_from_it() { use std::sync::Arc; - let mut levels: std::collections::HashMap>> = std::collections::HashMap::new(); + let mut levels: std::collections::HashMap>> = + std::collections::HashMap::new(); let clip_a = (PathBuf::from("/films/a.mkv"), 0, 300, 900); let clip_b = (PathBuf::from("/films/a.mkv"), 0, 1_200, 1_800); // Nothing yet -- neither clip's own read nor a background one. @@ -347,11 +357,17 @@ fn a_clips_slice_of_the_whole_scan_is_the_windows_its_own_read_would_have_found( assert_eq!(slice, (10..20).map(|i| i as f32).collect::>()); // The clip's own in point is where its slice starts, not the file's: // a take an hour into the film reads the same as one at its head. - assert_eq!(slice_whole_levels(&whole, fps, 0, 5), vec![0., 1., 2., 3., 4.]); + assert_eq!( + slice_whole_levels(&whole, fps, 0, 5), + vec![0., 1., 2., 3., 4.] + ); // Past what the background scan has read so far (still running, or // cancelled) is not padded with zeroes -- the caller is told nothing is // there yet, same as [`SilenceScan`]'s own cancel leaves a prefix. - assert_eq!(slice_whole_levels(&whole, fps, 35, 60), vec![35., 36., 37., 38., 39.]); + assert_eq!( + slice_whole_levels(&whole, fps, 35, 60), + vec![35., 36., 37., 38., 39.] + ); assert_eq!(slice_whole_levels(&whole, fps, 45, 60), Vec::::new()); // A rate that is not a rate reads nothing, the same refusal // `source_secs` makes for a background scan's own range. @@ -378,8 +394,7 @@ fn probing_ahead_lands_exactly_what_importing_in_place_lands() { let split = { let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open"); session.set_gain(0.0); - let (subs, probe) = - read_parts(&asset("test_av2.mp4"), &stage, Some(session.import_gate())); + let (subs, probe) = read_parts(&asset("test_av2.mp4"), &stage, Some(session.import_gate())); // This mp4 is walked now (an mp4 can carry `tx3g`) and has no // subtitle track in it, so the worker hands over an empty list -- // the same thing the import lands with. @@ -408,7 +423,11 @@ fn probing_ahead_lands_exactly_what_importing_in_place_lands() { // notice shows -- worded exactly as importing in place worded it. let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open"); session.set_gain(0.0); - let (_, probe) = read_parts(&asset("test_25fps.mp4"), &stage, Some(session.import_gate())); + let (_, probe) = read_parts( + &asset("test_25fps.mp4"), + &stage, + Some(session.import_gate()), + ); let on_the_worker = probe .expect("a container is probed") .map(|_| ()) @@ -426,7 +445,9 @@ fn probing_ahead_lands_exactly_what_importing_in_place_lands() { let mut moved = PlaybackSession::open(asset("test_av.mp4")).expect("open"); moved.set_gain(0.0); let (_, probe) = read_parts(&asset("test_av2.mp4"), &stage, Some(moved.import_gate())); - moved.import(&asset("test_still.png")).expect("a still joins"); + moved + .import(&asset("test_still.png")) + .expect("a still joins"); let stale = probe.expect("a container is probed").expect("av2 matches"); assert_eq!( moved.import_probed(&asset("test_av2.mp4"), stale).ok(), @@ -784,7 +805,12 @@ fn the_summary_states_the_file_before_it_is_written() { // still a real file with a real size. let short = estimated_bytes(Some(1_000_000), 3.).expect("a rate and a length"); assert_eq!(size_label(short), "375 kB"); - let frame = summary_tail(Path::new("/a/x.mp4"), estimated_bytes(Some(1_000_000), 1. / 60.), None, true); + let frame = summary_tail( + Path::new("/a/x.mp4"), + estimated_bytes(Some(1_000_000), 1. / 60.), + None, + true, + ); assert!( frame.contains("≈ 2 kB") && !frame.contains("0 MB") && !frame.contains("0 kB"), "{frame}" @@ -873,7 +899,10 @@ fn the_subtitle_plate_and_lanes_fit_the_smallest_window() { // What is left for the picture at the floor, with a project's two tracks // and a subtitle lane under them. let picture = 360. - HEADER_H - panel_h(3); - assert!(picture > 0., "a subtitle lane pushed the picture off the window"); + assert!( + picture > 0., + "a subtitle lane pushed the picture off the window" + ); // A two-line cue and the gap under it fit inside that, which is the // whole claim: the plate sits *over* the picture and must not need more // of it than there is. @@ -913,6 +942,8 @@ fn the_subtitle_plate_and_lanes_fit_the_smallest_window() { /// than crashing a startup on someone else's edit of the file. #[test] fn the_subtitle_style_file_round_trips_or_falls_back_to_defaults() { + let _config_env = config_env_lock(); + let dir = std::env::temp_dir().join(format!( "edith-subtitle-style-test-{}-{}", std::process::id(), @@ -922,9 +953,8 @@ fn the_subtitle_style_file_round_trips_or_falls_back_to_defaults() { .as_nanos() )); std::fs::create_dir_all(&dir).unwrap(); - // Scoped to this test alone: no other test reads XDG_CONFIG_HOME or the - // subtitle-style file it names, so this narrow, restored mutation of the - // process environment cannot race another test's own file. + // The shared process environment is serialized across every config + // round-trip test by `config_env_lock`. unsafe { std::env::set_var("XDG_CONFIG_HOME", &dir) }; // Nothing written yet: the defaults, not a crash on a missing file. @@ -932,10 +962,7 @@ fn the_subtitle_style_file_round_trips_or_falls_back_to_defaults() { // A save, read back whole: family and size both. save_subtitle_style(Some("Iosevka"), 22.).unwrap(); - assert_eq!( - load_subtitle_style(), - (Some("Iosevka".to_string()), 22.) - ); + assert_eq!(load_subtitle_style(), (Some("Iosevka".to_string()), 22.)); // The platform default (`None`) round-trips too, and is not a family // called "". @@ -961,6 +988,8 @@ fn the_subtitle_style_file_round_trips_or_falls_back_to_defaults() { /// relaunch reads instead of the field's hardcoded `true`. #[test] fn the_auto_proxies_default_round_trips_through_its_own_config_file_or_falls_back_to_on() { + let _config_env = config_env_lock(); + let dir = std::env::temp_dir().join(format!( "edith-auto-proxies-pref-test-{}-{}", std::process::id(), @@ -970,8 +999,8 @@ fn the_auto_proxies_default_round_trips_through_its_own_config_file_or_falls_bac .as_nanos() )); std::fs::create_dir_all(&dir).unwrap(); - // Scoped to this test alone, the same guarantee the subtitle-style test - // above makes for the same env var. + // `config_env_lock` serializes every test that changes this process-wide + // path. unsafe { std::env::set_var("XDG_CONFIG_HOME", &dir) }; // Nothing written yet: On, the field's own long-standing default. @@ -981,12 +1010,18 @@ fn the_auto_proxies_default_round_trips_through_its_own_config_file_or_falls_bac assert!(!load_auto_proxies_pref(), "off must round-trip"); save_auto_proxies_pref(true).unwrap(); - assert!(load_auto_proxies_pref(), "on must round-trip too, not just off"); + assert!( + load_auto_proxies_pref(), + "on must round-trip too, not just off" + ); // Garbled bytes -- a stray edit, or a future dialect -- read as On 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"); + assert!( + load_auto_proxies_pref(), + "unreadable content must fall back to On" + ); unsafe { std::env::remove_var("XDG_CONFIG_HOME") }; std::fs::remove_dir_all(&dir).ok(); @@ -1059,7 +1094,9 @@ fn subtitles_arrive_beside_the_media_and_inside_it() { // no source in it to import, so the drop door has to send it where `+ S` // sends it. Its two siblings are media and must not come here -- a // `.mka` is a song this would stop importing. - for name in ["subs.srt", "SUBS.SRT", "a.vtt", "a.ass", "a.ssa", "s.mks", "S.MKS"] { + for name in [ + "subs.srt", "SUBS.SRT", "a.vtt", "a.ass", "a.ssa", "s.mks", "S.MKS", + ] { assert!(is_subtitle(Path::new(name)), "{name}"); } for name in ["a.mp4", "a.mkv", "song.mka", "film.mk3d", "notes.txt", "a"] { @@ -1070,7 +1107,14 @@ fn subtitles_arrive_beside_the_media_and_inside_it() { // The Matroska half is the engine's own closed set, extension for // extension, so no file is walked here that it would refuse there. for name in [ - "film.MKV", "clip.webm", "clip.mp4", "a.m4v", "a.MOV", "song.mka", "s.mks", "f.MK3D", + "film.MKV", + "clip.webm", + "clip.mp4", + "a.m4v", + "a.MOV", + "song.mka", + "s.mks", + "f.MK3D", ] { assert!(carries_subtitles(Path::new(name)), "{name}"); assert!( @@ -1201,7 +1245,11 @@ fn subtitles_arrive_beside_the_media_and_inside_it() { .cut_regions(&[(15, 60)], &lanes) .expect("cut 0.5s..2.5s out"); assert_eq!(session.timeline_duration(), 3.0); - assert_eq!(session.subtitles()[0].cues.len(), 3, "the track is untouched"); + assert_eq!( + session.subtitles()[0].cues.len(), + 3, + "the track is untouched" + ); let mapped = session.timeline_cues(0); assert_eq!( mapped @@ -1312,7 +1360,11 @@ fn a_second_session_playing_never_moves_the_first() { preview.seek(1.0); preview.play(); - assert_eq!(timeline.now(), before, "the preview's seek moved the wrong session"); + assert_eq!( + timeline.now(), + before, + "the preview's seek moved the wrong session" + ); assert_eq!( timeline.is_playing(), before_playing, @@ -1341,7 +1393,11 @@ fn ticking_the_preview_session_never_moves_the_timeline() { // showing: only the active session -- the preview -- gets ticked. preview.tick(); - assert_eq!(timeline.now(), before, "ticking the preview moved the timeline's clock"); + assert_eq!( + timeline.now(), + before, + "ticking the preview moved the timeline's clock" + ); } /// [`bgra_to_rgba`] and [`save_screenshot`]'s own PNG write, round-tripped: a @@ -1357,7 +1413,11 @@ fn a_screenshot_frame_round_trips_through_its_png() { 255, 0, 0, 255, 255, 255, 255, 128, ]; let rgba = bgra_to_rgba(&bgra); - assert_eq!(rgba[0..4], [255, 0, 0, 255], "red survives the channel swap"); + assert_eq!( + rgba[0..4], + [255, 0, 0, 255], + "red survives the channel swap" + ); assert_eq!(rgba[4..8], [0, 255, 0, 255], "green is unmoved by the swap"); assert_eq!(rgba[8..12], [0, 0, 255, 255], "blue swaps into place"); assert_eq!(rgba[12..16], [255, 255, 255, 128], "alpha is untouched"); @@ -1368,7 +1428,11 @@ fn a_screenshot_frame_round_trips_through_its_png() { let buf = image::RgbaImage::from_raw(2, 2, rgba.clone()).expect("2x2 rgba buffer"); buf.save(&path).expect("png write"); let decoded = image::open(&path).expect("png read").to_rgba8(); - assert_eq!(decoded.into_raw(), rgba, "the PNG round-trips the pixels exactly"); + assert_eq!( + decoded.into_raw(), + rgba, + "the PNG round-trips the pixels exactly" + ); let _ = std::fs::remove_dir_all(&dir); } diff --git a/crates/app/src/tests/mod.rs b/crates/app/src/tests/mod.rs index 906abb0..12a6298 100644 --- a/crates/app/src/tests/mod.rs +++ b/crates/app/src/tests/mod.rs @@ -3,66 +3,59 @@ //! stays here is what every part of it shares -- the imports, the fixtures, //! and the source scans the guards read. -mod editing; -mod view; mod cards; -mod media; +mod editing; mod layout; +mod media; +mod view; use super::{ - ACCENT_PRIMARY, AUDIO_KBPS, COLOR_BANDS, COLOR_BAR_W, COLOR_STEP, COLOR_W, CONTROL_H, Clip, Ctx, DEFAULT_AUDIO_KBPS, EQ_BANDS_MAX, - EQ_CURVE_STEPS, EQ_FFT, EQ_FREQ_HIGH, EQ_FREQ_LOW, EQ_FREQ_STEP, EQ_GAIN_LIMIT, EQ_GRAPH_H, - EQ_HANDLE, EQ_Q_HIGH, EQ_Q_LOW, EQ_Q_STEP, EQ_SPECTRUM_DB, EQ_TICKS, EQ_W_MAX, ESCAPE, - EXPORT_FIXED_H, EXPORT_ROWS_H, EXPORT_W, Enable, EncoderSeat, ExportPreset, FORMATS, - Format, HEADER_GAP, HEADER_H, HEADER_W, HIST_BINS, HIST_H, HIST_SAMPLES, HIT_MIN, - KEYS_ROW_H, KEYS_ROWS_H, KEYS_W, KeyRow, LABEL_H, LABEL_MIN_W, LANE_H, LANES_MAX, - LIBRARY_MAX_W, LIBRARY_MIN_W, Lane, MENU_ITEMS, MENU_PAD, MENU_ROW_H, - SUB_LANE_H, lanes_h_mixed, lanes_shown_mixed, rows_below_mixed, - MBPS_DIGITS, MBPS_MAX, MBPS_MIN, MB_FLOOR, MENU_W, NO_FILE, NumberEdit, PANEL_H, ROW_ITEMS, RowCtx, RowItem, - Quality, ROW_H, RULER_HIT_H, SCROLL_NOTCH_SHARE, SILENCE_ROWS, - SOURCE_TINTS, SPEED_PRESETS, SPEED_STEP, BG_RAISED, SWATCH_W, Source, Speed, StreamInfo, - Transport, VOLUME_W, Volume, WAVE_BPS, WAVE_COL, WAVE_COLS_MAX, Wave, band_label, - bitrate_detail, bitrate_refusal, can_add, cancels_export, clipboard_after_remove, color_snap, commit_mbps, - containers, - enable, enable_lane, envelope, eq_card_w, eq_freq, eq_freq_label, eq_graph_h, eq_spectrum, eq_x, eq_y, - escape_leaves_player_fullscreen, - estimated_bytes, export_path, export_settings, format_key, + ACCENT_PRIMARY, AUDIO_KBPS, BG_RAISED, COLOR_BANDS, COLOR_BAR_W, COLOR_STEP, COLOR_W, + CONTROL_H, Clip, Ctx, DEFAULT_AUDIO_KBPS, EQ_BANDS_MAX, EQ_CURVE_STEPS, EQ_FFT, EQ_FREQ_HIGH, + EQ_FREQ_LOW, EQ_FREQ_STEP, EQ_GAIN_LIMIT, EQ_GRAPH_H, EQ_HANDLE, EQ_Q_HIGH, EQ_Q_LOW, + EQ_Q_STEP, EQ_SPECTRUM_DB, EQ_TICKS, EQ_W_MAX, ESCAPE, EXPORT_DONE, EXPORT_FIXED_H, + EXPORT_ROWS_H, EXPORT_W, Enable, EncoderSeat, ExportPreset, FORMATS, Format, HEADER_GAP, + HEADER_H, HEADER_W, HIST_BINS, HIST_H, HIST_SAMPLES, HIT_MIN, KEYS_ROW_H, KEYS_ROWS_H, KEYS_W, + KeyRow, LABEL_H, LABEL_MIN_W, LANE_H, LANES_MAX, LATE_RESYNC, LIBRARY_MAX_W, LIBRARY_MIN_W, + Lane, MB_FLOOR, MBPS_DIGITS, MBPS_MAX, MBPS_MIN, MENU_ITEMS, MENU_PAD, MENU_ROW_H, MENU_W, + NO_FILE, NOTICES_MAX, NumberEdit, OVERLAID, PANEL_H, Quality, RESYNC_GAP, ROW_H, ROW_ITEMS, + RULER_HIT_H, RowCtx, RowItem, SCROLL_NOTCH_SHARE, SILENCE_ROWS, SOURCE_TINTS, SPEED_PRESETS, + SPEED_STEP, STATUS_ERROR, STATUS_SUCCESS, STATUS_WARNING, SUB_LANE_H, SUB_PLAN_CHARS, SWATCH_W, + Source, Speed, StreamInfo, TIMELINE_SHARE, Transport, VOLUME_W, Volume, WAVE_BPS, WAVE_COL, + WAVE_COLS_MAX, Wave, active_lane, band_label, bitrate_detail, bitrate_refusal, can_add, + cancels_export, clipboard_after_remove, color_snap, commit_mbps, containers, enable, + enable_lane, envelope, eq_card_w, eq_freq, eq_freq_label, eq_graph_h, eq_spectrum, eq_x, eq_y, + escape_leaves_player_fullscreen, estimated_bytes, export_path, export_settings, format_key, format_line, format_refusal, fps_choices, fps_label, frac_along, frac_down, frame_at, - frame_rate_ladder, histogram, - inserted_band, is_bare_modifier, is_project, keymap, keys_filter, keys_rows, lanes_h, - active_lane, marked, menu_at, menu_items, menu_rows_h, next_audio_kbps, next_container, normalise, nothing_to_play, panel_h, project_path, - LATE_RESYNC, RESYNC_GAP, should_resync, - retarget, row_enable, row_items, scrub_due, secs_label, show_label, silence_rate, size_label, snap_cue, snap_marks, snapped, - SUB_PLAN_CHARS, source_tint, span_partner, speed_at, sub_pick_after_removal, subtitle_plan, summary_head, summary_tail, timecode, transport, - EXPORT_DONE, NOTICES_MAX, STATUS_ERROR, TIMELINE_SHARE, timeline_fixed_h, - px_below, STATUS_SUCCESS, STATUS_WARNING, notice_tone, - proxies_to_start, push_notice, typed, unseen_paths, unseen_sources, - whole_take, window_title, - OVERLAID, tip_may_paint, + frame_rate_ladder, histogram, inserted_band, is_bare_modifier, is_project, keymap, keys_filter, + keys_rows, lanes_h, lanes_h_mixed, lanes_shown_mixed, marked, menu_at, menu_items, menu_rows_h, + next_audio_kbps, next_container, normalise, nothing_to_play, notice_tone, panel_h, + project_path, proxies_to_start, push_notice, px_below, retarget, row_enable, row_items, + rows_below_mixed, scrub_due, secs_label, should_resync, show_label, silence_rate, size_label, + snap_cue, snap_marks, snapped, source_tint, span_partner, speed_at, sub_pick_after_removal, + subtitle_plan, summary_head, summary_tail, timecode, timeline_fixed_h, tip_may_paint, + transport, typed, unseen_paths, unseen_sources, whole_take, window_title, }; use super::{ - ActionId, Choice, EDGE_W, ETA_SPAN, Edge, FITS, FRAME_RATES, LaneKind, SubClip, PPS_DEFAULT, PPS_MIN, Preset, RESOLUTIONS, Repeat, - Scale, View, - ZOOM_MIN_FRAMES, ZOOM_OUT_MARGIN, ZOOM_STEP, audio_rate_choices, av1_hw_warning, clock, - encoder_choices, encoder_label, eta_secs, file_name, file_uri, - fit_choices, landing, lane_refuses, library_rows, live_idx, next_fit, next_resolution, - note_progress, px_along, - IMPORT_STALL, Import, ImportStage, SEEK_STALL, ScanKey, ScanPlan, SilenceScan, import_line, - Landing, arrival, launch_queue, full_scan_key, silence_cached, slice_whole_levels, - read_ahead, scan_plan, seek_line, silence_line, source_secs, stash_or_write, - repeats, resolution_choices, resolution_ladder, pending_resolution_choices, pending_fps_choices, - SAMPLE_RATES, sample_rate_choices, span_label, tone_choices, tone_label, - clip_width, frames_of_us, trimmed_clip, trimmed_sub, trims, unscannable, unusable, - visible_slice, + ActionId, Choice, EDGE_W, ETA_SPAN, Edge, FITS, FRAME_RATES, IMPORT_STALL, Import, ImportStage, + Landing, LaneKind, PPS_DEFAULT, PPS_MIN, Preset, RESOLUTIONS, Repeat, SAMPLE_RATES, SEEK_STALL, + Scale, ScanKey, ScanPlan, SilenceScan, SubClip, View, ZOOM_MIN_FRAMES, ZOOM_OUT_MARGIN, + ZOOM_STEP, arrival, audio_rate_choices, av1_hw_warning, clip_width, clock, encoder_choices, + encoder_label, eta_secs, file_name, file_uri, fit_choices, frames_of_us, full_scan_key, + import_line, landing, lane_refuses, launch_queue, library_rows, live_idx, next_fit, + next_resolution, note_progress, pending_fps_choices, pending_resolution_choices, px_along, + read_ahead, repeats, resolution_choices, resolution_ladder, sample_rate_choices, scan_plan, + seek_line, silence_cached, silence_line, slice_whole_levels, source_secs, span_label, + stash_or_write, tone_choices, tone_label, trimmed_clip, trimmed_sub, trims, unscannable, + unusable, visible_slice, }; use super::{ - SUB_BOTTOM, SUB_CUE_MIN_W, SUB_HEAD_H, SUB_LINE_H, SUB_ROWS_H, - SUB_STEM_SHARE, SUB_TEXT, clip_middle, cue_box, sub_bottom, - carries_subtitles, cues_at, file_tint, is_subtitle, lang_human, row_text_w, - Subs, subtitle_detail, subtitle_notice, subtitle_tail, - sub_pick_name, subtitle_rows, subtitle_toggle_notice, walk_subtitles, + SUB_BOTTOM, SUB_CUE_MIN_W, SUB_HEAD_H, SUB_LINE_H, SUB_ROWS_H, SUB_STEM_SHARE, SUB_TEXT, Subs, + carries_subtitles, clip_middle, cue_box, cues_at, file_tint, is_subtitle, lang_human, + row_text_w, sub_bottom, sub_pick_name, subtitle_detail, subtitle_notice, subtitle_rows, + subtitle_tail, subtitle_toggle_notice, walk_subtitles, }; use engine::PlaybackSession; @@ -77,6 +70,16 @@ use std::path::{Path, PathBuf}; use std::time::{Duration, Instant}; +use std::sync::{LazyLock, Mutex, MutexGuard}; + +static CONFIG_ENV_LOCK: LazyLock> = LazyLock::new(|| Mutex::new(())); + +fn config_env_lock() -> MutexGuard<'static, ()> { + CONFIG_ENV_LOCK + .lock() + .expect("config environment lock poisoned") +} + /// Every line of the window's source there is, as one string. The regions have /// moved house twice -- one `main.rs`, then `ui/`, then the tests out of it -- /// and a scan that names its files passes a rule by simply not looking where @@ -116,7 +119,9 @@ fn source_from(needle: &str) -> String { /// window instead. fn fn_body(name: &str) -> String { let text = source_from(&format!("fn {name}(")); - let end = text.find("\n }\n").map_or(text.len(), |at| at + "\n }\n".len()); + let end = text + .find("\n }\n") + .map_or(text.len(), |at| at + "\n }\n".len()); text[..end].to_string() } @@ -170,13 +175,7 @@ fn source(path: &str, stream: usize) -> Source { } } -fn info( - index: usize, - rate: u32, - channels: u16, - lang: Option<&str>, - decodable: bool, -) -> StreamInfo { +fn info(index: usize, rate: u32, channels: u16, lang: Option<&str>, decodable: bool) -> StreamInfo { StreamInfo { index, codec: if decodable { "aac" } else { "unknown" }.into(), diff --git a/crates/app/src/tests/view.rs b/crates/app/src/tests/view.rs index 3e95f4e..d34f3e4 100644 --- a/crates/app/src/tests/view.rs +++ b/crates/app/src/tests/view.rs @@ -221,13 +221,7 @@ fn a_rate_row_says_only_what_the_container_stated() { // A Matroska states no audio rate of its own: the sound is dropped from // the line, never drawn as "0". assert_eq!( - bitrate_detail( - Some(MediaBitrate { - audio: None, - ..all - }), - 1 - ), + bitrate_detail(Some(MediaBitrate { audio: None, ..all }), 1), "8.4 Mb/s · 7.9 video" ); // A still, or anything that would not open: the probe answered, and the @@ -293,7 +287,10 @@ fn a_stated_rate_never_renders_as_a_zero() { .filter_map(|part| part.split(' ').next()) .filter_map(|n| n.parse::().ok()) { - assert!(number > 0., "{small}/{big} bits a second rendered as {line:?}"); + assert!( + number > 0., + "{small}/{big} bits a second rendered as {line:?}" + ); } } } @@ -418,9 +415,7 @@ fn no_stroke_is_missing_from_the_keys_menu() { for (at, needle) in handler.match_indices("key == ") { let rest = &handler[at + needle.len()..]; let key = match rest.strip_prefix('"') { - Some(literal) => { - literal[..literal.find('"').expect("unterminated key")].to_string() - } + Some(literal) => literal[..literal.find('"').expect("unterminated key")].to_string(), // A named constant: the escape the cards get out by. None if rest.starts_with("ESCAPE") => crate::ESCAPE.to_string(), None => panic!("a key compared against something this cannot read: {rest:.20}"), @@ -589,7 +584,13 @@ fn zoom_stops_at_a_bedful_of_time_and_at_a_handful_of_frames() { // clamp against, and a zoom must survive the frame before the probe. let unpainted = View { bed: 0., - ..test_view(Scale { pps: 4e6, start: 3. }, duration) + ..test_view( + Scale { + pps: 4e6, + start: 3., + }, + duration, + ) }; assert_eq!(unpainted.settled().pps, 4e6); assert_eq!(unpainted.following(19.), unpainted.scale); @@ -622,7 +623,10 @@ fn zooming_out_reaches_the_end_of_a_timeline_however_long_it_is() { // window rather than against its edge. assert_eq!(wide.start, 0.); let end = wide.px_at(five_hours); - assert!(end < bed, "the end of the timeline is off the bed at {end} px"); + assert!( + end < bed, + "the end of the timeline is off the bed at {end} px" + ); assert!(end > bed * 0.9, "and not shrunk into a corner: {end} px"); assert!( (view(wide, five_hours).span() - five_hours * ZOOM_OUT_MARGIN).abs() < 1e-6, @@ -645,7 +649,10 @@ fn zooming_out_reaches_the_end_of_a_timeline_however_long_it_is() { // Whatever the length, the resting scale is nobody's content: the width // invariant, which a far stop measured off the content would break. assert_eq!(view(Scale::default(), 10.).settled(), Scale::default()); - assert_eq!(view(Scale::default(), five_hours).settled(), Scale::default()); + assert_eq!( + view(Scale::default(), five_hours).settled(), + Scale::default() + ); // Shrinking the timeline pulls a fully zoomed out view in with it -- // what was showing all of the timeline still shows all of it. let shrunk = view(wide, 1800.).settled(); @@ -764,7 +771,14 @@ fn the_view_follows_a_playhead_that_runs_off_the_bed() { #[test] fn a_scroll_during_playback_wins_until_the_head_catches_up() { let duration = 80.; - let mut scale = test_view(Scale { pps: 40., start: 0. }, duration).settled(); + let mut scale = test_view( + Scale { + pps: 40., + start: 0., + }, + duration, + ) + .settled(); // The render's arbitration, in the two lines it is there: a panned view // is left where the hand put it, and the pan ends where the head is // back on the bed. @@ -802,7 +816,10 @@ fn a_scroll_during_playback_wins_until_the_head_catches_up() { assert_eq!(start, scale.start, "and it did not jump to take it"); // ...and the next head that runs off the bed pulls the view again. let ran_off = frame(scale, &mut panned, start + span + 1.); - assert!(ran_off.start > start, "the follow follows again: {ran_off:?}"); + assert!( + ran_off.start > start, + "the follow follows again: {ran_off:?}" + ); // A paused hand is untouched by any of this: with no follow asking, // `shows` is the only thing the pan is ever released by. assert!(test_view(scale, duration).shows(scale.start)); diff --git a/crates/app/src/timeline_math.rs b/crates/app/src/timeline_math.rs index 62ac230..f3cf214 100644 --- a/crates/app/src/timeline_math.rs +++ b/crates/app/src/timeline_math.rs @@ -65,7 +65,11 @@ pub(crate) fn whole_take(session: &PlaybackSession, lane: Lane, idx: usize) -> b /// group id can mean (engine `links_are_consistent`), which is what leaves /// nothing for a second click to choose. `None` when no track has one, and the /// notice says so. -pub(crate) fn span_partner(session: &PlaybackSession, lane: Lane, idx: usize) -> Option<(Lane, usize)> { +pub(crate) fn span_partner( + session: &PlaybackSession, + lane: Lane, + idx: usize, +) -> Option<(Lane, usize)> { let clip = *session.lane_clips(lane).get(idx)?; let matches = |other: Lane| { let i = session.lane_clips(other).iter().position(|c| { @@ -138,8 +142,8 @@ impl Selection { } /// 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. + /// asks before it decides whether the menu is about the selection or + /// about the clip under it. pub(crate) fn contains(&self, pick: (Lane, usize)) -> bool { self.picks.contains(&pick) } @@ -187,12 +191,10 @@ pub(crate) fn caption_rate(sub: SubClip, fps: f64) -> Option { // own `speed` in the same spelling: 10s of words crossing 5s of timeline // is 2.00x. let permille = (window_us / span_us * 1000.).round(); - Some(Speed::from_permille( - permille.clamp( - f64::from(Speed::MIN.permille()), - f64::from(Speed::MAX.permille()), - ) as u16, - )) + Some(Speed::from_permille(permille.clamp( + f64::from(Speed::MIN.permille()), + f64::from(Speed::MAX.permille()), + ) as u16)) } /// The scrollbar's thumb over a track `w` px wide: `(x, width)` of the box @@ -202,12 +204,7 @@ pub(crate) fn caption_rate(sub: SubClip, fps: f64) -> Option { /// narrower than [`SCROLL_THUMB_MIN`] when there is (a thumb a pixel wide is a /// thumb no hand can hold), and never off the track either way -- the clamp, /// not the caller, owns that, because a drag's samples arrive raw. -pub(crate) fn scroll_thumb( - w: f32, - duration: f64, - start: f64, - span: f64, -) -> (f32, f32) { +pub(crate) fn scroll_thumb(w: f32, duration: f64, start: f64, span: f64) -> (f32, f32) { if w <= 0. || duration <= 0. || span >= duration { return (0., w.max(0.)); } @@ -260,7 +257,6 @@ pub(crate) fn marked( picks.contains(&here) || (link.is_some() && pick_links.contains(&link)) } - /// Whether a clip is wide enough to be worth naming. pub(crate) fn show_label(w: f32) -> bool { w >= LABEL_MIN_W @@ -341,7 +337,11 @@ pub(crate) fn walk_cut(idx: usize, len: usize, forward: bool, stride: usize) -> return 0; } let delta = stride.min(len - 1) as isize; - let at = if forward { idx as isize + delta } else { idx as isize - delta }; + let at = if forward { + idx as isize + delta + } else { + idx as isize - delta + }; at.clamp(0, len as isize - 1) as usize } @@ -496,7 +496,13 @@ pub(crate) fn normalise(mut peaks: Vec<(f32, f32)>) -> Vec<(f32, f32)> { /// -- a clip's waveform cannot paint over its neighbour -- and every column is /// at least a pixel tall, so silence reads as a line through the middle rather /// than as a polygon with no area. -pub(crate) fn envelope(peaks: &[(f32, f32)], from: f64, to: f64, w: f32, h: f32) -> Vec<(f32, f32, f32)> { +pub(crate) fn envelope( + peaks: &[(f32, f32)], + from: f64, + to: f64, + w: f32, + h: f32, +) -> Vec<(f32, f32, f32)> { if peaks.is_empty() || w <= 0. || h <= 0. { return Vec::new(); } @@ -517,13 +523,6 @@ pub(crate) fn envelope(peaks: &[(f32, f32)], from: f64, to: f64, w: f32, h: f32) .collect() } - - - - - - - /// Records its parent's laid-out box: gpui hands a mouse listener the window /// position only, and the ruler sits behind the panel's padding. Paints /// nothing and takes no hitbox of its own, so the click still reaches the bar. @@ -642,8 +641,7 @@ pub(crate) fn snap_marks( .iter() .enumerate() .filter(move |&(idx, clip)| { - Some((lane, idx)) != skip - && !(skip_link.is_some() && clip.link == skip_link) + Some((lane, idx)) != skip && !(skip_link.is_some() && clip.link == skip_link) }) .flat_map(|(_, clip)| [clip.start, clip.end()]) }) @@ -660,7 +658,13 @@ pub(crate) fn snap_marks( /// /// `on` is the switch ([`ActionId::ToggleSnap`]): off, the gesture lands raw and /// draws no line at all, which is the whole point of being able to turn it off. -pub(crate) fn snap_cue(on: bool, raw: u32, len: u32, tol: u32, marks: &[u32]) -> (u32, Option) { +pub(crate) fn snap_cue( + on: bool, + raw: u32, + len: u32, + tol: u32, + marks: &[u32], +) -> (u32, Option) { if !on { return (raw, None); } @@ -699,12 +703,12 @@ pub(crate) fn lane_refuses(path: &Path, lane: Lane) -> Option { let name = file_name(path); let label = lane.label(); match lane.kind { - LaneKind::Video if engine::is_audio(path) => { - Some(format!("NOT ON {label} — {name} has no picture; drop it on an audio lane")) - } - LaneKind::Audio if engine::is_image(path) => { - Some(format!("NOT ON {label} — {name} is a still image; drop it on a video lane")) - } + LaneKind::Video if engine::is_audio(path) => Some(format!( + "NOT ON {label} — {name} has no picture; drop it on an audio lane" + )), + LaneKind::Audio if engine::is_image(path) => Some(format!( + "NOT ON {label} — {name} is a still image; drop it on a video lane" + )), // A subtitle lane holds words and no media at all: the refusal is here // rather than at the engine's door so the shadow is tinted red on the // way down, like every other lane a file cannot go on. diff --git a/crates/app/src/transport.rs b/crates/app/src/transport.rs index 8824c74..355beb9 100644 --- a/crates/app/src/transport.rs +++ b/crates/app/src/transport.rs @@ -54,7 +54,9 @@ impl Volume { /// cannot wrap past silence into full volume. pub(crate) fn step(&mut self, up: bool) { self.steps = if up { - self.steps.saturating_add(Self::KEY_STEP).min(Self::MAX_STEPS) + self.steps + .saturating_add(Self::KEY_STEP) + .min(Self::MAX_STEPS) } else { self.steps.saturating_sub(Self::KEY_STEP) }; @@ -186,7 +188,12 @@ pub(crate) fn should_resync(late: f64, last: Option) -> bool { /// /// The press (`first`) never waits: it is the undo step the whole gesture rolls /// back to, so it has to be taken against the state the hand picked up. -pub(crate) fn stash_or_write(stash: &mut Option, value: T, first: bool, busy: bool) -> Option { +pub(crate) fn stash_or_write( + stash: &mut Option, + value: T, + first: bool, + busy: bool, +) -> Option { match busy && !first { true => { *stash = Some(value); diff --git a/crates/app/src/ui/bench_stance.rs b/crates/app/src/ui/bench_stance.rs index 43f7b4b..69802f7 100644 --- a/crates/app/src/ui/bench_stance.rs +++ b/crates/app/src/ui/bench_stance.rs @@ -743,10 +743,7 @@ fn lane_row( .as_ref() .map_or(0., |session| session.lane_gain_db(lane)); let shown = player.sub_lane_on(lane); - let chord_style = type_scale::mono( - type_scale::CHORD_METADATA_MIN_PX, - gpui::FontWeight::MEDIUM, - ); + let chord_style = type_scale::mono(type_scale::CHORD_METADATA_MIN_PX, gpui::FontWeight::MEDIUM); let drop = player .lane_drop .filter(|drop| drop.lane == lane && cx.has_active_drag()); @@ -815,13 +812,11 @@ fn lane_row( .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) .tooltip(move |_, cx| { cx.new(|_| { - Tip( - format!( - "{} {gain_db:+.0} dB — mix this lane", - lane.label() - ) - .into(), + Tip(format!( + "{} {gain_db:+.0} dB — mix this lane", + lane.label() ) + .into()) }) .into() }) @@ -849,13 +844,11 @@ fn lane_row( .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) .tooltip(move |_, cx| { cx.new(|_| { - Tip( - format!( - "{} — click to show this subtitle lane", - lane.label() - ) - .into(), + Tip(format!( + "{} — click to show this subtitle lane", + lane.label() ) + .into()) }) .into() }) @@ -883,13 +876,11 @@ fn lane_row( .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) .tooltip(move |_, cx| { cx.new(|_| { - Tip( - format!( - "Remove {} — it must be empty first", - lane.label() - ) - .into(), + Tip(format!( + "Remove {} — it must be empty first", + lane.label() ) + .into()) }) .into() }) diff --git a/crates/app/src/ui/dock_stance.rs b/crates/app/src/ui/dock_stance.rs index e8eab9c..b72f541 100644 --- a/crates/app/src/ui/dock_stance.rs +++ b/crates/app/src/ui/dock_stance.rs @@ -95,7 +95,6 @@ impl DockSort { } } - /// A ghost verb (DESIGN §4): borderless glyph/label in `ink2`, its chord in /// `ink3` beside it, read live off the keymap so it can never drift from the /// key that does the same thing. Hover is one fill step and an ink brighten; @@ -758,10 +757,7 @@ fn sources_tab(player: &Player, cx: &mut Context) -> impl IntoElement { || ("unused".contains(&filter) && *placed == 0) }) .collect(); - let unused_count = rows - .iter() - .filter(|(_, placed)| *placed == 0) - .count(); + let unused_count = rows.iter().filter(|(_, placed)| *placed == 0).count(); match player.dock_sort { DockSort::Recent => {} DockSort::Name => { diff --git a/crates/app/src/ui/inspector.rs b/crates/app/src/ui/inspector.rs index 2590af4..51ae599 100644 --- a/crates/app/src/ui/inspector.rs +++ b/crates/app/src/ui/inspector.rs @@ -7,15 +7,19 @@ //! panel, and opening one occludes zero timeline pixels //! (`an_inspector_section_occludes_no_timeline`). -use crate::*; use crate::ui::toolbar::{TONE_SLOT_W, ZOOM_SLOT_W}; +use crate::*; impl Player { /// The inspector column. Two sections that are always there -- the /// selection's and the project's -- and, over them, whichever settings card /// is open, which is a section of this panel rather than a sheet over the /// window. - pub(crate) fn inspector(&self, viewport: Size, cx: &mut Context) -> impl IntoElement { + pub(crate) fn inspector( + &self, + viewport: Size, + cx: &mut Context, + ) -> impl IntoElement { let width = self.split_px(Split::Inspector, viewport); // The cards measure themselves against the room they are given, and the // room they are given is this column -- not the window. @@ -114,9 +118,9 @@ impl Player { .anchor() .filter(|_| picked.is_none()) .and_then(|(lane, idx)| { - let sub = self.session.as_ref()?.sub_lane(lane).get(idx).copied()?; - Some((lane, sub)) - }); + let sub = self.session.as_ref()?.sub_lane(lane).get(idx).copied()?; + Some((lane, sub)) + }); // A multi-selection is named for its anchor and counted: what the // panel shows is the anchor's settings, and the count says there is // more in hand than the panel is showing. diff --git a/crates/app/src/ui/library.rs b/crates/app/src/ui/library.rs index 45717b6..4e1005d 100644 --- a/crates/app/src/ui/library.rs +++ b/crates/app/src/ui/library.rs @@ -1,9 +1,9 @@ //! The media library: the left panel's rows and the menu over them. -use crate::*; -use crate::ui::widgets::*; -use crate::ui::type_scale::Typeset; use crate::ui::stance::menu_floor; +use crate::ui::type_scale::Typeset; +use crate::ui::widgets::*; +use crate::*; impl Player { /// The media library: a row per source the timeline knows, in the order @@ -184,8 +184,11 @@ impl Player { let dragged = (path.clone(), stream); let menu_path = path.clone(); let preview_path = path.clone(); - let preview_tip: SharedString = - format!("Preview {} — plays it without touching the timeline", row.name).into(); + let preview_tip: SharedString = format!( + "Preview {} — plays it without touching the timeline", + row.name + ) + .into(); div() .id(("asset", i)) .flex_none() @@ -379,55 +382,49 @@ impl Player { // lanes and the inspector give. .overflow_y_scroll() .child( - div() - .flex_none() - .flex() - .items_center() - .gap(px(6.)) - .child( - div() - .flex_1() - .min_w(px(0.)) - .flex() - // Wraps rather than clipping: at the 640 px floor - // this column is 128 px wide and the third tab - // would hang off its edge, which is a control the - // pointer cannot reach. - .flex_wrap() - .gap(px(2.)) - .children(LIBRARY_TABS.map(|tab| { - let on = tab == self.library_tab; - div() - .id(("library-tab", tab as usize)) - .flex_none() - .h(px(HIT_MIN)) - .px(px(6.)) - .flex() - .items_center() - .rounded(px(3.)) - .text_size(px(11.)) - .text_color(rgb(match on { - true => FG_PRIMARY(), - false => FG_SECONDARY(), - })) - // One selection language everywhere: the - // same stroke a picked clip and a picked - // row wear. - .when(on, |d| { - d.bg(rgb(BG_SELECTED())) - .border_b_2() - .border_color(rgb(STROKE_SELECTED())) - }) - .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER()))) - .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { - this.library_tab = tab; - cx.notify(); - })) - .child(tab.label()) - })), - ) - , + div().flex_none().flex().items_center().gap(px(6.)).child( + div() + .flex_1() + .min_w(px(0.)) + .flex() + // Wraps rather than clipping: at the 640 px floor + // this column is 128 px wide and the third tab + // would hang off its edge, which is a control the + // pointer cannot reach. + .flex_wrap() + .gap(px(2.)) + .children(LIBRARY_TABS.map(|tab| { + let on = tab == self.library_tab; + div() + .id(("library-tab", tab as usize)) + .flex_none() + .h(px(HIT_MIN)) + .px(px(6.)) + .flex() + .items_center() + .rounded(px(3.)) + .text_size(px(11.)) + .text_color(rgb(match on { + true => FG_PRIMARY(), + false => FG_SECONDARY(), + })) + // One selection language everywhere: the + // same stroke a picked clip and a picked + // row wear. + .when(on, |d| { + d.bg(rgb(BG_SELECTED())) + .border_b_2() + .border_color(rgb(STROKE_SELECTED())) + }) + .cursor_pointer() + .hover(|s| s.bg(rgb(BG_HOVER()))) + .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { + this.library_tab = tab; + cx.notify(); + })) + .child(tab.label()) + })), + ), ) // The tab says what the one full-width control is for. Text holds // no rows of its own ([`LibraryTab::holds`]) -- it is the tracks @@ -466,26 +463,26 @@ impl Player { }) .when(self.library_tab != LibraryTab::Text, |d| { d.child(div().flex_none().child(control( - "import", - // Full width of the column: the way media gets in is - // the one affordance of the tabs that hold media, - // however narrow the window is. - width - 16., - // Filled with the accent while there is nothing to work - // on, because with an empty library this *is* the - // primary action -- and Export, which wears the accent - // the rest of the time, is dimmed until something is - // imported. One live accent in the window either way. - match rows.is_empty() { - true => ACCENT_PRIMARY(), - false => BG_RAISED(), - }, - None, - "Import", - "adds a file to this list — or drop one on the window".to_string(), - !exporting, - cx.listener(|this, _: &ClickEvent, _, cx| this.pick_and_import(cx)), - ))) + "import", + // Full width of the column: the way media gets in is + // the one affordance of the tabs that hold media, + // however narrow the window is. + width - 16., + // Filled with the accent while there is nothing to work + // on, because with an empty library this *is* the + // primary action -- and Export, which wears the accent + // the rest of the time, is dimmed until something is + // imported. One live accent in the window either way. + match rows.is_empty() { + true => ACCENT_PRIMARY(), + false => BG_RAISED(), + }, + None, + "Import", + "adds a file to this list — or drop one on the window".to_string(), + !exporting, + cx.listener(|this, _: &ClickEvent, _, cx| this.pick_and_import(cx)), + ))) }) .child( div() @@ -640,14 +637,16 @@ impl Player { rows.push( row(rows.len()) .child(label) - .child(chord_style( - div() - .min_w(px(0.)) - .truncate() - .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY())), + .child( + chord_style( + div() + .min_w(px(0.)) + .truncate() + .text_size(px(11.)) + .text_color(rgb(FG_SECONDARY())), + ) + .child(value), ) - .child(value)) .into_any_element(), ); } @@ -701,7 +700,12 @@ impl Player { // floor clamp and the room the list sizes against are `menu_floor`'s, // so a menu taller than the footprint scrolls instead of climbing // back over the picture. - let (at, room) = menu_floor(menu.at, viewport, darkroom, self.split_px(Split::Bench, viewport)); + let (at, room) = menu_floor( + menu.at, + viewport, + darkroom, + self.split_px(Split::Bench, viewport), + ); let list_h = menu_rows_h(rows.len(), room); let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h); let full: SharedString = path.display().to_string().into(); diff --git a/crates/app/src/ui/overlays.rs b/crates/app/src/ui/overlays.rs index a9babff..d7260b1 100644 --- a/crates/app/src/ui/overlays.rs +++ b/crates/app/src/ui/overlays.rs @@ -1,9 +1,9 @@ //! The bars and the floating cards that are not inspector sections. -use crate::*; -use crate::ui::widgets::*; use crate::ui::stance::menu_floor; use crate::ui::type_scale::{self, Typeset}; +use crate::ui::widgets::*; +use crate::*; impl Player { /// The running import holds its own bar above the notice's, for the notice @@ -305,18 +305,20 @@ impl Player { }) .when(!refusal.yes(), |d| d.opacity(0.4).cursor_not_allowed()) .when(refusal.yes(), |d| { - d.cursor_pointer().hover(|s| s.bg(rgb(BG_HOVER()))).on_click( - cx.listener(move |this, _: &ClickEvent, window, cx| { - // The card goes first: several of - // these open a card of their own, - // and every edit moves the indices - // the menus are holding. - this.keys_open = false; - this.rebinding = None; - this.act(action, window, cx); - cx.notify(); - }), - ) + d.cursor_pointer() + .hover(|s| s.bg(rgb(BG_HOVER()))) + .on_click(cx.listener( + move |this, _: &ClickEvent, window, cx| { + // The card goes first: several of + // these open a card of their own, + // and every edit moves the indices + // the menus are holding. + this.keys_open = false; + this.rebinding = None; + this.act(action, window, cx); + cx.notify(); + }, + )) }), ) .child( @@ -402,15 +404,9 @@ impl Player { .px(px(6.)) .text_size(px(11.)) .text_color(rgb(FG_SECONDARY())) - .child( - self.notices - .front() - .cloned() - .unwrap_or_else(|| { - "click an action to do it · click its key to change it" - .into() - }), - ), + .child(self.notices.front().cloned().unwrap_or_else(|| { + "click an action to do it · click its key to change it".into() + })), ) // The search box: no focus and no text field -- the // card's key handler is the field, exactly as the @@ -552,17 +548,19 @@ impl Player { rows.push( row(rows.len()) .child(label) - .child(chord_style( - div() - .min_w(px(0.)) - .truncate() - // A size smaller than the labels: a timecode - // pair is 25 characters and has to fit beside - // its label inside `MENU_W`. - .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY())), + .child( + chord_style( + div() + .min_w(px(0.)) + .truncate() + // A size smaller than the labels: a timecode + // pair is 25 characters and has to fit beside + // its label inside `MENU_W`. + .text_size(px(11.)) + .text_color(rgb(FG_SECONDARY())), + ) + .child(value), ) - .child(value)) .into_any_element(), ); } @@ -594,7 +592,9 @@ impl Player { this.close_all_gaps_on_lane(lane, cx); })) .child(format!("Close all {} gaps", lane.label())) - .child(chord_style(div().text_color(rgb(FG_SECONDARY()))).child("this track")) + .child( + chord_style(div().text_color(rgb(FG_SECONDARY()))).child("this track"), + ) .into_any_element(), ); } @@ -664,32 +664,36 @@ impl Player { // Every command wears its chord (DESIGN §4): mono, // `ink3`, the same face the spine badges and the // keys overlay already read theirs in. - None => chord_style(div().flex_shrink_0().text_color(rgb(FG_SECONDARY()))) - .child(self.keymap.display(action)), + None => { + chord_style(div().flex_shrink_0().text_color(rgb(FG_SECONDARY()))) + .child(self.keymap.display(action)) + } }) .when(!enabled, |d| d.opacity(0.4).cursor_not_allowed()) .when(enabled, |d| { d.cursor_pointer() .hover(|s| s.bg(rgb(BG_HOVER()))) - .on_click(cx.listener(move |this, event: &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 action == ActionId::Fit { - this.open_picker( - Pick::Fit(menu.lane, idx), - event.position(), - cx, - ); - } else { - this.act(action, window, cx); - } - })) + .on_click(cx.listener( + move |this, event: &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 action == ActionId::Fit { + this.open_picker( + Pick::Fit(menu.lane, idx), + event.position(), + cx, + ); + } else { + this.act(action, window, cx); + } + }, + )) }) .into_any_element(), ); @@ -725,7 +729,12 @@ impl Player { // footprint (`room`), not the whole window, so a menu taller than // the footprint scrolls inside its own plate instead of walking its // clamped top edge back up over the picture ([`menu_floor`]). - let (at, room) = menu_floor(menu.at, viewport, self.darkroom, self.split_px(Split::Bench, viewport)); + let (at, room) = menu_floor( + menu.at, + viewport, + self.darkroom, + self.split_px(Split::Bench, viewport), + ); let list_h = menu_rows_h(rows.len(), room); let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h); let full: SharedString = source @@ -899,7 +908,12 @@ impl Player { .collect(); // The window's own room, and the list scrolls only where the window has // none -- the clip menu's rule, one function for both. - let (at, room) = menu_floor(picker.at, viewport, darkroom, self.split_px(Split::Bench, viewport)); + let (at, room) = menu_floor( + picker.at, + viewport, + darkroom, + self.split_px(Split::Bench, viewport), + ); let list_h = menu_rows_h(rows.len(), room); let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h); Some( diff --git a/crates/app/src/ui/preview.rs b/crates/app/src/ui/preview.rs index 6c5234e..1d4745d 100644 --- a/crates/app/src/ui/preview.rs +++ b/crates/app/src/ui/preview.rs @@ -1,7 +1,7 @@ //! The picture: what is drawn over it and what is read off it. -use crate::*; use crate::ui::type_scale::{self, Typeset}; +use crate::*; use std::path::{Path, PathBuf}; impl Player { @@ -194,11 +194,11 @@ impl Player { self.active_fps(), ) .replace(':', "-"); - let text = match save_screenshot(bytes, size.width.0 as u32, size.height.0 as u32, &stem, &tc) - { - Ok(path) => format!("SAVED {}", path.display()), - Err(e) => format!("SCREENSHOT FAILED: {e}"), - }; + let text = + match save_screenshot(bytes, size.width.0 as u32, size.height.0 as u32, &stem, &tc) { + Ok(path) => format!("SAVED {}", path.display()), + Err(e) => format!("SCREENSHOT FAILED: {e}"), + }; self.notify_user(text.into()); cx.notify(); } diff --git a/crates/app/src/ui/settings_stance.rs b/crates/app/src/ui/settings_stance.rs index 72b805d..71ba086 100644 --- a/crates/app/src/ui/settings_stance.rs +++ b/crates/app/src/ui/settings_stance.rs @@ -32,8 +32,8 @@ //! since nothing in [`engine::project::Project`] holds a place to persist an //! override into. -use crate::*; use crate::ui::type_scale; +use crate::*; use engine::colorspace::ContentLight; /// A 9px uppercase Archivo section head, `ink3` -- [`dock_stance::section_head`]'s @@ -106,7 +106,9 @@ fn row_ink( on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, value_ink: u32, ) -> impl IntoElement { - row_full(id, label_text, value, hint, None, player, on_click, value_ink) + row_full( + id, label_text, value, hint, None, player, on_click, value_ink, + ) } /// The one row body all three wrappers share. `chord` is the stroke that also @@ -141,7 +143,9 @@ fn row_full( .tooltip(move |_, cx| cx.new(|_| Tip(hint.clone())).into()) .when(exporting, |d| d.opacity(0.4).cursor_not_allowed()) .when(!exporting, |d| { - d.cursor_pointer().hover(|s| s.bg(rgb(DARK_RAISED()))).on_click(on_click) + d.cursor_pointer() + .hover(|s| s.bg(rgb(DARK_RAISED()))) + .on_click(on_click) }) .child( div() @@ -244,7 +248,11 @@ fn project_section(player: &Player, cx: &mut Context) -> impl IntoElemen // Sample rate keeps its "Source" fallback: unlike resolution/fps it // states a real behaviour (derives from the first audio source) rather // than standing in for a value with nothing behind it. - let rate_val = match player.session.as_ref().map_or(player.pending_settings.2, |s| s.sample_rate()) { + let rate_val = match player + .session + .as_ref() + .map_or(player.pending_settings.2, |s| s.sample_rate()) + { Some(rate) => format!("{rate} Hz"), None => "Source".to_string(), }; @@ -259,7 +267,10 @@ fn project_section(player: &Player, cx: &mut Context) -> impl IntoElemen // persist one into. `—` for a project with no session, and for a session // whose file is SDR or simply declared nothing (most files declare // nothing here at all). - let light = player.session.as_ref().map_or(ContentLight::default(), engine::playback::PlaybackSession::content_light); + let light = player.session.as_ref().map_or( + ContentLight::default(), + engine::playback::PlaybackSession::content_light, + ); let (master_val, master_ink) = match (&player.session, light.mastering_max) { (Some(_), Some(nits)) => (format!("{nits:.0} nits"), INK1()), _ => ("—".to_string(), INK4()), @@ -467,7 +478,13 @@ pub(crate) fn render( .child("SETTINGS") .child( div() - .font(type_scale::mono(type_scale::CHORD_METADATA_MIN_PX, gpui::FontWeight::MEDIUM).font) + .font( + type_scale::mono( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + ) + .font, + ) .text_size(px(type_scale::CHORD_METADATA_MIN_PX)) .text_color(rgb(INK3())) .child(player.keymap.display(ActionId::Settings)), diff --git a/crates/app/src/ui/theme.rs b/crates/app/src/ui/theme.rs index 4996121..5c31115 100644 --- a/crates/app/src/ui/theme.rs +++ b/crates/app/src/ui/theme.rs @@ -377,7 +377,10 @@ pub mod cool { /// from somewhere else than its neighbour. The *kind* is the body colour now /// ([`super::clip_kind`]); this is the identity stripe and the library /// swatch, and it only has to be four things telling each other apart. - pub const SOURCE_TINTS: [u32; 12] = [0x4f8fd6, 0xd69a4f, 0x4fd6a8, 0xb14fd6, 0x4f8fd6, 0xd69a4f, 0x4fd6a8, 0xb14fd6, 0x4f8fd6, 0xd69a4f, 0x4fd6a8, 0xb14fd6]; + pub const SOURCE_TINTS: [u32; 12] = [ + 0x4f8fd6, 0xd69a4f, 0x4fd6a8, 0xb14fd6, 0x4f8fd6, 0xd69a4f, 0x4fd6a8, 0xb14fd6, 0x4f8fd6, + 0xd69a4f, 0x4fd6a8, 0xb14fd6, + ]; // -- feedback --------------------------------------------------------------- pub const STATUS_ERROR: u32 = 0xef4444; @@ -459,7 +462,10 @@ pub mod warm { /// Warm-side identity stripes: the same four-way distinctness the cool /// family's are held to, in hues that belong to this ground. - pub const SOURCE_TINTS: [u32; 12] = [0xe08a4f, 0x4fa8d6, 0x8fc94f, 0xd67aa8, 0xe08a4f, 0x4fa8d6, 0x8fc94f, 0xd67aa8, 0xe08a4f, 0x4fa8d6, 0x8fc94f, 0xd67aa8]; + pub const SOURCE_TINTS: [u32; 12] = [ + 0xe08a4f, 0x4fa8d6, 0x8fc94f, 0xd67aa8, 0xe08a4f, 0x4fa8d6, 0x8fc94f, 0xd67aa8, 0xe08a4f, + 0x4fa8d6, 0x8fc94f, 0xd67aa8, + ]; // -- feedback --------------------------------------------------------------- pub const STATUS_ERROR: u32 = 0xc85050; @@ -539,7 +545,10 @@ pub mod forest { pub const CLIP_IMAGE: u32 = 0x1a6a6a; pub const CLIP_TEXT: u32 = 0x6b46c1; - pub const SOURCE_TINTS: [u32; 12] = [0x5fd68f, 0xd6a45f, 0x5fa8d6, 0xc15fd6, 0x5fd68f, 0xd6a45f, 0x5fa8d6, 0xc15fd6, 0x5fd68f, 0xd6a45f, 0x5fa8d6, 0xc15fd6]; + pub const SOURCE_TINTS: [u32; 12] = [ + 0x5fd68f, 0xd6a45f, 0x5fa8d6, 0xc15fd6, 0x5fd68f, 0xd6a45f, 0x5fa8d6, 0xc15fd6, 0x5fd68f, + 0xd6a45f, 0x5fa8d6, 0xc15fd6, + ]; // -- feedback --------------------------------------------------------------- /// Not the accent family: a success that wore the emerald would say "this is @@ -618,7 +627,10 @@ pub mod violet { /// be the same purple. pub const CLIP_TEXT: u32 = 0x6d3fa8; - pub const SOURCE_TINTS: [u32; 12] = [0x9b7fe8, 0xe8a97f, 0x7fc8e8, 0xe87fb4, 0x9b7fe8, 0xe8a97f, 0x7fc8e8, 0xe87fb4, 0x9b7fe8, 0xe8a97f, 0x7fc8e8, 0xe87fb4]; + pub const SOURCE_TINTS: [u32; 12] = [ + 0x9b7fe8, 0xe8a97f, 0x7fc8e8, 0xe87fb4, 0x9b7fe8, 0xe8a97f, 0x7fc8e8, 0xe87fb4, 0x9b7fe8, + 0xe8a97f, 0x7fc8e8, 0xe87fb4, + ]; // -- feedback --------------------------------------------------------------- pub const STATUS_ERROR: u32 = 0xf87171; @@ -691,7 +703,10 @@ pub mod rose { pub const CLIP_IMAGE: u32 = 0x1c6270; pub const CLIP_TEXT: u32 = 0x6b46c1; - pub const SOURCE_TINTS: [u32; 12] = [0xe87f97, 0x7fc8e8, 0xe8c87f, 0x9b7fe8, 0xe87f97, 0x7fc8e8, 0xe8c87f, 0x9b7fe8, 0xe87f97, 0x7fc8e8, 0xe8c87f, 0x9b7fe8]; + pub const SOURCE_TINTS: [u32; 12] = [ + 0xe87f97, 0x7fc8e8, 0xe8c87f, 0x9b7fe8, 0xe87f97, 0x7fc8e8, 0xe8c87f, 0x9b7fe8, 0xe87f97, + 0x7fc8e8, 0xe8c87f, 0x9b7fe8, + ]; // -- feedback --------------------------------------------------------------- /// Brighter and more saturated than the accent it sits near on the wheel: on @@ -768,7 +783,10 @@ pub mod amber { pub const CLIP_IMAGE: u32 = 0x1c6270; pub const CLIP_TEXT: u32 = 0x6b46c1; - pub const SOURCE_TINTS: [u32; 12] = [0xe8b45f, 0x5fa8e8, 0x7fd69b, 0xd68fc1, 0xe8b45f, 0x5fa8e8, 0x7fd69b, 0xd68fc1, 0xe8b45f, 0x5fa8e8, 0x7fd69b, 0xd68fc1]; + pub const SOURCE_TINTS: [u32; 12] = [ + 0xe8b45f, 0x5fa8e8, 0x7fd69b, 0xd68fc1, 0xe8b45f, 0x5fa8e8, 0x7fd69b, 0xd68fc1, 0xe8b45f, + 0x5fa8e8, 0x7fd69b, 0xd68fc1, + ]; // -- feedback --------------------------------------------------------------- /// The warning steps to orange: amber *is* the accent here, and a warning @@ -843,7 +861,10 @@ pub mod ocean { pub const CLIP_IMAGE: u32 = 0x1c6270; pub const CLIP_TEXT: u32 = 0x6b46c1; - pub const SOURCE_TINTS: [u32; 12] = [0x5fa8e8, 0xe8a95f, 0x5fd6a0, 0xc98fe8, 0x5fa8e8, 0xe8a95f, 0x5fd6a0, 0xc98fe8, 0x5fa8e8, 0xe8a95f, 0x5fd6a0, 0xc98fe8]; + pub const SOURCE_TINTS: [u32; 12] = [ + 0x5fa8e8, 0xe8a95f, 0x5fd6a0, 0xc98fe8, 0x5fa8e8, 0xe8a95f, 0x5fd6a0, 0xc98fe8, 0x5fa8e8, + 0xe8a95f, 0x5fd6a0, 0xc98fe8, + ]; // -- feedback --------------------------------------------------------------- pub const STATUS_ERROR: u32 = 0xf05252; @@ -919,7 +940,10 @@ pub mod ice { pub const CLIP_IMAGE: u32 = 0x1c6270; pub const CLIP_TEXT: u32 = 0x6b46c1; - pub const SOURCE_TINTS: [u32; 12] = [0x7fd6e8, 0xe8b47f, 0x8fd69b, 0xc79be8, 0x7fd6e8, 0xe8b47f, 0x8fd69b, 0xc79be8, 0x7fd6e8, 0xe8b47f, 0x8fd69b, 0xc79be8]; + pub const SOURCE_TINTS: [u32; 12] = [ + 0x7fd6e8, 0xe8b47f, 0x8fd69b, 0xc79be8, 0x7fd6e8, 0xe8b47f, 0x8fd69b, 0xc79be8, 0x7fd6e8, + 0xe8b47f, 0x8fd69b, 0xc79be8, + ]; // -- feedback --------------------------------------------------------------- pub const STATUS_ERROR: u32 = 0xff6b6b; @@ -993,7 +1017,10 @@ pub mod orchid { pub const CLIP_IMAGE: u32 = 0x1c6270; pub const CLIP_TEXT: u32 = 0x5a45b8; - pub const SOURCE_TINTS: [u32; 12] = [0xe88fd6, 0x8fc9e8, 0xe8c48f, 0x8fe8b4, 0xe88fd6, 0x8fc9e8, 0xe8c48f, 0x8fe8b4, 0xe88fd6, 0x8fc9e8, 0xe8c48f, 0x8fe8b4]; + pub const SOURCE_TINTS: [u32; 12] = [ + 0xe88fd6, 0x8fc9e8, 0xe8c48f, 0x8fe8b4, 0xe88fd6, 0x8fc9e8, 0xe8c48f, 0x8fe8b4, 0xe88fd6, + 0x8fc9e8, 0xe8c48f, 0x8fe8b4, + ]; // -- feedback --------------------------------------------------------------- pub const STATUS_ERROR: u32 = 0xf87171; @@ -1082,7 +1109,10 @@ pub mod nord { /// Aurora and Frost at full strength: a swatch carries no text, so these are /// Nord's own numbers. - pub const SOURCE_TINTS: [u32; 12] = [0x88c0d0, 0xd08770, 0xa3be8c, 0xb48ead, 0x88c0d0, 0xd08770, 0xa3be8c, 0xb48ead, 0x88c0d0, 0xd08770, 0xa3be8c, 0xb48ead]; + pub const SOURCE_TINTS: [u32; 12] = [ + 0x88c0d0, 0xd08770, 0xa3be8c, 0xb48ead, 0x88c0d0, 0xd08770, 0xa3be8c, 0xb48ead, 0x88c0d0, + 0xd08770, 0xa3be8c, 0xb48ead, + ]; // -- feedback --------------------------------------------------------------- pub const STATUS_ERROR: u32 = 0xbf616a; @@ -1164,7 +1194,10 @@ pub mod gruvbox { pub const CLIP_IMAGE: u32 = 0x2f6a63; pub const CLIP_TEXT: u32 = 0x7a4a72; - pub const SOURCE_TINTS: [u32; 12] = [0xfe8019, 0x83a598, 0xb8bb26, 0xd3869b, 0xfe8019, 0x83a598, 0xb8bb26, 0xd3869b, 0xfe8019, 0x83a598, 0xb8bb26, 0xd3869b]; + pub const SOURCE_TINTS: [u32; 12] = [ + 0xfe8019, 0x83a598, 0xb8bb26, 0xd3869b, 0xfe8019, 0x83a598, 0xb8bb26, 0xd3869b, 0xfe8019, + 0x83a598, 0xb8bb26, 0xd3869b, + ]; // -- feedback --------------------------------------------------------------- pub const STATUS_ERROR: u32 = 0xfb4934; @@ -1240,7 +1273,10 @@ pub mod dracula { pub const CLIP_TEXT: u32 = 0x6a3fb0; /// Dracula's own six, four of them: a swatch carries no text. - pub const SOURCE_TINTS: [u32; 12] = [0xff79c6, 0x8be9fd, 0x50fa7b, 0xffb86c, 0xff79c6, 0x8be9fd, 0x50fa7b, 0xffb86c, 0xff79c6, 0x8be9fd, 0x50fa7b, 0xffb86c]; + pub const SOURCE_TINTS: [u32; 12] = [ + 0xff79c6, 0x8be9fd, 0x50fa7b, 0xffb86c, 0xff79c6, 0x8be9fd, 0x50fa7b, 0xffb86c, 0xff79c6, + 0x8be9fd, 0x50fa7b, 0xffb86c, + ]; // -- feedback --------------------------------------------------------------- pub const STATUS_ERROR: u32 = 0xff5555; @@ -1342,8 +1378,8 @@ pub mod darkroom { // wheel with a quantized dominant hue per import; until then the index // is `source % 12`, which still guarantees different sources differ. pub const SOURCE_TINTS: [u32; 12] = [ - 0x64b5d1, 0x647ed1, 0x8064d1, 0xb664d1, 0xd164b5, 0xd1647e, 0xd18064, - 0xd1b764, 0xb5d164, 0x7ed164, 0x64d180, 0x64d1b7, + 0x64b5d1, 0x647ed1, 0x8064d1, 0xb664d1, 0xd164b5, 0xd1647e, 0xd18064, 0xd1b764, 0xb5d164, + 0x7ed164, 0x64d180, 0x64d1b7, ]; // -- feedback ------------------------------------------------------------- diff --git a/crates/app/src/ui/timeband_stance.rs b/crates/app/src/ui/timeband_stance.rs index 60fc065..7908048 100644 --- a/crates/app/src/ui/timeband_stance.rs +++ b/crates/app/src/ui/timeband_stance.rs @@ -8,8 +8,8 @@ //! close to the mock's ~20px reading. Every size in this module comes from //! `ui::type_scale` (role, not a bare `px()` literal). -use crate::*; use crate::ui::type_scale::{self, label, mono}; +use crate::*; use gpui::FontWeight; thread_local! { @@ -178,8 +178,22 @@ fn range_marks(player: &Player, cx: &mut Context) -> impl IntoElement { .flex() .items_center() .gap(px(4.)) - .child(ghost("stance-mark-in", player, "I", ActionId::SetIn, false, cx)) - .child(ghost("stance-mark-out", player, "O", ActionId::SetOut, false, cx)) + .child(ghost( + "stance-mark-in", + player, + "I", + ActionId::SetIn, + false, + cx, + )) + .child(ghost( + "stance-mark-out", + player, + "O", + ActionId::SetOut, + false, + cx, + )) .child(ghost( "stance-clear-range", player, @@ -241,11 +255,25 @@ fn contact_strip(player: &Player, position: f64, cx: &mut Context) -> im .flat_map(|l| s.lane_clips(l).to_vec()) .filter_map(|clip| { let source = player.sources().get(clip.source)?; - let Wave::Peaks(peaks) = player.waves.get(&(source.path.clone(), source.audio_stream))?.clone() else { + let Wave::Peaks(peaks) = player + .waves + .get(&(source.path.clone(), source.audio_stream))? + .clone() + else { return None; }; - let (in_f, out_f) = (f64::from(clip.in_frame) / fps, f64::from(clip.out_frame) / fps); - Some((frac(clip.start), frac(clip.end()), peaks, in_f, out_f, source_tint(clip.source))) + let (in_f, out_f) = ( + f64::from(clip.in_frame) / fps, + f64::from(clip.out_frame) / fps, + ); + Some(( + frac(clip.start), + frac(clip.end()), + peaks, + in_f, + out_f, + source_tint(clip.source), + )) }) .collect() }) @@ -424,13 +452,10 @@ fn grip(id: &'static str, left: bool, top: bool) -> impl IntoElement { .h(px(6.)) .bg(rgb(INK1())), ) - .on_mouse_down( - MouseButton::Left, - move |event: &MouseDownEvent, _, cx| { - PAN_ANCHOR.with(|a| a.set(Some(f32::from(event.position.x)))); - cx.stop_propagation(); - }, - ) + .on_mouse_down(MouseButton::Left, move |event: &MouseDownEvent, _, cx| { + PAN_ANCHOR.with(|a| a.set(Some(f32::from(event.position.x)))); + cx.stop_propagation(); + }) } /// The Export chip (MOCK-SPEC "Export chip", DESIGN §4): the room's single @@ -501,7 +526,8 @@ fn volume_slider(player: &Player, cx: &mut Context) -> impl IntoElement .flex() .items_center() .tooltip(|_, cx| { - cx.new(|_| Tip("Volume — drag to set the level; the button mutes".into())).into() + cx.new(|_| Tip("Volume — drag to set the level; the button mutes".into())) + .into() }) .when(!enabled, |d| d.opacity(0.4).cursor_not_allowed()) .when(enabled, |d| { @@ -534,7 +560,11 @@ fn volume_slider(player: &Player, cx: &mut Context) -> impl IntoElement /// The whole band, left to right per MOCK-SPEC: hero timecode, ghost /// transport, cut readout, the contact strip filling the rest, the Export /// chip at the end. -pub(crate) fn render(player: &mut Player, position: f64, cx: &mut Context) -> impl IntoElement { +pub(crate) fn render( + player: &mut Player, + position: f64, + cx: &mut Context, +) -> impl IntoElement { let tc = timecode(position, player.active_fps()); div() .id("stance-time-band-row") @@ -584,7 +614,11 @@ pub(crate) fn render(player: &mut Player, position: f64, cx: &mut Context (lanes_box - LABEL_H - 8.).max(LANE_H), false => lanes_box, }; - let (thumb_x, thumb_w) = - scroll_thumb(view.bed, view.duration, view.scale.start.max(0.), view.span()); + let (thumb_x, thumb_w) = scroll_thumb( + view.bed, + view.duration, + view.scale.start.max(0.), + view.span(), + ); // Live, not a count of the lanes: the column reports where it has been // taken to, so the line empties itself as the last track comes up // instead of insisting there is still something below. The stack's own @@ -119,8 +123,7 @@ impl Player { let stack = self.lanes_scroll.bounds(); let track_h = f32::from(stack.size.height); let stack_max = f32::from(self.lanes_scroll.max_offset().height); - let (stack_y, stack_thumb_h) = - lanes_thumb(track_h, track_h + stack_max, track_h, scrolled); + let (stack_y, stack_thumb_h) = lanes_thumb(track_h, track_h + stack_max, track_h, scrolled); div() .flex_none() // Never more than its share of a short window: the lane column @@ -344,8 +347,7 @@ impl Player { |this, event: &ScrollWheelEvent, window, cx| { cx.stop_propagation(); let line = window.line_height(); - let dy = - f32::from(event.delta.pixel_delta(line).y); + let dy = f32::from(event.delta.pixel_delta(line).y); this.lanes_wheel(dy, cx); }, )) @@ -360,15 +362,11 @@ impl Player { // else on the bed; over the strip it is // nothing, and the clip beneath must not // answer it through the strip. - .on_mouse_down( - MouseButton::Right, - |_: &MouseDownEvent, _, cx| cx.stop_propagation(), - ) + .on_mouse_down(MouseButton::Right, |_: &MouseDownEvent, _, cx| { + cx.stop_propagation() + }) .on_mouse_move(cx.listener(Player::drag_move)) - .on_mouse_up( - MouseButton::Left, - cx.listener(Player::drag_release), - ) + .on_mouse_up(MouseButton::Left, cx.listener(Player::drag_release)) .child( div() .absolute() @@ -524,7 +522,11 @@ impl Player { /// /// `None` when there are none -- an empty heading is a section about /// nothing. - pub(crate) fn subtitle_section(&self, width: f32, cx: &mut Context) -> Option { + pub(crate) fn subtitle_section( + &self, + width: f32, + cx: &mut Context, + ) -> Option { let tracks = self.session.as_ref()?.subtitles(); if tracks.is_empty() { return None; @@ -588,13 +590,12 @@ impl Player { let carried: SharedString = title.clone().into(); // Named, because a × is the same glyph on every row and // the tooltip is what says which track it takes off. - let remove_tip: SharedString = - format!( - "Remove {title} from the palette — {} puts a file's subtitles \ + let remove_tip: SharedString = format!( + "Remove {title} from the palette — {} puts a file's subtitles \ back in it", - add_key - ) - .into(); + add_key + ) + .into(); div() // The *flat* index into the session's add-order // list, which is what a pick is and what a save @@ -710,13 +711,13 @@ impl Player { .rounded(px(3.)) .cursor_pointer() .hover(|s| s.bg(rgb(BG_HOVER()))) - .tooltip(move |_, cx| cx.new(|_| Tip(remove_tip.clone())).into()) - .on_click(cx.listener( - move |this, _: &ClickEvent, _, cx| { - cx.stop_propagation(); - this.remove_subtitle_track(track, cx); - }, - )) + .tooltip(move |_, cx| { + cx.new(|_| Tip(remove_tip.clone())).into() + }) + .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { + cx.stop_propagation(); + this.remove_subtitle_track(track, cx); + })) .child("×"), ) }) @@ -987,8 +988,8 @@ impl Player { .on_drop(cx.listener(move |this, drag: &LaneDrag, _, cx| { this.reorder_lane(drag.0, lane, cx); })) - .on_drag_move(cx.listener( - move |this, event: &DragMoveEvent, _, cx| { + .on_drag_move( + cx.listener(move |this, event: &DragMoveEvent, _, cx| { // Carried off this row, the line it was promising goes with // it: a cue left painted over a slot a release out here does // not commit is the drag saying one thing and the drop @@ -1000,8 +1001,8 @@ impl Player { return this.forget_lane_drop(lane, cx); } this.preview_lane_drop(event.drag(cx).0, lane, cx); - }, - )) + }), + ) // The fixed column the ruler above is offset by as well. Full lane // height, so it reads as the bed continuing rather than as a chip. .child( @@ -1854,20 +1855,20 @@ impl Player { zone }), ) - // No name drawn on the box itself: the cue blocks - // now fill its full height, and a label sitting - // over them fights the very thing this box exists - // to show. The tooltip still carries the words - // (`sub_tip`), and the ghost while dragging still - // names the track (`ghost`, above). - // The way back off the lane is the way every other - // box takes: the Delete stroke on the marked caption - // and the Delete row of its own menu - // ([`Player::lift_sub`]). The × that used to sit - // here is gone with them -- it was drawn only where - // the box was wide enough to hold it, so the one - // removal a caption had was the one a zoomed-out - // caption did not have. + // No name drawn on the box itself: the cue blocks + // now fill its full height, and a label sitting + // over them fights the very thing this box exists + // to show. The tooltip still carries the words + // (`sub_tip`), and the ghost while dragging still + // names the track (`ghost`, above). + // The way back off the lane is the way every other + // box takes: the Delete stroke on the marked caption + // and the Delete row of its own menu + // ([`Player::lift_sub`]). The × that used to sit + // here is gone with them -- it was drawn only where + // the box was wide enough to hold it, so the one + // removal a caption had was the one a zoomed-out + // caption did not have. })) // ...and where the words actually are inside those boxes: // the cues this lane shows on *this* timeline, each its own @@ -1932,13 +1933,18 @@ impl Player { .max(GHOST_MIN))) .rounded(px(3.)) .border_1() - .border_color(rgb(if g.refused { DROP_REFUSE() } else { FG_PRIMARY() })) + .border_color(rgb(if g.refused { + DROP_REFUSE() + } else { + FG_PRIMARY() + })) // The file's own swatch at a third of its weight, so // the box beneath is still legible through it -- and // the refusal red instead, for a lane that will not // take this drop at all. .bg(rgba( - ((if g.refused { DROP_REFUSE() } else { g.tint }) << 8) | GHOST_ALPHA, + ((if g.refused { DROP_REFUSE() } else { g.tint }) << 8) + | GHOST_ALPHA, )) })) // What the gesture in flight is about to land on, drawn on diff --git a/crates/app/src/ui/toolbar.rs b/crates/app/src/ui/toolbar.rs index 5d82e80..258858f 100644 --- a/crates/app/src/ui/toolbar.rs +++ b/crates/app/src/ui/toolbar.rs @@ -9,8 +9,8 @@ //! pointer while the very same actions still fired from the keys. One oracle, //! two doors -- if the key fires, the button fires. -use crate::*; use crate::ui::widgets::*; +use crate::*; impl Player { /// A toolbar button for `action`: enabled exactly when [`enable`] says the @@ -142,8 +142,7 @@ impl Player { this.open_export(cx); } }), - )) - , + )), ) } @@ -216,7 +215,9 @@ impl Player { "Loop", "restarts from the top on reaching the end, instead of stopping", ActionId::Loop, - cx.listener(|this, _: &ClickEvent, window, cx| this.act(ActionId::Loop, window, cx)), + cx.listener(|this, _: &ClickEvent, window, cx| { + this.act(ActionId::Loop, window, cx) + }), )) // One line, one fixed width: changing digits must not push the // strip around, and the clock is the one number that changes @@ -397,7 +398,9 @@ impl Player { None, if self.snap { "Snap on" } else { "Snap off" }, match self.snap { - true => "drags and trims land on clip edges, the playhead and the start", + true => { + "drags and trims land on clip edges, the playhead and the start" + } false => "drags and trims land exactly where the hand leaves them", }, ActionId::ToggleSnap, diff --git a/crates/app/src/ui/widgets.rs b/crates/app/src/ui/widgets.rs index 3a8b097..44c77fc 100644 --- a/crates/app/src/ui/widgets.rs +++ b/crates/app/src/ui/widgets.rs @@ -13,7 +13,12 @@ pub(crate) fn waveform(peaks: Arc>, from: f64, to: f64) -> impl /// secondary foreground -- the darkroom bench's own audio clips draw their /// envelope in the source's ink (DESIGN §5), which the legacy timeline never /// needed a colour for. -pub(crate) fn waveform_ink(peaks: Arc>, from: f64, to: f64, ink: u32) -> impl IntoElement { +pub(crate) fn waveform_ink( + peaks: Arc>, + from: f64, + to: f64, + ink: u32, +) -> impl IntoElement { canvas( |_, _, _| (), move |bounds, _, window, _| { @@ -229,7 +234,11 @@ pub(crate) fn volume_slider( .h_full() .w(relative(volume.along())) .rounded(px(2.)) - .bg(rgb(if volume.muted { FG_SECONDARY() } else { ACCENT_PRIMARY() })), + .bg(rgb(if volume.muted { + FG_SECONDARY() + } else { + ACCENT_PRIMARY() + })), ), ) } @@ -282,7 +291,10 @@ pub(crate) fn tip_may_paint(anchored_on_overlay: bool) -> bool { /// plate" -- canvas-on-panel, 2px radius, the room's own type /// (`ui::type_scale`), not a bordered box in an ad hoc size. fn tip_plate(text: &SharedString) -> Div { - let style = crate::ui::type_scale::label(crate::ui::type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM); + let style = crate::ui::type_scale::label( + crate::ui::type_scale::LABEL_ROW_PX, + gpui::FontWeight::MEDIUM, + ); div() .px(px(8.)) .py(px(4.))