Format Darkroom integration
Browse files at this commit9a27ee6922d4c6d6d6656d18dbe44845ceffa655Parent: ce03245- fix
- format Darkroom integration
36 changed files +1277 -656
- crates/app/src/audio_cards.rs +10 -3
- crates/app/src/eq_ui.rs +4 -7
- crates/app/src/export_ui.rs +23 -7
- crates/app/src/importing.rs +16 -4
- crates/app/src/main.rs +5 -5
- crates/app/src/notices.rs +4 -1
- crates/app/src/oracle.rs +8 -5
- crates/app/src/player/actions.rs +8 -3
- crates/app/src/player/cards.rs +32 -13
- crates/app/src/player/export.rs +14 -9
- crates/app/src/player/library.rs +47 -16
- crates/app/src/player/timeline_edit.rs +135 -57
- crates/app/src/player/transport.rs +21 -6
- crates/app/src/player/view.rs +24 -10
- crates/app/src/render.rs +17 -8
- crates/app/src/subs.rs +13 -3
- crates/app/src/tests/cards.rs +6 -2
- crates/app/src/tests/editing.rs +65 -28
- crates/app/src/tests/layout.rs +191 -57
- crates/app/src/tests/media.rs +95 -31
- crates/app/src/tests/mod.rs +56 -57
- crates/app/src/tests/view.rs +33 -16
- crates/app/src/timeline_math.rs +38 -34
- crates/app/src/transport.rs +9 -2
- crates/app/src/ui/bench_stance.rs +13 -22
- crates/app/src/ui/dock_stance.rs +1 -5
- crates/app/src/ui/inspector.rs +9 -5
- crates/app/src/ui/library.rs +86 -82
- crates/app/src/ui/overlays.rs +71 -57
- crates/app/src/ui/preview.rs +6 -6
- crates/app/src/ui/settings_stance.rs +23 -6
- crates/app/src/ui/theme.rs +50 -14
- crates/app/src/ui/timeband_stance.rs +66 -18
- crates/app/src/ui/timeline.rs +55 -49
- crates/app/src/ui/toolbar.rs +8 -5
- crates/app/src/ui/widgets.rs +15 -3
crates/app/src/audio_cards.rsmodified+10 -3
| @@ -131,7 +131,11 @@ pub(crate) const EQ_GRAPH_MAX_H: f32 = 320.; | |||
| 131 | /// pixels, an actually taller curve with more room per decibel and per | 131 | /// pixels, an actually taller curve with more room per decibel and per |
| 132 | /// decade. | 132 | /// decade. |
| 133 | pub(crate) fn eq_graph_h(maximized: bool) -> f32 { | 133 | pub(crate) fn eq_graph_h(maximized: bool) -> f32 { |
| 134 | - if maximized { EQ_GRAPH_MAX_H } else { EQ_GRAPH_H } | 134 | + if maximized { |
| 135 | + EQ_GRAPH_MAX_H | ||
| 136 | + } else { | ||
| 137 | + EQ_GRAPH_H | ||
| 138 | + } | ||
| 135 | } | 139 | } |
| 136 | 140 | ||
| 137 | /// How wide the equalizer card is allowed to get. It is the one card that is a | 141 | /// 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 { | |||
| 225 | /// clamp is a layout-time panic, not a compile-time one). | 229 | /// clamp is a layout-time panic, not a compile-time one). |
| 226 | #[test] | 230 | #[test] |
| 227 | fn maximized_graph_floor_matches_docked_and_never_exceeds_its_own_ceiling() { | 231 | fn maximized_graph_floor_matches_docked_and_never_exceeds_its_own_ceiling() { |
| 228 | - assert_eq!(eq_graph_h(false), EQ_GRAPH_H, "docked height must be the floor maximized also uses"); | 232 | + assert_eq!( |
| 233 | + eq_graph_h(false), | ||
| 234 | + EQ_GRAPH_H, | ||
| 235 | + "docked height must be the floor maximized also uses" | ||
| 236 | + ); | ||
| 229 | assert!(EQ_GRAPH_H <= EQ_GRAPH_MAX_H); | 237 | assert!(EQ_GRAPH_H <= EQ_GRAPH_MAX_H); |
| 230 | } | 238 | } |
| 231 | } | 239 | } |
| @@ -247,7 +255,6 @@ mod eq_tick_end_w_tests { | |||
| 247 | } | 255 | } |
| 248 | } | 256 | } |
| 249 | 257 | ||
| 250 | - | ||
| 251 | /// How many played samples one spectrum frame is transformed from. A power of | 258 | /// How many played samples one spectrum frame is transformed from. A power of |
| 252 | /// two ([`fft`] is radix-2) and the whole of the engine's tap: 1024 at 48 kHz | 259 | /// two ([`fft`] is radix-2) and the whole of the engine's tap: 1024 at 48 kHz |
| 253 | /// is a 47 Hz bin, fine enough that the bass end is a shape and short enough | 260 | /// is a 47 Hz bin, fine enough that the bass end is a shape and short enough |
crates/app/src/eq_ui.rsmodified+4 -7
| @@ -224,8 +224,7 @@ pub(crate) fn eq_curve(params: EqParams, sample_rate: u32) -> impl IntoElement { | |||
| 224 | let along = step as f32 / EQ_CURVE_STEPS as f32; | 224 | let along = step as f32 / EQ_CURVE_STEPS as f32; |
| 225 | point( | 225 | point( |
| 226 | o.x + s.width * along, | 226 | o.x + s.width * along, |
| 227 | - o.y + s.height | 227 | + o.y + s.height * eq_y(of.response_db(eq_freq(along), sample_rate)), |
| 228 | - * eq_y(of.response_db(eq_freq(along), sample_rate)), | ||
| 229 | ) | 228 | ) |
| 230 | }) | 229 | }) |
| 231 | .collect() | 230 | .collect() |
| @@ -233,11 +232,9 @@ pub(crate) fn eq_curve(params: EqParams, sample_rate: u32) -> impl IntoElement { | |||
| 233 | // One thread per band, first, so the sum is drawn over them. | 232 | // One thread per band, first, so the sum is drawn over them. |
| 234 | for band in ¶ms.bands { | 233 | for band in ¶ms.bands { |
| 235 | let mut bell = PathBuilder::stroke(px(1.)); | 234 | let mut bell = PathBuilder::stroke(px(1.)); |
| 236 | - for (step, at) in line(&EqParams { | 235 | + for (step, at) in line(&EqParams { bands: vec![*band] }) |
| 237 | - bands: vec![*band], | 236 | + .into_iter() |
| 238 | - }) | 237 | + .enumerate() |
| 239 | - .into_iter() | ||
| 240 | - .enumerate() | ||
| 241 | { | 238 | { |
| 242 | match step { | 239 | match step { |
| 243 | 0 => bell.move_to(at), | 240 | 0 => bell.move_to(at), |
crates/app/src/export_ui.rsmodified+23 -7
| @@ -607,7 +607,12 @@ pub(crate) fn fps_choices(current: f64, native: f64) -> Vec<ChoiceRow> { | |||
| 607 | /// The fit list's rows: all four policies against the canvas they place a | 607 | /// The fit list's rows: all four policies against the canvas they place a |
| 608 | /// picture on, since the word alone ("fill") says nothing about the size it is | 608 | /// picture on, since the word alone ("fill") says nothing about the size it is |
| 609 | /// filling -- which is the very thing the notice says after a stroke. | 609 | /// filling -- which is the very thing the notice says after a stroke. |
| 610 | -pub(crate) fn fit_choices(lane: Lane, idx: usize, current: FitPolicy, (w, h): (u32, u32)) -> Vec<ChoiceRow> { | 610 | +pub(crate) fn fit_choices( |
| 611 | + lane: Lane, | ||
| 612 | + idx: usize, | ||
| 613 | + current: FitPolicy, | ||
| 614 | + (w, h): (u32, u32), | ||
| 615 | +) -> Vec<ChoiceRow> { | ||
| 611 | FITS.into_iter() | 616 | FITS.into_iter() |
| 612 | .map(|fit| { | 617 | .map(|fit| { |
| 613 | ( | 618 | ( |
| @@ -688,9 +693,8 @@ pub(crate) fn encoder_choices(current: EncoderSeat) -> Vec<ChoiceRow> { | |||
| 688 | /// risk is theirs to be told about. `None` for every other pair, which is what | 693 | /// risk is theirs to be told about. `None` for every other pair, which is what |
| 689 | /// keeps this from becoming a row nobody reads. | 694 | /// keeps this from becoming a row nobody reads. |
| 690 | pub(crate) fn av1_hw_warning(format: Format, seat: EncoderSeat) -> Option<&'static str> { | 695 | pub(crate) fn av1_hw_warning(format: Format, seat: EncoderSeat) -> Option<&'static str> { |
| 691 | - (seat == EncoderSeat::Hardware && matches!(format, Format::Av1 | Format::Av1Mp4)).then_some( | 696 | + (seat == EncoderSeat::Hardware && matches!(format, Format::Av1 | Format::Av1Mp4)) |
| 692 | - "AV1 on the GPU reset this machine's driver once — Software is the safe seat", | 697 | + .then_some("AV1 on the GPU reset this machine's driver once — Software is the safe seat") |
| 693 | - ) | ||
| 694 | } | 698 | } |
| 695 | 699 | ||
| 696 | /// How a rendition is named where a person reads it: the panel button, the | 700 | /// 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, | |||
| 746 | /// sound will be, or that there is none. Every field here is one `ffprobe` | 750 | /// sound will be, or that there is none. Every field here is one `ffprobe` |
| 747 | /// reads back off the finished file, so the line is checkable rather than a | 751 | /// reads back off the finished file, so the line is checkable rather than a |
| 748 | /// promise. | 752 | /// promise. |
| 749 | -pub(crate) fn summary_head(format: Format, picture: Option<((u32, u32), f64)>, audio: &str) -> String { | 753 | +pub(crate) fn summary_head( |
| 754 | + format: Format, | ||
| 755 | + picture: Option<((u32, u32), f64)>, | ||
| 756 | + audio: &str, | ||
| 757 | +) -> String { | ||
| 750 | let line = match picture.filter(|_| format.has_video()) { | 758 | let line = match picture.filter(|_| format.has_video()) { |
| 751 | Some(((w, h), fps)) => { | 759 | Some(((w, h), fps)) => { |
| 752 | format!("{} · {w}x{h} · {} fps", format_line(format), fps_label(fps)) | 760 | 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 | |||
| 759 | /// The second: where it lands, roughly how big, and what will encode the | 767 | /// The second: where it lands, roughly how big, and what will encode the |
| 760 | /// picture -- the seat as the probe found it (`…` until it lands, never a | 768 | /// picture -- the seat as the probe found it (`…` until it lands, never a |
| 761 | /// guess), which is what the running export then names on its progress line. | 769 | /// guess), which is what the running export then names on its progress line. |
| 762 | -pub(crate) fn summary_tail(path: &Path, bytes: Option<u64>, seat: Option<&'static str>, video: bool) -> String { | 770 | +pub(crate) fn summary_tail( |
| 771 | + path: &Path, | ||
| 772 | + bytes: Option<u64>, | ||
| 773 | + seat: Option<&'static str>, | ||
| 774 | + video: bool, | ||
| 775 | +) -> String { | ||
| 763 | let size = bytes.map_or_else(String::new, |bytes| format!("≈ {}", size_label(bytes))); | 776 | let size = bytes.map_or_else(String::new, |bytes| format!("≈ {}", size_label(bytes))); |
| 764 | let seat = match (video, seat) { | 777 | let seat = match (video, seat) { |
| 765 | (true, Some(seat)) => seat, | 778 | (true, Some(seat)) => seat, |
| @@ -967,7 +980,10 @@ impl NumberEdit { | |||
| 967 | /// and stays inside the range, because a step is a walk through the legal | 980 | /// and stays inside the range, because a step is a walk through the legal |
| 968 | /// numbers rather than a way out of them. | 981 | /// numbers rather than a way out of them. |
| 969 | pub(crate) fn step(&mut self, by: i32) { | 982 | pub(crate) fn step(&mut self, by: i32) { |
| 970 | - let at = self.text.parse::<i32>().unwrap_or(MBPS_MIN as i32 - by.signum()); | 983 | + let at = self |
| 984 | + .text | ||
| 985 | + .parse::<i32>() | ||
| 986 | + .unwrap_or(MBPS_MIN as i32 - by.signum()); | ||
| 971 | self.text = (at + by) | 987 | self.text = (at + by) |
| 972 | .clamp(MBPS_MIN as i32, MBPS_MAX as i32) | 988 | .clamp(MBPS_MIN as i32, MBPS_MAX as i32) |
| 973 | .to_string(); | 989 | .to_string(); |
crates/app/src/importing.rsmodified+16 -4
| @@ -12,7 +12,8 @@ pub(crate) enum LibraryTab { | |||
| 12 | Text, | 12 | Text, |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | -pub(crate) const LIBRARY_TABS: [LibraryTab; 3] = [LibraryTab::Media, LibraryTab::Audio, LibraryTab::Text]; | 15 | +pub(crate) const LIBRARY_TABS: [LibraryTab; 3] = |
| 16 | + [LibraryTab::Media, LibraryTab::Audio, LibraryTab::Text]; | ||
| 16 | 17 | ||
| 17 | impl LibraryTab { | 18 | impl LibraryTab { |
| 18 | pub(crate) fn label(self) -> &'static str { | 19 | pub(crate) fn label(self) -> &'static str { |
| @@ -208,7 +209,10 @@ impl SilenceScan { | |||
| 208 | /// when the mark actually moves -- [`Import::poll`]'s contract, over a | 209 | /// when the mark actually moves -- [`Import::poll`]'s contract, over a |
| 209 | /// number instead of a stage. | 210 | /// number instead of a stage. |
| 210 | pub(crate) fn poll(&mut self) -> f32 { | 211 | pub(crate) fn poll(&mut self) -> f32 { |
| 211 | - let scanned = self.progress.scanned.load(std::sync::atomic::Ordering::Relaxed); | 212 | + let scanned = self |
| 213 | + .progress | ||
| 214 | + .scanned | ||
| 215 | + .load(std::sync::atomic::Ordering::Relaxed); | ||
| 212 | if scanned != self.seen { | 216 | if scanned != self.seen { |
| 213 | self.seen = scanned; | 217 | self.seen = scanned; |
| 214 | self.since = Instant::now(); | 218 | self.since = Instant::now(); |
| @@ -392,7 +396,12 @@ pub(crate) fn full_scan_key(path: &Path, stream: usize) -> ScanKey { | |||
| 392 | /// numbers the on-demand scan would have. Empty past the end of what the | 396 | /// numbers the on-demand scan would have. Empty past the end of what the |
| 393 | /// background read has landed so far -- a scan still running answers with | 397 | /// background read has landed so far -- a scan still running answers with |
| 394 | /// what it has, same as [`SilenceScan`]'s own cancel does. | 398 | /// what it has, same as [`SilenceScan`]'s own cancel does. |
| 395 | -pub(crate) fn slice_whole_levels(whole: &[f32], fps: f64, in_frame: u32, out_frame: u32) -> Vec<f32> { | 399 | +pub(crate) fn slice_whole_levels( |
| 400 | + whole: &[f32], | ||
| 401 | + fps: f64, | ||
| 402 | + in_frame: u32, | ||
| 403 | + out_frame: u32, | ||
| 404 | +) -> Vec<f32> { | ||
| 396 | if !(fps.is_finite() && fps > 0.) { | 405 | if !(fps.is_finite() && fps > 0.) { |
| 397 | return Vec::new(); | 406 | return Vec::new(); |
| 398 | } | 407 | } |
| @@ -411,7 +420,10 @@ pub(crate) fn slice_whole_levels(whole: &[f32], fps: f64, in_frame: u32, out_fra | |||
| 411 | /// ([`Player::cache_media`]). One function so `Player::open_silence`'s plan | 420 | /// ([`Player::cache_media`]). One function so `Player::open_silence`'s plan |
| 412 | /// and `Player::scan_silences`' lookup share the one contract for what | 421 | /// and `Player::scan_silences`' lookup share the one contract for what |
| 413 | /// "cached" means, instead of two copies that could drift. | 422 | /// "cached" means, instead of two copies that could drift. |
| 414 | -pub(crate) fn silence_cached(levels: &std::collections::HashMap<ScanKey, Arc<Vec<f32>>>, key: &ScanKey) -> bool { | 423 | +pub(crate) fn silence_cached( |
| 424 | + levels: &std::collections::HashMap<ScanKey, Arc<Vec<f32>>>, | ||
| 425 | + key: &ScanKey, | ||
| 426 | +) -> bool { | ||
| 415 | levels.contains_key(key) || levels.contains_key(&full_scan_key(&key.0, key.1)) | 427 | levels.contains_key(key) || levels.contains_key(&full_scan_key(&key.0, key.1)) |
| 416 | } | 428 | } |
| 417 | 429 | ||
crates/app/src/main.rsmodified+5 -5
| @@ -36,9 +36,9 @@ pub(crate) use menus::*; | |||
| 36 | pub(crate) use render::escape_leaves_player_fullscreen; | 36 | pub(crate) use render::escape_leaves_player_fullscreen; |
| 37 | // The Contain letterbox, shared with the subtitle picture overlay | 37 | // The Contain letterbox, shared with the subtitle picture overlay |
| 38 | // (ui/preview.rs) so both draw the same fitted rect the same way. | 38 | // (ui/preview.rs) so both draw the same fitted rect the same way. |
| 39 | -pub(crate) use render::letterboxed_image; | ||
| 40 | pub(crate) use notices::*; | 39 | pub(crate) use notices::*; |
| 41 | pub(crate) use oracle::*; | 40 | pub(crate) use oracle::*; |
| 41 | +pub(crate) use render::letterboxed_image; | ||
| 42 | pub(crate) use subs::*; | 42 | pub(crate) use subs::*; |
| 43 | pub(crate) use timeline_math::*; | 43 | pub(crate) use timeline_math::*; |
| 44 | pub(crate) use transform_ui::*; | 44 | pub(crate) use transform_ui::*; |
| @@ -72,10 +72,10 @@ use engine::{Clip, Codec, ExportHandle, Frame, MediaBitrate, PlaybackSession}; | |||
| 72 | use gpui::{ | 72 | use gpui::{ |
| 73 | AnyElement, App, Application, Bounds, ClickEvent, Context, Corners, CursorStyle, Div, | 73 | AnyElement, App, Application, Bounds, ClickEvent, Context, Corners, CursorStyle, Div, |
| 74 | DragMoveEvent, FocusHandle, KeyDownEvent, KeyUpEvent, MouseButton, MouseDownEvent, | 74 | DragMoveEvent, FocusHandle, KeyDownEvent, KeyUpEvent, MouseButton, MouseDownEvent, |
| 75 | - MouseExitEvent, MouseMoveEvent, MouseUpEvent, PathBuilder, Pixels, Point, RenderImage, ScrollDelta, | 75 | + MouseExitEvent, MouseMoveEvent, MouseUpEvent, PathBuilder, Pixels, Point, RenderImage, |
| 76 | - ScrollHandle, ScrollWheelEvent, SharedString, Size, Stateful, TextAlign, TitlebarOptions, | 76 | + ScrollDelta, ScrollHandle, ScrollWheelEvent, SharedString, Size, Stateful, TextAlign, |
| 77 | - Window, WindowBounds, WindowOptions, canvas, div, point, prelude::*, px, relative, rgb, rgba, | 77 | + TitlebarOptions, Window, WindowBounds, WindowOptions, canvas, div, point, prelude::*, px, |
| 78 | - size, | 78 | + relative, rgb, rgba, size, |
| 79 | }; | 79 | }; |
| 80 | 80 | ||
| 81 | struct Player { | 81 | struct Player { |
crates/app/src/notices.rsmodified+4 -1
| @@ -22,7 +22,10 @@ pub(crate) const NOTICE_MIN_W: f32 = 180.; | |||
| 22 | /// without a window: dedupe against the back, a ceiling, oldest out first -- | 22 | /// without a window: dedupe against the back, a ceiling, oldest out first -- |
| 23 | /// except an export's own outcome, which jumps to the front. [`Player::notify_user`] | 23 | /// except an export's own outcome, which jumps to the front. [`Player::notify_user`] |
| 24 | /// is the door every message comes through; this is what the door does. | 24 | /// is the door every message comes through; this is what the door does. |
| 25 | -pub(crate) fn push_notice(notices: &mut std::collections::VecDeque<SharedString>, message: SharedString) { | 25 | +pub(crate) fn push_notice( |
| 26 | + notices: &mut std::collections::VecDeque<SharedString>, | ||
| 27 | + message: SharedString, | ||
| 28 | +) { | ||
| 26 | // A repeat of what is already at the back is dropped -- holding a key that | 29 | // A repeat of what is already at the back is dropped -- holding a key that |
| 27 | // refuses would otherwise fill the queue with one sentence, and the count on | 30 | // refuses would otherwise fill the queue with one sentence, and the count on |
| 28 | // the bar would be a count of how long the key was held. | 31 | // the bar would be a count of how long the key was held. |
crates/app/src/oracle.rsmodified+8 -5
| @@ -107,7 +107,10 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable { | |||
| 107 | // the exporting card owns (`Player::open_settings`, one card at a time), | 107 | // the exporting card owns (`Player::open_settings`, one card at a time), |
| 108 | // so a permission this oracle granted here would be a permission nobody | 108 | // so a permission this oracle granted here would be a permission nobody |
| 109 | // could ever observe. It is refused below, with every other card. | 109 | // could ever observe. It is refused below, with every other card. |
| 110 | - if action == ActionId::Theme || action == ActionId::Fullscreen || action == ActionId::SubtitleStyle { | 110 | + if action == ActionId::Theme |
| 111 | + || action == ActionId::Fullscreen | ||
| 112 | + || action == ActionId::SubtitleStyle | ||
| 113 | + { | ||
| 111 | return Enable::Yes; | 114 | return Enable::Yes; |
| 112 | } | 115 | } |
| 113 | if action == ActionId::Settings { | 116 | if action == ActionId::Settings { |
| @@ -198,7 +201,9 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable { | |||
| 198 | // filters samples, and a video clip has none of its own here: the sound | 201 | // filters samples, and a video clip has none of its own here: the sound |
| 199 | // is the audio lane's, clip for clip. | 202 | // is the audio lane's, clip for clip. |
| 200 | ActionId::Equalizer => match ctx.clip { | 203 | ActionId::Equalizer => match ctx.clip { |
| 201 | - Some((_, lane)) if lane.kind != LaneKind::Audio => Enable::Hidden("this clip is picture"), | 204 | + Some((_, lane)) if lane.kind != LaneKind::Audio => { |
| 205 | + Enable::Hidden("this clip is picture") | ||
| 206 | + } | ||
| 202 | _ => Enable::Yes, | 207 | _ => Enable::Yes, |
| 203 | }, | 208 | }, |
| 204 | // A grade is a picture setting and an audio clip has no picture. A fit | 209 | // 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 { | |||
| 252 | // question, like the regroup above. | 257 | // question, like the regroup above. |
| 253 | ActionId::Detach => match (ctx.clip, ctx.caption) { | 258 | ActionId::Detach => match (ctx.clip, ctx.caption) { |
| 254 | (Some((clip, _)), _) if clip.link.is_none() => Enable::No("this clip is not grouped"), | 259 | (Some((clip, _)), _) if clip.link.is_none() => Enable::No("this clip is not grouped"), |
| 255 | - (None, true) if ctx.caption_link.is_none() => { | 260 | + (None, true) if ctx.caption_link.is_none() => Enable::No("this caption is not grouped"), |
| 256 | - Enable::No("this caption is not grouped") | ||
| 257 | - } | ||
| 258 | _ => Enable::Yes, | 261 | _ => Enable::Yes, |
| 259 | }, | 262 | }, |
| 260 | // The manual group: a *selection* of placements, at most one per lane. | 263 | // The manual group: a *selection* of placements, at most one per lane. |
crates/app/src/player/actions.rsmodified+8 -3
| @@ -318,8 +318,8 @@ impl Player { | |||
| 318 | return Ctx::default(); | 318 | return Ctx::default(); |
| 319 | }; | 319 | }; |
| 320 | let on = on.or(self.selected.anchor()); | 320 | let on = on.or(self.selected.anchor()); |
| 321 | - let clip = on | 321 | + let clip = |
| 322 | - .and_then(|(lane, idx)| session.lane_clips(lane).get(idx).map(|clip| (*clip, lane))); | 322 | + on.and_then(|(lane, idx)| session.lane_clips(lane).get(idx).map(|clip| (*clip, lane))); |
| 323 | let caption = on.is_some_and(|(lane, idx)| { | 323 | let caption = on.is_some_and(|(lane, idx)| { |
| 324 | lane.kind == LaneKind::Subtitle && idx < session.sub_lane(lane).len() | 324 | lane.kind == LaneKind::Subtitle && idx < session.sub_lane(lane).len() |
| 325 | }); | 325 | }); |
| @@ -340,7 +340,12 @@ impl Player { | |||
| 340 | // The same pair read in the other index space: a subtitle lane's | 340 | // The same pair read in the other index space: a subtitle lane's |
| 341 | // own, where the box that was clicked is a caption. | 341 | // own, where the box that was clicked is a caption. |
| 342 | caption, | 342 | caption, |
| 343 | - caption_link: caption.then(|| on.and_then(|(lane, idx)| session.sub_lane(lane).get(idx)).and_then(|s| s.link)).flatten(), | 343 | + caption_link: caption |
| 344 | + .then(|| { | ||
| 345 | + on.and_then(|(lane, idx)| session.sub_lane(lane).get(idx)) | ||
| 346 | + .and_then(|s| s.link) | ||
| 347 | + }) | ||
| 348 | + .flatten(), | ||
| 344 | image: clip.is_some_and(|(clip, _)| { | 349 | image: clip.is_some_and(|(clip, _)| { |
| 345 | session | 350 | session |
| 346 | .sources() | 351 | .sources() |
crates/app/src/player/cards.rsmodified+32 -13
| @@ -69,8 +69,11 @@ impl Player { | |||
| 69 | // timeline yet to cut at it. | 69 | // timeline yet to cut at it. |
| 70 | self.pending_settings.1 = Some(fps); | 70 | self.pending_settings.1 = Some(fps); |
| 71 | self.notify_user( | 71 | self.notify_user( |
| 72 | - format!("PROJECT: {} fps — takes effect on the next file opened", fps_label(fps)) | 72 | + format!( |
| 73 | - .into(), | 73 | + "PROJECT: {} fps — takes effect on the next file opened", |
| 74 | + fps_label(fps) | ||
| 75 | + ) | ||
| 76 | + .into(), | ||
| 74 | ); | 77 | ); |
| 75 | } | 78 | } |
| 76 | cx.notify(); | 79 | cx.notify(); |
| @@ -84,7 +87,9 @@ impl Player { | |||
| 84 | /// seek, an edit, a reopen), not the stream already playing | 87 | /// seek, an edit, a reopen), not the stream already playing |
| 85 | /// ([`engine::PlaybackSession::set_sample_rate`]). | 88 | /// ([`engine::PlaybackSession::set_sample_rate`]). |
| 86 | pub(crate) fn apply_sample_rate(&mut self, rate: Option<u32>, cx: &mut Context<Self>) { | 89 | pub(crate) fn apply_sample_rate(&mut self, rate: Option<u32>, cx: &mut Context<Self>) { |
| 87 | - let label = |rate: Option<u32>| rate.map_or("the source's own rate".to_string(), |r| format!("{r} Hz")); | 90 | + let label = |rate: Option<u32>| { |
| 91 | + rate.map_or("the source's own rate".to_string(), |r| format!("{r} Hz")) | ||
| 92 | + }; | ||
| 88 | if let Some(session) = &mut self.session { | 93 | if let Some(session) = &mut self.session { |
| 89 | session.set_sample_rate(rate); | 94 | session.set_sample_rate(rate); |
| 90 | self.notify_user( | 95 | self.notify_user( |
| @@ -97,8 +102,11 @@ impl Player { | |||
| 97 | } else { | 102 | } else { |
| 98 | self.pending_settings.2 = rate; | 103 | self.pending_settings.2 = rate; |
| 99 | self.notify_user( | 104 | self.notify_user( |
| 100 | - format!("PROJECT SOUND: {} — takes effect on the next file opened", label(rate)) | 105 | + format!( |
| 101 | - .into(), | 106 | + "PROJECT SOUND: {} — takes effect on the next file opened", |
| 107 | + label(rate) | ||
| 108 | + ) | ||
| 109 | + .into(), | ||
| 102 | ); | 110 | ); |
| 103 | } | 111 | } |
| 104 | cx.notify(); | 112 | cx.notify(); |
| @@ -450,7 +458,12 @@ impl Player { | |||
| 450 | /// Both writes: `live` is the one that takes no undo step, which is what | 458 | /// Both writes: `live` is the one that takes no undo step, which is what |
| 451 | /// every sample *inside* a drag goes through -- | 459 | /// every sample *inside* a drag goes through -- |
| 452 | /// [`write_color`](Self::write_color)'s own rule. | 460 | /// [`write_color`](Self::write_color)'s own rule. |
| 453 | - pub(crate) fn write_transform(&mut self, params: TransformParams, live: bool, cx: &mut Context<Self>) { | 461 | + pub(crate) fn write_transform( |
| 462 | + &mut self, | ||
| 463 | + params: TransformParams, | ||
| 464 | + live: bool, | ||
| 465 | + cx: &mut Context<Self>, | ||
| 466 | + ) { | ||
| 454 | self.pending_transform = None; | 467 | self.pending_transform = None; |
| 455 | let Some((lane, idx)) = self.transform_open else { | 468 | let Some((lane, idx)) = self.transform_open else { |
| 456 | return; | 469 | return; |
| @@ -904,7 +917,11 @@ impl Player { | |||
| 904 | if let Err(e) = save_subtitle_style(self.sub_family.as_deref(), self.sub_text) { | 917 | if let Err(e) = save_subtitle_style(self.sub_family.as_deref(), self.sub_text) { |
| 905 | let path = subtitle_style_path(); | 918 | let path = subtitle_style_path(); |
| 906 | self.notify_user( | 919 | self.notify_user( |
| 907 | - format!("SUBTITLE STYLE COULD NOT BE KEPT — {} — {e}", path.display()).into(), | 920 | + format!( |
| 921 | + "SUBTITLE STYLE COULD NOT BE KEPT — {} — {e}", | ||
| 922 | + path.display() | ||
| 923 | + ) | ||
| 924 | + .into(), | ||
| 908 | ); | 925 | ); |
| 909 | } | 926 | } |
| 910 | cx.notify(); | 927 | cx.notify(); |
| @@ -1336,11 +1353,8 @@ impl Player { | |||
| 1336 | // card opens on that; one in no group has no sound to equalize and | 1353 | // card opens on that; one in no group has no sound to equalize and |
| 1337 | // falls to the lane refusal below, in the words it always used. | 1354 | // falls to the lane refusal below, in the words it always used. |
| 1338 | let anchor = match (self.selected.anchor(), self.session.as_ref()) { | 1355 | let anchor = match (self.selected.anchor(), self.session.as_ref()) { |
| 1339 | - (Some((lane, idx)), Some(session)) | 1356 | + (Some((lane, idx)), Some(session)) if lane.kind == LaneKind::Subtitle => { |
| 1340 | - if lane.kind == LaneKind::Subtitle => | 1357 | + caption_media_half(session, (lane, idx), LaneKind::Audio).or(self.selected.anchor()) |
| 1341 | - { | ||
| 1342 | - caption_media_half(session, (lane, idx), LaneKind::Audio) | ||
| 1343 | - .or(self.selected.anchor()) | ||
| 1344 | } | 1358 | } |
| 1345 | _ => self.selected.anchor(), | 1359 | _ => self.selected.anchor(), |
| 1346 | }; | 1360 | }; |
| @@ -1499,7 +1513,12 @@ impl Player { | |||
| 1499 | /// missing from the darkroom for. Returns `true` when a card was open | 1513 | /// missing from the darkroom for. Returns `true` when a card was open |
| 1500 | /// and ate the key, the caller's cue to `cx.notify()` and stop exactly | 1514 | /// and ate the key, the caller's cue to `cx.notify()` and stop exactly |
| 1501 | /// where each of these branches used to `return` inline. | 1515 | /// where each of these branches used to `return` inline. |
| 1502 | - pub(crate) fn param_card_key(&mut self, key: &str, shift: bool, cx: &mut Context<Self>) -> bool { | 1516 | + pub(crate) fn param_card_key( |
| 1517 | + &mut self, | ||
| 1518 | + key: &str, | ||
| 1519 | + shift: bool, | ||
| 1520 | + cx: &mut Context<Self>, | ||
| 1521 | + ) -> bool { | ||
| 1503 | // The one chord every param card answers to, wherever the pointer | 1522 | // The one chord every param card answers to, wherever the pointer |
| 1504 | // toggle sits in `dark_card_head` -- mouse and key reach the same | 1523 | // toggle sits in `dark_card_head` -- mouse and key reach the same |
| 1505 | // switch (DESIGN's repeated "some options are only reachable via | 1524 | // switch (DESIGN's repeated "some options are only reachable via |
crates/app/src/player/export.rsmodified+14 -9
| @@ -109,7 +109,9 @@ impl Player { | |||
| 109 | engine::decode::DecodeSession::open_range(&path, 0, 1).ok()?; | 109 | engine::decode::DecodeSession::open_range(&path, 0, 1).ok()?; |
| 110 | let frame = rx.recv().ok()?; | 110 | let frame = rx.recv().ok()?; |
| 111 | let buf = image::RgbaImage::from_raw(frame.width, frame.height, frame.bgra)?; | 111 | let buf = image::RgbaImage::from_raw(frame.width, frame.height, frame.bgra)?; |
| 112 | - Some(std::sync::Arc::new(RenderImage::new(vec![image::Frame::new(buf)]))) | 112 | + Some(std::sync::Arc::new(RenderImage::new(vec![ |
| 113 | + image::Frame::new(buf), | ||
| 114 | + ]))) | ||
| 113 | } | 115 | } |
| 114 | }); | 116 | }); |
| 115 | cx.spawn(async move |this, cx| { | 117 | cx.spawn(async move |this, cx| { |
| @@ -250,7 +252,12 @@ impl Player { | |||
| 250 | let scan = cx.background_executor().spawn({ | 252 | let scan = cx.background_executor().spawn({ |
| 251 | let (path, stream, progress) = (key.0.clone(), key.1, Arc::clone(&progress)); | 253 | let (path, stream, progress) = (key.0.clone(), key.1, Arc::clone(&progress)); |
| 252 | async move { | 254 | async move { |
| 253 | - engine::silence::levels_with_progress(&path, stream, (0., f64::INFINITY), &progress) | 255 | + engine::silence::levels_with_progress( |
| 256 | + &path, | ||
| 257 | + stream, | ||
| 258 | + (0., f64::INFINITY), | ||
| 259 | + &progress, | ||
| 260 | + ) | ||
| 254 | } | 261 | } |
| 255 | }); | 262 | }); |
| 256 | cx.spawn(async move |this, cx| { | 263 | cx.spawn(async move |this, cx| { |
| @@ -299,8 +306,7 @@ impl Player { | |||
| 299 | let Some(session) = &self.session else { | 306 | let Some(session) = &self.session else { |
| 300 | return; | 307 | return; |
| 301 | }; | 308 | }; |
| 302 | - let settings = | 309 | + let settings = export_settings( |
| 303 | - export_settings( | ||
| 304 | self.quality, | 310 | self.quality, |
| 305 | self.custom_mbps, | 311 | self.custom_mbps, |
| 306 | self.format, | 312 | self.format, |
| @@ -338,9 +344,9 @@ impl Player { | |||
| 338 | return; | 344 | return; |
| 339 | } | 345 | } |
| 340 | self.export_seat = Some((key.0.clone(), key.1, key.2.clone(), None)); | 346 | self.export_seat = Some((key.0.clone(), key.1, key.2.clone(), None)); |
| 341 | - let probed = cx.background_executor().spawn(async move { | 347 | + let probed = cx |
| 342 | - engine::export::planned_seats(&project, &meta, &settings) | 348 | + .background_executor() |
| 343 | - }); | 349 | + .spawn(async move { engine::export::planned_seats(&project, &meta, &settings) }); |
| 344 | cx.spawn(async move |this, cx| { | 350 | cx.spawn(async move |this, cx| { |
| 345 | let probed = probed.await; | 351 | let probed = probed.await; |
| 346 | this.update(cx, |this, cx| { | 352 | this.update(cx, |this, cx| { |
| @@ -676,8 +682,7 @@ impl Player { | |||
| 676 | if self.export.is_some() { | 682 | if self.export.is_some() { |
| 677 | return; | 683 | return; |
| 678 | } | 684 | } |
| 679 | - let mut settings = | 685 | + let mut settings = export_settings( |
| 680 | - export_settings( | ||
| 681 | self.quality, | 686 | self.quality, |
| 682 | self.custom_mbps, | 687 | self.custom_mbps, |
| 683 | self.format, | 688 | self.format, |
crates/app/src/player/library.rsmodified+47 -16
| @@ -153,7 +153,8 @@ impl Player { | |||
| 153 | // in the way of a re-add starting a fresh one | 153 | // in the way of a re-add starting a fresh one |
| 154 | // ([`Player::cache_media`]'s dedupe reads presence here). | 154 | // ([`Player::cache_media`]'s dedupe reads presence here). |
| 155 | if let Some(scan) = self.silence_bg.remove(&(path.to_path_buf(), stream)) { | 155 | if let Some(scan) = self.silence_bg.remove(&(path.to_path_buf(), stream)) { |
| 156 | - scan.cancel.store(true, std::sync::atomic::Ordering::Relaxed); | 156 | + scan.cancel |
| 157 | + .store(true, std::sync::atomic::Ordering::Relaxed); | ||
| 157 | } | 158 | } |
| 158 | // The picked row may be the one that just went, and the engine | 159 | // The picked row may be the one that just went, and the engine |
| 159 | // reseeks, so this owes the flag reset like every other edit. | 160 | // reseeks, so this owes the flag reset like every other edit. |
| @@ -332,7 +333,8 @@ impl Player { | |||
| 332 | // empty (`Player::cache_media`'s spawn checks this flag before it | 333 | // empty (`Player::cache_media`'s spawn checks this flag before it |
| 333 | // inserts). | 334 | // inserts). |
| 334 | for scan in self.silence_bg.values() { | 335 | for scan in self.silence_bg.values() { |
| 335 | - scan.cancel.store(true, std::sync::atomic::Ordering::Relaxed); | 336 | + scan.cancel |
| 337 | + .store(true, std::sync::atomic::Ordering::Relaxed); | ||
| 336 | } | 338 | } |
| 337 | self.silence_bg.clear(); | 339 | self.silence_bg.clear(); |
| 338 | // Every gesture in flight, dropped for `reset_after_reseek`'s reason | 340 | // Every gesture in flight, dropped for `reset_after_reseek`'s reason |
| @@ -383,7 +385,10 @@ impl Player { | |||
| 383 | // The timeline would otherwise keep playing under the preview -- two | 385 | // The timeline would otherwise keep playing under the preview -- two |
| 384 | // soundtracks at once -- so it is paused here and resumed on the way | 386 | // soundtracks at once -- so it is paused here and resumed on the way |
| 385 | // out only if this is what paused it ([`Player::close_preview`]). | 387 | // out only if this is what paused it ([`Player::close_preview`]). |
| 386 | - self.preview_playing = self.session.as_ref().is_some_and(PlaybackSession::is_playing); | 388 | + self.preview_playing = self |
| 389 | + .session | ||
| 390 | + .as_ref() | ||
| 391 | + .is_some_and(PlaybackSession::is_playing); | ||
| 387 | if let Some(session) = self.session.as_mut() { | 392 | if let Some(session) = self.session.as_mut() { |
| 388 | session.pause(); | 393 | session.pause(); |
| 389 | } | 394 | } |
| @@ -396,8 +401,11 @@ impl Player { | |||
| 396 | session.play(); | 401 | session.play(); |
| 397 | self.preview_session = Some(session); | 402 | self.preview_session = Some(session); |
| 398 | self.notify_user( | 403 | self.notify_user( |
| 399 | - format!("PREVIEWING {} — not on the timeline; esc stops it", file_name(path)) | 404 | + format!( |
| 400 | - .into(), | 405 | + "PREVIEWING {} — not on the timeline; esc stops it", |
| 406 | + file_name(path) | ||
| 407 | + ) | ||
| 408 | + .into(), | ||
| 401 | ); | 409 | ); |
| 402 | } | 410 | } |
| 403 | Err(e) => self.notify_user(format!("PREVIEW FAILED: {e}").into()), | 411 | Err(e) => self.notify_user(format!("PREVIEW FAILED: {e}").into()), |
| @@ -890,7 +898,11 @@ impl Player { | |||
| 890 | if let Err(e) = save_proxies_pref(on) { | 898 | if let Err(e) = save_proxies_pref(on) { |
| 891 | let path = proxies_pref_path(); | 899 | let path = proxies_pref_path(); |
| 892 | self.notify_user( | 900 | self.notify_user( |
| 893 | - format!("PROXIES DEFAULT COULD NOT BE KEPT — {} — {e}", path.display()).into(), | 901 | + format!( |
| 902 | + "PROXIES DEFAULT COULD NOT BE KEPT — {} — {e}", | ||
| 903 | + path.display() | ||
| 904 | + ) | ||
| 905 | + .into(), | ||
| 894 | ); | 906 | ); |
| 895 | } | 907 | } |
| 896 | self.notify_user(text.into()); | 908 | self.notify_user(text.into()); |
| @@ -931,7 +943,11 @@ impl Player { | |||
| 931 | if let Err(e) = save_auto_proxies_pref(on) { | 943 | if let Err(e) = save_auto_proxies_pref(on) { |
| 932 | let path = auto_proxies_pref_path(); | 944 | let path = auto_proxies_pref_path(); |
| 933 | self.notify_user( | 945 | self.notify_user( |
| 934 | - format!("AUTO PROXIES DEFAULT COULD NOT BE KEPT — {} — {e}", path.display()).into(), | 946 | + format!( |
| 947 | + "AUTO PROXIES DEFAULT COULD NOT BE KEPT — {} — {e}", | ||
| 948 | + path.display() | ||
| 949 | + ) | ||
| 950 | + .into(), | ||
| 935 | ); | 951 | ); |
| 936 | } | 952 | } |
| 937 | self.notify_user(text.into()); | 953 | self.notify_user(text.into()); |
| @@ -987,7 +1003,12 @@ impl Player { | |||
| 987 | /// The export guard again, and not for the caller's sake: an export can | 1003 | /// The export guard again, and not for the caller's sake: an export can |
| 988 | /// have started during the seconds the worker was reading, and a drop | 1004 | /// have started during the seconds the worker was reading, and a drop |
| 989 | /// during an export has always been a silent no-op. | 1005 | /// during an export has always been a silent no-op. |
| 990 | - pub(crate) fn take_import(&mut self, path: &std::path::Path, landed: Landed, cx: &mut Context<Self>) { | 1006 | + pub(crate) fn take_import( |
| 1007 | + &mut self, | ||
| 1008 | + path: &std::path::Path, | ||
| 1009 | + landed: Landed, | ||
| 1010 | + cx: &mut Context<Self>, | ||
| 1011 | + ) { | ||
| 991 | if self.exporting().is_some() { | 1012 | if self.exporting().is_some() { |
| 992 | return; | 1013 | return; |
| 993 | } | 1014 | } |
| @@ -1310,7 +1331,12 @@ impl Player { | |||
| 1310 | /// off the worker that read the file ([`read_ahead`]), like every other | 1331 | /// off the worker that read the file ([`read_ahead`]), like every other |
| 1311 | /// door's do, and what is left here is the push. The engine dedupes by | 1332 | /// door's do, and what is left here is the push. The engine dedupes by |
| 1312 | /// (file, track), so the same `.srt` twice is one row and says so. | 1333 | /// (file, track), so the same `.srt` twice is one row and says so. |
| 1313 | - pub(crate) fn take_subtitles(&mut self, path: &std::path::Path, subs: Subs, cx: &mut Context<Self>) { | 1334 | + pub(crate) fn take_subtitles( |
| 1335 | + &mut self, | ||
| 1336 | + path: &std::path::Path, | ||
| 1337 | + subs: Subs, | ||
| 1338 | + cx: &mut Context<Self>, | ||
| 1339 | + ) { | ||
| 1314 | let added = self | 1340 | let added = self |
| 1315 | .session | 1341 | .session |
| 1316 | .as_mut() | 1342 | .as_mut() |
| @@ -1330,10 +1356,7 @@ impl Player { | |||
| 1330 | cx: &mut Context<Self>, | 1356 | cx: &mut Context<Self>, |
| 1331 | ) { | 1357 | ) { |
| 1332 | let text = match added { | 1358 | let text = match added { |
| 1333 | - Some(Ok(0)) => format!( | 1359 | + Some(Ok(0)) => format!("{}'s subtitles are in the palette already", file_name(path)), |
| 1334 | - "{}'s subtitles are in the palette already", | ||
| 1335 | - file_name(path) | ||
| 1336 | - ), | ||
| 1337 | // Where they are and what to do with them: the tracks are in the | 1360 | // Where they are and what to do with them: the tracks are in the |
| 1338 | // palette and nothing is placed until one is dragged onto an S | 1361 | // palette and nothing is placed until one is dragged onto an S |
| 1339 | // track, which is the whole of what this door does. | 1362 | // track, which is the whole of what this door does. |
| @@ -1608,8 +1631,12 @@ impl Player { | |||
| 1608 | /// their own. | 1631 | /// their own. |
| 1609 | fn recovery_offer(project_path: &Path) -> Option<PathBuf> { | 1632 | fn recovery_offer(project_path: &Path) -> Option<PathBuf> { |
| 1610 | let sidecar = Self::autosave_path(project_path)?; | 1633 | let sidecar = Self::autosave_path(project_path)?; |
| 1611 | - let project_mtime = std::fs::metadata(project_path).and_then(|m| m.modified()).ok()?; | 1634 | + let project_mtime = std::fs::metadata(project_path) |
| 1612 | - let sidecar_mtime = std::fs::metadata(&sidecar).and_then(|m| m.modified()).ok()?; | 1635 | + .and_then(|m| m.modified()) |
| 1636 | + .ok()?; | ||
| 1637 | + let sidecar_mtime = std::fs::metadata(&sidecar) | ||
| 1638 | + .and_then(|m| m.modified()) | ||
| 1639 | + .ok()?; | ||
| 1613 | (sidecar_mtime > project_mtime).then_some(sidecar) | 1640 | (sidecar_mtime > project_mtime).then_some(sidecar) |
| 1614 | } | 1641 | } |
| 1615 | 1642 | ||
| @@ -1650,7 +1677,11 @@ impl Player { | |||
| 1650 | /// write is not something a person can do anything about right now, and a | 1677 | /// write is not something a person can do anything about right now, and a |
| 1651 | /// modal over it would be worse than the risk it is guarding against. | 1678 | /// modal over it would be worse than the risk it is guarding against. |
| 1652 | fn autosave_tick(&mut self, cx: &mut Context<Self>) { | 1679 | fn autosave_tick(&mut self, cx: &mut Context<Self>) { |
| 1653 | - if !Self::autosave_gate(self.autosave_armed, self.autosave_dirty, self.exporting().is_some()) { | 1680 | + if !Self::autosave_gate( |
| 1681 | + self.autosave_armed, | ||
| 1682 | + self.autosave_dirty, | ||
| 1683 | + self.exporting().is_some(), | ||
| 1684 | + ) { | ||
| 1654 | return; | 1685 | return; |
| 1655 | } | 1686 | } |
| 1656 | let now = Instant::now(); | 1687 | let now = Instant::now(); |
crates/app/src/player/timeline_edit.rsmodified+135 -57
| @@ -150,13 +150,11 @@ impl Player { | |||
| 150 | self.notify_user(format!("NOT GROUPED — {e}").into()); | 150 | self.notify_user(format!("NOT GROUPED — {e}").into()); |
| 151 | } | 151 | } |
| 152 | } | 152 | } |
| 153 | - None => { | 153 | + None => self.notify_user( |
| 154 | - self.notify_user( | 154 | + "NOTHING TO GROUP WITH — no clip on another track covers exactly these \ |
| 155 | - "NOTHING TO GROUP WITH — no clip on another track covers exactly these \ | ||
| 156 | frames; ctrl-click the clips to group instead" | 155 | frames; ctrl-click the clips to group instead" |
| 157 | - .into(), | 156 | + .into(), |
| 158 | - ) | 157 | + ), |
| 159 | - } | ||
| 160 | }, | 158 | }, |
| 161 | (None, ..) => {} | 159 | (None, ..) => {} |
| 162 | } | 160 | } |
| @@ -184,10 +182,12 @@ impl Player { | |||
| 184 | // A caption carrying a group id is a member, and a member goes the | 182 | // A caption carrying a group id is a member, and a member goes the |
| 185 | // way its group goes -- the engine's own door decides how much of | 183 | // way its group goes -- the engine's own door decides how much of |
| 186 | // that is media (and so a reseek) and how much is a lift. | 184 | // that is media (and so a reseek) and how much is a lift. |
| 187 | - let grouped = self | 185 | + let grouped = self.session.as_ref().is_some_and(|session| { |
| 188 | - .session | 186 | + session |
| 189 | - .as_ref() | 187 | + .sub_lane(lane) |
| 190 | - .is_some_and(|session| session.sub_lane(lane).get(idx).is_some_and(|s| s.link.is_some())); | 188 | + .get(idx) |
| 189 | + .is_some_and(|s| s.link.is_some()) | ||
| 190 | + }); | ||
| 191 | match grouped { | 191 | match grouped { |
| 192 | true => { | 192 | true => { |
| 193 | if self | 193 | if self |
| @@ -310,7 +310,14 @@ impl Player { | |||
| 310 | /// nothing is said about it. The engine reseeks, so all this owes is the | 310 | /// nothing is said about it. The engine reseeks, so all this owes is the |
| 311 | /// flag reset -- and the selection, whose index was that lane's own and now | 311 | /// flag reset -- and the selection, whose index was that lane's own and now |
| 312 | /// names a different clip there. | 312 | /// names a different clip there. |
| 313 | - pub(crate) fn move_clip(&mut self, from: Lane, idx: usize, to: Lane, x: Pixels, cx: &mut Context<Self>) { | 313 | + pub(crate) fn move_clip( |
| 314 | + &mut self, | ||
| 315 | + from: Lane, | ||
| 316 | + idx: usize, | ||
| 317 | + to: Lane, | ||
| 318 | + x: Pixels, | ||
| 319 | + cx: &mut Context<Self>, | ||
| 320 | + ) { | ||
| 314 | if self.exporting().is_some() { | 321 | if self.exporting().is_some() { |
| 315 | return; | 322 | return; |
| 316 | } | 323 | } |
| @@ -343,27 +350,23 @@ impl Player { | |||
| 343 | // front-end already knows: a lane's kind, and where the clip was. | 350 | // front-end already knows: a lane's kind, and where the clip was. |
| 344 | // Everything else that could refuse (a clip that is not there) | 351 | // Everything else that could refuse (a clip that is not there) |
| 345 | // cannot be dragged. | 352 | // cannot be dragged. |
| 346 | - false if from.kind != to.kind => { | 353 | + false if from.kind != to.kind => self.notify_user( |
| 347 | - self.notify_user( | 354 | + format!( |
| 348 | - format!( | 355 | + "NOT ON {} — that is a {kind} clip; drop it on a {lanes} lane", |
| 349 | - "NOT ON {} — that is a {kind} clip; drop it on a {lanes} lane", | 356 | + to.label() |
| 350 | - to.label() | ||
| 351 | - ) | ||
| 352 | - .into(), | ||
| 353 | ) | 357 | ) |
| 354 | - } | 358 | + .into(), |
| 359 | + ), | ||
| 355 | // Picked up and put back down where it was: a click, and a click | 360 | // Picked up and put back down where it was: a click, and a click |
| 356 | // says nothing. | 361 | // says nothing. |
| 357 | false if from == to && start == was => {} | 362 | false if from == to && start == was => {} |
| 358 | - false => { | 363 | + false => self.notify_user( |
| 359 | - self.notify_user( | 364 | + format!( |
| 360 | - format!( | 365 | + "NOT MOVED — another clip already covers those frames on {}", |
| 361 | - "NOT MOVED — another clip already covers those frames on {}", | 366 | + to.label() |
| 362 | - to.label() | ||
| 363 | - ) | ||
| 364 | - .into(), | ||
| 365 | ) | 367 | ) |
| 366 | - } | 368 | + .into(), |
| 369 | + ), | ||
| 367 | } | 370 | } |
| 368 | cx.notify(); | 371 | cx.notify(); |
| 369 | } | 372 | } |
| @@ -472,7 +475,11 @@ impl Player { | |||
| 472 | /// during the gesture -- an undo, another drop -- moves the indices gpui | 475 | /// during the gesture -- an undo, another drop -- moves the indices gpui |
| 473 | /// froze into the payload. | 476 | /// froze into the payload. |
| 474 | pub(crate) fn dragged_sub(&self, drag: &SubDrag) -> Option<usize> { | 477 | pub(crate) fn dragged_sub(&self, drag: &SubDrag) -> Option<usize> { |
| 475 | - live_idx(self.session.as_ref()?.sub_lane(drag.lane), drag.idx, drag.sub) | 478 | + live_idx( |
| 479 | + self.session.as_ref()?.sub_lane(drag.lane), | ||
| 480 | + drag.idx, | ||
| 481 | + drag.sub, | ||
| 482 | + ) | ||
| 476 | } | 483 | } |
| 477 | 484 | ||
| 478 | /// A placed caption let go at window `x` over subtitle lane `to`: it lands | 485 | /// A placed caption let go at window `x` over subtitle lane `to`: it lands |
| @@ -604,7 +611,10 @@ impl Player { | |||
| 604 | lane.label(), | 611 | lane.label(), |
| 605 | old.label() | 612 | old.label() |
| 606 | ), | 613 | ), |
| 607 | - None => format!("{} IS SHOWN — its captions are over the picture", lane.label()), | 614 | + None => format!( |
| 615 | + "{} IS SHOWN — its captions are over the picture", | ||
| 616 | + lane.label() | ||
| 617 | + ), | ||
| 608 | }; | 618 | }; |
| 609 | self.notify_user(text.into()); | 619 | self.notify_user(text.into()); |
| 610 | cx.notify(); | 620 | cx.notify(); |
| @@ -644,7 +654,13 @@ impl Player { | |||
| 644 | /// over: [`Player::preview_ghost`]'s twin, refused for any lane that is not a | 654 | /// over: [`Player::preview_ghost`]'s twin, refused for any lane that is not a |
| 645 | /// subtitle lane -- which is the answer [`Project::move_sub`] gives at the | 655 | /// subtitle lane -- which is the answer [`Project::move_sub`] gives at the |
| 646 | /// release. | 656 | /// release. |
| 647 | - pub(crate) fn preview_ghost_sub(&mut self, drag: &SubDrag, to: Lane, x: Pixels, cx: &mut Context<Self>) { | 657 | + pub(crate) fn preview_ghost_sub( |
| 658 | + &mut self, | ||
| 659 | + drag: &SubDrag, | ||
| 660 | + to: Lane, | ||
| 661 | + x: Pixels, | ||
| 662 | + cx: &mut Context<Self>, | ||
| 663 | + ) { | ||
| 648 | let (start, _) = self.sub_drop_frame(drag.sub, x); | 664 | let (start, _) = self.sub_drop_frame(drag.sub, x); |
| 649 | let ghost = Ghost { | 665 | let ghost = Ghost { |
| 650 | lane: to, | 666 | lane: to, |
| @@ -659,7 +675,13 @@ impl Player { | |||
| 659 | /// The same for a palette row on its way down: it lands at the frame it is | 675 | /// The same for a palette row on its way down: it lands at the frame it is |
| 660 | /// let go on ([`Player::place_frame`]) and is as long as the whole track it | 676 | /// let go on ([`Player::place_frame`]) and is as long as the whole track it |
| 661 | /// names. | 677 | /// names. |
| 662 | - pub(crate) fn preview_ghost_pick(&mut self, track: usize, to: Lane, x: Pixels, cx: &mut Context<Self>) { | 678 | + pub(crate) fn preview_ghost_pick( |
| 679 | + &mut self, | ||
| 680 | + track: usize, | ||
| 681 | + to: Lane, | ||
| 682 | + x: Pixels, | ||
| 683 | + cx: &mut Context<Self>, | ||
| 684 | + ) { | ||
| 663 | let ghost = Ghost { | 685 | let ghost = Ghost { |
| 664 | lane: to, | 686 | lane: to, |
| 665 | start: self.place_frame(x).0, | 687 | start: self.place_frame(x).0, |
| @@ -683,7 +705,12 @@ impl Player { | |||
| 683 | /// the scroll clamp pins the bed's right edge to the duration, and the | 705 | /// the scroll clamp pins the bed's right edge to the duration, and the |
| 684 | /// pointer has no pixel past it. The upgrade is to let the scroll clamp | 706 | /// pointer has no pixel past it. The upgrade is to let the scroll clamp |
| 685 | /// leave a screen of empty bed after the end, the way every NLE does. | 707 | /// leave a screen of empty bed after the end, the way every NLE does. |
| 686 | - pub(crate) fn drop_frame(&self, from: Lane, idx: usize, x: Pixels) -> Option<(u32, Option<u32>)> { | 708 | + pub(crate) fn drop_frame( |
| 709 | + &self, | ||
| 710 | + from: Lane, | ||
| 711 | + idx: usize, | ||
| 712 | + x: Pixels, | ||
| 713 | + ) -> Option<(u32, Option<u32>)> { | ||
| 687 | let clip = self.session.as_ref()?.lane_clips(from).get(idx).copied()?; | 714 | let clip = self.session.as_ref()?.lane_clips(from).get(idx).copied()?; |
| 688 | let marks = self.snap_targets(Some((from, idx))); | 715 | let marks = self.snap_targets(Some((from, idx))); |
| 689 | Some(landing( | 716 | Some(landing( |
| @@ -727,7 +754,13 @@ impl Player { | |||
| 727 | /// [`Player::drop_frame`] will commit, worked out on every move of the drag, | 754 | /// [`Player::drop_frame`] will commit, worked out on every move of the drag, |
| 728 | /// so what the eye was promised is where the release puts it. A pointer that | 755 | /// so what the eye was promised is where the release puts it. A pointer that |
| 729 | /// has wandered off the bed promises nothing. | 756 | /// has wandered off the bed promises nothing. |
| 730 | - pub(crate) fn preview_drop(&mut self, from: Lane, idx: usize, x: Pixels, cx: &mut Context<Self>) { | 757 | + pub(crate) fn preview_drop( |
| 758 | + &mut self, | ||
| 759 | + from: Lane, | ||
| 760 | + idx: usize, | ||
| 761 | + x: Pixels, | ||
| 762 | + cx: &mut Context<Self>, | ||
| 763 | + ) { | ||
| 731 | let cue = self.drop_frame(from, idx, x).and_then(|(_, cue)| cue); | 764 | let cue = self.drop_frame(from, idx, x).and_then(|(_, cue)| cue); |
| 732 | self.set_cue(cue, x, cx); | 765 | self.set_cue(cue, x, cx); |
| 733 | } | 766 | } |
| @@ -746,7 +779,13 @@ impl Player { | |||
| 746 | /// are one answer -- and its own length at this zoom. A lane of the other | 779 | /// are one answer -- and its own length at this zoom. A lane of the other |
| 747 | /// kind refuses the drop ([`Project::move_clip`]), and the shadow says so | 780 | /// kind refuses the drop ([`Project::move_clip`]), and the shadow says so |
| 748 | /// before the release does. | 781 | /// before the release does. |
| 749 | - pub(crate) fn preview_ghost(&mut self, drag: &ClipDrag, to: Lane, x: Pixels, cx: &mut Context<Self>) { | 782 | + pub(crate) fn preview_ghost( |
| 783 | + &mut self, | ||
| 784 | + drag: &ClipDrag, | ||
| 785 | + to: Lane, | ||
| 786 | + x: Pixels, | ||
| 787 | + cx: &mut Context<Self>, | ||
| 788 | + ) { | ||
| 750 | let ghost = self | 789 | let ghost = self |
| 751 | .dragged(drag) | 790 | .dragged(drag) |
| 752 | .and_then(|idx| self.drop_frame(drag.lane, idx, x)) | 791 | .and_then(|idx| self.drop_frame(drag.lane, idx, x)) |
| @@ -802,7 +841,13 @@ impl Player { | |||
| 802 | /// width -- the length the library row already reports. A file this lane | 841 | /// width -- the length the library row already reports. A file this lane |
| 803 | /// cannot hold ([`lane_refuses`]) is tinted as refused, which is the answer | 842 | /// cannot hold ([`lane_refuses`]) is tinted as refused, which is the answer |
| 804 | /// the release would give in words. | 843 | /// the release would give in words. |
| 805 | - pub(crate) fn preview_ghost_asset(&mut self, path: &Path, to: Lane, x: Pixels, cx: &mut Context<Self>) { | 844 | + pub(crate) fn preview_ghost_asset( |
| 845 | + &mut self, | ||
| 846 | + path: &Path, | ||
| 847 | + to: Lane, | ||
| 848 | + x: Pixels, | ||
| 849 | + cx: &mut Context<Self>, | ||
| 850 | + ) { | ||
| 806 | let ghost = Ghost { | 851 | let ghost = Ghost { |
| 807 | lane: to, | 852 | lane: to, |
| 808 | start: self.place_frame(x).0, | 853 | start: self.place_frame(x).0, |
| @@ -974,7 +1019,8 @@ impl Player { | |||
| 974 | .get(clip.source) | 1019 | .get(clip.source) |
| 975 | .and_then(|entry| self.syncs.get(&entry.path)) | 1020 | .and_then(|entry| self.syncs.get(&entry.path)) |
| 976 | .is_some_and(|keys| { | 1021 | .is_some_and(|keys| { |
| 977 | - keys.binary_search(&(clip.in_frame + (now - clip.start))).is_ok() | 1022 | + keys.binary_search(&(clip.in_frame + (now - clip.start))) |
| 1023 | + .is_ok() | ||
| 978 | }) | 1024 | }) |
| 979 | }) | 1025 | }) |
| 980 | }) | 1026 | }) |
| @@ -1022,7 +1068,13 @@ impl Player { | |||
| 1022 | /// one of the clips a ctrl-click selection already holds keeps that | 1068 | /// one of the clips a ctrl-click selection already holds keeps that |
| 1023 | /// selection, so the menu's Group is about the whole of it. A right-click | 1069 | /// selection, so the menu's Group is about the whole of it. A right-click |
| 1024 | /// anywhere else is the single mark, exactly as a left press is. | 1070 | /// anywhere else is the single mark, exactly as a left press is. |
| 1025 | - pub(crate) fn open_menu(&mut self, lane: Lane, idx: usize, at: Point<Pixels>, cx: &mut Context<Self>) { | 1071 | + pub(crate) fn open_menu( |
| 1072 | + &mut self, | ||
| 1073 | + lane: Lane, | ||
| 1074 | + idx: usize, | ||
| 1075 | + at: Point<Pixels>, | ||
| 1076 | + cx: &mut Context<Self>, | ||
| 1077 | + ) { | ||
| 1026 | if self.modal() { | 1078 | if self.modal() { |
| 1027 | return; | 1079 | return; |
| 1028 | } | 1080 | } |
| @@ -1041,7 +1093,14 @@ impl Player { | |||
| 1041 | /// Opens the same menu on the gap under the pointer instead of a clip -- | 1093 | /// Opens the same menu on the gap under the pointer instead of a clip -- |
| 1042 | /// the empty-bench-space door to [`Player::close_gap`]. Nothing is | 1094 | /// the empty-bench-space door to [`Player::close_gap`]. Nothing is |
| 1043 | /// selected: a gap owns no clip to select, unlike [`Player::open_menu`]. | 1095 | /// selected: a gap owns no clip to select, unlike [`Player::open_menu`]. |
| 1044 | - pub(crate) fn open_gap_menu(&mut self, lane: Lane, start: u32, frames: u32, at: Point<Pixels>, cx: &mut Context<Self>) { | 1096 | + pub(crate) fn open_gap_menu( |
| 1097 | + &mut self, | ||
| 1098 | + lane: Lane, | ||
| 1099 | + start: u32, | ||
| 1100 | + frames: u32, | ||
| 1101 | + at: Point<Pixels>, | ||
| 1102 | + cx: &mut Context<Self>, | ||
| 1103 | + ) { | ||
| 1045 | if self.modal() { | 1104 | if self.modal() { |
| 1046 | return; | 1105 | return; |
| 1047 | } | 1106 | } |
| @@ -1063,7 +1122,13 @@ impl Player { | |||
| 1063 | /// of step with each other, which no lane's own gap is worth. A take | 1122 | /// of step with each other, which no lane's own gap is worth. A take |
| 1064 | /// whose gap does not match on its other lane is refused in words, not | 1123 | /// whose gap does not match on its other lane is refused in words, not |
| 1065 | /// silence ([`engine::Project::gap_take_scope`]). | 1124 | /// silence ([`engine::Project::gap_take_scope`]). |
| 1066 | - pub(crate) fn close_gap(&mut self, lane: Lane, start: u32, frames: u32, cx: &mut Context<Self>) { | 1125 | + pub(crate) fn close_gap( |
| 1126 | + &mut self, | ||
| 1127 | + lane: Lane, | ||
| 1128 | + start: u32, | ||
| 1129 | + frames: u32, | ||
| 1130 | + cx: &mut Context<Self>, | ||
| 1131 | + ) { | ||
| 1067 | let Some(session) = self.session.as_mut() else { | 1132 | let Some(session) = self.session.as_mut() else { |
| 1068 | return; | 1133 | return; |
| 1069 | }; | 1134 | }; |
| @@ -1268,10 +1333,7 @@ impl Player { | |||
| 1268 | /// and not with the one that would have been there unzoomed. The one | 1333 | /// and not with the one that would have been there unzoomed. The one |
| 1269 | /// question a trim, a grab and a drop all ask. | 1334 | /// question a trim, a grab and a drop all ask. |
| 1270 | pub(crate) fn frame_under(&self, x: Pixels) -> u32 { | 1335 | pub(crate) fn frame_under(&self, x: Pixels) -> u32 { |
| 1271 | - frame_at( | 1336 | + frame_at(self.scale.time_at(px_along(x, self.ruler.get())), self.fps) |
| 1272 | - self.scale.time_at(px_along(x, self.ruler.get())), | ||
| 1273 | - self.fps, | ||
| 1274 | - ) | ||
| 1275 | } | 1337 | } |
| 1276 | 1338 | ||
| 1277 | /// The release: the whole drag reaches the engine as one edit, so it is one | 1339 | /// The release: the whole drag reaches the engine as one edit, so it is one |
| @@ -1388,10 +1450,13 @@ impl Player { | |||
| 1388 | return; | 1450 | return; |
| 1389 | }; | 1451 | }; |
| 1390 | self.mark_dirty(); | 1452 | self.mark_dirty(); |
| 1391 | - let set = self.session.as_mut().is_some_and(|session| match fade.is_in { | 1453 | + let set = self |
| 1392 | - true => session.set_fade_in(fade.lane, fade.idx, fade.to), | 1454 | + .session |
| 1393 | - false => session.set_fade_out(fade.lane, fade.idx, fade.to), | 1455 | + .as_mut() |
| 1394 | - }); | 1456 | + .is_some_and(|session| match fade.is_in { |
| 1457 | + true => session.set_fade_in(fade.lane, fade.idx, fade.to), | ||
| 1458 | + false => session.set_fade_out(fade.lane, fade.idx, fade.to), | ||
| 1459 | + }); | ||
| 1395 | if set { | 1460 | if set { |
| 1396 | cx.notify(); | 1461 | cx.notify(); |
| 1397 | } | 1462 | } |
| @@ -1426,7 +1491,9 @@ impl Player { | |||
| 1426 | [a, b] if a.0 == b.0 && a.1.abs_diff(b.1) == 1 => Some((a.0, a.1.min(b.1))), | 1491 | [a, b] if a.0 == b.0 && a.1.abs_diff(b.1) == 1 => Some((a.0, a.1.min(b.1))), |
| 1427 | _ => self.selected.anchor(), | 1492 | _ => self.selected.anchor(), |
| 1428 | }) else { | 1493 | }) else { |
| 1429 | - self.notify_user("NOTHING TO CROSSFADE — select an audio clip that has a neighbour".into()); | 1494 | + self.notify_user( |
| 1495 | + "NOTHING TO CROSSFADE — select an audio clip that has a neighbour".into(), | ||
| 1496 | + ); | ||
| 1430 | cx.notify(); | 1497 | cx.notify(); |
| 1431 | return; | 1498 | return; |
| 1432 | }; | 1499 | }; |
| @@ -1456,7 +1523,9 @@ impl Player { | |||
| 1456 | [a, b] if a.0 == b.0 && a.1.abs_diff(b.1) == 1 => Some((a.0, a.1.min(b.1))), | 1523 | [a, b] if a.0 == b.0 && a.1.abs_diff(b.1) == 1 => Some((a.0, a.1.min(b.1))), |
| 1457 | _ => self.selected.anchor(), | 1524 | _ => self.selected.anchor(), |
| 1458 | }) else { | 1525 | }) else { |
| 1459 | - self.notify_user("NOTHING TO DISSOLVE — select a video clip that has a neighbour".into()); | 1526 | + self.notify_user( |
| 1527 | + "NOTHING TO DISSOLVE — select a video clip that has a neighbour".into(), | ||
| 1528 | + ); | ||
| 1460 | cx.notify(); | 1529 | cx.notify(); |
| 1461 | return; | 1530 | return; |
| 1462 | }; | 1531 | }; |
| @@ -1465,7 +1534,11 @@ impl Player { | |||
| 1465 | return; | 1534 | return; |
| 1466 | }; | 1535 | }; |
| 1467 | let removing = session.transition_out_of(lane, idx) > 0; | 1536 | let removing = session.transition_out_of(lane, idx) > 0; |
| 1468 | - let frames = if removing { 0 } else { self.fps.round().max(1.) as u32 }; | 1537 | + let frames = if removing { |
| 1538 | + 0 | ||
| 1539 | + } else { | ||
| 1540 | + self.fps.round().max(1.) as u32 | ||
| 1541 | + }; | ||
| 1469 | if !session.set_transition_out(lane, idx, frames) { | 1542 | if !session.set_transition_out(lane, idx, frames) { |
| 1470 | self.notify_user( | 1543 | self.notify_user( |
| 1471 | "NOTHING TO DISSOLVE — it takes two video clips sitting end to end on one lane" | 1544 | "NOTHING TO DISSOLVE — it takes two video clips sitting end to end on one lane" |
| @@ -1489,10 +1562,14 @@ impl Player { | |||
| 1489 | }) else { | 1562 | }) else { |
| 1490 | return clip; | 1563 | return clip; |
| 1491 | }; | 1564 | }; |
| 1492 | - let to = self.followed(trim, (lane, idx), match trim.edge { | 1565 | + let to = self.followed( |
| 1493 | - Edge::Start => clip.start, | 1566 | + trim, |
| 1494 | - Edge::End => clip.end(), | 1567 | + (lane, idx), |
| 1495 | - }); | 1568 | + match trim.edge { |
| 1569 | + Edge::Start => clip.start, | ||
| 1570 | + Edge::End => clip.end(), | ||
| 1571 | + }, | ||
| 1572 | + ); | ||
| 1496 | let still = self.session.as_ref().is_some_and(|session| { | 1573 | let still = self.session.as_ref().is_some_and(|session| { |
| 1497 | session | 1574 | session |
| 1498 | .sources() | 1575 | .sources() |
| @@ -1507,9 +1584,10 @@ impl Player { | |||
| 1507 | /// caption in the dragged group follows by the same delta, against its own | 1584 | /// caption in the dragged group follows by the same delta, against its own |
| 1508 | /// walls. | 1585 | /// walls. |
| 1509 | pub(crate) fn trimmed_sub(&self, lane: Lane, idx: usize, sub: SubClip) -> SubClip { | 1586 | pub(crate) fn trimmed_sub(&self, lane: Lane, idx: usize, sub: SubClip) -> SubClip { |
| 1510 | - let Some(trim) = self.trim.filter(|t| { | 1587 | + let Some(trim) = self |
| 1511 | - (t.lane, t.idx) == (lane, idx) || (t.link.is_some() && t.link == sub.link) | 1588 | + .trim |
| 1512 | - }) else { | 1589 | + .filter(|t| (t.lane, t.idx) == (lane, idx) || (t.link.is_some() && t.link == sub.link)) |
| 1590 | + else { | ||
| 1513 | return sub; | 1591 | return sub; |
| 1514 | }; | 1592 | }; |
| 1515 | let to = self.followed( | 1593 | let to = self.followed( |
crates/app/src/player/transport.rsmodified+21 -6
| @@ -51,8 +51,7 @@ impl Player { | |||
| 51 | // seen without a manual replay after every nudge. Checked off the | 51 | // seen without a manual replay after every nudge. Checked off the |
| 52 | // engine's own clock, not a frame counter this pump keeps -- the | 52 | // engine's own clock, not a frame counter this pump keeps -- the |
| 53 | // same `now()` [`Player::step`] reads. | 53 | // same `now()` [`Player::step`] reads. |
| 54 | - if session.is_playing() | 54 | + if session.is_playing() && should_loop_restart(frame_at(session.now(), fps), self.loop_trim) |
| 55 | - && should_loop_restart(frame_at(session.now(), fps), self.loop_trim) | ||
| 56 | { | 55 | { |
| 57 | let start = self.loop_trim.map_or(0, |(lo, _)| lo); | 56 | let start = self.loop_trim.map_or(0, |(lo, _)| lo); |
| 58 | session.seek(f64::from(start) / fps); | 57 | session.seek(f64::from(start) / fps); |
| @@ -456,10 +455,22 @@ mod tests { | |||
| 456 | /// otherwise silently stop covering). | 455 | /// otherwise silently stop covering). |
| 457 | #[test] | 456 | #[test] |
| 458 | fn the_loop_restarts_only_on_the_crossing_with_loop_on() { | 457 | fn the_loop_restarts_only_on_the_crossing_with_loop_on() { |
| 459 | - assert!(crosses_into_loop(Transport::Playing, Transport::Ended, true)); | 458 | + assert!(crosses_into_loop( |
| 460 | - assert!(!crosses_into_loop(Transport::Playing, Transport::Ended, false)); | 459 | + Transport::Playing, |
| 460 | + Transport::Ended, | ||
| 461 | + true | ||
| 462 | + )); | ||
| 463 | + assert!(!crosses_into_loop( | ||
| 464 | + Transport::Playing, | ||
| 465 | + Transport::Ended, | ||
| 466 | + false | ||
| 467 | + )); | ||
| 461 | assert!(!crosses_into_loop(Transport::Ended, Transport::Ended, true)); | 468 | assert!(!crosses_into_loop(Transport::Ended, Transport::Ended, true)); |
| 462 | - assert!(!crosses_into_loop(Transport::Ended, Transport::Playing, true)); | 469 | + assert!(!crosses_into_loop( |
| 470 | + Transport::Ended, | ||
| 471 | + Transport::Playing, | ||
| 472 | + true | ||
| 473 | + )); | ||
| 463 | } | 474 | } |
| 464 | 475 | ||
| 465 | /// `loop_restart_frame` picks the seek target the crossing above plays | 476 | /// `loop_restart_frame` picks the seek target the crossing above plays |
| @@ -493,7 +504,11 @@ mod tests { | |||
| 493 | let loop_trim = Some((30, 60)); | 504 | let loop_trim = Some((30, 60)); |
| 494 | let armed = loop_on || loop_trim.is_some(); | 505 | let armed = loop_on || loop_trim.is_some(); |
| 495 | assert!(armed, "loop_trim alone must arm the crossing"); | 506 | assert!(armed, "loop_trim alone must arm the crossing"); |
| 496 | - assert!(crosses_into_loop(Transport::Playing, Transport::Ended, armed)); | 507 | + assert!(crosses_into_loop( |
| 508 | + Transport::Playing, | ||
| 509 | + Transport::Ended, | ||
| 510 | + armed | ||
| 511 | + )); | ||
| 497 | assert_eq!(loop_restart_frame(loop_on, loop_trim), Some(30)); | 512 | assert_eq!(loop_restart_frame(loop_on, loop_trim), Some(30)); |
| 498 | } | 513 | } |
| 499 | 514 | ||
crates/app/src/player/view.rsmodified+24 -10
| @@ -170,7 +170,13 @@ impl Player { | |||
| 170 | /// One clip's fit policy set, whichever asked: the stroke that steps to the | 170 | /// One clip's fit policy set, whichever asked: the stroke that steps to the |
| 171 | /// next one and the list that names one outright come through here, so they | 171 | /// next one and the list that names one outright come through here, so they |
| 172 | /// cannot differ in what they do or in what they say they did. | 172 | /// cannot differ in what they do or in what they say they did. |
| 173 | - pub(crate) fn apply_fit(&mut self, lane: Lane, idx: usize, fit: FitPolicy, cx: &mut Context<Self>) { | 173 | + pub(crate) fn apply_fit( |
| 174 | + &mut self, | ||
| 175 | + lane: Lane, | ||
| 176 | + idx: usize, | ||
| 177 | + fit: FitPolicy, | ||
| 178 | + cx: &mut Context<Self>, | ||
| 179 | + ) { | ||
| 174 | if let Some(session) = &mut self.session | 180 | if let Some(session) = &mut self.session |
| 175 | && session.set_fit(lane, idx, fit) | 181 | && session.set_fit(lane, idx, fit) |
| 176 | { | 182 | { |
| @@ -247,8 +253,12 @@ impl Player { | |||
| 247 | if view.bed <= 0. || view.duration <= 0. { | 253 | if view.bed <= 0. || view.duration <= 0. { |
| 248 | return; | 254 | return; |
| 249 | } | 255 | } |
| 250 | - let (thumb_x, thumb_w) = | 256 | + let (thumb_x, thumb_w) = scroll_thumb( |
| 251 | - scroll_thumb(view.bed, view.duration, view.scale.start.max(0.), view.span()); | 257 | + view.bed, |
| 258 | + view.duration, | ||
| 259 | + view.scale.start.max(0.), | ||
| 260 | + view.span(), | ||
| 261 | + ); | ||
| 252 | let at = px_along(x, self.scroll_track.get()); | 262 | let at = px_along(x, self.scroll_track.get()); |
| 253 | let grab = match (thumb_x..thumb_x + thumb_w).contains(&at) { | 263 | let grab = match (thumb_x..thumb_x + thumb_w).contains(&at) { |
| 254 | true => at - thumb_x, | 264 | true => at - thumb_x, |
| @@ -263,11 +273,13 @@ impl Player { | |||
| 263 | // leaves is always a real place inside it -- at the thumb's floor | 273 | // leaves is always a real place inside it -- at the thumb's floor |
| 264 | // width as much as anywhere else. | 274 | // width as much as anywhere else. |
| 265 | false => { | 275 | false => { |
| 266 | - let start = f64::from((at - thumb_w / 2.).max(0.)) | 276 | + let start = f64::from((at - thumb_w / 2.).max(0.)) / f64::from(view.bed.max(1.)) |
| 267 | - / f64::from(view.bed.max(1.)) | ||
| 268 | * view.duration; | 277 | * view.duration; |
| 269 | self.scale = View { | 278 | self.scale = View { |
| 270 | - scale: Scale { start, ..view.scale }, | 279 | + scale: Scale { |
| 280 | + start, | ||
| 281 | + ..view.scale | ||
| 282 | + }, | ||
| 271 | ..view | 283 | ..view |
| 272 | } | 284 | } |
| 273 | .settled(); | 285 | .settled(); |
| @@ -297,7 +309,10 @@ impl Player { | |||
| 297 | // is the clamp's to hold, exactly as every scrollbar's is. | 309 | // is the clamp's to hold, exactly as every scrollbar's is. |
| 298 | let start = f64::from((at - grab).max(0.)) / f64::from(view.bed.max(1.)) * view.duration; | 310 | let start = f64::from((at - grab).max(0.)) / f64::from(view.bed.max(1.)) * view.duration; |
| 299 | self.scale = View { | 311 | self.scale = View { |
| 300 | - scale: Scale { start, ..view.scale }, | 312 | + scale: Scale { |
| 313 | + start, | ||
| 314 | + ..view.scale | ||
| 315 | + }, | ||
| 301 | ..view | 316 | ..view |
| 302 | } | 317 | } |
| 303 | .settled(); | 318 | .settled(); |
| @@ -335,9 +350,8 @@ impl Player { | |||
| 335 | // the track by [`lanes_thumb`], so the grab this leaves is always | 350 | // the track by [`lanes_thumb`], so the grab this leaves is always |
| 336 | // a real place inside it. | 351 | // a real place inside it. |
| 337 | false => { | 352 | false => { |
| 338 | - let to = self.lanes_taken( | 353 | + let to = |
| 339 | - (at - thumb_h / 2.).max(0.) / (track - thumb_h).max(1.) * max, | 354 | + self.lanes_taken((at - thumb_h / 2.).max(0.) / (track - thumb_h).max(1.) * max); |
| 340 | - ); | ||
| 341 | self.lanes_scroll | 355 | self.lanes_scroll |
| 342 | .set_offset(point(self.lanes_scroll.offset().x, px(-to))); | 356 | .set_offset(point(self.lanes_scroll.offset().x, px(-to))); |
| 343 | thumb_h / 2. | 357 | thumb_h / 2. |
crates/app/src/render.rsmodified+17 -8
| @@ -9,7 +9,11 @@ use crate::*; | |||
| 9 | /// not a card drawn over it, so it goes before a menu close or a preview | 9 | /// not a card drawn over it, so it goes before a menu close or a preview |
| 10 | /// close gets a look at the same key. See the call site in [`Player::render`] | 10 | /// close gets a look at the same key. See the call site in [`Player::render`] |
| 11 | /// for the deliberate order this buys with a preview open underneath. | 11 | /// for the deliberate order this buys with a preview open underneath. |
| 12 | -pub(crate) fn escape_leaves_player_fullscreen(key: &str, ctrl: bool, player_fullscreen: bool) -> bool { | 12 | +pub(crate) fn escape_leaves_player_fullscreen( |
| 13 | + key: &str, | ||
| 14 | + ctrl: bool, | ||
| 15 | + player_fullscreen: bool, | ||
| 16 | +) -> bool { | ||
| 13 | key == ESCAPE && !ctrl && player_fullscreen | 17 | key == ESCAPE && !ctrl && player_fullscreen |
| 14 | } | 18 | } |
| 15 | 19 | ||
| @@ -99,8 +103,7 @@ impl Player { | |||
| 99 | // broken -- so it says what it wants instead. The window | 103 | // broken -- so it says what it wants instead. The window |
| 100 | // is already the drop target. | 104 | // is already the drop target. |
| 101 | .or_else(|| { | 105 | .or_else(|| { |
| 102 | - (self.active_session().is_none()) | 106 | + (self.active_session().is_none()).then(|| empty_hint().into_any_element()) |
| 103 | - .then(|| empty_hint().into_any_element()) | ||
| 104 | }), | 107 | }), |
| 105 | ) | 108 | ) |
| 106 | // After the picture, so the plate is drawn over it rather than | 109 | // After the picture, so the plate is drawn over it rather than |
| @@ -374,7 +377,11 @@ impl Render for Player { | |||
| 374 | // legacy "Add at playhead" button's pointer one, live only | 377 | // legacy "Add at playhead" button's pointer one, live only |
| 375 | // where a row is actually picked so a bare enter elsewhere | 378 | // where a row is actually picked so a bare enter elsewhere |
| 376 | // keeps meaning whatever it already means below. | 379 | // keeps meaning whatever it already means below. |
| 377 | - if key == "enter" && this.dock_src_active && this.selected_asset.is_some() && this.exporting().is_none() { | 380 | + if key == "enter" |
| 381 | + && this.dock_src_active | ||
| 382 | + && this.selected_asset.is_some() | ||
| 383 | + && this.exporting().is_none() | ||
| 384 | + { | ||
| 378 | if let Some((path, stream)) = this.selected_asset.clone() { | 385 | if let Some((path, stream)) = this.selected_asset.clone() { |
| 379 | this.insert_source(&path, stream, None, None, cx); | 386 | this.insert_source(&path, stream, None, None, cx); |
| 380 | } | 387 | } |
| @@ -657,10 +664,12 @@ impl Render for Player { | |||
| 657 | .flex_1() | 664 | .flex_1() |
| 658 | .min_h(px(0.)) | 665 | .min_h(px(0.)) |
| 659 | .flex() | 666 | .flex() |
| 660 | - .child(self.library( | 667 | + .child( |
| 661 | - self.split_px(Split::Library, window.viewport_size()), | 668 | + self.library( |
| 662 | - cx, | 669 | + self.split_px(Split::Library, window.viewport_size()), |
| 663 | - )) | 670 | + cx, |
| 671 | + ), | ||
| 672 | + ) | ||
| 664 | // The seams, one per pair of regions: what a hand | 673 | // The seams, one per pair of regions: what a hand |
| 665 | // drags to give a panel more room and its | 674 | // drags to give a panel more room and its |
| 666 | // neighbour less ([`divider`]). | 675 | // neighbour less ([`divider`]). |
crates/app/src/subs.rsmodified+13 -3
| @@ -168,7 +168,11 @@ pub(crate) fn open_ahead( | |||
| 168 | /// import into, which fills the library instead. One function because they are | 168 | /// import into, which fills the library instead. One function because they are |
| 169 | /// one read -- the engine's two doors differ by which lanes come up empty | 169 | /// one read -- the engine's two doors differ by which lanes come up empty |
| 170 | /// ([`engine::PlaybackSession::open_library`]), not by what they walk. | 170 | /// ([`engine::PlaybackSession::open_library`]), not by what they walk. |
| 171 | -pub(crate) fn open_whole(path: &std::path::Path, place: bool, stage: &std::sync::atomic::AtomicU8) -> Landed { | 171 | +pub(crate) fn open_whole( |
| 172 | + path: &std::path::Path, | ||
| 173 | + place: bool, | ||
| 174 | + stage: &std::sync::atomic::AtomicU8, | ||
| 175 | +) -> Landed { | ||
| 172 | use std::sync::atomic::Ordering::Relaxed; | 176 | use std::sync::atomic::Ordering::Relaxed; |
| 173 | let opened = match place { | 177 | let opened = match place { |
| 174 | true => PlaybackSession::open(path), | 178 | true => PlaybackSession::open(path), |
| @@ -270,7 +274,10 @@ pub(crate) fn walk_subtitles(path: &std::path::Path) -> Subs { | |||
| 270 | /// this runs on the worker ([`open_ahead`]), never the render thread; an | 274 | /// this runs on the worker ([`open_ahead`]), never the render thread; an |
| 271 | /// import splits the two halves across the hop instead ([`read_ahead`] walks, | 275 | /// import splits the two halves across the hop instead ([`read_ahead`] walks, |
| 272 | /// [`subtitle_tail`] pushes). | 276 | /// [`subtitle_tail`] pushes). |
| 273 | -pub(crate) fn subtitle_notice(session: &mut PlaybackSession, path: &std::path::Path) -> Option<String> { | 277 | +pub(crate) fn subtitle_notice( |
| 278 | + session: &mut PlaybackSession, | ||
| 279 | + path: &std::path::Path, | ||
| 280 | +) -> Option<String> { | ||
| 274 | subtitle_tail(session, walk_subtitles(path)) | 281 | subtitle_tail(session, walk_subtitles(path)) |
| 275 | } | 282 | } |
| 276 | 283 | ||
| @@ -606,7 +613,10 @@ pub(crate) fn sub_pick_after_removal(picked: usize, removed: usize, left: usize) | |||
| 606 | picked.min(left.saturating_sub(1)) | 613 | picked.min(left.saturating_sub(1)) |
| 607 | } | 614 | } |
| 608 | 615 | ||
| 609 | -pub(crate) fn sub_pick_name(tracks: &[engine::subtitle::SubtitleTrack], track: usize) -> Option<String> { | 616 | +pub(crate) fn sub_pick_name( |
| 617 | + tracks: &[engine::subtitle::SubtitleTrack], | ||
| 618 | + track: usize, | ||
| 619 | +) -> Option<String> { | ||
| 610 | subtitle_rows(tracks).into_iter().find_map(|group| { | 620 | subtitle_rows(tracks).into_iter().find_map(|group| { |
| 611 | let row = group.rows.iter().find(|row| row.track == track)?; | 621 | let row = group.rows.iter().find(|row| row.track == track)?; |
| 612 | let track = match group.rows.len() > 1 { | 622 | let track = match group.rows.len() > 1 { |
crates/app/src/tests/cards.rsmodified+6 -2
| @@ -2009,6 +2009,8 @@ fn a_maximized_card_can_never_rise_above_the_picture_no_matter_the_bench_height( | |||
| 2009 | /// invent. | 2009 | /// invent. |
| 2010 | #[test] | 2010 | #[test] |
| 2011 | fn a_maximized_card_reopens_exactly_as_left_across_a_restart() { | 2011 | fn a_maximized_card_reopens_exactly_as_left_across_a_restart() { |
| 2012 | + let _config_env = config_env_lock(); | ||
| 2013 | + | ||
| 2012 | let dir = std::env::temp_dir().join(format!( | 2014 | let dir = std::env::temp_dir().join(format!( |
| 2013 | "edith-test-maximized-{}-{}", | 2015 | "edith-test-maximized-{}-{}", |
| 2014 | std::process::id(), | 2016 | std::process::id(), |
| @@ -2018,8 +2020,8 @@ fn a_maximized_card_reopens_exactly_as_left_across_a_restart() { | |||
| 2018 | .as_nanos() | 2020 | .as_nanos() |
| 2019 | )); | 2021 | )); |
| 2020 | std::fs::create_dir_all(&dir).unwrap(); | 2022 | std::fs::create_dir_all(&dir).unwrap(); |
| 2021 | - // Scoped to this test alone, the same reasoning `tests/media.rs`'s own | 2023 | + // `config_env_lock` serializes every test that changes this process-wide |
| 2022 | - // XDG_CONFIG_HOME mutation gives: nothing else reads this file. | 2024 | + // path. |
| 2023 | unsafe { std::env::set_var("XDG_CONFIG_HOME", &dir) }; | 2025 | unsafe { std::env::set_var("XDG_CONFIG_HOME", &dir) }; |
| 2024 | 2026 | ||
| 2025 | // Nothing written yet: the default (not maximized), not a crash on a | 2027 | // Nothing written yet: the default (not maximized), not a crash on a |
| @@ -2073,6 +2075,8 @@ fn darkroom_preview_mounts_stop_and_drag_scrub() { | |||
| 2073 | && preview.contains("this.preview_scrub_to(event.position.x, true, cx)"), | 2075 | && preview.contains("this.preview_scrub_to(event.position.x, true, cx)"), |
| 2074 | "the mounted preview scrub no longer starts its drag-and-seek gesture" | 2076 | "the mounted preview scrub no longer starts its drag-and-seek gesture" |
| 2075 | ); | 2077 | ); |
| 2078 | +} | ||
| 2079 | + | ||
| 2076 | /// Source management must stay reachable in the Darkroom itself: per-row | 2080 | /// Source management must stay reachable in the Darkroom itself: per-row |
| 2077 | /// stand-in control/progress, pointer Add-at-playhead alongside its `↵` chord, | 2081 | /// stand-in control/progress, pointer Add-at-playhead alongside its `↵` chord, |
| 2078 | /// and the three legacy source questions as dock filters. The test reads the | 2082 | /// and the three legacy source questions as dock filters. The test reads the |
crates/app/src/tests/editing.rsmodified+65 -28
| @@ -80,8 +80,7 @@ fn an_import_adds_a_row_at_its_own_length_and_leaves_the_lanes_alone() { | |||
| 80 | /// an export. | 80 | /// an export. |
| 81 | #[test] | 81 | #[test] |
| 82 | fn a_song_opens_the_window_by_itself() { | 82 | fn a_song_opens_the_window_by_itself() { |
| 83 | - let mut session = | 83 | + let mut session = PlaybackSession::open(asset("test_tone.mp3")).expect("a song is a timeline"); |
| 84 | - PlaybackSession::open(asset("test_tone.mp3")).expect("a song is a timeline"); | ||
| 85 | session.set_gain(0.0); | 84 | session.set_gain(0.0); |
| 86 | // The source's own path, which is the canonical one a row carries. | 85 | // The source's own path, which is the canonical one a row carries. |
| 87 | let path = session.sources()[0].path.clone(); | 86 | 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() { | |||
| 345 | ); | 344 | ); |
| 346 | // ...and the same reading with a clip under it is the clip menu, untouched: | 345 | // ...and the same reading with a clip under it is the clip menu, untouched: |
| 347 | // the flag is off wherever a `Clip` was clicked. | 346 | // the flag is off wherever a `Clip` was clicked. |
| 348 | - assert!(menu_items(Ctx { | 347 | + assert!( |
| 349 | - timeline: true, | 348 | + menu_items(Ctx { |
| 350 | - ..Ctx::default() | 349 | + timeline: true, |
| 351 | - }) | 350 | + ..Ctx::default() |
| 352 | - .contains(&ActionId::Cut)); | 351 | + }) |
| 352 | + .contains(&ActionId::Cut) | ||
| 353 | + ); | ||
| 353 | } | 354 | } |
| 354 | 355 | ||
| 355 | /// A timeline with a subtitle palette and an empty subtitle lane: what a | 356 | /// A timeline with a subtitle palette and an empty subtitle lane: what a |
| @@ -383,7 +384,9 @@ fn one_second(start: u32) -> SubClip { | |||
| 383 | fn a_refused_caption_drop_leaves_the_mark_where_it_was() { | 384 | fn a_refused_caption_drop_leaves_the_mark_where_it_was() { |
| 384 | use crate::sub_mark; | 385 | use crate::sub_mark; |
| 385 | let (mut session, lane) = with_subtitle_lane(); | 386 | let (mut session, lane) = with_subtitle_lane(); |
| 386 | - session.place_sub(lane, 0, one_second(0)).expect("A goes down"); | 387 | + session |
| 388 | + .place_sub(lane, 0, one_second(0)) | ||
| 389 | + .expect("A goes down"); | ||
| 387 | session | 390 | session |
| 388 | .place_sub(lane, 60, one_second(0)) | 391 | .place_sub(lane, 60, one_second(0)) |
| 389 | .expect("B goes down after it"); | 392 | .expect("B goes down after it"); |
| @@ -517,8 +520,14 @@ fn a_caption_anchor_names_the_media_half_of_its_group() { | |||
| 517 | .place_sub(lane, 0, one_second(0)) | 520 | .place_sub(lane, 0, one_second(0)) |
| 518 | .expect("the caption goes down"); | 521 | .expect("the caption goes down"); |
| 519 | // Ungrouped: no pictures and no sound behind the words. | 522 | // Ungrouped: no pictures and no sound behind the words. |
| 520 | - assert_eq!(caption_media_half(&session, (lane, 0), LaneKind::Video), None); | 523 | + assert_eq!( |
| 521 | - assert_eq!(caption_media_half(&session, (lane, 0), LaneKind::Audio), None); | 524 | + caption_media_half(&session, (lane, 0), LaneKind::Video), |
| 525 | + None | ||
| 526 | + ); | ||
| 527 | + assert_eq!( | ||
| 528 | + caption_media_half(&session, (lane, 0), LaneKind::Audio), | ||
| 529 | + None | ||
| 530 | + ); | ||
| 522 | // Grouped with the take -- whose sound rides along unasked -- both halves | 531 | // Grouped with the take -- whose sound rides along unasked -- both halves |
| 523 | // answer by lane and index. | 532 | // answer by lane and index. |
| 524 | session | 533 | session |
| @@ -601,7 +610,9 @@ fn the_playhead_actions_still_work_with_a_caption_marked() { | |||
| 601 | // And the edits themselves, on a timeline holding a placed caption: the | 610 | // And the edits themselves, on a timeline holding a placed caption: the |
| 602 | // split at the playhead and the rejoin at the seam it leaves. | 611 | // split at the playhead and the rejoin at the seam it leaves. |
| 603 | let (mut session, lane) = with_subtitle_lane(); | 612 | let (mut session, lane) = with_subtitle_lane(); |
| 604 | - session.place_sub(lane, 0, one_second(0)).expect("it goes down"); | 613 | + session |
| 614 | + .place_sub(lane, 0, one_second(0)) | ||
| 615 | + .expect("it goes down"); | ||
| 605 | let clips = session.lane_clips(Lane::V1).len(); | 616 | let clips = session.lane_clips(Lane::V1).len(); |
| 606 | assert!(session.cut_at(2.0), "the playhead splits the clip under it"); | 617 | assert!(session.cut_at(2.0), "the playhead splits the clip under it"); |
| 607 | assert_eq!(session.lane_clips(Lane::V1).len(), clips + 1); | 618 | 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() { | |||
| 665 | ..clip | 676 | ..clip |
| 666 | }; | 677 | }; |
| 667 | assert_eq!(slow.frames(), 240, "a quarter speed is four times as long"); | 678 | assert_eq!(slow.frames(), 240, "a quarter speed is four times as long"); |
| 668 | - assert!(offered(&slow, v1, ActionId::Cut, 34), "34 is a source frame"); | 679 | + assert!( |
| 680 | + offered(&slow, v1, ActionId::Cut, 34), | ||
| 681 | + "34 is a source frame" | ||
| 682 | + ); | ||
| 669 | assert!(!offered(&slow, v1, ActionId::Cut, 35)); | 683 | assert!(!offered(&slow, v1, ActionId::Cut, 35)); |
| 670 | assert_eq!( | 684 | assert_eq!( |
| 671 | on(&slow, v1, ActionId::Cut, 35).why(), | 685 | 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() { | |||
| 785 | assert!(on(&clip, lane, action, 60).why().is_some()); | 799 | assert!(on(&clip, lane, action, 60).why().is_some()); |
| 786 | } | 800 | } |
| 787 | assert!(matches!(on(&clip, v1, ActionId::Cut, 30), Enable::No(_))); | 801 | assert!(matches!(on(&clip, v1, ActionId::Cut, 30), Enable::No(_))); |
| 788 | - assert!(matches!(on(&clip, v1, ActionId::Regroup, 60), Enable::No(_))); | 802 | + assert!(matches!( |
| 803 | + on(&clip, v1, ActionId::Regroup, 60), | ||
| 804 | + Enable::No(_) | ||
| 805 | + )); | ||
| 789 | assert!(matches!(on(&clip, v1, ActionId::Detach, 0), Enable::No(_))); | 806 | assert!(matches!(on(&clip, v1, ActionId::Detach, 0), Enable::No(_))); |
| 790 | // Every refusal says something, and says it short enough to sit in the | 807 | // Every refusal says something, and says it short enough to sit in the |
| 791 | // menu's right-hand column beside a label -- the still's included, which | 808 | // 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() { | |||
| 943 | // for it, never the card that grows. | 960 | // for it, never the card that grows. |
| 944 | let items = MENU_ITEMS.len() + 1; // Properties | 961 | let items = MENU_ITEMS.len() + 1; // Properties |
| 945 | let floor = size(px(640.), px(360.)); | 962 | let floor = size(px(640.), px(360.)); |
| 946 | - assert!(MENU_PAD * 2. + menu_rows_h(items, floor) <= 360., "too tall"); | 963 | + assert!( |
| 964 | + MENU_PAD * 2. + menu_rows_h(items, floor) <= 360., | ||
| 965 | + "too tall" | ||
| 966 | + ); | ||
| 947 | assert!( | 967 | assert!( |
| 948 | menu_rows_h(items, floor) / MENU_ROW_H >= 12., | 968 | menu_rows_h(items, floor) / MENU_ROW_H >= 12., |
| 949 | "too few items visible to scan on the smallest window" | 969 | "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() { | |||
| 1093 | assert!(row_enable(RowItem::RemoveWithClips, placed).yes()); | 1113 | assert!(row_enable(RowItem::RemoveWithClips, placed).yes()); |
| 1094 | let unplaced = row_items(live); | 1114 | let unplaced = row_items(live); |
| 1095 | assert!(unplaced.contains(&RowItem::Remove) && !unplaced.contains(&RowItem::RemoveWithClips)); | 1115 | assert!(unplaced.contains(&RowItem::Remove) && !unplaced.contains(&RowItem::RemoveWithClips)); |
| 1096 | - assert!(!row_enable( | 1116 | + assert!( |
| 1097 | - RowItem::RemoveWithClips, | 1117 | + !row_enable( |
| 1098 | - RowCtx { exporting: true, ..placed } | 1118 | + RowItem::RemoveWithClips, |
| 1099 | - ) | 1119 | + RowCtx { |
| 1100 | - .yes()); | 1120 | + exporting: true, |
| 1121 | + ..placed | ||
| 1122 | + } | ||
| 1123 | + ) | ||
| 1124 | + .yes() | ||
| 1125 | + ); | ||
| 1101 | assert!(!row_enable(RowItem::Add, RowCtx::default()).yes()); | 1126 | assert!(!row_enable(RowItem::Add, RowCtx::default()).yes()); |
| 1102 | // Every refusal is short enough to sit in the hint column beside its | 1127 | // Every refusal is short enough to sit in the hint column beside its |
| 1103 | // label, the clip menu's rule. | 1128 | // label, the clip menu's rule. |
| @@ -1288,7 +1313,10 @@ fn a_clip_box_is_never_narrower_than_its_target() { | |||
| 1288 | pps: 0.1, | 1313 | pps: 0.1, |
| 1289 | start: 0., | 1314 | start: 0., |
| 1290 | }; | 1315 | }; |
| 1291 | - assert!(far.width_px(2.) < 1., "the fixture is not zoomed out enough"); | 1316 | + assert!( |
| 1317 | + far.width_px(2.) < 1., | ||
| 1318 | + "the fixture is not zoomed out enough" | ||
| 1319 | + ); | ||
| 1292 | assert_eq!(clip_width(far.width_px(2.)), HIT_MIN); | 1320 | assert_eq!(clip_width(far.width_px(2.)), HIT_MIN); |
| 1293 | // Zero is the floor's own case: a clip trimmed to nothing, and the | 1321 | // Zero is the floor's own case: a clip trimmed to nothing, and the |
| 1294 | // width a lane draws before its first frame is measured. | 1322 | // 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() { | |||
| 1378 | let file = dir.join("lanes.edith"); | 1406 | let file = dir.join("lanes.edith"); |
| 1379 | session.save_project(&file).expect("save the project"); | 1407 | session.save_project(&file).expect("save the project"); |
| 1380 | let text = std::fs::read_to_string(&file).expect("read it back"); | 1408 | let text = std::fs::read_to_string(&file).expect("read it back"); |
| 1381 | - let (sound, rest): (Vec<&str>, Vec<&str>) = | 1409 | + let (sound, rest): (Vec<&str>, Vec<&str>) = text.lines().partition(|l| l.starts_with("audio ")); |
| 1382 | - text.lines().partition(|l| l.starts_with("audio ")); | ||
| 1383 | std::fs::write( | 1410 | std::fs::write( |
| 1384 | &file, | 1411 | &file, |
| 1385 | format!("{}\n{}\n", rest.join("\n"), sound.join("\n")), | 1412 | 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() { | |||
| 1479 | // The same door with a *second audio stream* of a file already there: | 1506 | // The same door with a *second audio stream* of a file already there: |
| 1480 | // a new source entry, the same picture, and the row that was dragged | 1507 | // a new source entry, the same picture, and the row that was dragged |
| 1481 | // is what plays. This is the whole user-facing point of the slice. | 1508 | // is what plays. This is the whole user-facing point of the slice. |
| 1482 | - let mut session = | 1509 | + let mut session = PlaybackSession::open(asset("test_multilang.mp4")).expect("open the fixture"); |
| 1483 | - PlaybackSession::open(asset("test_multilang.mp4")).expect("open the fixture"); | ||
| 1484 | session.set_gain(0.0); | 1510 | session.set_gain(0.0); |
| 1485 | let path = session.sources()[0].path.clone(); | 1511 | let path = session.sources()[0].path.clone(); |
| 1486 | let frames = session.file_frames(&path); | 1512 | let frames = session.file_frames(&path); |
| @@ -1920,7 +1946,8 @@ fn a_grouped_clip_on_an_added_lane_closes_its_hole_with_its_caption() { | |||
| 1920 | "its grouped caption went with it, not left as an orphan" | 1946 | "its grouped caption went with it, not left as an orphan" |
| 1921 | ); | 1947 | ); |
| 1922 | assert_eq!( | 1948 | assert_eq!( |
| 1923 | - session.sub_lane(sub_lane)[0].start, 30, | 1949 | + session.sub_lane(sub_lane)[0].start, |
| 1950 | + 30, | ||
| 1924 | "and the hole under it closed: the caption after it slid up" | 1951 | "and the hole under it closed: the caption after it slid up" |
| 1925 | ); | 1952 | ); |
| 1926 | } | 1953 | } |
| @@ -2106,7 +2133,11 @@ fn nudge_edge_moves_one_frame_and_clamps_to_the_room() { | |||
| 2106 | assert_eq!(nudge_edge(50, 1, 0, 100), 51); | 2133 | assert_eq!(nudge_edge(50, 1, 0, 100), 51); |
| 2107 | assert_eq!(nudge_edge(50, -1, 0, 100), 49); | 2134 | assert_eq!(nudge_edge(50, -1, 0, 100), 49); |
| 2108 | assert_eq!(nudge_edge(0, -1, 0, 100), 0, "the room's own floor holds"); | 2135 | assert_eq!(nudge_edge(0, -1, 0, 100), 0, "the room's own floor holds"); |
| 2109 | - assert_eq!(nudge_edge(100, 1, 0, 100), 100, "the room's own ceiling holds"); | 2136 | + assert_eq!( |
| 2137 | + nudge_edge(100, 1, 0, 100), | ||
| 2138 | + 100, | ||
| 2139 | + "the room's own ceiling holds" | ||
| 2140 | + ); | ||
| 2110 | // A 4px-wide clip's room can be one frame wide: still clamps, never | 2141 | // A 4px-wide clip's room can be one frame wide: still clamps, never |
| 2111 | // panics on the narrow end. | 2142 | // panics on the narrow end. |
| 2112 | assert_eq!(nudge_edge(5, 1, 5, 5), 5); | 2143 | assert_eq!(nudge_edge(5, 1, 5, 5), 5); |
| @@ -2119,8 +2150,14 @@ fn should_loop_restart_only_at_the_windows_far_edge() { | |||
| 2119 | use crate::timeline_math::should_loop_restart; | 2150 | use crate::timeline_math::should_loop_restart; |
| 2120 | assert!(!should_loop_restart(40, Some((30, 60)))); | 2151 | assert!(!should_loop_restart(40, Some((30, 60)))); |
| 2121 | assert!(should_loop_restart(60, Some((30, 60)))); | 2152 | assert!(should_loop_restart(60, Some((30, 60)))); |
| 2122 | - assert!(should_loop_restart(61, Some((30, 60))), "past it restarts too"); | 2153 | + assert!( |
| 2123 | - assert!(!should_loop_restart(60, None), "loop-trim off restarts nothing"); | 2154 | + should_loop_restart(61, Some((30, 60))), |
| 2155 | + "past it restarts too" | ||
| 2156 | + ); | ||
| 2157 | + assert!( | ||
| 2158 | + !should_loop_restart(60, None), | ||
| 2159 | + "loop-trim off restarts nothing" | ||
| 2160 | + ); | ||
| 2124 | } | 2161 | } |
| 2125 | 2162 | ||
| 2126 | /// The paused-then-started repro this predicate was blamed for and cleared | 2163 | /// The paused-then-started repro this predicate was blamed for and cleared |
crates/app/src/tests/layout.rsmodified+191 -57
| @@ -102,7 +102,10 @@ fn no_colour_is_written_outside_the_theme() { | |||
| 102 | .lines() | 102 | .lines() |
| 103 | .filter(|l| l.contains("rgb(0x") || l.contains("rgba(0x")) | 103 | .filter(|l| l.contains("rgb(0x") || l.contains("rgba(0x")) |
| 104 | .collect(); | 104 | .collect(); |
| 105 | - assert!(stray.is_empty(), "colour written outside the theme: {stray:?}"); | 105 | + assert!( |
| 106 | + stray.is_empty(), | ||
| 107 | + "colour written outside the theme: {stray:?}" | ||
| 108 | + ); | ||
| 106 | } | 109 | } |
| 107 | 110 | ||
| 108 | /// The literal-grep above is blind to a hue arriving through a theme | 111 | /// 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() { | |||
| 127 | (hex.len() == 8 && !hex.ends_with("ff")).then_some(name.trim()) | 130 | (hex.len() == 8 && !hex.ends_with("ff")).then_some(name.trim()) |
| 128 | }) | 131 | }) |
| 129 | .collect(); | 132 | .collect(); |
| 130 | - assert!(alpha_roles.len() >= 8, "the theme's alpha-carrying roles moved; this scan is blind"); | 133 | + assert!( |
| 134 | + alpha_roles.len() >= 8, | ||
| 135 | + "the theme's alpha-carrying roles moved; this scan is blind" | ||
| 136 | + ); | ||
| 131 | 137 | ||
| 132 | let source = ui_source(); | 138 | let source = ui_source(); |
| 133 | let mut misuses = Vec::new(); | 139 | let mut misuses = Vec::new(); |
| @@ -136,7 +142,10 @@ fn an_alpha_carrying_role_never_reaches_rgb() { | |||
| 136 | misuses.push(*role); | 142 | misuses.push(*role); |
| 137 | } | 143 | } |
| 138 | } | 144 | } |
| 139 | - assert!(misuses.is_empty(), "alpha-carrying role(s) reaching rgb() instead of rgba(): {misuses:?}"); | 145 | + assert!( |
| 146 | + misuses.is_empty(), | ||
| 147 | + "alpha-carrying role(s) reaching rgb() instead of rgba(): {misuses:?}" | ||
| 148 | + ); | ||
| 140 | } | 149 | } |
| 141 | 150 | ||
| 142 | /// "It scrolls" is not "it can be found": at the 640x360 floor the timeline | 151 | /// "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() { | |||
| 145 | /// being scrolled, or it is an instruction nobody can carry out. | 154 | /// being scrolled, or it is an instruction nobody can carry out. |
| 146 | #[test] | 155 | #[test] |
| 147 | fn the_line_about_what_is_below_the_fold_counts_what_is_still_below_it() { | 156 | fn the_line_about_what_is_below_the_fold_counts_what_is_still_below_it() { |
| 148 | - | ||
| 149 | // The timeline is a region and not the window: its chrome -- the | 157 | // The timeline is a region and not the window: its chrome -- the |
| 150 | // scrollbar strip's row included, which is the larger of the two the | 158 | // scrollbar strip's row included, which is the larger of the two the |
| 151 | // zoom can leave in it -- and one whole lane fit the share it may take | 159 | // 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() { | |||
| 199 | push_notice(&mut q, "NOTHING ADDED — no video stream".into()); | 207 | push_notice(&mut q, "NOTHING ADDED — no video stream".into()); |
| 200 | push_notice(&mut q, "NOTHING ADDED — the file is not there".into()); | 208 | push_notice(&mut q, "NOTHING ADDED — the file is not there".into()); |
| 201 | assert_eq!(q.len(), 2); | 209 | assert_eq!(q.len(), 2); |
| 202 | - assert_eq!(q.front().map(|n: &gpui::SharedString| n.as_ref()), Some("NOTHING ADDED — no video stream")); | 210 | + assert_eq!( |
| 211 | + q.front().map(|n: &gpui::SharedString| n.as_ref()), | ||
| 212 | + Some("NOTHING ADDED — no video stream") | ||
| 213 | + ); | ||
| 203 | 214 | ||
| 204 | // A held key that refuses says its one sentence once: the count on the | 215 | // A held key that refuses says its one sentence once: the count on the |
| 205 | // bar is a count of messages, not of how long the key was held. | 216 | // 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() { | |||
| 212 | push_notice(&mut q, format!("SCAN FAILED: {i}").into()); | 223 | push_notice(&mut q, format!("SCAN FAILED: {i}").into()); |
| 213 | } | 224 | } |
| 214 | assert_eq!(q.len(), NOTICES_MAX); | 225 | assert_eq!(q.len(), NOTICES_MAX); |
| 215 | - assert_eq!(q.back().map(|n: &gpui::SharedString| n.as_ref()), Some("SCAN FAILED: 10")); | 226 | + assert_eq!( |
| 227 | + q.back().map(|n: &gpui::SharedString| n.as_ref()), | ||
| 228 | + Some("SCAN FAILED: 10") | ||
| 229 | + ); | ||
| 216 | 230 | ||
| 217 | // Answering the bar brings the next one up, oldest first. | 231 | // Answering the bar brings the next one up, oldest first. |
| 218 | let front = q.pop_front(); | 232 | let front = q.pop_front(); |
| @@ -225,7 +239,10 @@ fn a_second_message_queues_behind_the_first_instead_of_erasing_it() { | |||
| 225 | #[test] | 239 | #[test] |
| 226 | fn an_export_outcome_jumps_the_queue() { | 240 | fn an_export_outcome_jumps_the_queue() { |
| 227 | let mut q = std::collections::VecDeque::new(); | 241 | let mut q = std::collections::VecDeque::new(); |
| 228 | - push_notice(&mut q, "PROXY READY for a.mp4 — Proxies on cuts on it".into()); | 242 | + push_notice( |
| 243 | + &mut q, | ||
| 244 | + "PROXY READY for a.mp4 — Proxies on cuts on it".into(), | ||
| 245 | + ); | ||
| 229 | push_notice(&mut q, "SUBTITLES b.srt — 1 track(s) in the palette".into()); | 246 | push_notice(&mut q, "SUBTITLES b.srt — 1 track(s) in the palette".into()); |
| 230 | push_notice(&mut q, format!("{EXPORT_DONE}out.mp4").into()); | 247 | push_notice(&mut q, format!("{EXPORT_DONE}out.mp4").into()); |
| 231 | assert_eq!(q.len(), 3); | 248 | assert_eq!(q.len(), 3); |
| @@ -237,7 +254,10 @@ fn an_export_outcome_jumps_the_queue() { | |||
| 237 | 254 | ||
| 238 | // A failed export is the same class: the outcome, whichever it was. | 255 | // A failed export is the same class: the outcome, whichever it was. |
| 239 | let mut q = std::collections::VecDeque::new(); | 256 | let mut q = std::collections::VecDeque::new(); |
| 240 | - push_notice(&mut q, "PROXY READY for a.mp4 — Proxies on cuts on it".into()); | 257 | + push_notice( |
| 258 | + &mut q, | ||
| 259 | + "PROXY READY for a.mp4 — Proxies on cuts on it".into(), | ||
| 260 | + ); | ||
| 241 | push_notice(&mut q, "EXPORT FAILED: disk full".into()); | 261 | push_notice(&mut q, "EXPORT FAILED: disk full".into()); |
| 242 | assert_eq!( | 262 | assert_eq!( |
| 243 | q.front().map(|n: &gpui::SharedString| n.as_ref()), | 263 | q.front().map(|n: &gpui::SharedString| n.as_ref()), |
| @@ -250,8 +270,14 @@ fn an_export_outcome_jumps_the_queue() { | |||
| 250 | #[test] | 270 | #[test] |
| 251 | fn a_message_wears_the_colour_its_own_words_say() { | 271 | fn a_message_wears_the_colour_its_own_words_say() { |
| 252 | assert_eq!(notice_tone("SCAN FAILED: no audio"), STATUS_ERROR()); | 272 | assert_eq!(notice_tone("SCAN FAILED: no audio"), STATUS_ERROR()); |
| 253 | - assert_eq!(notice_tone(&format!("{EXPORT_DONE}out.mp4")), STATUS_SUCCESS()); | 273 | + assert_eq!( |
| 254 | - assert_eq!(notice_tone("NOTHING DETACHED — not grouped"), STATUS_WARNING()); | 274 | + notice_tone(&format!("{EXPORT_DONE}out.mp4")), |
| 275 | + STATUS_SUCCESS() | ||
| 276 | + ); | ||
| 277 | + assert_eq!( | ||
| 278 | + notice_tone("NOTHING DETACHED — not grouped"), | ||
| 279 | + STATUS_WARNING() | ||
| 280 | + ); | ||
| 255 | assert_eq!(notice_tone("SNAP ON"), ACCENT_PRIMARY()); | 281 | assert_eq!(notice_tone("SNAP ON"), ACCENT_PRIMARY()); |
| 256 | } | 282 | } |
| 257 | 283 | ||
| @@ -267,7 +293,12 @@ fn an_inspector_section_occludes_no_timeline() { | |||
| 267 | // leave this rule reading a file the render is no longer in. | 293 | // leave this rule reading a file the render is no longer in. |
| 268 | let render = source_from("impl Render for Player"); | 294 | let render = source_from("impl Render for Player"); |
| 269 | for card in [ | 295 | for card in [ |
| 270 | - "eq_card", "color_card", "speed_card", "silence_card", "mix_card", "subtitle_style_card", | 296 | + "eq_card", |
| 297 | + "color_card", | ||
| 298 | + "speed_card", | ||
| 299 | + "silence_card", | ||
| 300 | + "mix_card", | ||
| 301 | + "subtitle_style_card", | ||
| 271 | ] { | 302 | ] { |
| 272 | assert!( | 303 | assert!( |
| 273 | inspector.contains(&format!("self.{card}(")), | 304 | inspector.contains(&format!("self.{card}(")), |
| @@ -394,8 +425,8 @@ fn a_lane_row_is_a_fixed_header_and_a_bed_that_can_be_hit() { | |||
| 394 | /// a hand can hold, and never off the ends. | 425 | /// a hand can hold, and never off the ends. |
| 395 | #[test] | 426 | #[test] |
| 396 | fn the_scroll_thumb_is_the_visible_share_at_its_own_place() { | 427 | fn the_scroll_thumb_is_the_visible_share_at_its_own_place() { |
| 397 | - use crate::scroll_thumb; | ||
| 398 | use crate::SCROLL_THUMB_MIN; | 428 | use crate::SCROLL_THUMB_MIN; |
| 429 | + use crate::scroll_thumb; | ||
| 399 | 430 | ||
| 400 | // Nothing to scroll: the strip fills and says so. | 431 | // Nothing to scroll: the strip fills and says so. |
| 401 | assert_eq!(scroll_thumb(400., 10., 0., 12.), (0., 400.)); | 432 | 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() { | |||
| 469 | // had: the region grows by the strip's row when it appears, by | 500 | // had: the region grows by the strip's row when it appears, by |
| 470 | // exactly the row the lanes would otherwise lose to it. | 501 | // exactly the row the lanes would otherwise lose to it. |
| 471 | assert_eq!(timeline_h(2, scroll) - timeline_fixed_h(scroll), lanes_h(2)); | 502 | assert_eq!(timeline_h(2, scroll) - timeline_fixed_h(scroll), lanes_h(2)); |
| 472 | - assert_eq!( | 503 | + assert_eq!(timeline_h(6, scroll) - timeline_fixed_h(scroll), lanes_h(6)); |
| 473 | - timeline_h(6, scroll) - timeline_fixed_h(scroll), | ||
| 474 | - lanes_h(6) | ||
| 475 | - ); | ||
| 476 | // ...and the floor keeps a whole lane standing under the line, on | 504 | // ...and the floor keeps a whole lane standing under the line, on |
| 477 | // either face of the zoom boundary. | 505 | // either face of the zoom boundary. |
| 478 | let floor = split_size(Split::Timeline, Some(0.), 2, window, scroll); | 506 | 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() { | |||
| 507 | /// on the track, the time axis's own thumb turned through a right angle. | 535 | /// on the track, the time axis's own thumb turned through a right angle. |
| 508 | #[test] | 536 | #[test] |
| 509 | fn the_lane_thumb_is_the_visible_share_of_the_stack() { | 537 | fn the_lane_thumb_is_the_visible_share_of_the_stack() { |
| 510 | - use crate::lanes_thumb; | ||
| 511 | use crate::SCROLL_THUMB_MIN; | 538 | use crate::SCROLL_THUMB_MIN; |
| 539 | + use crate::lanes_thumb; | ||
| 512 | 540 | ||
| 513 | // Whole stack on screen: the track fills and there is nothing to scroll. | 541 | // Whole stack on screen: the track fills and there is nothing to scroll. |
| 514 | assert_eq!(lanes_thumb(200., 104., 200., 0.), (0., 200.)); | 542 | 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() { | |||
| 1152 | // What the engine answers about the one pick that reached it, and what | 1180 | // What the engine answers about the one pick that reached it, and what |
| 1153 | // this side knows about the row that did not. | 1181 | // this side knows about the row that did not. |
| 1154 | let named = subtitle_plan("[ASS] → embedded".to_string(), &two, &[0]); | 1182 | let named = subtitle_plan("[ASS] → embedded".to_string(), &two, &[0]); |
| 1155 | - assert_eq!(named, "[ASS] → embedded; [ASS] [FOR DUB] — in the palette, on no track"); | 1183 | + assert_eq!( |
| 1184 | + named, | ||
| 1185 | + "[ASS] → embedded; [ASS] [FOR DUB] — in the palette, on no track" | ||
| 1186 | + ); | ||
| 1156 | assert!( | 1187 | assert!( |
| 1157 | named.chars().count() <= SUB_PLAN_CHARS, | 1188 | named.chars().count() <= SUB_PLAN_CHARS, |
| 1158 | "two tracks fit the value box: {named}" | 1189 | "two tracks fit the value box: {named}" |
| @@ -1439,8 +1470,14 @@ fn a_subtitle_group_header_is_never_gated_on_window_height() { | |||
| 1439 | .find("subtitle-group-head") | 1470 | .find("subtitle-group-head") |
| 1440 | .expect("no id on the group header"); | 1471 | .expect("no id on the group header"); |
| 1441 | let block = &timeline[head_at..(head_at + 2400).min(timeline.len())]; | 1472 | let block = &timeline[head_at..(head_at + 2400).min(timeline.len())]; |
| 1442 | - assert!(block.contains("sub_folded.remove"), "no fold-open path: {block}"); | 1473 | + assert!( |
| 1443 | - assert!(block.contains("sub_folded.insert"), "no fold-shut path: {block}"); | 1474 | + block.contains("sub_folded.remove"), |
| 1475 | + "no fold-open path: {block}" | ||
| 1476 | + ); | ||
| 1477 | + assert!( | ||
| 1478 | + block.contains("sub_folded.insert"), | ||
| 1479 | + "no fold-shut path: {block}" | ||
| 1480 | + ); | ||
| 1444 | assert!( | 1481 | assert!( |
| 1445 | block.contains("\"1 track\"") || block.contains("tracks"), | 1482 | block.contains("\"1 track\"") || block.contains("tracks"), |
| 1446 | "the header does not say how many tracks it holds: {block}" | 1483 | "the header does not say how many tracks it holds: {block}" |
| @@ -1765,7 +1802,10 @@ fn a_dragged_divider_stops_before_either_panel_disappears() { | |||
| 1765 | // timeline's answer is stated for both of its faces: the timeline fits | 1802 | // timeline's answer is stated for both of its faces: the timeline fits |
| 1766 | // the bed with nothing to scroll to, and zoomed in past that line the | 1803 | // the bed with nothing to scroll to, and zoomed in past that line the |
| 1767 | // strip's row joins the furniture. | 1804 | // strip's row joins the furniture. |
| 1768 | - assert_eq!(split_size(Split::Library, None, 2, window, false), library_w(1280.)); | 1805 | + assert_eq!( |
| 1806 | + split_size(Split::Library, None, 2, window, false), | ||
| 1807 | + library_w(1280.) | ||
| 1808 | + ); | ||
| 1769 | assert_eq!( | 1809 | assert_eq!( |
| 1770 | split_size(Split::Inspector, None, 2, window, false), | 1810 | split_size(Split::Inspector, None, 2, window, false), |
| 1771 | inspector_w(1280.) | 1811 | inspector_w(1280.) |
| @@ -1779,8 +1819,14 @@ fn a_dragged_divider_stops_before_either_panel_disappears() { | |||
| 1779 | timeline_h(2, true).min(720. * TIMELINE_SHARE) | 1819 | timeline_h(2, true).min(720. * TIMELINE_SHARE) |
| 1780 | ); | 1820 | ); |
| 1781 | // Dragged, it is what the hand asked for... | 1821 | // Dragged, it is what the hand asked for... |
| 1782 | - assert_eq!(split_size(Split::Library, Some(300.), 2, window, false), 300.); | 1822 | + assert_eq!( |
| 1783 | - assert_eq!(split_size(Split::Timeline, Some(300.), 2, window, false), 300.); | 1823 | + split_size(Split::Library, Some(300.), 2, window, false), |
| 1824 | + 300. | ||
| 1825 | + ); | ||
| 1826 | + assert_eq!( | ||
| 1827 | + split_size(Split::Timeline, Some(300.), 2, window, false), | ||
| 1828 | + 300. | ||
| 1829 | + ); | ||
| 1784 | // ...and never past either end of it. | 1830 | // ...and never past either end of it. |
| 1785 | assert_eq!( | 1831 | assert_eq!( |
| 1786 | split_size(Split::Library, Some(0.), 2, window, false), | 1832 | split_size(Split::Library, Some(0.), 2, window, false), |
| @@ -1824,7 +1870,10 @@ fn a_dragged_divider_stops_before_either_panel_disappears() { | |||
| 1824 | ); | 1870 | ); |
| 1825 | // A size dragged with one track and kept while a second arrives is raised | 1871 | // A size dragged with one track and kept while a second arrives is raised |
| 1826 | // to the new floor as it is read, not silently drawn under it. | 1872 | // to the new floor as it is read, not silently drawn under it. |
| 1827 | - assert_eq!(split_size(Split::Timeline, Some(126.), 2, window, true), floor); | 1873 | + assert_eq!( |
| 1874 | + split_size(Split::Timeline, Some(126.), 2, window, true), | ||
| 1875 | + floor | ||
| 1876 | + ); | ||
| 1828 | // And the floor still fits the share the shortest window gives the region. | 1877 | // And the floor still fits the share the shortest window gives the region. |
| 1829 | assert!(floor <= 360. * TIMELINE_SHARE, "{floor} px will not fit"); | 1878 | assert!(floor <= 360. * TIMELINE_SHARE, "{floor} px will not fit"); |
| 1830 | assert_eq!( | 1879 | assert_eq!( |
| @@ -1866,7 +1915,9 @@ fn a_dragged_divider_stops_before_either_panel_disappears() { | |||
| 1866 | #[test] | 1915 | #[test] |
| 1867 | fn the_darkroom_seams_stop_before_either_side_disappears() { | 1916 | fn the_darkroom_seams_stop_before_either_side_disappears() { |
| 1868 | use crate::ui::theme::INSPECTOR_MIN_W; | 1917 | use crate::ui::theme::INSPECTOR_MIN_W; |
| 1869 | - use crate::{BENCH_MIN_H, SIDE_MAX_FRAC, SPLIT_W, Split, split_bounds, split_drag_size, split_size}; | 1918 | + use crate::{ |
| 1919 | + BENCH_MIN_H, SIDE_MAX_FRAC, SPLIT_W, Split, split_bounds, split_drag_size, split_size, | ||
| 1920 | + }; | ||
| 1870 | use gpui::{point, px, size}; | 1921 | use gpui::{point, px, size}; |
| 1871 | 1922 | ||
| 1872 | let window = size(px(1280.), px(720.)); | 1923 | let window = size(px(1280.), px(720.)); |
| @@ -1935,7 +1986,10 @@ fn both_default_lanes_fit_the_bench_at_its_floor() { | |||
| 1935 | // row (`layout::LEDGER_SEAM_CLEARANCE`) so the last lane's own last pixel | 1986 | // row (`layout::LEDGER_SEAM_CLEARANCE`) so the last lane's own last pixel |
| 1936 | // never shares a row with the ledger's border, which lands here as | 1987 | // never shares a row with the ledger's border, which lands here as |
| 1937 | // `avail` being a touch over the two-rows-plus-gap tight fit. | 1988 | // `avail` being a touch over the two-rows-plus-gap tight fit. |
| 1938 | - assert!(h >= LANE_MIN_H, "the floor should give both lanes at least their own minimum ({h} < {LANE_MIN_H})"); | 1989 | + assert!( |
| 1990 | + h >= LANE_MIN_H, | ||
| 1991 | + "the floor should give both lanes at least their own minimum ({h} < {LANE_MIN_H})" | ||
| 1992 | + ); | ||
| 1939 | let content = 2. * h + ROW_GAP; | 1993 | let content = 2. * h + ROW_GAP; |
| 1940 | assert!( | 1994 | assert!( |
| 1941 | content <= avail + 1e-4, | 1995 | content <= avail + 1e-4, |
| @@ -2061,7 +2115,9 @@ fn the_notice_plate_cannot_reach_the_bench_at_any_height() { | |||
| 2061 | #[test] | 2115 | #[test] |
| 2062 | fn the_notice_plate_declares_a_bounded_wrapping_text_layout() { | 2116 | fn the_notice_plate_declares_a_bounded_wrapping_text_layout() { |
| 2063 | let stance = src_text("ui/stance.rs"); | 2117 | let stance = src_text("ui/stance.rs"); |
| 2064 | - let notice_start = stance.find("fn notice_plate(").expect("notice plate moved or renamed"); | 2118 | + let notice_start = stance |
| 2119 | + .find("fn notice_plate(") | ||
| 2120 | + .expect("notice plate moved or renamed"); | ||
| 2065 | let notice_end = stance[notice_start..] | 2121 | let notice_end = stance[notice_start..] |
| 2066 | .find("\n/// Thin strip") | 2122 | .find("\n/// Thin strip") |
| 2067 | .map(|end| notice_start + end) | 2123 | .map(|end| notice_start + end) |
| @@ -2078,7 +2134,6 @@ fn the_notice_plate_declares_a_bounded_wrapping_text_layout() { | |||
| 2078 | ); | 2134 | ); |
| 2079 | } | 2135 | } |
| 2080 | 2136 | ||
| 2081 | - | ||
| 2082 | /// A round trip through the file: what is saved is what the next load reads | 2137 | /// A round trip through the file: what is saved is what the next load reads |
| 2083 | /// back, one seam touched and the other left at its default -- a scratch | 2138 | /// back, one seam touched and the other left at its default -- a scratch |
| 2084 | /// path, not the real config, the same isolation `keymap::tests`' own | 2139 | /// 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() { | |||
| 2198 | 2253 | ||
| 2199 | // Defined in order is not composed in order -- `render()` has to call | 2254 | // Defined in order is not composed in order -- `render()` has to call |
| 2200 | // them in it too, or the geometry above is dead prose. | 2255 | // them in it too, or the geometry above is dead prose. |
| 2201 | - let render_body = | 2256 | + let render_body = &stance[stance |
| 2202 | - &stance[stance.find("pub(crate) fn render(").expect("the stance's entry point")..]; | 2257 | + .find("pub(crate) fn render(") |
| 2258 | + .expect("the stance's entry point")..]; | ||
| 2203 | // Open paren only, no close: DESIGN §12 steps 3 and 4 hand most of the | 2259 | // Open paren only, no close: DESIGN §12 steps 3 and 4 hand most of the |
| 2204 | // regions player/window state to read, so their call sites carry | 2260 | // regions player/window state to read, so their call sites carry |
| 2205 | // arguments now. Order is what this asserts, not arity. | 2261 | // arguments now. Order is what this asserts, not arity. |
| 2206 | - let calls = ["spine(", "screen(", "time_band(", "bench(", "ledger(", "dock("]; | 2262 | + let calls = [ |
| 2263 | + "spine(", | ||
| 2264 | + "screen(", | ||
| 2265 | + "time_band(", | ||
| 2266 | + "bench(", | ||
| 2267 | + "ledger(", | ||
| 2268 | + "dock(", | ||
| 2269 | + ]; | ||
| 2207 | let composed: Vec<usize> = calls | 2270 | let composed: Vec<usize> = calls |
| 2208 | .iter() | 2271 | .iter() |
| 2209 | .map(|c| { | 2272 | .map(|c| { |
| @@ -2320,7 +2383,10 @@ fn every_darkroom_menu_sizes_its_list_against_the_floor_room_not_the_raw_viewpor | |||
| 2320 | call -- every darkroom menu must clamp both its anchor and its \ | 2383 | call -- every darkroom menu must clamp both its anchor and its \ |
| 2321 | list room together" | 2384 | list room together" |
| 2322 | ); | 2385 | ); |
| 2323 | - assert!(sizings > 0, "{file} no longer opens any menu -- update this guard"); | 2386 | + assert!( |
| 2387 | + sizings > 0, | ||
| 2388 | + "{file} no longer opens any menu -- update this guard" | ||
| 2389 | + ); | ||
| 2324 | } | 2390 | } |
| 2325 | } | 2391 | } |
| 2326 | 2392 | ||
| @@ -2338,10 +2404,19 @@ fn every_darkroom_menu_sizes_its_list_against_the_floor_room_not_the_raw_viewpor | |||
| 2338 | #[test] | 2404 | #[test] |
| 2339 | fn settings_project_and_editor_sections_open_disjoint_doors() { | 2405 | fn settings_project_and_editor_sections_open_disjoint_doors() { |
| 2340 | let source = src_text("ui/settings_stance.rs"); | 2406 | let source = src_text("ui/settings_stance.rs"); |
| 2341 | - let project_start = source.find("fn project_section(").expect("the project section"); | 2407 | + let project_start = source |
| 2342 | - let editor_start = source.find("fn editor_section(").expect("the editor section"); | 2408 | + .find("fn project_section(") |
| 2343 | - let render_start = source.find("pub(crate) fn render(").expect("the page's render fn"); | 2409 | + .expect("the project section"); |
| 2344 | - assert!(project_start < editor_start && editor_start < render_start, "the three fns moved; this scan is blind"); | 2410 | + let editor_start = source |
| 2411 | + .find("fn editor_section(") | ||
| 2412 | + .expect("the editor section"); | ||
| 2413 | + let render_start = source | ||
| 2414 | + .find("pub(crate) fn render(") | ||
| 2415 | + .expect("the page's render fn"); | ||
| 2416 | + assert!( | ||
| 2417 | + project_start < editor_start && editor_start < render_start, | ||
| 2418 | + "the three fns moved; this scan is blind" | ||
| 2419 | + ); | ||
| 2345 | let project_body = &source[project_start..editor_start]; | 2420 | let project_body = &source[project_start..editor_start]; |
| 2346 | let editor_body = &source[editor_start..render_start]; | 2421 | let editor_body = &source[editor_start..render_start]; |
| 2347 | 2422 | ||
| @@ -2354,7 +2429,10 @@ fn settings_project_and_editor_sections_open_disjoint_doors() { | |||
| 2354 | // every picker. | 2429 | // every picker. |
| 2355 | let editor_no_theme = editor_body.replace("open_picker(Pick::Theme", ""); | 2430 | let editor_no_theme = editor_body.replace("open_picker(Pick::Theme", ""); |
| 2356 | for door in ["open_picker(", "open_mix("] { | 2431 | for door in ["open_picker(", "open_mix("] { |
| 2357 | - assert!(project_body.contains(door), "PROJECT section no longer opens {door} -- update this guard"); | 2432 | + assert!( |
| 2433 | + project_body.contains(door), | ||
| 2434 | + "PROJECT section no longer opens {door} -- update this guard" | ||
| 2435 | + ); | ||
| 2358 | assert!( | 2436 | assert!( |
| 2359 | !editor_no_theme.contains(door), | 2437 | !editor_no_theme.contains(door), |
| 2360 | "EDITOR section opens {door}, a project-file door -- that value belongs in PROJECT, not here" | 2438 | "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() { | |||
| 2364 | editor_body.contains("open_picker(Pick::Theme"), | 2442 | editor_body.contains("open_picker(Pick::Theme"), |
| 2365 | "the palette row left EDITOR -- it is a ~/.config preference, not a project value" | 2443 | "the palette row left EDITOR -- it is a ~/.config preference, not a project value" |
| 2366 | ); | 2444 | ); |
| 2367 | - for door in ["toggle_proxies(", "toggle_auto_proxies(", "open_subtitle_style("] { | 2445 | + for door in [ |
| 2368 | - assert!(editor_body.contains(door), "EDITOR section no longer opens {door} -- update this guard"); | 2446 | + "toggle_proxies(", |
| 2447 | + "toggle_auto_proxies(", | ||
| 2448 | + "open_subtitle_style(", | ||
| 2449 | + ] { | ||
| 2450 | + assert!( | ||
| 2451 | + editor_body.contains(door), | ||
| 2452 | + "EDITOR section no longer opens {door} -- update this guard" | ||
| 2453 | + ); | ||
| 2369 | assert!( | 2454 | assert!( |
| 2370 | !project_body.contains(door), | 2455 | !project_body.contains(door), |
| 2371 | "PROJECT section opens {door}, an editor-only door -- that value belongs in EDITOR, not here" | 2456 | "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() { | |||
| 2375 | // through an opener, which is the one place a config-file write (the | 2460 | // through an opener, which is the one place a config-file write (the |
| 2376 | // subtitle style card's Save, this window's next project load) is | 2461 | // subtitle style card's Save, this window's next project load) is |
| 2377 | // allowed to live. | 2462 | // allowed to live. |
| 2378 | - for path_fn in ["dock_stance::config_path", "theme::config_path", "Keymap::config_path"] { | 2463 | + for path_fn in [ |
| 2379 | - assert!(!project_body.contains(path_fn), "PROJECT section touches {path_fn} directly"); | 2464 | + "dock_stance::config_path", |
| 2380 | - assert!(!editor_body.contains(path_fn), "EDITOR section touches {path_fn} directly"); | 2465 | + "theme::config_path", |
| 2466 | + "Keymap::config_path", | ||
| 2467 | + ] { | ||
| 2468 | + assert!( | ||
| 2469 | + !project_body.contains(path_fn), | ||
| 2470 | + "PROJECT section touches {path_fn} directly" | ||
| 2471 | + ); | ||
| 2472 | + assert!( | ||
| 2473 | + !editor_body.contains(path_fn), | ||
| 2474 | + "EDITOR section touches {path_fn} directly" | ||
| 2475 | + ); | ||
| 2381 | } | 2476 | } |
| 2382 | } | 2477 | } |
| 2383 | 2478 | ||
| @@ -2395,9 +2490,16 @@ fn settings_row_hints_naming_config_edith_have_a_matching_pref_pair() { | |||
| 2395 | let source = src_text("ui/settings_stance.rs"); | 2490 | let source = src_text("ui/settings_stance.rs"); |
| 2396 | let library = src_text("player/library.rs"); | 2491 | let library = src_text("player/library.rs"); |
| 2397 | // (row id, the stem its pref functions are named after) | 2492 | // (row id, the stem its pref functions are named after) |
| 2398 | - for (row_id, stem) in [("settings-proxies", "proxies"), ("settings-auto-proxies", "auto_proxies")] { | 2493 | + for (row_id, stem) in [ |
| 2399 | - let row_start = source.find(&format!("\"{row_id}\"")).unwrap_or_else(|| panic!("{row_id} row moved or renamed -- update this guard")); | 2494 | + ("settings-proxies", "proxies"), |
| 2400 | - let row_end = source[row_start..].find(",\n ))").map_or(source.len(), |i| row_start + i); | 2495 | + ("settings-auto-proxies", "auto_proxies"), |
| 2496 | + ] { | ||
| 2497 | + let row_start = source | ||
| 2498 | + .find(&format!("\"{row_id}\"")) | ||
| 2499 | + .unwrap_or_else(|| panic!("{row_id} row moved or renamed -- update this guard")); | ||
| 2500 | + let row_end = source[row_start..] | ||
| 2501 | + .find(",\n ))") | ||
| 2502 | + .map_or(source.len(), |i| row_start + i); | ||
| 2401 | let row_text = &source[row_start..row_end]; | 2503 | let row_text = &source[row_start..row_end]; |
| 2402 | if !row_text.contains("~/.config/edith") { | 2504 | if !row_text.contains("~/.config/edith") { |
| 2403 | continue; | 2505 | continue; |
| @@ -2422,10 +2524,18 @@ fn settings_row_hints_naming_config_edith_have_a_matching_pref_pair() { | |||
| 2422 | #[test] | 2524 | #[test] |
| 2423 | fn settings_project_rows_have_no_bare_noun_placeholder() { | 2525 | fn settings_project_rows_have_no_bare_noun_placeholder() { |
| 2424 | let source = src_text("ui/settings_stance.rs"); | 2526 | let source = src_text("ui/settings_stance.rs"); |
| 2425 | - let project_start = source.find("fn project_section(").expect("the project section"); | 2527 | + let project_start = source |
| 2426 | - let editor_start = source.find("fn editor_section(").expect("the editor section"); | 2528 | + .find("fn project_section(") |
| 2529 | + .expect("the project section"); | ||
| 2530 | + let editor_start = source | ||
| 2531 | + .find("fn editor_section(") | ||
| 2532 | + .expect("the editor section"); | ||
| 2427 | let project_body = &source[project_start..editor_start]; | 2533 | let project_body = &source[project_start..editor_start]; |
| 2428 | - for placeholder in ["\"Size\".to_string()", "\"Rate\".to_string()", "\"HDR\".to_string()"] { | 2534 | + for placeholder in [ |
| 2535 | + "\"Size\".to_string()", | ||
| 2536 | + "\"Rate\".to_string()", | ||
| 2537 | + "\"HDR\".to_string()", | ||
| 2538 | + ] { | ||
| 2429 | assert!( | 2539 | assert!( |
| 2430 | !project_body.contains(placeholder), | 2540 | !project_body.contains(placeholder), |
| 2431 | "a PROJECT row fell back to the bare noun {placeholder} -- it reads as a value with no project open" | 2541 | "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() { | |||
| 2442 | #[test] | 2552 | #[test] |
| 2443 | fn hdr_reference_rows_read_content_light_and_use_the_established_empty_state() { | 2553 | fn hdr_reference_rows_read_content_light_and_use_the_established_empty_state() { |
| 2444 | let source = src_text("ui/settings_stance.rs"); | 2554 | let source = src_text("ui/settings_stance.rs"); |
| 2445 | - let project_start = source.find("fn project_section(").expect("the project section"); | 2555 | + let project_start = source |
| 2446 | - let editor_start = source.find("fn editor_section(").expect("the editor section"); | 2556 | + .find("fn project_section(") |
| 2557 | + .expect("the project section"); | ||
| 2558 | + let editor_start = source | ||
| 2559 | + .find("fn editor_section(") | ||
| 2560 | + .expect("the editor section"); | ||
| 2447 | let project_body = &source[project_start..editor_start]; | 2561 | let project_body = &source[project_start..editor_start]; |
| 2448 | 2562 | ||
| 2449 | - assert!(project_body.contains("settings-hdr-reference"), "the HDR reference row is missing"); | 2563 | + assert!( |
| 2450 | - assert!(project_body.contains("settings-content-light"), "the content-light row is missing"); | 2564 | + project_body.contains("settings-hdr-reference"), |
| 2565 | + "the HDR reference row is missing" | ||
| 2566 | + ); | ||
| 2567 | + assert!( | ||
| 2568 | + project_body.contains("settings-content-light"), | ||
| 2569 | + "the content-light row is missing" | ||
| 2570 | + ); | ||
| 2451 | 2571 | ||
| 2452 | // Reads the real declared numbers, not an invented default or a fixed | 2572 | // Reads the real declared numbers, not an invented default or a fixed |
| 2453 | // string standing in for one. | 2573 | // string standing in for one. |
| 2454 | for field in ["mastering_max", "max_cll", "max_fall"] { | 2574 | for field in ["mastering_max", "max_cll", "max_fall"] { |
| 2455 | - assert!(project_body.contains(field), "the HDR reference rows do not read ContentLight::{field}"); | 2575 | + assert!( |
| 2576 | + project_body.contains(field), | ||
| 2577 | + "the HDR reference rows do not read ContentLight::{field}" | ||
| 2578 | + ); | ||
| 2456 | } | 2579 | } |
| 2457 | 2580 | ||
| 2458 | // No override field exists on the engine side to write one into, so the | 2581 | // No override field exists on the engine side to write one into, so the |
| 2459 | // row must never claim a picker/opener the way every other PROJECT row | 2582 | // row must never claim a picker/opener the way every other PROJECT row |
| 2460 | // does -- it is built with `row_static`, not `row`/`row_ink`. | 2583 | // does -- it is built with `row_static`, not `row`/`row_ink`. |
| 2461 | - assert!(project_body.contains("row_static(\n \"settings-hdr-reference\""), "the HDR reference row must be read-only (row_static), not a picker"); | 2584 | + assert!( |
| 2462 | - assert!(project_body.contains("row_static(\n \"settings-content-light\""), "the content-light row must be read-only (row_static), not a picker"); | 2585 | + project_body.contains("row_static(\n \"settings-hdr-reference\""), |
| 2586 | + "the HDR reference row must be read-only (row_static), not a picker" | ||
| 2587 | + ); | ||
| 2588 | + assert!( | ||
| 2589 | + project_body.contains("row_static(\n \"settings-content-light\""), | ||
| 2590 | + "the content-light row must be read-only (row_static), not a picker" | ||
| 2591 | + ); | ||
| 2463 | 2592 | ||
| 2464 | // The established empty state: a bare "—" reused, never a second idiom | 2593 | // The established empty state: a bare "—" reused, never a second idiom |
| 2465 | // ("N/A", "None", "Unknown"...) invented for the same absence. | 2594 | // ("N/A", "None", "Unknown"...) invented for the same absence. |
| 2466 | - assert!(project_body.contains("\"—\".to_string()"), "the HDR reference rows must reuse the page's own empty-state dash"); | 2595 | + assert!( |
| 2596 | + project_body.contains("\"—\".to_string()"), | ||
| 2597 | + "the HDR reference rows must reuse the page's own empty-state dash" | ||
| 2598 | + ); | ||
| 2467 | } | 2599 | } |
| 2468 | /// The parity class this user has reported four separate times: "some | 2600 | /// The parity class this user has reported four separate times: "some |
| 2469 | /// options are only reachable via keyboard shortcut". A source scan (this | 2601 | /// 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() { | |||
| 2558 | } | 2690 | } |
| 2559 | 2691 | ||
| 2560 | let lane = &bench[bench.find("fn lane_row(").expect("the lane renderer") | 2692 | let lane = &bench[bench.find("fn lane_row(").expect("the lane renderer") |
| 2561 | - ..bench.find("pub(crate) fn render(").expect("the bench renderer")]; | 2693 | + ..bench |
| 2694 | + .find("pub(crate) fn render(") | ||
| 2695 | + .expect("the bench renderer")]; | ||
| 2562 | for needle in [ | 2696 | for needle in [ |
| 2563 | "this.preview_lane_drop(event.drag(cx).0, lane, cx)", | 2697 | "this.preview_lane_drop(event.drag(cx).0, lane, cx)", |
| 2564 | "this.forget_lane_drop(lane, cx)", | 2698 | "this.forget_lane_drop(lane, cx)", |
crates/app/src/tests/media.rsmodified+95 -31
| @@ -2,10 +2,12 @@ | |||
| 2 | //! command line, the scans, the codecs offered, and the subtitles found. | 2 | //! command line, the scans, the codecs offered, and the subtitles found. |
| 3 | 3 | ||
| 4 | use super::*; | 4 | use super::*; |
| 5 | +use crate::player::library::{ | ||
| 6 | + auto_proxies_pref_path, load_auto_proxies_pref, save_auto_proxies_pref, | ||
| 7 | +}; | ||
| 5 | use crate::subs::{ | 8 | use crate::subs::{ |
| 6 | - load_subtitle_style, save_subtitle_style, sub_line_h_for, subtitle_style_path, SUB_SIZE_RANGE, | 9 | + SUB_SIZE_RANGE, load_subtitle_style, save_subtitle_style, sub_line_h_for, subtitle_style_path, |
| 7 | }; | 10 | }; |
| 8 | -use crate::player::library::{auto_proxies_pref_path, load_auto_proxies_pref, save_auto_proxies_pref}; | ||
| 9 | use crate::ui::preview::{bgra_to_rgba, screenshot_path}; | 11 | use crate::ui::preview::{bgra_to_rgba, screenshot_path}; |
| 10 | 12 | ||
| 11 | /// The import line's own state machine, driven the way a repaint drives | 13 | /// 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() { | |||
| 160 | } | 162 | } |
| 161 | // The release, whatever the worker is doing. | 163 | // The release, whatever the worker is doing. |
| 162 | written.extend(stash.take()); | 164 | written.extend(stash.take()); |
| 163 | - assert_eq!(written, vec![0, 9, 19, 29, 39], "one write per frame landed"); | 165 | + assert_eq!( |
| 166 | + written, | ||
| 167 | + vec![0, 9, 19, 29, 39], | ||
| 168 | + "one write per frame landed" | ||
| 169 | + ); | ||
| 164 | } | 170 | } |
| 165 | 171 | ||
| 166 | /// The one value a gesture may never lose: where the hand let go. The | 172 | /// 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() { | |||
| 293 | assert_eq!(scan_plan(false, Some(&a), &half), ScanPlan::Start); | 299 | assert_eq!(scan_plan(false, Some(&a), &half), ScanPlan::Start); |
| 294 | // ...and the seconds asked for are the clip's, at the project's rate. | 300 | // ...and the seconds asked for are the clip's, at the project's rate. |
| 295 | assert_eq!(source_secs(&half, 30.), (0., 50.)); | 301 | assert_eq!(source_secs(&half, 30.), (0., 50.)); |
| 296 | - assert_eq!(source_secs(&(half.0.clone(), 0, 900, 1500), 30.), (30., 50.)); | 302 | + assert_eq!( |
| 303 | + source_secs(&(half.0.clone(), 0, 900, 1500), 30.), | ||
| 304 | + (30., 50.) | ||
| 305 | + ); | ||
| 297 | // A rate that is not one reads the file rather than nothing. | 306 | // A rate that is not one reads the file rather than nothing. |
| 298 | assert_eq!(source_secs(&half, 0.), (0., f64::INFINITY)); | 307 | assert_eq!(source_secs(&half, 0.), (0., f64::INFINITY)); |
| 299 | } | 308 | } |
| @@ -307,7 +316,8 @@ fn a_second_film_does_not_cost_the_first_one_its_levels() { | |||
| 307 | #[test] | 316 | #[test] |
| 308 | fn a_warm_whole_source_scan_answers_the_card_for_every_clip_cut_from_it() { | 317 | fn a_warm_whole_source_scan_answers_the_card_for_every_clip_cut_from_it() { |
| 309 | use std::sync::Arc; | 318 | use std::sync::Arc; |
| 310 | - let mut levels: std::collections::HashMap<ScanKey, Arc<Vec<f32>>> = std::collections::HashMap::new(); | 319 | + let mut levels: std::collections::HashMap<ScanKey, Arc<Vec<f32>>> = |
| 320 | + std::collections::HashMap::new(); | ||
| 311 | let clip_a = (PathBuf::from("/films/a.mkv"), 0, 300, 900); | 321 | let clip_a = (PathBuf::from("/films/a.mkv"), 0, 300, 900); |
| 312 | let clip_b = (PathBuf::from("/films/a.mkv"), 0, 1_200, 1_800); | 322 | let clip_b = (PathBuf::from("/films/a.mkv"), 0, 1_200, 1_800); |
| 313 | // Nothing yet -- neither clip's own read nor a background one. | 323 | // 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( | |||
| 347 | assert_eq!(slice, (10..20).map(|i| i as f32).collect::<Vec<f32>>()); | 357 | assert_eq!(slice, (10..20).map(|i| i as f32).collect::<Vec<f32>>()); |
| 348 | // The clip's own in point is where its slice starts, not the file's: | 358 | // The clip's own in point is where its slice starts, not the file's: |
| 349 | // a take an hour into the film reads the same as one at its head. | 359 | // a take an hour into the film reads the same as one at its head. |
| 350 | - assert_eq!(slice_whole_levels(&whole, fps, 0, 5), vec![0., 1., 2., 3., 4.]); | 360 | + assert_eq!( |
| 361 | + slice_whole_levels(&whole, fps, 0, 5), | ||
| 362 | + vec![0., 1., 2., 3., 4.] | ||
| 363 | + ); | ||
| 351 | // Past what the background scan has read so far (still running, or | 364 | // Past what the background scan has read so far (still running, or |
| 352 | // cancelled) is not padded with zeroes -- the caller is told nothing is | 365 | // cancelled) is not padded with zeroes -- the caller is told nothing is |
| 353 | // there yet, same as [`SilenceScan`]'s own cancel leaves a prefix. | 366 | // there yet, same as [`SilenceScan`]'s own cancel leaves a prefix. |
| 354 | - assert_eq!(slice_whole_levels(&whole, fps, 35, 60), vec![35., 36., 37., 38., 39.]); | 367 | + assert_eq!( |
| 368 | + slice_whole_levels(&whole, fps, 35, 60), | ||
| 369 | + vec![35., 36., 37., 38., 39.] | ||
| 370 | + ); | ||
| 355 | assert_eq!(slice_whole_levels(&whole, fps, 45, 60), Vec::<f32>::new()); | 371 | assert_eq!(slice_whole_levels(&whole, fps, 45, 60), Vec::<f32>::new()); |
| 356 | // A rate that is not a rate reads nothing, the same refusal | 372 | // A rate that is not a rate reads nothing, the same refusal |
| 357 | // `source_secs` makes for a background scan's own range. | 373 | // `source_secs` makes for a background scan's own range. |
| @@ -378,8 +394,7 @@ fn probing_ahead_lands_exactly_what_importing_in_place_lands() { | |||
| 378 | let split = { | 394 | let split = { |
| 379 | let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open"); | 395 | let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open"); |
| 380 | session.set_gain(0.0); | 396 | session.set_gain(0.0); |
| 381 | - let (subs, probe) = | 397 | + let (subs, probe) = read_parts(&asset("test_av2.mp4"), &stage, Some(session.import_gate())); |
| 382 | - read_parts(&asset("test_av2.mp4"), &stage, Some(session.import_gate())); | ||
| 383 | // This mp4 is walked now (an mp4 can carry `tx3g`) and has no | 398 | // This mp4 is walked now (an mp4 can carry `tx3g`) and has no |
| 384 | // subtitle track in it, so the worker hands over an empty list -- | 399 | // subtitle track in it, so the worker hands over an empty list -- |
| 385 | // the same thing the import lands with. | 400 | // the same thing the import lands with. |
| @@ -408,7 +423,11 @@ fn probing_ahead_lands_exactly_what_importing_in_place_lands() { | |||
| 408 | // notice shows -- worded exactly as importing in place worded it. | 423 | // notice shows -- worded exactly as importing in place worded it. |
| 409 | let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open"); | 424 | let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open"); |
| 410 | session.set_gain(0.0); | 425 | session.set_gain(0.0); |
| 411 | - let (_, probe) = read_parts(&asset("test_25fps.mp4"), &stage, Some(session.import_gate())); | 426 | + let (_, probe) = read_parts( |
| 427 | + &asset("test_25fps.mp4"), | ||
| 428 | + &stage, | ||
| 429 | + Some(session.import_gate()), | ||
| 430 | + ); | ||
| 412 | let on_the_worker = probe | 431 | let on_the_worker = probe |
| 413 | .expect("a container is probed") | 432 | .expect("a container is probed") |
| 414 | .map(|_| ()) | 433 | .map(|_| ()) |
| @@ -426,7 +445,9 @@ fn probing_ahead_lands_exactly_what_importing_in_place_lands() { | |||
| 426 | let mut moved = PlaybackSession::open(asset("test_av.mp4")).expect("open"); | 445 | let mut moved = PlaybackSession::open(asset("test_av.mp4")).expect("open"); |
| 427 | moved.set_gain(0.0); | 446 | moved.set_gain(0.0); |
| 428 | let (_, probe) = read_parts(&asset("test_av2.mp4"), &stage, Some(moved.import_gate())); | 447 | let (_, probe) = read_parts(&asset("test_av2.mp4"), &stage, Some(moved.import_gate())); |
| 429 | - moved.import(&asset("test_still.png")).expect("a still joins"); | 448 | + moved |
| 449 | + .import(&asset("test_still.png")) | ||
| 450 | + .expect("a still joins"); | ||
| 430 | let stale = probe.expect("a container is probed").expect("av2 matches"); | 451 | let stale = probe.expect("a container is probed").expect("av2 matches"); |
| 431 | assert_eq!( | 452 | assert_eq!( |
| 432 | moved.import_probed(&asset("test_av2.mp4"), stale).ok(), | 453 | moved.import_probed(&asset("test_av2.mp4"), stale).ok(), |
| @@ -784,7 +805,12 @@ fn the_summary_states_the_file_before_it_is_written() { | |||
| 784 | // still a real file with a real size. | 805 | // still a real file with a real size. |
| 785 | let short = estimated_bytes(Some(1_000_000), 3.).expect("a rate and a length"); | 806 | let short = estimated_bytes(Some(1_000_000), 3.).expect("a rate and a length"); |
| 786 | assert_eq!(size_label(short), "375 kB"); | 807 | assert_eq!(size_label(short), "375 kB"); |
| 787 | - let frame = summary_tail(Path::new("/a/x.mp4"), estimated_bytes(Some(1_000_000), 1. / 60.), None, true); | 808 | + let frame = summary_tail( |
| 809 | + Path::new("/a/x.mp4"), | ||
| 810 | + estimated_bytes(Some(1_000_000), 1. / 60.), | ||
| 811 | + None, | ||
| 812 | + true, | ||
| 813 | + ); | ||
| 788 | assert!( | 814 | assert!( |
| 789 | frame.contains("≈ 2 kB") && !frame.contains("0 MB") && !frame.contains("0 kB"), | 815 | frame.contains("≈ 2 kB") && !frame.contains("0 MB") && !frame.contains("0 kB"), |
| 790 | "{frame}" | 816 | "{frame}" |
| @@ -873,7 +899,10 @@ fn the_subtitle_plate_and_lanes_fit_the_smallest_window() { | |||
| 873 | // What is left for the picture at the floor, with a project's two tracks | 899 | // What is left for the picture at the floor, with a project's two tracks |
| 874 | // and a subtitle lane under them. | 900 | // and a subtitle lane under them. |
| 875 | let picture = 360. - HEADER_H - panel_h(3); | 901 | let picture = 360. - HEADER_H - panel_h(3); |
| 876 | - assert!(picture > 0., "a subtitle lane pushed the picture off the window"); | 902 | + assert!( |
| 903 | + picture > 0., | ||
| 904 | + "a subtitle lane pushed the picture off the window" | ||
| 905 | + ); | ||
| 877 | // A two-line cue and the gap under it fit inside that, which is the | 906 | // A two-line cue and the gap under it fit inside that, which is the |
| 878 | // whole claim: the plate sits *over* the picture and must not need more | 907 | // whole claim: the plate sits *over* the picture and must not need more |
| 879 | // of it than there is. | 908 | // of it than there is. |
| @@ -913,6 +942,8 @@ fn the_subtitle_plate_and_lanes_fit_the_smallest_window() { | |||
| 913 | /// than crashing a startup on someone else's edit of the file. | 942 | /// than crashing a startup on someone else's edit of the file. |
| 914 | #[test] | 943 | #[test] |
| 915 | fn the_subtitle_style_file_round_trips_or_falls_back_to_defaults() { | 944 | fn the_subtitle_style_file_round_trips_or_falls_back_to_defaults() { |
| 945 | + let _config_env = config_env_lock(); | ||
| 946 | + | ||
| 916 | let dir = std::env::temp_dir().join(format!( | 947 | let dir = std::env::temp_dir().join(format!( |
| 917 | "edith-subtitle-style-test-{}-{}", | 948 | "edith-subtitle-style-test-{}-{}", |
| 918 | std::process::id(), | 949 | std::process::id(), |
| @@ -922,9 +953,8 @@ fn the_subtitle_style_file_round_trips_or_falls_back_to_defaults() { | |||
| 922 | .as_nanos() | 953 | .as_nanos() |
| 923 | )); | 954 | )); |
| 924 | std::fs::create_dir_all(&dir).unwrap(); | 955 | std::fs::create_dir_all(&dir).unwrap(); |
| 925 | - // Scoped to this test alone: no other test reads XDG_CONFIG_HOME or the | 956 | + // The shared process environment is serialized across every config |
| 926 | - // subtitle-style file it names, so this narrow, restored mutation of the | 957 | + // round-trip test by `config_env_lock`. |
| 927 | - // process environment cannot race another test's own file. | ||
| 928 | unsafe { std::env::set_var("XDG_CONFIG_HOME", &dir) }; | 958 | unsafe { std::env::set_var("XDG_CONFIG_HOME", &dir) }; |
| 929 | 959 | ||
| 930 | // Nothing written yet: the defaults, not a crash on a missing file. | 960 | // 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() { | |||
| 932 | 962 | ||
| 933 | // A save, read back whole: family and size both. | 963 | // A save, read back whole: family and size both. |
| 934 | save_subtitle_style(Some("Iosevka"), 22.).unwrap(); | 964 | save_subtitle_style(Some("Iosevka"), 22.).unwrap(); |
| 935 | - assert_eq!( | 965 | + assert_eq!(load_subtitle_style(), (Some("Iosevka".to_string()), 22.)); |
| 936 | - load_subtitle_style(), | ||
| 937 | - (Some("Iosevka".to_string()), 22.) | ||
| 938 | - ); | ||
| 939 | 966 | ||
| 940 | // The platform default (`None`) round-trips too, and is not a family | 967 | // The platform default (`None`) round-trips too, and is not a family |
| 941 | // called "". | 968 | // called "". |
| @@ -961,6 +988,8 @@ fn the_subtitle_style_file_round_trips_or_falls_back_to_defaults() { | |||
| 961 | /// relaunch reads instead of the field's hardcoded `true`. | 988 | /// relaunch reads instead of the field's hardcoded `true`. |
| 962 | #[test] | 989 | #[test] |
| 963 | fn the_auto_proxies_default_round_trips_through_its_own_config_file_or_falls_back_to_on() { | 990 | fn the_auto_proxies_default_round_trips_through_its_own_config_file_or_falls_back_to_on() { |
| 991 | + let _config_env = config_env_lock(); | ||
| 992 | + | ||
| 964 | let dir = std::env::temp_dir().join(format!( | 993 | let dir = std::env::temp_dir().join(format!( |
| 965 | "edith-auto-proxies-pref-test-{}-{}", | 994 | "edith-auto-proxies-pref-test-{}-{}", |
| 966 | std::process::id(), | 995 | std::process::id(), |
| @@ -970,8 +999,8 @@ fn the_auto_proxies_default_round_trips_through_its_own_config_file_or_falls_bac | |||
| 970 | .as_nanos() | 999 | .as_nanos() |
| 971 | )); | 1000 | )); |
| 972 | std::fs::create_dir_all(&dir).unwrap(); | 1001 | std::fs::create_dir_all(&dir).unwrap(); |
| 973 | - // Scoped to this test alone, the same guarantee the subtitle-style test | 1002 | + // `config_env_lock` serializes every test that changes this process-wide |
| 974 | - // above makes for the same env var. | 1003 | + // path. |
| 975 | unsafe { std::env::set_var("XDG_CONFIG_HOME", &dir) }; | 1004 | unsafe { std::env::set_var("XDG_CONFIG_HOME", &dir) }; |
| 976 | 1005 | ||
| 977 | // Nothing written yet: On, the field's own long-standing default. | 1006 | // 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 | |||
| 981 | assert!(!load_auto_proxies_pref(), "off must round-trip"); | 1010 | assert!(!load_auto_proxies_pref(), "off must round-trip"); |
| 982 | 1011 | ||
| 983 | save_auto_proxies_pref(true).unwrap(); | 1012 | save_auto_proxies_pref(true).unwrap(); |
| 984 | - assert!(load_auto_proxies_pref(), "on must round-trip too, not just off"); | 1013 | + assert!( |
| 1014 | + load_auto_proxies_pref(), | ||
| 1015 | + "on must round-trip too, not just off" | ||
| 1016 | + ); | ||
| 985 | 1017 | ||
| 986 | // Garbled bytes -- a stray edit, or a future dialect -- read as On rather | 1018 | // Garbled bytes -- a stray edit, or a future dialect -- read as On rather |
| 987 | // than failing a startup on someone else's edit of the file. | 1019 | // than failing a startup on someone else's edit of the file. |
| 988 | std::fs::write(auto_proxies_pref_path(), "not on or off\n").unwrap(); | 1020 | std::fs::write(auto_proxies_pref_path(), "not on or off\n").unwrap(); |
| 989 | - assert!(load_auto_proxies_pref(), "unreadable content must fall back to On"); | 1021 | + assert!( |
| 1022 | + load_auto_proxies_pref(), | ||
| 1023 | + "unreadable content must fall back to On" | ||
| 1024 | + ); | ||
| 990 | 1025 | ||
| 991 | unsafe { std::env::remove_var("XDG_CONFIG_HOME") }; | 1026 | unsafe { std::env::remove_var("XDG_CONFIG_HOME") }; |
| 992 | std::fs::remove_dir_all(&dir).ok(); | 1027 | std::fs::remove_dir_all(&dir).ok(); |
| @@ -1059,7 +1094,9 @@ fn subtitles_arrive_beside_the_media_and_inside_it() { | |||
| 1059 | // no source in it to import, so the drop door has to send it where `+ S` | 1094 | // no source in it to import, so the drop door has to send it where `+ S` |
| 1060 | // sends it. Its two siblings are media and must not come here -- a | 1095 | // sends it. Its two siblings are media and must not come here -- a |
| 1061 | // `.mka` is a song this would stop importing. | 1096 | // `.mka` is a song this would stop importing. |
| 1062 | - for name in ["subs.srt", "SUBS.SRT", "a.vtt", "a.ass", "a.ssa", "s.mks", "S.MKS"] { | 1097 | + for name in [ |
| 1098 | + "subs.srt", "SUBS.SRT", "a.vtt", "a.ass", "a.ssa", "s.mks", "S.MKS", | ||
| 1099 | + ] { | ||
| 1063 | assert!(is_subtitle(Path::new(name)), "{name}"); | 1100 | assert!(is_subtitle(Path::new(name)), "{name}"); |
| 1064 | } | 1101 | } |
| 1065 | for name in ["a.mp4", "a.mkv", "song.mka", "film.mk3d", "notes.txt", "a"] { | 1102 | 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() { | |||
| 1070 | // The Matroska half is the engine's own closed set, extension for | 1107 | // The Matroska half is the engine's own closed set, extension for |
| 1071 | // extension, so no file is walked here that it would refuse there. | 1108 | // extension, so no file is walked here that it would refuse there. |
| 1072 | for name in [ | 1109 | for name in [ |
| 1073 | - "film.MKV", "clip.webm", "clip.mp4", "a.m4v", "a.MOV", "song.mka", "s.mks", "f.MK3D", | 1110 | + "film.MKV", |
| 1111 | + "clip.webm", | ||
| 1112 | + "clip.mp4", | ||
| 1113 | + "a.m4v", | ||
| 1114 | + "a.MOV", | ||
| 1115 | + "song.mka", | ||
| 1116 | + "s.mks", | ||
| 1117 | + "f.MK3D", | ||
| 1074 | ] { | 1118 | ] { |
| 1075 | assert!(carries_subtitles(Path::new(name)), "{name}"); | 1119 | assert!(carries_subtitles(Path::new(name)), "{name}"); |
| 1076 | assert!( | 1120 | assert!( |
| @@ -1201,7 +1245,11 @@ fn subtitles_arrive_beside_the_media_and_inside_it() { | |||
| 1201 | .cut_regions(&[(15, 60)], &lanes) | 1245 | .cut_regions(&[(15, 60)], &lanes) |
| 1202 | .expect("cut 0.5s..2.5s out"); | 1246 | .expect("cut 0.5s..2.5s out"); |
| 1203 | assert_eq!(session.timeline_duration(), 3.0); | 1247 | assert_eq!(session.timeline_duration(), 3.0); |
| 1204 | - assert_eq!(session.subtitles()[0].cues.len(), 3, "the track is untouched"); | 1248 | + assert_eq!( |
| 1249 | + session.subtitles()[0].cues.len(), | ||
| 1250 | + 3, | ||
| 1251 | + "the track is untouched" | ||
| 1252 | + ); | ||
| 1205 | let mapped = session.timeline_cues(0); | 1253 | let mapped = session.timeline_cues(0); |
| 1206 | assert_eq!( | 1254 | assert_eq!( |
| 1207 | mapped | 1255 | mapped |
| @@ -1312,7 +1360,11 @@ fn a_second_session_playing_never_moves_the_first() { | |||
| 1312 | preview.seek(1.0); | 1360 | preview.seek(1.0); |
| 1313 | preview.play(); | 1361 | preview.play(); |
| 1314 | 1362 | ||
| 1315 | - assert_eq!(timeline.now(), before, "the preview's seek moved the wrong session"); | 1363 | + assert_eq!( |
| 1364 | + timeline.now(), | ||
| 1365 | + before, | ||
| 1366 | + "the preview's seek moved the wrong session" | ||
| 1367 | + ); | ||
| 1316 | assert_eq!( | 1368 | assert_eq!( |
| 1317 | timeline.is_playing(), | 1369 | timeline.is_playing(), |
| 1318 | before_playing, | 1370 | before_playing, |
| @@ -1341,7 +1393,11 @@ fn ticking_the_preview_session_never_moves_the_timeline() { | |||
| 1341 | // showing: only the active session -- the preview -- gets ticked. | 1393 | // showing: only the active session -- the preview -- gets ticked. |
| 1342 | preview.tick(); | 1394 | preview.tick(); |
| 1343 | 1395 | ||
| 1344 | - assert_eq!(timeline.now(), before, "ticking the preview moved the timeline's clock"); | 1396 | + assert_eq!( |
| 1397 | + timeline.now(), | ||
| 1398 | + before, | ||
| 1399 | + "ticking the preview moved the timeline's clock" | ||
| 1400 | + ); | ||
| 1345 | } | 1401 | } |
| 1346 | 1402 | ||
| 1347 | /// [`bgra_to_rgba`] and [`save_screenshot`]'s own PNG write, round-tripped: a | 1403 | /// [`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() { | |||
| 1357 | 255, 0, 0, 255, 255, 255, 255, 128, | 1413 | 255, 0, 0, 255, 255, 255, 255, 128, |
| 1358 | ]; | 1414 | ]; |
| 1359 | let rgba = bgra_to_rgba(&bgra); | 1415 | let rgba = bgra_to_rgba(&bgra); |
| 1360 | - assert_eq!(rgba[0..4], [255, 0, 0, 255], "red survives the channel swap"); | 1416 | + assert_eq!( |
| 1417 | + rgba[0..4], | ||
| 1418 | + [255, 0, 0, 255], | ||
| 1419 | + "red survives the channel swap" | ||
| 1420 | + ); | ||
| 1361 | assert_eq!(rgba[4..8], [0, 255, 0, 255], "green is unmoved by the swap"); | 1421 | assert_eq!(rgba[4..8], [0, 255, 0, 255], "green is unmoved by the swap"); |
| 1362 | assert_eq!(rgba[8..12], [0, 0, 255, 255], "blue swaps into place"); | 1422 | assert_eq!(rgba[8..12], [0, 0, 255, 255], "blue swaps into place"); |
| 1363 | assert_eq!(rgba[12..16], [255, 255, 255, 128], "alpha is untouched"); | 1423 | 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() { | |||
| 1368 | let buf = image::RgbaImage::from_raw(2, 2, rgba.clone()).expect("2x2 rgba buffer"); | 1428 | let buf = image::RgbaImage::from_raw(2, 2, rgba.clone()).expect("2x2 rgba buffer"); |
| 1369 | buf.save(&path).expect("png write"); | 1429 | buf.save(&path).expect("png write"); |
| 1370 | let decoded = image::open(&path).expect("png read").to_rgba8(); | 1430 | let decoded = image::open(&path).expect("png read").to_rgba8(); |
| 1371 | - assert_eq!(decoded.into_raw(), rgba, "the PNG round-trips the pixels exactly"); | 1431 | + assert_eq!( |
| 1432 | + decoded.into_raw(), | ||
| 1433 | + rgba, | ||
| 1434 | + "the PNG round-trips the pixels exactly" | ||
| 1435 | + ); | ||
| 1372 | let _ = std::fs::remove_dir_all(&dir); | 1436 | let _ = std::fs::remove_dir_all(&dir); |
| 1373 | } | 1437 | } |
| 1374 | 1438 | ||
crates/app/src/tests/mod.rsmodified+56 -57
| @@ -3,66 +3,59 @@ | |||
| 3 | //! stays here is what every part of it shares -- the imports, the fixtures, | 3 | //! stays here is what every part of it shares -- the imports, the fixtures, |
| 4 | //! and the source scans the guards read. | 4 | //! and the source scans the guards read. |
| 5 | 5 | ||
| 6 | -mod editing; | ||
| 7 | -mod view; | ||
| 8 | mod cards; | 6 | mod cards; |
| 9 | -mod media; | 7 | +mod editing; |
| 10 | mod layout; | 8 | mod layout; |
| 9 | +mod media; | ||
| 10 | +mod view; | ||
| 11 | 11 | ||
| 12 | use super::{ | 12 | use super::{ |
| 13 | - ACCENT_PRIMARY, AUDIO_KBPS, COLOR_BANDS, COLOR_BAR_W, COLOR_STEP, COLOR_W, CONTROL_H, Clip, Ctx, DEFAULT_AUDIO_KBPS, EQ_BANDS_MAX, | 13 | + ACCENT_PRIMARY, AUDIO_KBPS, BG_RAISED, COLOR_BANDS, COLOR_BAR_W, COLOR_STEP, COLOR_W, |
| 14 | - EQ_CURVE_STEPS, EQ_FFT, EQ_FREQ_HIGH, EQ_FREQ_LOW, EQ_FREQ_STEP, EQ_GAIN_LIMIT, EQ_GRAPH_H, | 14 | + CONTROL_H, Clip, Ctx, DEFAULT_AUDIO_KBPS, EQ_BANDS_MAX, EQ_CURVE_STEPS, EQ_FFT, EQ_FREQ_HIGH, |
| 15 | - EQ_HANDLE, EQ_Q_HIGH, EQ_Q_LOW, EQ_Q_STEP, EQ_SPECTRUM_DB, EQ_TICKS, EQ_W_MAX, ESCAPE, | 15 | + EQ_FREQ_LOW, EQ_FREQ_STEP, EQ_GAIN_LIMIT, EQ_GRAPH_H, EQ_HANDLE, EQ_Q_HIGH, EQ_Q_LOW, |
| 16 | - EXPORT_FIXED_H, EXPORT_ROWS_H, EXPORT_W, Enable, EncoderSeat, ExportPreset, FORMATS, | 16 | + EQ_Q_STEP, EQ_SPECTRUM_DB, EQ_TICKS, EQ_W_MAX, ESCAPE, EXPORT_DONE, EXPORT_FIXED_H, |
| 17 | - Format, HEADER_GAP, HEADER_H, HEADER_W, HIST_BINS, HIST_H, HIST_SAMPLES, HIT_MIN, | 17 | + EXPORT_ROWS_H, EXPORT_W, Enable, EncoderSeat, ExportPreset, FORMATS, Format, HEADER_GAP, |
| 18 | - KEYS_ROW_H, KEYS_ROWS_H, KEYS_W, KeyRow, LABEL_H, LABEL_MIN_W, LANE_H, LANES_MAX, | 18 | + HEADER_H, HEADER_W, HIST_BINS, HIST_H, HIST_SAMPLES, HIT_MIN, KEYS_ROW_H, KEYS_ROWS_H, KEYS_W, |
| 19 | - LIBRARY_MAX_W, LIBRARY_MIN_W, Lane, MENU_ITEMS, MENU_PAD, MENU_ROW_H, | 19 | + KeyRow, LABEL_H, LABEL_MIN_W, LANE_H, LANES_MAX, LATE_RESYNC, LIBRARY_MAX_W, LIBRARY_MIN_W, |
| 20 | - SUB_LANE_H, lanes_h_mixed, lanes_shown_mixed, rows_below_mixed, | 20 | + Lane, MB_FLOOR, MBPS_DIGITS, MBPS_MAX, MBPS_MIN, MENU_ITEMS, MENU_PAD, MENU_ROW_H, MENU_W, |
| 21 | - MBPS_DIGITS, MBPS_MAX, MBPS_MIN, MB_FLOOR, MENU_W, NO_FILE, NumberEdit, PANEL_H, ROW_ITEMS, RowCtx, RowItem, | 21 | + NO_FILE, NOTICES_MAX, NumberEdit, OVERLAID, PANEL_H, Quality, RESYNC_GAP, ROW_H, ROW_ITEMS, |
| 22 | - Quality, ROW_H, RULER_HIT_H, SCROLL_NOTCH_SHARE, SILENCE_ROWS, | 22 | + RULER_HIT_H, RowCtx, RowItem, SCROLL_NOTCH_SHARE, SILENCE_ROWS, SOURCE_TINTS, SPEED_PRESETS, |
| 23 | - SOURCE_TINTS, SPEED_PRESETS, SPEED_STEP, BG_RAISED, SWATCH_W, Source, Speed, StreamInfo, | 23 | + SPEED_STEP, STATUS_ERROR, STATUS_SUCCESS, STATUS_WARNING, SUB_LANE_H, SUB_PLAN_CHARS, SWATCH_W, |
| 24 | - Transport, VOLUME_W, Volume, WAVE_BPS, WAVE_COL, WAVE_COLS_MAX, Wave, band_label, | 24 | + Source, Speed, StreamInfo, TIMELINE_SHARE, Transport, VOLUME_W, Volume, WAVE_BPS, WAVE_COL, |
| 25 | - bitrate_detail, bitrate_refusal, can_add, cancels_export, clipboard_after_remove, color_snap, commit_mbps, | 25 | + WAVE_COLS_MAX, Wave, active_lane, band_label, bitrate_detail, bitrate_refusal, can_add, |
| 26 | - containers, | 26 | + cancels_export, clipboard_after_remove, color_snap, commit_mbps, containers, enable, |
| 27 | - enable, enable_lane, envelope, eq_card_w, eq_freq, eq_freq_label, eq_graph_h, eq_spectrum, eq_x, eq_y, | 27 | + enable_lane, envelope, eq_card_w, eq_freq, eq_freq_label, eq_graph_h, eq_spectrum, eq_x, eq_y, |
| 28 | - escape_leaves_player_fullscreen, | 28 | + escape_leaves_player_fullscreen, estimated_bytes, export_path, export_settings, format_key, |
| 29 | - estimated_bytes, export_path, export_settings, format_key, | ||
| 30 | format_line, format_refusal, fps_choices, fps_label, frac_along, frac_down, frame_at, | 29 | format_line, format_refusal, fps_choices, fps_label, frac_along, frac_down, frame_at, |
| 31 | - frame_rate_ladder, histogram, | 30 | + frame_rate_ladder, histogram, inserted_band, is_bare_modifier, is_project, keymap, keys_filter, |
| 32 | - inserted_band, is_bare_modifier, is_project, keymap, keys_filter, keys_rows, lanes_h, | 31 | + keys_rows, lanes_h, lanes_h_mixed, lanes_shown_mixed, marked, menu_at, menu_items, menu_rows_h, |
| 33 | - active_lane, marked, menu_at, menu_items, menu_rows_h, next_audio_kbps, next_container, normalise, nothing_to_play, panel_h, project_path, | 32 | + next_audio_kbps, next_container, normalise, nothing_to_play, notice_tone, panel_h, |
| 34 | - LATE_RESYNC, RESYNC_GAP, should_resync, | 33 | + project_path, proxies_to_start, push_notice, px_below, retarget, row_enable, row_items, |
| 35 | - retarget, row_enable, row_items, scrub_due, secs_label, show_label, silence_rate, size_label, snap_cue, snap_marks, snapped, | 34 | + rows_below_mixed, scrub_due, secs_label, should_resync, show_label, silence_rate, size_label, |
| 36 | - SUB_PLAN_CHARS, source_tint, span_partner, speed_at, sub_pick_after_removal, subtitle_plan, summary_head, summary_tail, timecode, transport, | 35 | + snap_cue, snap_marks, snapped, source_tint, span_partner, speed_at, sub_pick_after_removal, |
| 37 | - EXPORT_DONE, NOTICES_MAX, STATUS_ERROR, TIMELINE_SHARE, timeline_fixed_h, | 36 | + subtitle_plan, summary_head, summary_tail, timecode, timeline_fixed_h, tip_may_paint, |
| 38 | - px_below, STATUS_SUCCESS, STATUS_WARNING, notice_tone, | 37 | + transport, typed, unseen_paths, unseen_sources, whole_take, window_title, |
| 39 | - proxies_to_start, push_notice, typed, unseen_paths, unseen_sources, | ||
| 40 | - whole_take, window_title, | ||
| 41 | - OVERLAID, tip_may_paint, | ||
| 42 | }; | 38 | }; |
| 43 | 39 | ||
| 44 | use super::{ | 40 | use super::{ |
| 45 | - ActionId, Choice, EDGE_W, ETA_SPAN, Edge, FITS, FRAME_RATES, LaneKind, SubClip, PPS_DEFAULT, PPS_MIN, Preset, RESOLUTIONS, Repeat, | 41 | + ActionId, Choice, EDGE_W, ETA_SPAN, Edge, FITS, FRAME_RATES, IMPORT_STALL, Import, ImportStage, |
| 46 | - Scale, View, | 42 | + Landing, LaneKind, PPS_DEFAULT, PPS_MIN, Preset, RESOLUTIONS, Repeat, SAMPLE_RATES, SEEK_STALL, |
| 47 | - ZOOM_MIN_FRAMES, ZOOM_OUT_MARGIN, ZOOM_STEP, audio_rate_choices, av1_hw_warning, clock, | 43 | + Scale, ScanKey, ScanPlan, SilenceScan, SubClip, View, ZOOM_MIN_FRAMES, ZOOM_OUT_MARGIN, |
| 48 | - encoder_choices, encoder_label, eta_secs, file_name, file_uri, | 44 | + ZOOM_STEP, arrival, audio_rate_choices, av1_hw_warning, clip_width, clock, encoder_choices, |
| 49 | - fit_choices, landing, lane_refuses, library_rows, live_idx, next_fit, next_resolution, | 45 | + encoder_label, eta_secs, file_name, file_uri, fit_choices, frames_of_us, full_scan_key, |
| 50 | - note_progress, px_along, | 46 | + import_line, landing, lane_refuses, launch_queue, library_rows, live_idx, next_fit, |
| 51 | - IMPORT_STALL, Import, ImportStage, SEEK_STALL, ScanKey, ScanPlan, SilenceScan, import_line, | 47 | + next_resolution, note_progress, pending_fps_choices, pending_resolution_choices, px_along, |
| 52 | - Landing, arrival, launch_queue, full_scan_key, silence_cached, slice_whole_levels, | 48 | + read_ahead, repeats, resolution_choices, resolution_ladder, sample_rate_choices, scan_plan, |
| 53 | - read_ahead, scan_plan, seek_line, silence_line, source_secs, stash_or_write, | 49 | + seek_line, silence_cached, silence_line, slice_whole_levels, source_secs, span_label, |
| 54 | - repeats, resolution_choices, resolution_ladder, pending_resolution_choices, pending_fps_choices, | 50 | + stash_or_write, tone_choices, tone_label, trimmed_clip, trimmed_sub, trims, unscannable, |
| 55 | - SAMPLE_RATES, sample_rate_choices, span_label, tone_choices, tone_label, | 51 | + unusable, visible_slice, |
| 56 | - clip_width, frames_of_us, trimmed_clip, trimmed_sub, trims, unscannable, unusable, | ||
| 57 | - visible_slice, | ||
| 58 | }; | 52 | }; |
| 59 | 53 | ||
| 60 | use super::{ | 54 | use super::{ |
| 61 | - SUB_BOTTOM, SUB_CUE_MIN_W, SUB_HEAD_H, SUB_LINE_H, SUB_ROWS_H, | 55 | + SUB_BOTTOM, SUB_CUE_MIN_W, SUB_HEAD_H, SUB_LINE_H, SUB_ROWS_H, SUB_STEM_SHARE, SUB_TEXT, Subs, |
| 62 | - SUB_STEM_SHARE, SUB_TEXT, clip_middle, cue_box, sub_bottom, | 56 | + carries_subtitles, clip_middle, cue_box, cues_at, file_tint, is_subtitle, lang_human, |
| 63 | - carries_subtitles, cues_at, file_tint, is_subtitle, lang_human, row_text_w, | 57 | + row_text_w, sub_bottom, sub_pick_name, subtitle_detail, subtitle_notice, subtitle_rows, |
| 64 | - Subs, subtitle_detail, subtitle_notice, subtitle_tail, | 58 | + subtitle_tail, subtitle_toggle_notice, walk_subtitles, |
| 65 | - sub_pick_name, subtitle_rows, subtitle_toggle_notice, walk_subtitles, | ||
| 66 | }; | 59 | }; |
| 67 | 60 | ||
| 68 | use engine::PlaybackSession; | 61 | use engine::PlaybackSession; |
| @@ -77,6 +70,16 @@ use std::path::{Path, PathBuf}; | |||
| 77 | 70 | ||
| 78 | use std::time::{Duration, Instant}; | 71 | use std::time::{Duration, Instant}; |
| 79 | 72 | ||
| 73 | +use std::sync::{LazyLock, Mutex, MutexGuard}; | ||
| 74 | + | ||
| 75 | +static CONFIG_ENV_LOCK: LazyLock<Mutex<()>> = LazyLock::new(|| Mutex::new(())); | ||
| 76 | + | ||
| 77 | +fn config_env_lock() -> MutexGuard<'static, ()> { | ||
| 78 | + CONFIG_ENV_LOCK | ||
| 79 | + .lock() | ||
| 80 | + .expect("config environment lock poisoned") | ||
| 81 | +} | ||
| 82 | + | ||
| 80 | /// Every line of the window's source there is, as one string. The regions have | 83 | /// Every line of the window's source there is, as one string. The regions have |
| 81 | /// moved house twice -- one `main.rs`, then `ui/`, then the tests out of it -- | 84 | /// moved house twice -- one `main.rs`, then `ui/`, then the tests out of it -- |
| 82 | /// and a scan that names its files passes a rule by simply not looking where | 85 | /// 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 { | |||
| 116 | /// window instead. | 119 | /// window instead. |
| 117 | fn fn_body(name: &str) -> String { | 120 | fn fn_body(name: &str) -> String { |
| 118 | let text = source_from(&format!("fn {name}(")); | 121 | let text = source_from(&format!("fn {name}(")); |
| 119 | - let end = text.find("\n }\n").map_or(text.len(), |at| at + "\n }\n".len()); | 122 | + let end = text |
| 123 | + .find("\n }\n") | ||
| 124 | + .map_or(text.len(), |at| at + "\n }\n".len()); | ||
| 120 | text[..end].to_string() | 125 | text[..end].to_string() |
| 121 | } | 126 | } |
| 122 | 127 | ||
| @@ -170,13 +175,7 @@ fn source(path: &str, stream: usize) -> Source { | |||
| 170 | } | 175 | } |
| 171 | } | 176 | } |
| 172 | 177 | ||
| 173 | -fn info( | 178 | +fn info(index: usize, rate: u32, channels: u16, lang: Option<&str>, decodable: bool) -> StreamInfo { |
| 174 | - index: usize, | ||
| 175 | - rate: u32, | ||
| 176 | - channels: u16, | ||
| 177 | - lang: Option<&str>, | ||
| 178 | - decodable: bool, | ||
| 179 | -) -> StreamInfo { | ||
| 180 | StreamInfo { | 179 | StreamInfo { |
| 181 | index, | 180 | index, |
| 182 | codec: if decodable { "aac" } else { "unknown" }.into(), | 181 | codec: if decodable { "aac" } else { "unknown" }.into(), |
crates/app/src/tests/view.rsmodified+33 -16
| @@ -221,13 +221,7 @@ fn a_rate_row_says_only_what_the_container_stated() { | |||
| 221 | // A Matroska states no audio rate of its own: the sound is dropped from | 221 | // A Matroska states no audio rate of its own: the sound is dropped from |
| 222 | // the line, never drawn as "0". | 222 | // the line, never drawn as "0". |
| 223 | assert_eq!( | 223 | assert_eq!( |
| 224 | - bitrate_detail( | 224 | + bitrate_detail(Some(MediaBitrate { audio: None, ..all }), 1), |
| 225 | - Some(MediaBitrate { | ||
| 226 | - audio: None, | ||
| 227 | - ..all | ||
| 228 | - }), | ||
| 229 | - 1 | ||
| 230 | - ), | ||
| 231 | "8.4 Mb/s · 7.9 video" | 225 | "8.4 Mb/s · 7.9 video" |
| 232 | ); | 226 | ); |
| 233 | // A still, or anything that would not open: the probe answered, and the | 227 | // 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() { | |||
| 293 | .filter_map(|part| part.split(' ').next()) | 287 | .filter_map(|part| part.split(' ').next()) |
| 294 | .filter_map(|n| n.parse::<f64>().ok()) | 288 | .filter_map(|n| n.parse::<f64>().ok()) |
| 295 | { | 289 | { |
| 296 | - assert!(number > 0., "{small}/{big} bits a second rendered as {line:?}"); | 290 | + assert!( |
| 291 | + number > 0., | ||
| 292 | + "{small}/{big} bits a second rendered as {line:?}" | ||
| 293 | + ); | ||
| 297 | } | 294 | } |
| 298 | } | 295 | } |
| 299 | } | 296 | } |
| @@ -418,9 +415,7 @@ fn no_stroke_is_missing_from_the_keys_menu() { | |||
| 418 | for (at, needle) in handler.match_indices("key == ") { | 415 | for (at, needle) in handler.match_indices("key == ") { |
| 419 | let rest = &handler[at + needle.len()..]; | 416 | let rest = &handler[at + needle.len()..]; |
| 420 | let key = match rest.strip_prefix('"') { | 417 | let key = match rest.strip_prefix('"') { |
| 421 | - Some(literal) => { | 418 | + Some(literal) => literal[..literal.find('"').expect("unterminated key")].to_string(), |
| 422 | - literal[..literal.find('"').expect("unterminated key")].to_string() | ||
| 423 | - } | ||
| 424 | // A named constant: the escape the cards get out by. | 419 | // A named constant: the escape the cards get out by. |
| 425 | None if rest.starts_with("ESCAPE") => crate::ESCAPE.to_string(), | 420 | None if rest.starts_with("ESCAPE") => crate::ESCAPE.to_string(), |
| 426 | None => panic!("a key compared against something this cannot read: {rest:.20}"), | 421 | 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() { | |||
| 589 | // clamp against, and a zoom must survive the frame before the probe. | 584 | // clamp against, and a zoom must survive the frame before the probe. |
| 590 | let unpainted = View { | 585 | let unpainted = View { |
| 591 | bed: 0., | 586 | bed: 0., |
| 592 | - ..test_view(Scale { pps: 4e6, start: 3. }, duration) | 587 | + ..test_view( |
| 588 | + Scale { | ||
| 589 | + pps: 4e6, | ||
| 590 | + start: 3., | ||
| 591 | + }, | ||
| 592 | + duration, | ||
| 593 | + ) | ||
| 593 | }; | 594 | }; |
| 594 | assert_eq!(unpainted.settled().pps, 4e6); | 595 | assert_eq!(unpainted.settled().pps, 4e6); |
| 595 | assert_eq!(unpainted.following(19.), unpainted.scale); | 596 | assert_eq!(unpainted.following(19.), unpainted.scale); |
| @@ -622,7 +623,10 @@ fn zooming_out_reaches_the_end_of_a_timeline_however_long_it_is() { | |||
| 622 | // window rather than against its edge. | 623 | // window rather than against its edge. |
| 623 | assert_eq!(wide.start, 0.); | 624 | assert_eq!(wide.start, 0.); |
| 624 | let end = wide.px_at(five_hours); | 625 | let end = wide.px_at(five_hours); |
| 625 | - assert!(end < bed, "the end of the timeline is off the bed at {end} px"); | 626 | + assert!( |
| 627 | + end < bed, | ||
| 628 | + "the end of the timeline is off the bed at {end} px" | ||
| 629 | + ); | ||
| 626 | assert!(end > bed * 0.9, "and not shrunk into a corner: {end} px"); | 630 | assert!(end > bed * 0.9, "and not shrunk into a corner: {end} px"); |
| 627 | assert!( | 631 | assert!( |
| 628 | (view(wide, five_hours).span() - five_hours * ZOOM_OUT_MARGIN).abs() < 1e-6, | 632 | (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() { | |||
| 645 | // Whatever the length, the resting scale is nobody's content: the width | 649 | // Whatever the length, the resting scale is nobody's content: the width |
| 646 | // invariant, which a far stop measured off the content would break. | 650 | // invariant, which a far stop measured off the content would break. |
| 647 | assert_eq!(view(Scale::default(), 10.).settled(), Scale::default()); | 651 | assert_eq!(view(Scale::default(), 10.).settled(), Scale::default()); |
| 648 | - assert_eq!(view(Scale::default(), five_hours).settled(), Scale::default()); | 652 | + assert_eq!( |
| 653 | + view(Scale::default(), five_hours).settled(), | ||
| 654 | + Scale::default() | ||
| 655 | + ); | ||
| 649 | // Shrinking the timeline pulls a fully zoomed out view in with it -- | 656 | // Shrinking the timeline pulls a fully zoomed out view in with it -- |
| 650 | // what was showing all of the timeline still shows all of it. | 657 | // what was showing all of the timeline still shows all of it. |
| 651 | let shrunk = view(wide, 1800.).settled(); | 658 | let shrunk = view(wide, 1800.).settled(); |
| @@ -764,7 +771,14 @@ fn the_view_follows_a_playhead_that_runs_off_the_bed() { | |||
| 764 | #[test] | 771 | #[test] |
| 765 | fn a_scroll_during_playback_wins_until_the_head_catches_up() { | 772 | fn a_scroll_during_playback_wins_until_the_head_catches_up() { |
| 766 | let duration = 80.; | 773 | let duration = 80.; |
| 767 | - let mut scale = test_view(Scale { pps: 40., start: 0. }, duration).settled(); | 774 | + let mut scale = test_view( |
| 775 | + Scale { | ||
| 776 | + pps: 40., | ||
| 777 | + start: 0., | ||
| 778 | + }, | ||
| 779 | + duration, | ||
| 780 | + ) | ||
| 781 | + .settled(); | ||
| 768 | // The render's arbitration, in the two lines it is there: a panned view | 782 | // The render's arbitration, in the two lines it is there: a panned view |
| 769 | // is left where the hand put it, and the pan ends where the head is | 783 | // is left where the hand put it, and the pan ends where the head is |
| 770 | // back on the bed. | 784 | // back on the bed. |
| @@ -802,7 +816,10 @@ fn a_scroll_during_playback_wins_until_the_head_catches_up() { | |||
| 802 | assert_eq!(start, scale.start, "and it did not jump to take it"); | 816 | assert_eq!(start, scale.start, "and it did not jump to take it"); |
| 803 | // ...and the next head that runs off the bed pulls the view again. | 817 | // ...and the next head that runs off the bed pulls the view again. |
| 804 | let ran_off = frame(scale, &mut panned, start + span + 1.); | 818 | let ran_off = frame(scale, &mut panned, start + span + 1.); |
| 805 | - assert!(ran_off.start > start, "the follow follows again: {ran_off:?}"); | 819 | + assert!( |
| 820 | + ran_off.start > start, | ||
| 821 | + "the follow follows again: {ran_off:?}" | ||
| 822 | + ); | ||
| 806 | // A paused hand is untouched by any of this: with no follow asking, | 823 | // A paused hand is untouched by any of this: with no follow asking, |
| 807 | // `shows` is the only thing the pan is ever released by. | 824 | // `shows` is the only thing the pan is ever released by. |
| 808 | assert!(test_view(scale, duration).shows(scale.start)); | 825 | assert!(test_view(scale, duration).shows(scale.start)); |
crates/app/src/timeline_math.rsmodified+38 -34
| @@ -65,7 +65,11 @@ pub(crate) fn whole_take(session: &PlaybackSession, lane: Lane, idx: usize) -> b | |||
| 65 | /// group id can mean (engine `links_are_consistent`), which is what leaves | 65 | /// group id can mean (engine `links_are_consistent`), which is what leaves |
| 66 | /// nothing for a second click to choose. `None` when no track has one, and the | 66 | /// nothing for a second click to choose. `None` when no track has one, and the |
| 67 | /// notice says so. | 67 | /// notice says so. |
| 68 | -pub(crate) fn span_partner(session: &PlaybackSession, lane: Lane, idx: usize) -> Option<(Lane, usize)> { | 68 | +pub(crate) fn span_partner( |
| 69 | + session: &PlaybackSession, | ||
| 70 | + lane: Lane, | ||
| 71 | + idx: usize, | ||
| 72 | +) -> Option<(Lane, usize)> { | ||
| 69 | let clip = *session.lane_clips(lane).get(idx)?; | 73 | let clip = *session.lane_clips(lane).get(idx)?; |
| 70 | let matches = |other: Lane| { | 74 | let matches = |other: Lane| { |
| 71 | let i = session.lane_clips(other).iter().position(|c| { | 75 | let i = session.lane_clips(other).iter().position(|c| { |
| @@ -138,8 +142,8 @@ impl Selection { | |||
| 138 | } | 142 | } |
| 139 | 143 | ||
| 140 | /// Whether `pick` is one of the selection's -- the question a right-click | 144 | /// Whether `pick` is one of the selection's -- the question a right-click |
| 141 | - /// asks before it decides whether the menu is about the selection or | 145 | + /// asks before it decides whether the menu is about the selection or |
| 142 | - /// about the clip under it. | 146 | + /// about the clip under it. |
| 143 | pub(crate) fn contains(&self, pick: (Lane, usize)) -> bool { | 147 | pub(crate) fn contains(&self, pick: (Lane, usize)) -> bool { |
| 144 | self.picks.contains(&pick) | 148 | self.picks.contains(&pick) |
| 145 | } | 149 | } |
| @@ -187,12 +191,10 @@ pub(crate) fn caption_rate(sub: SubClip, fps: f64) -> Option<Speed> { | |||
| 187 | // own `speed` in the same spelling: 10s of words crossing 5s of timeline | 191 | // own `speed` in the same spelling: 10s of words crossing 5s of timeline |
| 188 | // is 2.00x. | 192 | // is 2.00x. |
| 189 | let permille = (window_us / span_us * 1000.).round(); | 193 | let permille = (window_us / span_us * 1000.).round(); |
| 190 | - Some(Speed::from_permille( | 194 | + Some(Speed::from_permille(permille.clamp( |
| 191 | - permille.clamp( | 195 | + f64::from(Speed::MIN.permille()), |
| 192 | - f64::from(Speed::MIN.permille()), | 196 | + f64::from(Speed::MAX.permille()), |
| 193 | - f64::from(Speed::MAX.permille()), | 197 | + ) as u16)) |
| 194 | - ) as u16, | ||
| 195 | - )) | ||
| 196 | } | 198 | } |
| 197 | 199 | ||
| 198 | /// The scrollbar's thumb over a track `w` px wide: `(x, width)` of the box | 200 | /// 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<Speed> { | |||
| 202 | /// narrower than [`SCROLL_THUMB_MIN`] when there is (a thumb a pixel wide is a | 204 | /// narrower than [`SCROLL_THUMB_MIN`] when there is (a thumb a pixel wide is a |
| 203 | /// thumb no hand can hold), and never off the track either way -- the clamp, | 205 | /// thumb no hand can hold), and never off the track either way -- the clamp, |
| 204 | /// not the caller, owns that, because a drag's samples arrive raw. | 206 | /// not the caller, owns that, because a drag's samples arrive raw. |
| 205 | -pub(crate) fn scroll_thumb( | 207 | +pub(crate) fn scroll_thumb(w: f32, duration: f64, start: f64, span: f64) -> (f32, f32) { |
| 206 | - w: f32, | ||
| 207 | - duration: f64, | ||
| 208 | - start: f64, | ||
| 209 | - span: f64, | ||
| 210 | -) -> (f32, f32) { | ||
| 211 | if w <= 0. || duration <= 0. || span >= duration { | 208 | if w <= 0. || duration <= 0. || span >= duration { |
| 212 | return (0., w.max(0.)); | 209 | return (0., w.max(0.)); |
| 213 | } | 210 | } |
| @@ -260,7 +257,6 @@ pub(crate) fn marked( | |||
| 260 | picks.contains(&here) || (link.is_some() && pick_links.contains(&link)) | 257 | picks.contains(&here) || (link.is_some() && pick_links.contains(&link)) |
| 261 | } | 258 | } |
| 262 | 259 | ||
| 263 | - | ||
| 264 | /// Whether a clip is wide enough to be worth naming. | 260 | /// Whether a clip is wide enough to be worth naming. |
| 265 | pub(crate) fn show_label(w: f32) -> bool { | 261 | pub(crate) fn show_label(w: f32) -> bool { |
| 266 | w >= LABEL_MIN_W | 262 | w >= LABEL_MIN_W |
| @@ -341,7 +337,11 @@ pub(crate) fn walk_cut(idx: usize, len: usize, forward: bool, stride: usize) -> | |||
| 341 | return 0; | 337 | return 0; |
| 342 | } | 338 | } |
| 343 | let delta = stride.min(len - 1) as isize; | 339 | let delta = stride.min(len - 1) as isize; |
| 344 | - let at = if forward { idx as isize + delta } else { idx as isize - delta }; | 340 | + let at = if forward { |
| 341 | + idx as isize + delta | ||
| 342 | + } else { | ||
| 343 | + idx as isize - delta | ||
| 344 | + }; | ||
| 345 | at.clamp(0, len as isize - 1) as usize | 345 | at.clamp(0, len as isize - 1) as usize |
| 346 | } | 346 | } |
| 347 | 347 | ||
| @@ -496,7 +496,13 @@ pub(crate) fn normalise(mut peaks: Vec<(f32, f32)>) -> Vec<(f32, f32)> { | |||
| 496 | /// -- a clip's waveform cannot paint over its neighbour -- and every column is | 496 | /// -- a clip's waveform cannot paint over its neighbour -- and every column is |
| 497 | /// at least a pixel tall, so silence reads as a line through the middle rather | 497 | /// at least a pixel tall, so silence reads as a line through the middle rather |
| 498 | /// than as a polygon with no area. | 498 | /// than as a polygon with no area. |
| 499 | -pub(crate) fn envelope(peaks: &[(f32, f32)], from: f64, to: f64, w: f32, h: f32) -> Vec<(f32, f32, f32)> { | 499 | +pub(crate) fn envelope( |
| 500 | + peaks: &[(f32, f32)], | ||
| 501 | + from: f64, | ||
| 502 | + to: f64, | ||
| 503 | + w: f32, | ||
| 504 | + h: f32, | ||
| 505 | +) -> Vec<(f32, f32, f32)> { | ||
| 500 | if peaks.is_empty() || w <= 0. || h <= 0. { | 506 | if peaks.is_empty() || w <= 0. || h <= 0. { |
| 501 | return Vec::new(); | 507 | return Vec::new(); |
| 502 | } | 508 | } |
| @@ -517,13 +523,6 @@ pub(crate) fn envelope(peaks: &[(f32, f32)], from: f64, to: f64, w: f32, h: f32) | |||
| 517 | .collect() | 523 | .collect() |
| 518 | } | 524 | } |
| 519 | 525 | ||
| 520 | - | ||
| 521 | - | ||
| 522 | - | ||
| 523 | - | ||
| 524 | - | ||
| 525 | - | ||
| 526 | - | ||
| 527 | /// Records its parent's laid-out box: gpui hands a mouse listener the window | 526 | /// Records its parent's laid-out box: gpui hands a mouse listener the window |
| 528 | /// position only, and the ruler sits behind the panel's padding. Paints | 527 | /// position only, and the ruler sits behind the panel's padding. Paints |
| 529 | /// nothing and takes no hitbox of its own, so the click still reaches the bar. | 528 | /// nothing and takes no hitbox of its own, so the click still reaches the bar. |
| @@ -642,8 +641,7 @@ pub(crate) fn snap_marks( | |||
| 642 | .iter() | 641 | .iter() |
| 643 | .enumerate() | 642 | .enumerate() |
| 644 | .filter(move |&(idx, clip)| { | 643 | .filter(move |&(idx, clip)| { |
| 645 | - Some((lane, idx)) != skip | 644 | + Some((lane, idx)) != skip && !(skip_link.is_some() && clip.link == skip_link) |
| 646 | - && !(skip_link.is_some() && clip.link == skip_link) | ||
| 647 | }) | 645 | }) |
| 648 | .flat_map(|(_, clip)| [clip.start, clip.end()]) | 646 | .flat_map(|(_, clip)| [clip.start, clip.end()]) |
| 649 | }) | 647 | }) |
| @@ -660,7 +658,13 @@ pub(crate) fn snap_marks( | |||
| 660 | /// | 658 | /// |
| 661 | /// `on` is the switch ([`ActionId::ToggleSnap`]): off, the gesture lands raw and | 659 | /// `on` is the switch ([`ActionId::ToggleSnap`]): off, the gesture lands raw and |
| 662 | /// draws no line at all, which is the whole point of being able to turn it off. | 660 | /// draws no line at all, which is the whole point of being able to turn it off. |
| 663 | -pub(crate) fn snap_cue(on: bool, raw: u32, len: u32, tol: u32, marks: &[u32]) -> (u32, Option<u32>) { | 661 | +pub(crate) fn snap_cue( |
| 662 | + on: bool, | ||
| 663 | + raw: u32, | ||
| 664 | + len: u32, | ||
| 665 | + tol: u32, | ||
| 666 | + marks: &[u32], | ||
| 667 | +) -> (u32, Option<u32>) { | ||
| 664 | if !on { | 668 | if !on { |
| 665 | return (raw, None); | 669 | return (raw, None); |
| 666 | } | 670 | } |
| @@ -699,12 +703,12 @@ pub(crate) fn lane_refuses(path: &Path, lane: Lane) -> Option<String> { | |||
| 699 | let name = file_name(path); | 703 | let name = file_name(path); |
| 700 | let label = lane.label(); | 704 | let label = lane.label(); |
| 701 | match lane.kind { | 705 | match lane.kind { |
| 702 | - LaneKind::Video if engine::is_audio(path) => { | 706 | + LaneKind::Video if engine::is_audio(path) => Some(format!( |
| 703 | - Some(format!("NOT ON {label} — {name} has no picture; drop it on an audio lane")) | 707 | + "NOT ON {label} — {name} has no picture; drop it on an audio lane" |
| 704 | - } | 708 | + )), |
| 705 | - LaneKind::Audio if engine::is_image(path) => { | 709 | + LaneKind::Audio if engine::is_image(path) => Some(format!( |
| 706 | - Some(format!("NOT ON {label} — {name} is a still image; drop it on a video lane")) | 710 | + "NOT ON {label} — {name} is a still image; drop it on a video lane" |
| 707 | - } | 711 | + )), |
| 708 | // A subtitle lane holds words and no media at all: the refusal is here | 712 | // A subtitle lane holds words and no media at all: the refusal is here |
| 709 | // rather than at the engine's door so the shadow is tinted red on the | 713 | // rather than at the engine's door so the shadow is tinted red on the |
| 710 | // way down, like every other lane a file cannot go on. | 714 | // way down, like every other lane a file cannot go on. |
crates/app/src/transport.rsmodified+9 -2
| @@ -54,7 +54,9 @@ impl Volume { | |||
| 54 | /// cannot wrap past silence into full volume. | 54 | /// cannot wrap past silence into full volume. |
| 55 | pub(crate) fn step(&mut self, up: bool) { | 55 | pub(crate) fn step(&mut self, up: bool) { |
| 56 | self.steps = if up { | 56 | self.steps = if up { |
| 57 | - self.steps.saturating_add(Self::KEY_STEP).min(Self::MAX_STEPS) | 57 | + self.steps |
| 58 | + .saturating_add(Self::KEY_STEP) | ||
| 59 | + .min(Self::MAX_STEPS) | ||
| 58 | } else { | 60 | } else { |
| 59 | self.steps.saturating_sub(Self::KEY_STEP) | 61 | self.steps.saturating_sub(Self::KEY_STEP) |
| 60 | }; | 62 | }; |
| @@ -186,7 +188,12 @@ pub(crate) fn should_resync(late: f64, last: Option<Instant>) -> bool { | |||
| 186 | /// | 188 | /// |
| 187 | /// The press (`first`) never waits: it is the undo step the whole gesture rolls | 189 | /// The press (`first`) never waits: it is the undo step the whole gesture rolls |
| 188 | /// back to, so it has to be taken against the state the hand picked up. | 190 | /// back to, so it has to be taken against the state the hand picked up. |
| 189 | -pub(crate) fn stash_or_write<T: Copy>(stash: &mut Option<T>, value: T, first: bool, busy: bool) -> Option<T> { | 191 | +pub(crate) fn stash_or_write<T: Copy>( |
| 192 | + stash: &mut Option<T>, | ||
| 193 | + value: T, | ||
| 194 | + first: bool, | ||
| 195 | + busy: bool, | ||
| 196 | +) -> Option<T> { | ||
| 190 | match busy && !first { | 197 | match busy && !first { |
| 191 | true => { | 198 | true => { |
| 192 | *stash = Some(value); | 199 | *stash = Some(value); |
crates/app/src/ui/bench_stance.rsmodified+13 -22
| @@ -743,10 +743,7 @@ fn lane_row( | |||
| 743 | .as_ref() | 743 | .as_ref() |
| 744 | .map_or(0., |session| session.lane_gain_db(lane)); | 744 | .map_or(0., |session| session.lane_gain_db(lane)); |
| 745 | let shown = player.sub_lane_on(lane); | 745 | let shown = player.sub_lane_on(lane); |
| 746 | - let chord_style = type_scale::mono( | 746 | + let chord_style = type_scale::mono(type_scale::CHORD_METADATA_MIN_PX, gpui::FontWeight::MEDIUM); |
| 747 | - type_scale::CHORD_METADATA_MIN_PX, | ||
| 748 | - gpui::FontWeight::MEDIUM, | ||
| 749 | - ); | ||
| 750 | let drop = player | 747 | let drop = player |
| 751 | .lane_drop | 748 | .lane_drop |
| 752 | .filter(|drop| drop.lane == lane && cx.has_active_drag()); | 749 | .filter(|drop| drop.lane == lane && cx.has_active_drag()); |
| @@ -815,13 +812,11 @@ fn lane_row( | |||
| 815 | .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) | 812 | .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) |
| 816 | .tooltip(move |_, cx| { | 813 | .tooltip(move |_, cx| { |
| 817 | cx.new(|_| { | 814 | cx.new(|_| { |
| 818 | - Tip( | 815 | + Tip(format!( |
| 819 | - format!( | 816 | + "{} {gain_db:+.0} dB — mix this lane", |
| 820 | - "{} {gain_db:+.0} dB — mix this lane", | 817 | + lane.label() |
| 821 | - lane.label() | ||
| 822 | - ) | ||
| 823 | - .into(), | ||
| 824 | ) | 818 | ) |
| 819 | + .into()) | ||
| 825 | }) | 820 | }) |
| 826 | .into() | 821 | .into() |
| 827 | }) | 822 | }) |
| @@ -849,13 +844,11 @@ fn lane_row( | |||
| 849 | .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) | 844 | .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) |
| 850 | .tooltip(move |_, cx| { | 845 | .tooltip(move |_, cx| { |
| 851 | cx.new(|_| { | 846 | cx.new(|_| { |
| 852 | - Tip( | 847 | + Tip(format!( |
| 853 | - format!( | 848 | + "{} — click to show this subtitle lane", |
| 854 | - "{} — click to show this subtitle lane", | 849 | + lane.label() |
| 855 | - lane.label() | ||
| 856 | - ) | ||
| 857 | - .into(), | ||
| 858 | ) | 850 | ) |
| 851 | + .into()) | ||
| 859 | }) | 852 | }) |
| 860 | .into() | 853 | .into() |
| 861 | }) | 854 | }) |
| @@ -883,13 +876,11 @@ fn lane_row( | |||
| 883 | .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) | 876 | .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) |
| 884 | .tooltip(move |_, cx| { | 877 | .tooltip(move |_, cx| { |
| 885 | cx.new(|_| { | 878 | cx.new(|_| { |
| 886 | - Tip( | 879 | + Tip(format!( |
| 887 | - format!( | 880 | + "Remove {} — it must be empty first", |
| 888 | - "Remove {} — it must be empty first", | 881 | + lane.label() |
| 889 | - lane.label() | ||
| 890 | - ) | ||
| 891 | - .into(), | ||
| 892 | ) | 882 | ) |
| 883 | + .into()) | ||
| 893 | }) | 884 | }) |
| 894 | .into() | 885 | .into() |
| 895 | }) | 886 | }) |
crates/app/src/ui/dock_stance.rsmodified+1 -5
| @@ -95,7 +95,6 @@ impl DockSort { | |||
| 95 | } | 95 | } |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | - | ||
| 99 | /// A ghost verb (DESIGN §4): borderless glyph/label in `ink2`, its chord in | 98 | /// A ghost verb (DESIGN §4): borderless glyph/label in `ink2`, its chord in |
| 100 | /// `ink3` beside it, read live off the keymap so it can never drift from the | 99 | /// `ink3` beside it, read live off the keymap so it can never drift from the |
| 101 | /// key that does the same thing. Hover is one fill step and an ink brighten; | 100 | /// 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<Player>) -> impl IntoElement { | |||
| 758 | || ("unused".contains(&filter) && *placed == 0) | 757 | || ("unused".contains(&filter) && *placed == 0) |
| 759 | }) | 758 | }) |
| 760 | .collect(); | 759 | .collect(); |
| 761 | - let unused_count = rows | 760 | + let unused_count = rows.iter().filter(|(_, placed)| *placed == 0).count(); |
| 762 | - .iter() | ||
| 763 | - .filter(|(_, placed)| *placed == 0) | ||
| 764 | - .count(); | ||
| 765 | match player.dock_sort { | 761 | match player.dock_sort { |
| 766 | DockSort::Recent => {} | 762 | DockSort::Recent => {} |
| 767 | DockSort::Name => { | 763 | DockSort::Name => { |
crates/app/src/ui/inspector.rsmodified+9 -5
| @@ -7,15 +7,19 @@ | |||
| 7 | //! panel, and opening one occludes zero timeline pixels | 7 | //! panel, and opening one occludes zero timeline pixels |
| 8 | //! (`an_inspector_section_occludes_no_timeline`). | 8 | //! (`an_inspector_section_occludes_no_timeline`). |
| 9 | 9 | ||
| 10 | -use crate::*; | ||
| 11 | use crate::ui::toolbar::{TONE_SLOT_W, ZOOM_SLOT_W}; | 10 | use crate::ui::toolbar::{TONE_SLOT_W, ZOOM_SLOT_W}; |
| 11 | +use crate::*; | ||
| 12 | 12 | ||
| 13 | impl Player { | 13 | impl Player { |
| 14 | /// The inspector column. Two sections that are always there -- the | 14 | /// The inspector column. Two sections that are always there -- the |
| 15 | /// selection's and the project's -- and, over them, whichever settings card | 15 | /// selection's and the project's -- and, over them, whichever settings card |
| 16 | /// is open, which is a section of this panel rather than a sheet over the | 16 | /// is open, which is a section of this panel rather than a sheet over the |
| 17 | /// window. | 17 | /// window. |
| 18 | - pub(crate) fn inspector(&self, viewport: Size<Pixels>, cx: &mut Context<Self>) -> impl IntoElement { | 18 | + pub(crate) fn inspector( |
| 19 | + &self, | ||
| 20 | + viewport: Size<Pixels>, | ||
| 21 | + cx: &mut Context<Self>, | ||
| 22 | + ) -> impl IntoElement { | ||
| 19 | let width = self.split_px(Split::Inspector, viewport); | 23 | let width = self.split_px(Split::Inspector, viewport); |
| 20 | // The cards measure themselves against the room they are given, and the | 24 | // The cards measure themselves against the room they are given, and the |
| 21 | // room they are given is this column -- not the window. | 25 | // room they are given is this column -- not the window. |
| @@ -114,9 +118,9 @@ impl Player { | |||
| 114 | .anchor() | 118 | .anchor() |
| 115 | .filter(|_| picked.is_none()) | 119 | .filter(|_| picked.is_none()) |
| 116 | .and_then(|(lane, idx)| { | 120 | .and_then(|(lane, idx)| { |
| 117 | - let sub = self.session.as_ref()?.sub_lane(lane).get(idx).copied()?; | 121 | + let sub = self.session.as_ref()?.sub_lane(lane).get(idx).copied()?; |
| 118 | - Some((lane, sub)) | 122 | + Some((lane, sub)) |
| 119 | - }); | 123 | + }); |
| 120 | // A multi-selection is named for its anchor and counted: what the | 124 | // A multi-selection is named for its anchor and counted: what the |
| 121 | // panel shows is the anchor's settings, and the count says there is | 125 | // panel shows is the anchor's settings, and the count says there is |
| 122 | // more in hand than the panel is showing. | 126 | // more in hand than the panel is showing. |
crates/app/src/ui/library.rsmodified+86 -82
| @@ -1,9 +1,9 @@ | |||
| 1 | //! The media library: the left panel's rows and the menu over them. | 1 | //! The media library: the left panel's rows and the menu over them. |
| 2 | 2 | ||
| 3 | -use crate::*; | ||
| 4 | -use crate::ui::widgets::*; | ||
| 5 | -use crate::ui::type_scale::Typeset; | ||
| 6 | use crate::ui::stance::menu_floor; | 3 | use crate::ui::stance::menu_floor; |
| 4 | +use crate::ui::type_scale::Typeset; | ||
| 5 | +use crate::ui::widgets::*; | ||
| 6 | +use crate::*; | ||
| 7 | 7 | ||
| 8 | impl Player { | 8 | impl Player { |
| 9 | /// The media library: a row per source the timeline knows, in the order | 9 | /// The media library: a row per source the timeline knows, in the order |
| @@ -184,8 +184,11 @@ impl Player { | |||
| 184 | let dragged = (path.clone(), stream); | 184 | let dragged = (path.clone(), stream); |
| 185 | let menu_path = path.clone(); | 185 | let menu_path = path.clone(); |
| 186 | let preview_path = path.clone(); | 186 | let preview_path = path.clone(); |
| 187 | - let preview_tip: SharedString = | 187 | + let preview_tip: SharedString = format!( |
| 188 | - format!("Preview {} — plays it without touching the timeline", row.name).into(); | 188 | + "Preview {} — plays it without touching the timeline", |
| 189 | + row.name | ||
| 190 | + ) | ||
| 191 | + .into(); | ||
| 189 | div() | 192 | div() |
| 190 | .id(("asset", i)) | 193 | .id(("asset", i)) |
| 191 | .flex_none() | 194 | .flex_none() |
| @@ -379,55 +382,49 @@ impl Player { | |||
| 379 | // lanes and the inspector give. | 382 | // lanes and the inspector give. |
| 380 | .overflow_y_scroll() | 383 | .overflow_y_scroll() |
| 381 | .child( | 384 | .child( |
| 382 | - div() | 385 | + div().flex_none().flex().items_center().gap(px(6.)).child( |
| 383 | - .flex_none() | 386 | + div() |
| 384 | - .flex() | 387 | + .flex_1() |
| 385 | - .items_center() | 388 | + .min_w(px(0.)) |
| 386 | - .gap(px(6.)) | 389 | + .flex() |
| 387 | - .child( | 390 | + // Wraps rather than clipping: at the 640 px floor |
| 388 | - div() | 391 | + // this column is 128 px wide and the third tab |
| 389 | - .flex_1() | 392 | + // would hang off its edge, which is a control the |
| 390 | - .min_w(px(0.)) | 393 | + // pointer cannot reach. |
| 391 | - .flex() | 394 | + .flex_wrap() |
| 392 | - // Wraps rather than clipping: at the 640 px floor | 395 | + .gap(px(2.)) |
| 393 | - // this column is 128 px wide and the third tab | 396 | + .children(LIBRARY_TABS.map(|tab| { |
| 394 | - // would hang off its edge, which is a control the | 397 | + let on = tab == self.library_tab; |
| 395 | - // pointer cannot reach. | 398 | + div() |
| 396 | - .flex_wrap() | 399 | + .id(("library-tab", tab as usize)) |
| 397 | - .gap(px(2.)) | 400 | + .flex_none() |
| 398 | - .children(LIBRARY_TABS.map(|tab| { | 401 | + .h(px(HIT_MIN)) |
| 399 | - let on = tab == self.library_tab; | 402 | + .px(px(6.)) |
| 400 | - div() | 403 | + .flex() |
| 401 | - .id(("library-tab", tab as usize)) | 404 | + .items_center() |
| 402 | - .flex_none() | 405 | + .rounded(px(3.)) |
| 403 | - .h(px(HIT_MIN)) | 406 | + .text_size(px(11.)) |
| 404 | - .px(px(6.)) | 407 | + .text_color(rgb(match on { |
| 405 | - .flex() | 408 | + true => FG_PRIMARY(), |
| 406 | - .items_center() | 409 | + false => FG_SECONDARY(), |
| 407 | - .rounded(px(3.)) | 410 | + })) |
| 408 | - .text_size(px(11.)) | 411 | + // One selection language everywhere: the |
| 409 | - .text_color(rgb(match on { | 412 | + // same stroke a picked clip and a picked |
| 410 | - true => FG_PRIMARY(), | 413 | + // row wear. |
| 411 | - false => FG_SECONDARY(), | 414 | + .when(on, |d| { |
| 412 | - })) | 415 | + d.bg(rgb(BG_SELECTED())) |
| 413 | - // One selection language everywhere: the | 416 | + .border_b_2() |
| 414 | - // same stroke a picked clip and a picked | 417 | + .border_color(rgb(STROKE_SELECTED())) |
| 415 | - // row wear. | 418 | + }) |
| 416 | - .when(on, |d| { | 419 | + .cursor_pointer() |
| 417 | - d.bg(rgb(BG_SELECTED())) | 420 | + .hover(|s| s.bg(rgb(BG_HOVER()))) |
| 418 | - .border_b_2() | 421 | + .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { |
| 419 | - .border_color(rgb(STROKE_SELECTED())) | 422 | + this.library_tab = tab; |
| 420 | - }) | 423 | + cx.notify(); |
| 421 | - .cursor_pointer() | 424 | + })) |
| 422 | - .hover(|s| s.bg(rgb(BG_HOVER()))) | 425 | + .child(tab.label()) |
| 423 | - .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | 426 | + })), |
| 424 | - this.library_tab = tab; | 427 | + ), |
| 425 | - cx.notify(); | ||
| 426 | - })) | ||
| 427 | - .child(tab.label()) | ||
| 428 | - })), | ||
| 429 | - ) | ||
| 430 | - , | ||
| 431 | ) | 428 | ) |
| 432 | // The tab says what the one full-width control is for. Text holds | 429 | // The tab says what the one full-width control is for. Text holds |
| 433 | // no rows of its own ([`LibraryTab::holds`]) -- it is the tracks | 430 | // no rows of its own ([`LibraryTab::holds`]) -- it is the tracks |
| @@ -466,26 +463,26 @@ impl Player { | |||
| 466 | }) | 463 | }) |
| 467 | .when(self.library_tab != LibraryTab::Text, |d| { | 464 | .when(self.library_tab != LibraryTab::Text, |d| { |
| 468 | d.child(div().flex_none().child(control( | 465 | d.child(div().flex_none().child(control( |
| 469 | - "import", | 466 | + "import", |
| 470 | - // Full width of the column: the way media gets in is | 467 | + // Full width of the column: the way media gets in is |
| 471 | - // the one affordance of the tabs that hold media, | 468 | + // the one affordance of the tabs that hold media, |
| 472 | - // however narrow the window is. | 469 | + // however narrow the window is. |
| 473 | - width - 16., | 470 | + width - 16., |
| 474 | - // Filled with the accent while there is nothing to work | 471 | + // Filled with the accent while there is nothing to work |
| 475 | - // on, because with an empty library this *is* the | 472 | + // on, because with an empty library this *is* the |
| 476 | - // primary action -- and Export, which wears the accent | 473 | + // primary action -- and Export, which wears the accent |
| 477 | - // the rest of the time, is dimmed until something is | 474 | + // the rest of the time, is dimmed until something is |
| 478 | - // imported. One live accent in the window either way. | 475 | + // imported. One live accent in the window either way. |
| 479 | - match rows.is_empty() { | 476 | + match rows.is_empty() { |
| 480 | - true => ACCENT_PRIMARY(), | 477 | + true => ACCENT_PRIMARY(), |
| 481 | - false => BG_RAISED(), | 478 | + false => BG_RAISED(), |
| 482 | - }, | 479 | + }, |
| 483 | - None, | 480 | + None, |
| 484 | - "Import", | 481 | + "Import", |
| 485 | - "adds a file to this list — or drop one on the window".to_string(), | 482 | + "adds a file to this list — or drop one on the window".to_string(), |
| 486 | - !exporting, | 483 | + !exporting, |
| 487 | - cx.listener(|this, _: &ClickEvent, _, cx| this.pick_and_import(cx)), | 484 | + cx.listener(|this, _: &ClickEvent, _, cx| this.pick_and_import(cx)), |
| 488 | - ))) | 485 | + ))) |
| 489 | }) | 486 | }) |
| 490 | .child( | 487 | .child( |
| 491 | div() | 488 | div() |
| @@ -640,14 +637,16 @@ impl Player { | |||
| 640 | rows.push( | 637 | rows.push( |
| 641 | row(rows.len()) | 638 | row(rows.len()) |
| 642 | .child(label) | 639 | .child(label) |
| 643 | - .child(chord_style( | 640 | + .child( |
| 644 | - div() | 641 | + chord_style( |
| 645 | - .min_w(px(0.)) | 642 | + div() |
| 646 | - .truncate() | 643 | + .min_w(px(0.)) |
| 647 | - .text_size(px(11.)) | 644 | + .truncate() |
| 648 | - .text_color(rgb(FG_SECONDARY())), | 645 | + .text_size(px(11.)) |
| 646 | + .text_color(rgb(FG_SECONDARY())), | ||
| 647 | + ) | ||
| 648 | + .child(value), | ||
| 649 | ) | 649 | ) |
| 650 | - .child(value)) | ||
| 651 | .into_any_element(), | 650 | .into_any_element(), |
| 652 | ); | 651 | ); |
| 653 | } | 652 | } |
| @@ -701,7 +700,12 @@ impl Player { | |||
| 701 | // floor clamp and the room the list sizes against are `menu_floor`'s, | 700 | // floor clamp and the room the list sizes against are `menu_floor`'s, |
| 702 | // so a menu taller than the footprint scrolls instead of climbing | 701 | // so a menu taller than the footprint scrolls instead of climbing |
| 703 | // back over the picture. | 702 | // back over the picture. |
| 704 | - let (at, room) = menu_floor(menu.at, viewport, darkroom, self.split_px(Split::Bench, viewport)); | 703 | + let (at, room) = menu_floor( |
| 704 | + menu.at, | ||
| 705 | + viewport, | ||
| 706 | + darkroom, | ||
| 707 | + self.split_px(Split::Bench, viewport), | ||
| 708 | + ); | ||
| 705 | let list_h = menu_rows_h(rows.len(), room); | 709 | let list_h = menu_rows_h(rows.len(), room); |
| 706 | let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h); | 710 | let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h); |
| 707 | let full: SharedString = path.display().to_string().into(); | 711 | let full: SharedString = path.display().to_string().into(); |
crates/app/src/ui/overlays.rsmodified+71 -57
| @@ -1,9 +1,9 @@ | |||
| 1 | //! The bars and the floating cards that are not inspector sections. | 1 | //! The bars and the floating cards that are not inspector sections. |
| 2 | 2 | ||
| 3 | -use crate::*; | ||
| 4 | -use crate::ui::widgets::*; | ||
| 5 | use crate::ui::stance::menu_floor; | 3 | use crate::ui::stance::menu_floor; |
| 6 | use crate::ui::type_scale::{self, Typeset}; | 4 | use crate::ui::type_scale::{self, Typeset}; |
| 5 | +use crate::ui::widgets::*; | ||
| 6 | +use crate::*; | ||
| 7 | 7 | ||
| 8 | impl Player { | 8 | impl Player { |
| 9 | /// The running import holds its own bar above the notice's, for the notice | 9 | /// The running import holds its own bar above the notice's, for the notice |
| @@ -305,18 +305,20 @@ impl Player { | |||
| 305 | }) | 305 | }) |
| 306 | .when(!refusal.yes(), |d| d.opacity(0.4).cursor_not_allowed()) | 306 | .when(!refusal.yes(), |d| d.opacity(0.4).cursor_not_allowed()) |
| 307 | .when(refusal.yes(), |d| { | 307 | .when(refusal.yes(), |d| { |
| 308 | - d.cursor_pointer().hover(|s| s.bg(rgb(BG_HOVER()))).on_click( | 308 | + d.cursor_pointer() |
| 309 | - cx.listener(move |this, _: &ClickEvent, window, cx| { | 309 | + .hover(|s| s.bg(rgb(BG_HOVER()))) |
| 310 | - // The card goes first: several of | 310 | + .on_click(cx.listener( |
| 311 | - // these open a card of their own, | 311 | + move |this, _: &ClickEvent, window, cx| { |
| 312 | - // and every edit moves the indices | 312 | + // The card goes first: several of |
| 313 | - // the menus are holding. | 313 | + // these open a card of their own, |
| 314 | - this.keys_open = false; | 314 | + // and every edit moves the indices |
| 315 | - this.rebinding = None; | 315 | + // the menus are holding. |
| 316 | - this.act(action, window, cx); | 316 | + this.keys_open = false; |
| 317 | - cx.notify(); | 317 | + this.rebinding = None; |
| 318 | - }), | 318 | + this.act(action, window, cx); |
| 319 | - ) | 319 | + cx.notify(); |
| 320 | + }, | ||
| 321 | + )) | ||
| 320 | }), | 322 | }), |
| 321 | ) | 323 | ) |
| 322 | .child( | 324 | .child( |
| @@ -402,15 +404,9 @@ impl Player { | |||
| 402 | .px(px(6.)) | 404 | .px(px(6.)) |
| 403 | .text_size(px(11.)) | 405 | .text_size(px(11.)) |
| 404 | .text_color(rgb(FG_SECONDARY())) | 406 | .text_color(rgb(FG_SECONDARY())) |
| 405 | - .child( | 407 | + .child(self.notices.front().cloned().unwrap_or_else(|| { |
| 406 | - self.notices | 408 | + "click an action to do it · click its key to change it".into() |
| 407 | - .front() | 409 | + })), |
| 408 | - .cloned() | ||
| 409 | - .unwrap_or_else(|| { | ||
| 410 | - "click an action to do it · click its key to change it" | ||
| 411 | - .into() | ||
| 412 | - }), | ||
| 413 | - ), | ||
| 414 | ) | 410 | ) |
| 415 | // The search box: no focus and no text field -- the | 411 | // The search box: no focus and no text field -- the |
| 416 | // card's key handler is the field, exactly as the | 412 | // card's key handler is the field, exactly as the |
| @@ -552,17 +548,19 @@ impl Player { | |||
| 552 | rows.push( | 548 | rows.push( |
| 553 | row(rows.len()) | 549 | row(rows.len()) |
| 554 | .child(label) | 550 | .child(label) |
| 555 | - .child(chord_style( | 551 | + .child( |
| 556 | - div() | 552 | + chord_style( |
| 557 | - .min_w(px(0.)) | 553 | + div() |
| 558 | - .truncate() | 554 | + .min_w(px(0.)) |
| 559 | - // A size smaller than the labels: a timecode | 555 | + .truncate() |
| 560 | - // pair is 25 characters and has to fit beside | 556 | + // A size smaller than the labels: a timecode |
| 561 | - // its label inside `MENU_W`. | 557 | + // pair is 25 characters and has to fit beside |
| 562 | - .text_size(px(11.)) | 558 | + // its label inside `MENU_W`. |
| 563 | - .text_color(rgb(FG_SECONDARY())), | 559 | + .text_size(px(11.)) |
| 560 | + .text_color(rgb(FG_SECONDARY())), | ||
| 561 | + ) | ||
| 562 | + .child(value), | ||
| 564 | ) | 563 | ) |
| 565 | - .child(value)) | ||
| 566 | .into_any_element(), | 564 | .into_any_element(), |
| 567 | ); | 565 | ); |
| 568 | } | 566 | } |
| @@ -594,7 +592,9 @@ impl Player { | |||
| 594 | this.close_all_gaps_on_lane(lane, cx); | 592 | this.close_all_gaps_on_lane(lane, cx); |
| 595 | })) | 593 | })) |
| 596 | .child(format!("Close all {} gaps", lane.label())) | 594 | .child(format!("Close all {} gaps", lane.label())) |
| 597 | - .child(chord_style(div().text_color(rgb(FG_SECONDARY()))).child("this track")) | 595 | + .child( |
| 596 | + chord_style(div().text_color(rgb(FG_SECONDARY()))).child("this track"), | ||
| 597 | + ) | ||
| 598 | .into_any_element(), | 598 | .into_any_element(), |
| 599 | ); | 599 | ); |
| 600 | } | 600 | } |
| @@ -664,32 +664,36 @@ impl Player { | |||
| 664 | // Every command wears its chord (DESIGN §4): mono, | 664 | // Every command wears its chord (DESIGN §4): mono, |
| 665 | // `ink3`, the same face the spine badges and the | 665 | // `ink3`, the same face the spine badges and the |
| 666 | // keys overlay already read theirs in. | 666 | // keys overlay already read theirs in. |
| 667 | - None => chord_style(div().flex_shrink_0().text_color(rgb(FG_SECONDARY()))) | 667 | + None => { |
| 668 | - .child(self.keymap.display(action)), | 668 | + chord_style(div().flex_shrink_0().text_color(rgb(FG_SECONDARY()))) |
| 669 | + .child(self.keymap.display(action)) | ||
| 670 | + } | ||
| 669 | }) | 671 | }) |
| 670 | .when(!enabled, |d| d.opacity(0.4).cursor_not_allowed()) | 672 | .when(!enabled, |d| d.opacity(0.4).cursor_not_allowed()) |
| 671 | .when(enabled, |d| { | 673 | .when(enabled, |d| { |
| 672 | d.cursor_pointer() | 674 | d.cursor_pointer() |
| 673 | .hover(|s| s.bg(rgb(BG_HOVER()))) | 675 | .hover(|s| s.bg(rgb(BG_HOVER()))) |
| 674 | - .on_click(cx.listener(move |this, event: &ClickEvent, window, cx| { | 676 | + .on_click(cx.listener( |
| 675 | - // Closed first: the action moves the very | 677 | + move |this, event: &ClickEvent, window, cx| { |
| 676 | - // indices this menu is holding. | 678 | + // Closed first: the action moves the very |
| 677 | - this.context_menu = None; | 679 | + // indices this menu is holding. |
| 678 | - // The one item that is a *choice* and not a | 680 | + this.context_menu = None; |
| 679 | - // doing: four policies, so the pointer gets | 681 | + // The one item that is a *choice* and not a |
| 680 | - // the list of them on this clip rather than | 682 | + // doing: four policies, so the pointer gets |
| 681 | - // the next one stepped to behind the click. | 683 | + // the list of them on this clip rather than |
| 682 | - // The stroke still steps -- same door. | 684 | + // the next one stepped to behind the click. |
| 683 | - if action == ActionId::Fit { | 685 | + // The stroke still steps -- same door. |
| 684 | - this.open_picker( | 686 | + if action == ActionId::Fit { |
| 685 | - Pick::Fit(menu.lane, idx), | 687 | + this.open_picker( |
| 686 | - event.position(), | 688 | + Pick::Fit(menu.lane, idx), |
| 687 | - cx, | 689 | + event.position(), |
| 688 | - ); | 690 | + cx, |
| 689 | - } else { | 691 | + ); |
| 690 | - this.act(action, window, cx); | 692 | + } else { |
| 691 | - } | 693 | + this.act(action, window, cx); |
| 692 | - })) | 694 | + } |
| 695 | + }, | ||
| 696 | + )) | ||
| 693 | }) | 697 | }) |
| 694 | .into_any_element(), | 698 | .into_any_element(), |
| 695 | ); | 699 | ); |
| @@ -725,7 +729,12 @@ impl Player { | |||
| 725 | // footprint (`room`), not the whole window, so a menu taller than | 729 | // footprint (`room`), not the whole window, so a menu taller than |
| 726 | // the footprint scrolls inside its own plate instead of walking its | 730 | // the footprint scrolls inside its own plate instead of walking its |
| 727 | // clamped top edge back up over the picture ([`menu_floor`]). | 731 | // clamped top edge back up over the picture ([`menu_floor`]). |
| 728 | - let (at, room) = menu_floor(menu.at, viewport, self.darkroom, self.split_px(Split::Bench, viewport)); | 732 | + let (at, room) = menu_floor( |
| 733 | + menu.at, | ||
| 734 | + viewport, | ||
| 735 | + self.darkroom, | ||
| 736 | + self.split_px(Split::Bench, viewport), | ||
| 737 | + ); | ||
| 729 | let list_h = menu_rows_h(rows.len(), room); | 738 | let list_h = menu_rows_h(rows.len(), room); |
| 730 | let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h); | 739 | let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h); |
| 731 | let full: SharedString = source | 740 | let full: SharedString = source |
| @@ -899,7 +908,12 @@ impl Player { | |||
| 899 | .collect(); | 908 | .collect(); |
| 900 | // The window's own room, and the list scrolls only where the window has | 909 | // The window's own room, and the list scrolls only where the window has |
| 901 | // none -- the clip menu's rule, one function for both. | 910 | // none -- the clip menu's rule, one function for both. |
| 902 | - let (at, room) = menu_floor(picker.at, viewport, darkroom, self.split_px(Split::Bench, viewport)); | 911 | + let (at, room) = menu_floor( |
| 912 | + picker.at, | ||
| 913 | + viewport, | ||
| 914 | + darkroom, | ||
| 915 | + self.split_px(Split::Bench, viewport), | ||
| 916 | + ); | ||
| 903 | let list_h = menu_rows_h(rows.len(), room); | 917 | let list_h = menu_rows_h(rows.len(), room); |
| 904 | let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h); | 918 | let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h); |
| 905 | Some( | 919 | Some( |
crates/app/src/ui/preview.rsmodified+6 -6
| @@ -1,7 +1,7 @@ | |||
| 1 | //! The picture: what is drawn over it and what is read off it. | 1 | //! The picture: what is drawn over it and what is read off it. |
| 2 | 2 | ||
| 3 | -use crate::*; | ||
| 4 | use crate::ui::type_scale::{self, Typeset}; | 3 | use crate::ui::type_scale::{self, Typeset}; |
| 4 | +use crate::*; | ||
| 5 | use std::path::{Path, PathBuf}; | 5 | use std::path::{Path, PathBuf}; |
| 6 | 6 | ||
| 7 | impl Player { | 7 | impl Player { |
| @@ -194,11 +194,11 @@ impl Player { | |||
| 194 | self.active_fps(), | 194 | self.active_fps(), |
| 195 | ) | 195 | ) |
| 196 | .replace(':', "-"); | 196 | .replace(':', "-"); |
| 197 | - let text = match save_screenshot(bytes, size.width.0 as u32, size.height.0 as u32, &stem, &tc) | 197 | + let text = |
| 198 | - { | 198 | + match save_screenshot(bytes, size.width.0 as u32, size.height.0 as u32, &stem, &tc) { |
| 199 | - Ok(path) => format!("SAVED {}", path.display()), | 199 | + Ok(path) => format!("SAVED {}", path.display()), |
| 200 | - Err(e) => format!("SCREENSHOT FAILED: {e}"), | 200 | + Err(e) => format!("SCREENSHOT FAILED: {e}"), |
| 201 | - }; | 201 | + }; |
| 202 | self.notify_user(text.into()); | 202 | self.notify_user(text.into()); |
| 203 | cx.notify(); | 203 | cx.notify(); |
| 204 | } | 204 | } |
crates/app/src/ui/settings_stance.rsmodified+23 -6
| @@ -32,8 +32,8 @@ | |||
| 32 | //! since nothing in [`engine::project::Project`] holds a place to persist an | 32 | //! since nothing in [`engine::project::Project`] holds a place to persist an |
| 33 | //! override into. | 33 | //! override into. |
| 34 | 34 | ||
| 35 | -use crate::*; | ||
| 36 | use crate::ui::type_scale; | 35 | use crate::ui::type_scale; |
| 36 | +use crate::*; | ||
| 37 | use engine::colorspace::ContentLight; | 37 | use engine::colorspace::ContentLight; |
| 38 | 38 | ||
| 39 | /// A 9px uppercase Archivo section head, `ink3` -- [`dock_stance::section_head`]'s | 39 | /// A 9px uppercase Archivo section head, `ink3` -- [`dock_stance::section_head`]'s |
| @@ -106,7 +106,9 @@ fn row_ink( | |||
| 106 | on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, | 106 | on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, |
| 107 | value_ink: u32, | 107 | value_ink: u32, |
| 108 | ) -> impl IntoElement { | 108 | ) -> impl IntoElement { |
| 109 | - row_full(id, label_text, value, hint, None, player, on_click, value_ink) | 109 | + row_full( |
| 110 | + id, label_text, value, hint, None, player, on_click, value_ink, | ||
| 111 | + ) | ||
| 110 | } | 112 | } |
| 111 | 113 | ||
| 112 | /// The one row body all three wrappers share. `chord` is the stroke that also | 114 | /// The one row body all three wrappers share. `chord` is the stroke that also |
| @@ -141,7 +143,9 @@ fn row_full( | |||
| 141 | .tooltip(move |_, cx| cx.new(|_| Tip(hint.clone())).into()) | 143 | .tooltip(move |_, cx| cx.new(|_| Tip(hint.clone())).into()) |
| 142 | .when(exporting, |d| d.opacity(0.4).cursor_not_allowed()) | 144 | .when(exporting, |d| d.opacity(0.4).cursor_not_allowed()) |
| 143 | .when(!exporting, |d| { | 145 | .when(!exporting, |d| { |
| 144 | - d.cursor_pointer().hover(|s| s.bg(rgb(DARK_RAISED()))).on_click(on_click) | 146 | + d.cursor_pointer() |
| 147 | + .hover(|s| s.bg(rgb(DARK_RAISED()))) | ||
| 148 | + .on_click(on_click) | ||
| 145 | }) | 149 | }) |
| 146 | .child( | 150 | .child( |
| 147 | div() | 151 | div() |
| @@ -244,7 +248,11 @@ fn project_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElemen | |||
| 244 | // Sample rate keeps its "Source" fallback: unlike resolution/fps it | 248 | // Sample rate keeps its "Source" fallback: unlike resolution/fps it |
| 245 | // states a real behaviour (derives from the first audio source) rather | 249 | // states a real behaviour (derives from the first audio source) rather |
| 246 | // than standing in for a value with nothing behind it. | 250 | // than standing in for a value with nothing behind it. |
| 247 | - let rate_val = match player.session.as_ref().map_or(player.pending_settings.2, |s| s.sample_rate()) { | 251 | + let rate_val = match player |
| 252 | + .session | ||
| 253 | + .as_ref() | ||
| 254 | + .map_or(player.pending_settings.2, |s| s.sample_rate()) | ||
| 255 | + { | ||
| 248 | Some(rate) => format!("{rate} Hz"), | 256 | Some(rate) => format!("{rate} Hz"), |
| 249 | None => "Source".to_string(), | 257 | None => "Source".to_string(), |
| 250 | }; | 258 | }; |
| @@ -259,7 +267,10 @@ fn project_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElemen | |||
| 259 | // persist one into. `—` for a project with no session, and for a session | 267 | // persist one into. `—` for a project with no session, and for a session |
| 260 | // whose file is SDR or simply declared nothing (most files declare | 268 | // whose file is SDR or simply declared nothing (most files declare |
| 261 | // nothing here at all). | 269 | // nothing here at all). |
| 262 | - let light = player.session.as_ref().map_or(ContentLight::default(), engine::playback::PlaybackSession::content_light); | 270 | + let light = player.session.as_ref().map_or( |
| 271 | + ContentLight::default(), | ||
| 272 | + engine::playback::PlaybackSession::content_light, | ||
| 273 | + ); | ||
| 263 | let (master_val, master_ink) = match (&player.session, light.mastering_max) { | 274 | let (master_val, master_ink) = match (&player.session, light.mastering_max) { |
| 264 | (Some(_), Some(nits)) => (format!("{nits:.0} nits"), INK1()), | 275 | (Some(_), Some(nits)) => (format!("{nits:.0} nits"), INK1()), |
| 265 | _ => ("—".to_string(), INK4()), | 276 | _ => ("—".to_string(), INK4()), |
| @@ -467,7 +478,13 @@ pub(crate) fn render( | |||
| 467 | .child("SETTINGS") | 478 | .child("SETTINGS") |
| 468 | .child( | 479 | .child( |
| 469 | div() | 480 | div() |
| 470 | - .font(type_scale::mono(type_scale::CHORD_METADATA_MIN_PX, gpui::FontWeight::MEDIUM).font) | 481 | + .font( |
| 482 | + type_scale::mono( | ||
| 483 | + type_scale::CHORD_METADATA_MIN_PX, | ||
| 484 | + gpui::FontWeight::MEDIUM, | ||
| 485 | + ) | ||
| 486 | + .font, | ||
| 487 | + ) | ||
| 471 | .text_size(px(type_scale::CHORD_METADATA_MIN_PX)) | 488 | .text_size(px(type_scale::CHORD_METADATA_MIN_PX)) |
| 472 | .text_color(rgb(INK3())) | 489 | .text_color(rgb(INK3())) |
| 473 | .child(player.keymap.display(ActionId::Settings)), | 490 | .child(player.keymap.display(ActionId::Settings)), |
crates/app/src/ui/theme.rsmodified+50 -14
| @@ -377,7 +377,10 @@ pub mod cool { | |||
| 377 | /// from somewhere else than its neighbour. The *kind* is the body colour now | 377 | /// from somewhere else than its neighbour. The *kind* is the body colour now |
| 378 | /// ([`super::clip_kind`]); this is the identity stripe and the library | 378 | /// ([`super::clip_kind`]); this is the identity stripe and the library |
| 379 | /// swatch, and it only has to be four things telling each other apart. | 379 | /// swatch, and it only has to be four things telling each other apart. |
| 380 | - pub const SOURCE_TINTS: [u32; 12] = [0x4f8fd6, 0xd69a4f, 0x4fd6a8, 0xb14fd6, 0x4f8fd6, 0xd69a4f, 0x4fd6a8, 0xb14fd6, 0x4f8fd6, 0xd69a4f, 0x4fd6a8, 0xb14fd6]; | 380 | + pub const SOURCE_TINTS: [u32; 12] = [ |
| 381 | + 0x4f8fd6, 0xd69a4f, 0x4fd6a8, 0xb14fd6, 0x4f8fd6, 0xd69a4f, 0x4fd6a8, 0xb14fd6, 0x4f8fd6, | ||
| 382 | + 0xd69a4f, 0x4fd6a8, 0xb14fd6, | ||
| 383 | + ]; | ||
| 381 | 384 | ||
| 382 | // -- feedback --------------------------------------------------------------- | 385 | // -- feedback --------------------------------------------------------------- |
| 383 | pub const STATUS_ERROR: u32 = 0xef4444; | 386 | pub const STATUS_ERROR: u32 = 0xef4444; |
| @@ -459,7 +462,10 @@ pub mod warm { | |||
| 459 | 462 | ||
| 460 | /// Warm-side identity stripes: the same four-way distinctness the cool | 463 | /// Warm-side identity stripes: the same four-way distinctness the cool |
| 461 | /// family's are held to, in hues that belong to this ground. | 464 | /// family's are held to, in hues that belong to this ground. |
| 462 | - pub const SOURCE_TINTS: [u32; 12] = [0xe08a4f, 0x4fa8d6, 0x8fc94f, 0xd67aa8, 0xe08a4f, 0x4fa8d6, 0x8fc94f, 0xd67aa8, 0xe08a4f, 0x4fa8d6, 0x8fc94f, 0xd67aa8]; | 465 | + pub const SOURCE_TINTS: [u32; 12] = [ |
| 466 | + 0xe08a4f, 0x4fa8d6, 0x8fc94f, 0xd67aa8, 0xe08a4f, 0x4fa8d6, 0x8fc94f, 0xd67aa8, 0xe08a4f, | ||
| 467 | + 0x4fa8d6, 0x8fc94f, 0xd67aa8, | ||
| 468 | + ]; | ||
| 463 | 469 | ||
| 464 | // -- feedback --------------------------------------------------------------- | 470 | // -- feedback --------------------------------------------------------------- |
| 465 | pub const STATUS_ERROR: u32 = 0xc85050; | 471 | pub const STATUS_ERROR: u32 = 0xc85050; |
| @@ -539,7 +545,10 @@ pub mod forest { | |||
| 539 | pub const CLIP_IMAGE: u32 = 0x1a6a6a; | 545 | pub const CLIP_IMAGE: u32 = 0x1a6a6a; |
| 540 | pub const CLIP_TEXT: u32 = 0x6b46c1; | 546 | pub const CLIP_TEXT: u32 = 0x6b46c1; |
| 541 | 547 | ||
| 542 | - pub const SOURCE_TINTS: [u32; 12] = [0x5fd68f, 0xd6a45f, 0x5fa8d6, 0xc15fd6, 0x5fd68f, 0xd6a45f, 0x5fa8d6, 0xc15fd6, 0x5fd68f, 0xd6a45f, 0x5fa8d6, 0xc15fd6]; | 548 | + pub const SOURCE_TINTS: [u32; 12] = [ |
| 549 | + 0x5fd68f, 0xd6a45f, 0x5fa8d6, 0xc15fd6, 0x5fd68f, 0xd6a45f, 0x5fa8d6, 0xc15fd6, 0x5fd68f, | ||
| 550 | + 0xd6a45f, 0x5fa8d6, 0xc15fd6, | ||
| 551 | + ]; | ||
| 543 | 552 | ||
| 544 | // -- feedback --------------------------------------------------------------- | 553 | // -- feedback --------------------------------------------------------------- |
| 545 | /// Not the accent family: a success that wore the emerald would say "this is | 554 | /// Not the accent family: a success that wore the emerald would say "this is |
| @@ -618,7 +627,10 @@ pub mod violet { | |||
| 618 | /// be the same purple. | 627 | /// be the same purple. |
| 619 | pub const CLIP_TEXT: u32 = 0x6d3fa8; | 628 | pub const CLIP_TEXT: u32 = 0x6d3fa8; |
| 620 | 629 | ||
| 621 | - pub const SOURCE_TINTS: [u32; 12] = [0x9b7fe8, 0xe8a97f, 0x7fc8e8, 0xe87fb4, 0x9b7fe8, 0xe8a97f, 0x7fc8e8, 0xe87fb4, 0x9b7fe8, 0xe8a97f, 0x7fc8e8, 0xe87fb4]; | 630 | + pub const SOURCE_TINTS: [u32; 12] = [ |
| 631 | + 0x9b7fe8, 0xe8a97f, 0x7fc8e8, 0xe87fb4, 0x9b7fe8, 0xe8a97f, 0x7fc8e8, 0xe87fb4, 0x9b7fe8, | ||
| 632 | + 0xe8a97f, 0x7fc8e8, 0xe87fb4, | ||
| 633 | + ]; | ||
| 622 | 634 | ||
| 623 | // -- feedback --------------------------------------------------------------- | 635 | // -- feedback --------------------------------------------------------------- |
| 624 | pub const STATUS_ERROR: u32 = 0xf87171; | 636 | pub const STATUS_ERROR: u32 = 0xf87171; |
| @@ -691,7 +703,10 @@ pub mod rose { | |||
| 691 | pub const CLIP_IMAGE: u32 = 0x1c6270; | 703 | pub const CLIP_IMAGE: u32 = 0x1c6270; |
| 692 | pub const CLIP_TEXT: u32 = 0x6b46c1; | 704 | pub const CLIP_TEXT: u32 = 0x6b46c1; |
| 693 | 705 | ||
| 694 | - pub const SOURCE_TINTS: [u32; 12] = [0xe87f97, 0x7fc8e8, 0xe8c87f, 0x9b7fe8, 0xe87f97, 0x7fc8e8, 0xe8c87f, 0x9b7fe8, 0xe87f97, 0x7fc8e8, 0xe8c87f, 0x9b7fe8]; | 706 | + pub const SOURCE_TINTS: [u32; 12] = [ |
| 707 | + 0xe87f97, 0x7fc8e8, 0xe8c87f, 0x9b7fe8, 0xe87f97, 0x7fc8e8, 0xe8c87f, 0x9b7fe8, 0xe87f97, | ||
| 708 | + 0x7fc8e8, 0xe8c87f, 0x9b7fe8, | ||
| 709 | + ]; | ||
| 695 | 710 | ||
| 696 | // -- feedback --------------------------------------------------------------- | 711 | // -- feedback --------------------------------------------------------------- |
| 697 | /// Brighter and more saturated than the accent it sits near on the wheel: on | 712 | /// Brighter and more saturated than the accent it sits near on the wheel: on |
| @@ -768,7 +783,10 @@ pub mod amber { | |||
| 768 | pub const CLIP_IMAGE: u32 = 0x1c6270; | 783 | pub const CLIP_IMAGE: u32 = 0x1c6270; |
| 769 | pub const CLIP_TEXT: u32 = 0x6b46c1; | 784 | pub const CLIP_TEXT: u32 = 0x6b46c1; |
| 770 | 785 | ||
| 771 | - pub const SOURCE_TINTS: [u32; 12] = [0xe8b45f, 0x5fa8e8, 0x7fd69b, 0xd68fc1, 0xe8b45f, 0x5fa8e8, 0x7fd69b, 0xd68fc1, 0xe8b45f, 0x5fa8e8, 0x7fd69b, 0xd68fc1]; | 786 | + pub const SOURCE_TINTS: [u32; 12] = [ |
| 787 | + 0xe8b45f, 0x5fa8e8, 0x7fd69b, 0xd68fc1, 0xe8b45f, 0x5fa8e8, 0x7fd69b, 0xd68fc1, 0xe8b45f, | ||
| 788 | + 0x5fa8e8, 0x7fd69b, 0xd68fc1, | ||
| 789 | + ]; | ||
| 772 | 790 | ||
| 773 | // -- feedback --------------------------------------------------------------- | 791 | // -- feedback --------------------------------------------------------------- |
| 774 | /// The warning steps to orange: amber *is* the accent here, and a warning | 792 | /// The warning steps to orange: amber *is* the accent here, and a warning |
| @@ -843,7 +861,10 @@ pub mod ocean { | |||
| 843 | pub const CLIP_IMAGE: u32 = 0x1c6270; | 861 | pub const CLIP_IMAGE: u32 = 0x1c6270; |
| 844 | pub const CLIP_TEXT: u32 = 0x6b46c1; | 862 | pub const CLIP_TEXT: u32 = 0x6b46c1; |
| 845 | 863 | ||
| 846 | - pub const SOURCE_TINTS: [u32; 12] = [0x5fa8e8, 0xe8a95f, 0x5fd6a0, 0xc98fe8, 0x5fa8e8, 0xe8a95f, 0x5fd6a0, 0xc98fe8, 0x5fa8e8, 0xe8a95f, 0x5fd6a0, 0xc98fe8]; | 864 | + pub const SOURCE_TINTS: [u32; 12] = [ |
| 865 | + 0x5fa8e8, 0xe8a95f, 0x5fd6a0, 0xc98fe8, 0x5fa8e8, 0xe8a95f, 0x5fd6a0, 0xc98fe8, 0x5fa8e8, | ||
| 866 | + 0xe8a95f, 0x5fd6a0, 0xc98fe8, | ||
| 867 | + ]; | ||
| 847 | 868 | ||
| 848 | // -- feedback --------------------------------------------------------------- | 869 | // -- feedback --------------------------------------------------------------- |
| 849 | pub const STATUS_ERROR: u32 = 0xf05252; | 870 | pub const STATUS_ERROR: u32 = 0xf05252; |
| @@ -919,7 +940,10 @@ pub mod ice { | |||
| 919 | pub const CLIP_IMAGE: u32 = 0x1c6270; | 940 | pub const CLIP_IMAGE: u32 = 0x1c6270; |
| 920 | pub const CLIP_TEXT: u32 = 0x6b46c1; | 941 | pub const CLIP_TEXT: u32 = 0x6b46c1; |
| 921 | 942 | ||
| 922 | - pub const SOURCE_TINTS: [u32; 12] = [0x7fd6e8, 0xe8b47f, 0x8fd69b, 0xc79be8, 0x7fd6e8, 0xe8b47f, 0x8fd69b, 0xc79be8, 0x7fd6e8, 0xe8b47f, 0x8fd69b, 0xc79be8]; | 943 | + pub const SOURCE_TINTS: [u32; 12] = [ |
| 944 | + 0x7fd6e8, 0xe8b47f, 0x8fd69b, 0xc79be8, 0x7fd6e8, 0xe8b47f, 0x8fd69b, 0xc79be8, 0x7fd6e8, | ||
| 945 | + 0xe8b47f, 0x8fd69b, 0xc79be8, | ||
| 946 | + ]; | ||
| 923 | 947 | ||
| 924 | // -- feedback --------------------------------------------------------------- | 948 | // -- feedback --------------------------------------------------------------- |
| 925 | pub const STATUS_ERROR: u32 = 0xff6b6b; | 949 | pub const STATUS_ERROR: u32 = 0xff6b6b; |
| @@ -993,7 +1017,10 @@ pub mod orchid { | |||
| 993 | pub const CLIP_IMAGE: u32 = 0x1c6270; | 1017 | pub const CLIP_IMAGE: u32 = 0x1c6270; |
| 994 | pub const CLIP_TEXT: u32 = 0x5a45b8; | 1018 | pub const CLIP_TEXT: u32 = 0x5a45b8; |
| 995 | 1019 | ||
| 996 | - pub const SOURCE_TINTS: [u32; 12] = [0xe88fd6, 0x8fc9e8, 0xe8c48f, 0x8fe8b4, 0xe88fd6, 0x8fc9e8, 0xe8c48f, 0x8fe8b4, 0xe88fd6, 0x8fc9e8, 0xe8c48f, 0x8fe8b4]; | 1020 | + pub const SOURCE_TINTS: [u32; 12] = [ |
| 1021 | + 0xe88fd6, 0x8fc9e8, 0xe8c48f, 0x8fe8b4, 0xe88fd6, 0x8fc9e8, 0xe8c48f, 0x8fe8b4, 0xe88fd6, | ||
| 1022 | + 0x8fc9e8, 0xe8c48f, 0x8fe8b4, | ||
| 1023 | + ]; | ||
| 997 | 1024 | ||
| 998 | // -- feedback --------------------------------------------------------------- | 1025 | // -- feedback --------------------------------------------------------------- |
| 999 | pub const STATUS_ERROR: u32 = 0xf87171; | 1026 | pub const STATUS_ERROR: u32 = 0xf87171; |
| @@ -1082,7 +1109,10 @@ pub mod nord { | |||
| 1082 | 1109 | ||
| 1083 | /// Aurora and Frost at full strength: a swatch carries no text, so these are | 1110 | /// Aurora and Frost at full strength: a swatch carries no text, so these are |
| 1084 | /// Nord's own numbers. | 1111 | /// Nord's own numbers. |
| 1085 | - pub const SOURCE_TINTS: [u32; 12] = [0x88c0d0, 0xd08770, 0xa3be8c, 0xb48ead, 0x88c0d0, 0xd08770, 0xa3be8c, 0xb48ead, 0x88c0d0, 0xd08770, 0xa3be8c, 0xb48ead]; | 1112 | + pub const SOURCE_TINTS: [u32; 12] = [ |
| 1113 | + 0x88c0d0, 0xd08770, 0xa3be8c, 0xb48ead, 0x88c0d0, 0xd08770, 0xa3be8c, 0xb48ead, 0x88c0d0, | ||
| 1114 | + 0xd08770, 0xa3be8c, 0xb48ead, | ||
| 1115 | + ]; | ||
| 1086 | 1116 | ||
| 1087 | // -- feedback --------------------------------------------------------------- | 1117 | // -- feedback --------------------------------------------------------------- |
| 1088 | pub const STATUS_ERROR: u32 = 0xbf616a; | 1118 | pub const STATUS_ERROR: u32 = 0xbf616a; |
| @@ -1164,7 +1194,10 @@ pub mod gruvbox { | |||
| 1164 | pub const CLIP_IMAGE: u32 = 0x2f6a63; | 1194 | pub const CLIP_IMAGE: u32 = 0x2f6a63; |
| 1165 | pub const CLIP_TEXT: u32 = 0x7a4a72; | 1195 | pub const CLIP_TEXT: u32 = 0x7a4a72; |
| 1166 | 1196 | ||
| 1167 | - pub const SOURCE_TINTS: [u32; 12] = [0xfe8019, 0x83a598, 0xb8bb26, 0xd3869b, 0xfe8019, 0x83a598, 0xb8bb26, 0xd3869b, 0xfe8019, 0x83a598, 0xb8bb26, 0xd3869b]; | 1197 | + pub const SOURCE_TINTS: [u32; 12] = [ |
| 1198 | + 0xfe8019, 0x83a598, 0xb8bb26, 0xd3869b, 0xfe8019, 0x83a598, 0xb8bb26, 0xd3869b, 0xfe8019, | ||
| 1199 | + 0x83a598, 0xb8bb26, 0xd3869b, | ||
| 1200 | + ]; | ||
| 1168 | 1201 | ||
| 1169 | // -- feedback --------------------------------------------------------------- | 1202 | // -- feedback --------------------------------------------------------------- |
| 1170 | pub const STATUS_ERROR: u32 = 0xfb4934; | 1203 | pub const STATUS_ERROR: u32 = 0xfb4934; |
| @@ -1240,7 +1273,10 @@ pub mod dracula { | |||
| 1240 | pub const CLIP_TEXT: u32 = 0x6a3fb0; | 1273 | pub const CLIP_TEXT: u32 = 0x6a3fb0; |
| 1241 | 1274 | ||
| 1242 | /// Dracula's own six, four of them: a swatch carries no text. | 1275 | /// Dracula's own six, four of them: a swatch carries no text. |
| 1243 | - pub const SOURCE_TINTS: [u32; 12] = [0xff79c6, 0x8be9fd, 0x50fa7b, 0xffb86c, 0xff79c6, 0x8be9fd, 0x50fa7b, 0xffb86c, 0xff79c6, 0x8be9fd, 0x50fa7b, 0xffb86c]; | 1276 | + pub const SOURCE_TINTS: [u32; 12] = [ |
| 1277 | + 0xff79c6, 0x8be9fd, 0x50fa7b, 0xffb86c, 0xff79c6, 0x8be9fd, 0x50fa7b, 0xffb86c, 0xff79c6, | ||
| 1278 | + 0x8be9fd, 0x50fa7b, 0xffb86c, | ||
| 1279 | + ]; | ||
| 1244 | 1280 | ||
| 1245 | // -- feedback --------------------------------------------------------------- | 1281 | // -- feedback --------------------------------------------------------------- |
| 1246 | pub const STATUS_ERROR: u32 = 0xff5555; | 1282 | pub const STATUS_ERROR: u32 = 0xff5555; |
| @@ -1342,8 +1378,8 @@ pub mod darkroom { | |||
| 1342 | // wheel with a quantized dominant hue per import; until then the index | 1378 | // wheel with a quantized dominant hue per import; until then the index |
| 1343 | // is `source % 12`, which still guarantees different sources differ. | 1379 | // is `source % 12`, which still guarantees different sources differ. |
| 1344 | pub const SOURCE_TINTS: [u32; 12] = [ | 1380 | pub const SOURCE_TINTS: [u32; 12] = [ |
| 1345 | - 0x64b5d1, 0x647ed1, 0x8064d1, 0xb664d1, 0xd164b5, 0xd1647e, 0xd18064, | 1381 | + 0x64b5d1, 0x647ed1, 0x8064d1, 0xb664d1, 0xd164b5, 0xd1647e, 0xd18064, 0xd1b764, 0xb5d164, |
| 1346 | - 0xd1b764, 0xb5d164, 0x7ed164, 0x64d180, 0x64d1b7, | 1382 | + 0x7ed164, 0x64d180, 0x64d1b7, |
| 1347 | ]; | 1383 | ]; |
| 1348 | 1384 | ||
| 1349 | // -- feedback ------------------------------------------------------------- | 1385 | // -- feedback ------------------------------------------------------------- |
crates/app/src/ui/timeband_stance.rsmodified+66 -18
| @@ -8,8 +8,8 @@ | |||
| 8 | //! close to the mock's ~20px reading. Every size in this module comes from | 8 | //! close to the mock's ~20px reading. Every size in this module comes from |
| 9 | //! `ui::type_scale` (role, not a bare `px()` literal). | 9 | //! `ui::type_scale` (role, not a bare `px()` literal). |
| 10 | 10 | ||
| 11 | -use crate::*; | ||
| 12 | use crate::ui::type_scale::{self, label, mono}; | 11 | use crate::ui::type_scale::{self, label, mono}; |
| 12 | +use crate::*; | ||
| 13 | use gpui::FontWeight; | 13 | use gpui::FontWeight; |
| 14 | 14 | ||
| 15 | thread_local! { | 15 | thread_local! { |
| @@ -178,8 +178,22 @@ fn range_marks(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | |||
| 178 | .flex() | 178 | .flex() |
| 179 | .items_center() | 179 | .items_center() |
| 180 | .gap(px(4.)) | 180 | .gap(px(4.)) |
| 181 | - .child(ghost("stance-mark-in", player, "I", ActionId::SetIn, false, cx)) | 181 | + .child(ghost( |
| 182 | - .child(ghost("stance-mark-out", player, "O", ActionId::SetOut, false, cx)) | 182 | + "stance-mark-in", |
| 183 | + player, | ||
| 184 | + "I", | ||
| 185 | + ActionId::SetIn, | ||
| 186 | + false, | ||
| 187 | + cx, | ||
| 188 | + )) | ||
| 189 | + .child(ghost( | ||
| 190 | + "stance-mark-out", | ||
| 191 | + player, | ||
| 192 | + "O", | ||
| 193 | + ActionId::SetOut, | ||
| 194 | + false, | ||
| 195 | + cx, | ||
| 196 | + )) | ||
| 183 | .child(ghost( | 197 | .child(ghost( |
| 184 | "stance-clear-range", | 198 | "stance-clear-range", |
| 185 | player, | 199 | player, |
| @@ -241,11 +255,25 @@ fn contact_strip(player: &Player, position: f64, cx: &mut Context<Player>) -> im | |||
| 241 | .flat_map(|l| s.lane_clips(l).to_vec()) | 255 | .flat_map(|l| s.lane_clips(l).to_vec()) |
| 242 | .filter_map(|clip| { | 256 | .filter_map(|clip| { |
| 243 | let source = player.sources().get(clip.source)?; | 257 | let source = player.sources().get(clip.source)?; |
| 244 | - let Wave::Peaks(peaks) = player.waves.get(&(source.path.clone(), source.audio_stream))?.clone() else { | 258 | + let Wave::Peaks(peaks) = player |
| 259 | + .waves | ||
| 260 | + .get(&(source.path.clone(), source.audio_stream))? | ||
| 261 | + .clone() | ||
| 262 | + else { | ||
| 245 | return None; | 263 | return None; |
| 246 | }; | 264 | }; |
| 247 | - let (in_f, out_f) = (f64::from(clip.in_frame) / fps, f64::from(clip.out_frame) / fps); | 265 | + let (in_f, out_f) = ( |
| 248 | - Some((frac(clip.start), frac(clip.end()), peaks, in_f, out_f, source_tint(clip.source))) | 266 | + f64::from(clip.in_frame) / fps, |
| 267 | + f64::from(clip.out_frame) / fps, | ||
| 268 | + ); | ||
| 269 | + Some(( | ||
| 270 | + frac(clip.start), | ||
| 271 | + frac(clip.end()), | ||
| 272 | + peaks, | ||
| 273 | + in_f, | ||
| 274 | + out_f, | ||
| 275 | + source_tint(clip.source), | ||
| 276 | + )) | ||
| 249 | }) | 277 | }) |
| 250 | .collect() | 278 | .collect() |
| 251 | }) | 279 | }) |
| @@ -424,13 +452,10 @@ fn grip(id: &'static str, left: bool, top: bool) -> impl IntoElement { | |||
| 424 | .h(px(6.)) | 452 | .h(px(6.)) |
| 425 | .bg(rgb(INK1())), | 453 | .bg(rgb(INK1())), |
| 426 | ) | 454 | ) |
| 427 | - .on_mouse_down( | 455 | + .on_mouse_down(MouseButton::Left, move |event: &MouseDownEvent, _, cx| { |
| 428 | - MouseButton::Left, | 456 | + PAN_ANCHOR.with(|a| a.set(Some(f32::from(event.position.x)))); |
| 429 | - move |event: &MouseDownEvent, _, cx| { | 457 | + cx.stop_propagation(); |
| 430 | - PAN_ANCHOR.with(|a| a.set(Some(f32::from(event.position.x)))); | 458 | + }) |
| 431 | - cx.stop_propagation(); | ||
| 432 | - }, | ||
| 433 | - ) | ||
| 434 | } | 459 | } |
| 435 | 460 | ||
| 436 | /// The Export chip (MOCK-SPEC "Export chip", DESIGN §4): the room's single | 461 | /// 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<Player>) -> impl IntoElement | |||
| 501 | .flex() | 526 | .flex() |
| 502 | .items_center() | 527 | .items_center() |
| 503 | .tooltip(|_, cx| { | 528 | .tooltip(|_, cx| { |
| 504 | - cx.new(|_| Tip("Volume — drag to set the level; the button mutes".into())).into() | 529 | + cx.new(|_| Tip("Volume — drag to set the level; the button mutes".into())) |
| 530 | + .into() | ||
| 505 | }) | 531 | }) |
| 506 | .when(!enabled, |d| d.opacity(0.4).cursor_not_allowed()) | 532 | .when(!enabled, |d| d.opacity(0.4).cursor_not_allowed()) |
| 507 | .when(enabled, |d| { | 533 | .when(enabled, |d| { |
| @@ -534,7 +560,11 @@ fn volume_slider(player: &Player, cx: &mut Context<Player>) -> impl IntoElement | |||
| 534 | /// The whole band, left to right per MOCK-SPEC: hero timecode, ghost | 560 | /// The whole band, left to right per MOCK-SPEC: hero timecode, ghost |
| 535 | /// transport, cut readout, the contact strip filling the rest, the Export | 561 | /// transport, cut readout, the contact strip filling the rest, the Export |
| 536 | /// chip at the end. | 562 | /// chip at the end. |
| 537 | -pub(crate) fn render(player: &mut Player, position: f64, cx: &mut Context<Player>) -> impl IntoElement { | 563 | +pub(crate) fn render( |
| 564 | + player: &mut Player, | ||
| 565 | + position: f64, | ||
| 566 | + cx: &mut Context<Player>, | ||
| 567 | +) -> impl IntoElement { | ||
| 538 | let tc = timecode(position, player.active_fps()); | 568 | let tc = timecode(position, player.active_fps()); |
| 539 | div() | 569 | div() |
| 540 | .id("stance-time-band-row") | 570 | .id("stance-time-band-row") |
| @@ -584,7 +614,11 @@ pub(crate) fn render(player: &mut Player, position: f64, cx: &mut Context<Player | |||
| 584 | .child(ghost( | 614 | .child(ghost( |
| 585 | "stance-tb-play", | 615 | "stance-tb-play", |
| 586 | player, | 616 | player, |
| 587 | - if player.transport().is_playing() { "❚❚" } else { "▶" }, | 617 | + if player.transport().is_playing() { |
| 618 | + "❚❚" | ||
| 619 | + } else { | ||
| 620 | + "▶" | ||
| 621 | + }, | ||
| 588 | ActionId::Play, | 622 | ActionId::Play, |
| 589 | false, | 623 | false, |
| 590 | cx, | 624 | cx, |
| @@ -676,7 +710,14 @@ pub(crate) fn render(player: &mut Player, position: f64, cx: &mut Context<Player | |||
| 676 | .flex() | 710 | .flex() |
| 677 | .items_center() | 711 | .items_center() |
| 678 | .gap(px(6.)) | 712 | .gap(px(6.)) |
| 679 | - .child(ghost("stance-tb-vol-down", player, "−", ActionId::VolumeDown, false, cx)) | 713 | + .child(ghost( |
| 714 | + "stance-tb-vol-down", | ||
| 715 | + player, | ||
| 716 | + "−", | ||
| 717 | + ActionId::VolumeDown, | ||
| 718 | + false, | ||
| 719 | + cx, | ||
| 720 | + )) | ||
| 680 | .child(ghost( | 721 | .child(ghost( |
| 681 | "stance-tb-mute", | 722 | "stance-tb-mute", |
| 682 | player, | 723 | player, |
| @@ -690,7 +731,14 @@ pub(crate) fn render(player: &mut Player, position: f64, cx: &mut Context<Player | |||
| 690 | cx, | 731 | cx, |
| 691 | )) | 732 | )) |
| 692 | .child(volume_slider(player, cx)) | 733 | .child(volume_slider(player, cx)) |
| 693 | - .child(ghost("stance-tb-vol-up", player, "+", ActionId::VolumeUp, false, cx)), | 734 | + .child(ghost( |
| 735 | + "stance-tb-vol-up", | ||
| 736 | + player, | ||
| 737 | + "+", | ||
| 738 | + ActionId::VolumeUp, | ||
| 739 | + false, | ||
| 740 | + cx, | ||
| 741 | + )), | ||
| 694 | ) | 742 | ) |
| 695 | .child(range_marks(player, cx)) | 743 | .child(range_marks(player, cx)) |
| 696 | .child(cut_readout(player)) | 744 | .child(cut_readout(player)) |
crates/app/src/ui/timeline.rsmodified+55 -49
| @@ -1,7 +1,7 @@ | |||
| 1 | //! The bottom region: the ruler, the lanes and the subtitle strip. | 1 | //! The bottom region: the ruler, the lanes and the subtitle strip. |
| 2 | 2 | ||
| 3 | -use crate::*; | ||
| 4 | use crate::ui::widgets::*; | 3 | use crate::ui::widgets::*; |
| 4 | +use crate::*; | ||
| 5 | 5 | ||
| 6 | impl Player { | 6 | impl Player { |
| 7 | /// The bottom region, full width under everything else: the timecode and | 7 | /// The bottom region, full width under everything else: the timecode and |
| @@ -102,8 +102,12 @@ impl Player { | |||
| 102 | true => (lanes_box - LABEL_H - 8.).max(LANE_H), | 102 | true => (lanes_box - LABEL_H - 8.).max(LANE_H), |
| 103 | false => lanes_box, | 103 | false => lanes_box, |
| 104 | }; | 104 | }; |
| 105 | - let (thumb_x, thumb_w) = | 105 | + let (thumb_x, thumb_w) = scroll_thumb( |
| 106 | - scroll_thumb(view.bed, view.duration, view.scale.start.max(0.), view.span()); | 106 | + view.bed, |
| 107 | + view.duration, | ||
| 108 | + view.scale.start.max(0.), | ||
| 109 | + view.span(), | ||
| 110 | + ); | ||
| 107 | // Live, not a count of the lanes: the column reports where it has been | 111 | // Live, not a count of the lanes: the column reports where it has been |
| 108 | // taken to, so the line empties itself as the last track comes up | 112 | // taken to, so the line empties itself as the last track comes up |
| 109 | // instead of insisting there is still something below. The stack's own | 113 | // instead of insisting there is still something below. The stack's own |
| @@ -119,8 +123,7 @@ impl Player { | |||
| 119 | let stack = self.lanes_scroll.bounds(); | 123 | let stack = self.lanes_scroll.bounds(); |
| 120 | let track_h = f32::from(stack.size.height); | 124 | let track_h = f32::from(stack.size.height); |
| 121 | let stack_max = f32::from(self.lanes_scroll.max_offset().height); | 125 | let stack_max = f32::from(self.lanes_scroll.max_offset().height); |
| 122 | - let (stack_y, stack_thumb_h) = | 126 | + let (stack_y, stack_thumb_h) = lanes_thumb(track_h, track_h + stack_max, track_h, scrolled); |
| 123 | - lanes_thumb(track_h, track_h + stack_max, track_h, scrolled); | ||
| 124 | div() | 127 | div() |
| 125 | .flex_none() | 128 | .flex_none() |
| 126 | // Never more than its share of a short window: the lane column | 129 | // Never more than its share of a short window: the lane column |
| @@ -344,8 +347,7 @@ impl Player { | |||
| 344 | |this, event: &ScrollWheelEvent, window, cx| { | 347 | |this, event: &ScrollWheelEvent, window, cx| { |
| 345 | cx.stop_propagation(); | 348 | cx.stop_propagation(); |
| 346 | let line = window.line_height(); | 349 | let line = window.line_height(); |
| 347 | - let dy = | 350 | + let dy = f32::from(event.delta.pixel_delta(line).y); |
| 348 | - f32::from(event.delta.pixel_delta(line).y); | ||
| 349 | this.lanes_wheel(dy, cx); | 351 | this.lanes_wheel(dy, cx); |
| 350 | }, | 352 | }, |
| 351 | )) | 353 | )) |
| @@ -360,15 +362,11 @@ impl Player { | |||
| 360 | // else on the bed; over the strip it is | 362 | // else on the bed; over the strip it is |
| 361 | // nothing, and the clip beneath must not | 363 | // nothing, and the clip beneath must not |
| 362 | // answer it through the strip. | 364 | // answer it through the strip. |
| 363 | - .on_mouse_down( | 365 | + .on_mouse_down(MouseButton::Right, |_: &MouseDownEvent, _, cx| { |
| 364 | - MouseButton::Right, | 366 | + cx.stop_propagation() |
| 365 | - |_: &MouseDownEvent, _, cx| cx.stop_propagation(), | 367 | + }) |
| 366 | - ) | ||
| 367 | .on_mouse_move(cx.listener(Player::drag_move)) | 368 | .on_mouse_move(cx.listener(Player::drag_move)) |
| 368 | - .on_mouse_up( | 369 | + .on_mouse_up(MouseButton::Left, cx.listener(Player::drag_release)) |
| 369 | - MouseButton::Left, | ||
| 370 | - cx.listener(Player::drag_release), | ||
| 371 | - ) | ||
| 372 | .child( | 370 | .child( |
| 373 | div() | 371 | div() |
| 374 | .absolute() | 372 | .absolute() |
| @@ -524,7 +522,11 @@ impl Player { | |||
| 524 | /// | 522 | /// |
| 525 | /// `None` when there are none -- an empty heading is a section about | 523 | /// `None` when there are none -- an empty heading is a section about |
| 526 | /// nothing. | 524 | /// nothing. |
| 527 | - pub(crate) fn subtitle_section(&self, width: f32, cx: &mut Context<Self>) -> Option<impl IntoElement> { | 525 | + pub(crate) fn subtitle_section( |
| 526 | + &self, | ||
| 527 | + width: f32, | ||
| 528 | + cx: &mut Context<Self>, | ||
| 529 | + ) -> Option<impl IntoElement> { | ||
| 528 | let tracks = self.session.as_ref()?.subtitles(); | 530 | let tracks = self.session.as_ref()?.subtitles(); |
| 529 | if tracks.is_empty() { | 531 | if tracks.is_empty() { |
| 530 | return None; | 532 | return None; |
| @@ -588,13 +590,12 @@ impl Player { | |||
| 588 | let carried: SharedString = title.clone().into(); | 590 | let carried: SharedString = title.clone().into(); |
| 589 | // Named, because a × is the same glyph on every row and | 591 | // Named, because a × is the same glyph on every row and |
| 590 | // the tooltip is what says which track it takes off. | 592 | // the tooltip is what says which track it takes off. |
| 591 | - let remove_tip: SharedString = | 593 | + let remove_tip: SharedString = format!( |
| 592 | - format!( | 594 | + "Remove {title} from the palette — {} puts a file's subtitles \ |
| 593 | - "Remove {title} from the palette — {} puts a file's subtitles \ | ||
| 594 | back in it", | 595 | back in it", |
| 595 | - add_key | 596 | + add_key |
| 596 | - ) | 597 | + ) |
| 597 | - .into(); | 598 | + .into(); |
| 598 | div() | 599 | div() |
| 599 | // The *flat* index into the session's add-order | 600 | // The *flat* index into the session's add-order |
| 600 | // list, which is what a pick is and what a save | 601 | // list, which is what a pick is and what a save |
| @@ -710,13 +711,13 @@ impl Player { | |||
| 710 | .rounded(px(3.)) | 711 | .rounded(px(3.)) |
| 711 | .cursor_pointer() | 712 | .cursor_pointer() |
| 712 | .hover(|s| s.bg(rgb(BG_HOVER()))) | 713 | .hover(|s| s.bg(rgb(BG_HOVER()))) |
| 713 | - .tooltip(move |_, cx| cx.new(|_| Tip(remove_tip.clone())).into()) | 714 | + .tooltip(move |_, cx| { |
| 714 | - .on_click(cx.listener( | 715 | + cx.new(|_| Tip(remove_tip.clone())).into() |
| 715 | - move |this, _: &ClickEvent, _, cx| { | 716 | + }) |
| 716 | - cx.stop_propagation(); | 717 | + .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { |
| 717 | - this.remove_subtitle_track(track, cx); | 718 | + cx.stop_propagation(); |
| 718 | - }, | 719 | + this.remove_subtitle_track(track, cx); |
| 719 | - )) | 720 | + })) |
| 720 | .child("×"), | 721 | .child("×"), |
| 721 | ) | 722 | ) |
| 722 | }) | 723 | }) |
| @@ -987,8 +988,8 @@ impl Player { | |||
| 987 | .on_drop(cx.listener(move |this, drag: &LaneDrag, _, cx| { | 988 | .on_drop(cx.listener(move |this, drag: &LaneDrag, _, cx| { |
| 988 | this.reorder_lane(drag.0, lane, cx); | 989 | this.reorder_lane(drag.0, lane, cx); |
| 989 | })) | 990 | })) |
| 990 | - .on_drag_move(cx.listener( | 991 | + .on_drag_move( |
| 991 | - move |this, event: &DragMoveEvent<LaneDrag>, _, cx| { | 992 | + cx.listener(move |this, event: &DragMoveEvent<LaneDrag>, _, cx| { |
| 992 | // Carried off this row, the line it was promising goes with | 993 | // Carried off this row, the line it was promising goes with |
| 993 | // it: a cue left painted over a slot a release out here does | 994 | // it: a cue left painted over a slot a release out here does |
| 994 | // not commit is the drag saying one thing and the drop | 995 | // not commit is the drag saying one thing and the drop |
| @@ -1000,8 +1001,8 @@ impl Player { | |||
| 1000 | return this.forget_lane_drop(lane, cx); | 1001 | return this.forget_lane_drop(lane, cx); |
| 1001 | } | 1002 | } |
| 1002 | this.preview_lane_drop(event.drag(cx).0, lane, cx); | 1003 | this.preview_lane_drop(event.drag(cx).0, lane, cx); |
| 1003 | - }, | 1004 | + }), |
| 1004 | - )) | 1005 | + ) |
| 1005 | // The fixed column the ruler above is offset by as well. Full lane | 1006 | // The fixed column the ruler above is offset by as well. Full lane |
| 1006 | // height, so it reads as the bed continuing rather than as a chip. | 1007 | // height, so it reads as the bed continuing rather than as a chip. |
| 1007 | .child( | 1008 | .child( |
| @@ -1854,20 +1855,20 @@ impl Player { | |||
| 1854 | zone | 1855 | zone |
| 1855 | }), | 1856 | }), |
| 1856 | ) | 1857 | ) |
| 1857 | - // No name drawn on the box itself: the cue blocks | 1858 | + // No name drawn on the box itself: the cue blocks |
| 1858 | - // now fill its full height, and a label sitting | 1859 | + // now fill its full height, and a label sitting |
| 1859 | - // over them fights the very thing this box exists | 1860 | + // over them fights the very thing this box exists |
| 1860 | - // to show. The tooltip still carries the words | 1861 | + // to show. The tooltip still carries the words |
| 1861 | - // (`sub_tip`), and the ghost while dragging still | 1862 | + // (`sub_tip`), and the ghost while dragging still |
| 1862 | - // names the track (`ghost`, above). | 1863 | + // names the track (`ghost`, above). |
| 1863 | - // The way back off the lane is the way every other | 1864 | + // The way back off the lane is the way every other |
| 1864 | - // box takes: the Delete stroke on the marked caption | 1865 | + // box takes: the Delete stroke on the marked caption |
| 1865 | - // and the Delete row of its own menu | 1866 | + // and the Delete row of its own menu |
| 1866 | - // ([`Player::lift_sub`]). The × that used to sit | 1867 | + // ([`Player::lift_sub`]). The × that used to sit |
| 1867 | - // here is gone with them -- it was drawn only where | 1868 | + // here is gone with them -- it was drawn only where |
| 1868 | - // the box was wide enough to hold it, so the one | 1869 | + // the box was wide enough to hold it, so the one |
| 1869 | - // removal a caption had was the one a zoomed-out | 1870 | + // removal a caption had was the one a zoomed-out |
| 1870 | - // caption did not have. | 1871 | + // caption did not have. |
| 1871 | })) | 1872 | })) |
| 1872 | // ...and where the words actually are inside those boxes: | 1873 | // ...and where the words actually are inside those boxes: |
| 1873 | // the cues this lane shows on *this* timeline, each its own | 1874 | // the cues this lane shows on *this* timeline, each its own |
| @@ -1932,13 +1933,18 @@ impl Player { | |||
| 1932 | .max(GHOST_MIN))) | 1933 | .max(GHOST_MIN))) |
| 1933 | .rounded(px(3.)) | 1934 | .rounded(px(3.)) |
| 1934 | .border_1() | 1935 | .border_1() |
| 1935 | - .border_color(rgb(if g.refused { DROP_REFUSE() } else { FG_PRIMARY() })) | 1936 | + .border_color(rgb(if g.refused { |
| 1937 | + DROP_REFUSE() | ||
| 1938 | + } else { | ||
| 1939 | + FG_PRIMARY() | ||
| 1940 | + })) | ||
| 1936 | // The file's own swatch at a third of its weight, so | 1941 | // The file's own swatch at a third of its weight, so |
| 1937 | // the box beneath is still legible through it -- and | 1942 | // the box beneath is still legible through it -- and |
| 1938 | // the refusal red instead, for a lane that will not | 1943 | // the refusal red instead, for a lane that will not |
| 1939 | // take this drop at all. | 1944 | // take this drop at all. |
| 1940 | .bg(rgba( | 1945 | .bg(rgba( |
| 1941 | - ((if g.refused { DROP_REFUSE() } else { g.tint }) << 8) | GHOST_ALPHA, | 1946 | + ((if g.refused { DROP_REFUSE() } else { g.tint }) << 8) |
| 1947 | + | GHOST_ALPHA, | ||
| 1942 | )) | 1948 | )) |
| 1943 | })) | 1949 | })) |
| 1944 | // What the gesture in flight is about to land on, drawn on | 1950 | // What the gesture in flight is about to land on, drawn on |
crates/app/src/ui/toolbar.rsmodified+8 -5
| @@ -9,8 +9,8 @@ | |||
| 9 | //! pointer while the very same actions still fired from the keys. One oracle, | 9 | //! pointer while the very same actions still fired from the keys. One oracle, |
| 10 | //! two doors -- if the key fires, the button fires. | 10 | //! two doors -- if the key fires, the button fires. |
| 11 | 11 | ||
| 12 | -use crate::*; | ||
| 13 | use crate::ui::widgets::*; | 12 | use crate::ui::widgets::*; |
| 13 | +use crate::*; | ||
| 14 | 14 | ||
| 15 | impl Player { | 15 | impl Player { |
| 16 | /// A toolbar button for `action`: enabled exactly when [`enable`] says the | 16 | /// A toolbar button for `action`: enabled exactly when [`enable`] says the |
| @@ -142,8 +142,7 @@ impl Player { | |||
| 142 | this.open_export(cx); | 142 | this.open_export(cx); |
| 143 | } | 143 | } |
| 144 | }), | 144 | }), |
| 145 | - )) | 145 | + )), |
| 146 | - , | ||
| 147 | ) | 146 | ) |
| 148 | } | 147 | } |
| 149 | 148 | ||
| @@ -216,7 +215,9 @@ impl Player { | |||
| 216 | "Loop", | 215 | "Loop", |
| 217 | "restarts from the top on reaching the end, instead of stopping", | 216 | "restarts from the top on reaching the end, instead of stopping", |
| 218 | ActionId::Loop, | 217 | ActionId::Loop, |
| 219 | - cx.listener(|this, _: &ClickEvent, window, cx| this.act(ActionId::Loop, window, cx)), | 218 | + cx.listener(|this, _: &ClickEvent, window, cx| { |
| 219 | + this.act(ActionId::Loop, window, cx) | ||
| 220 | + }), | ||
| 220 | )) | 221 | )) |
| 221 | // One line, one fixed width: changing digits must not push the | 222 | // One line, one fixed width: changing digits must not push the |
| 222 | // strip around, and the clock is the one number that changes | 223 | // strip around, and the clock is the one number that changes |
| @@ -397,7 +398,9 @@ impl Player { | |||
| 397 | None, | 398 | None, |
| 398 | if self.snap { "Snap on" } else { "Snap off" }, | 399 | if self.snap { "Snap on" } else { "Snap off" }, |
| 399 | match self.snap { | 400 | match self.snap { |
| 400 | - true => "drags and trims land on clip edges, the playhead and the start", | 401 | + true => { |
| 402 | + "drags and trims land on clip edges, the playhead and the start" | ||
| 403 | + } | ||
| 401 | false => "drags and trims land exactly where the hand leaves them", | 404 | false => "drags and trims land exactly where the hand leaves them", |
| 402 | }, | 405 | }, |
| 403 | ActionId::ToggleSnap, | 406 | ActionId::ToggleSnap, |
crates/app/src/ui/widgets.rsmodified+15 -3
| @@ -13,7 +13,12 @@ pub(crate) fn waveform(peaks: Arc<Vec<(f32, f32)>>, from: f64, to: f64) -> impl | |||
| 13 | /// secondary foreground -- the darkroom bench's own audio clips draw their | 13 | /// secondary foreground -- the darkroom bench's own audio clips draw their |
| 14 | /// envelope in the source's ink (DESIGN §5), which the legacy timeline never | 14 | /// envelope in the source's ink (DESIGN §5), which the legacy timeline never |
| 15 | /// needed a colour for. | 15 | /// needed a colour for. |
| 16 | -pub(crate) fn waveform_ink(peaks: Arc<Vec<(f32, f32)>>, from: f64, to: f64, ink: u32) -> impl IntoElement { | 16 | +pub(crate) fn waveform_ink( |
| 17 | + peaks: Arc<Vec<(f32, f32)>>, | ||
| 18 | + from: f64, | ||
| 19 | + to: f64, | ||
| 20 | + ink: u32, | ||
| 21 | +) -> impl IntoElement { | ||
| 17 | canvas( | 22 | canvas( |
| 18 | |_, _, _| (), | 23 | |_, _, _| (), |
| 19 | move |bounds, _, window, _| { | 24 | move |bounds, _, window, _| { |
| @@ -229,7 +234,11 @@ pub(crate) fn volume_slider( | |||
| 229 | .h_full() | 234 | .h_full() |
| 230 | .w(relative(volume.along())) | 235 | .w(relative(volume.along())) |
| 231 | .rounded(px(2.)) | 236 | .rounded(px(2.)) |
| 232 | - .bg(rgb(if volume.muted { FG_SECONDARY() } else { ACCENT_PRIMARY() })), | 237 | + .bg(rgb(if volume.muted { |
| 238 | + FG_SECONDARY() | ||
| 239 | + } else { | ||
| 240 | + ACCENT_PRIMARY() | ||
| 241 | + })), | ||
| 233 | ), | 242 | ), |
| 234 | ) | 243 | ) |
| 235 | } | 244 | } |
| @@ -282,7 +291,10 @@ pub(crate) fn tip_may_paint(anchored_on_overlay: bool) -> bool { | |||
| 282 | /// plate" -- canvas-on-panel, 2px radius, the room's own type | 291 | /// plate" -- canvas-on-panel, 2px radius, the room's own type |
| 283 | /// (`ui::type_scale`), not a bordered box in an ad hoc size. | 292 | /// (`ui::type_scale`), not a bordered box in an ad hoc size. |
| 284 | fn tip_plate(text: &SharedString) -> Div { | 293 | fn tip_plate(text: &SharedString) -> Div { |
| 285 | - let style = crate::ui::type_scale::label(crate::ui::type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM); | 294 | + let style = crate::ui::type_scale::label( |
| 295 | + crate::ui::type_scale::LABEL_ROW_PX, | ||
| 296 | + gpui::FontWeight::MEDIUM, | ||
| 297 | + ); | ||
| 286 | div() | 298 | div() |
| 287 | .px(px(8.)) | 299 | .px(px(8.)) |
| 288 | .py(px(4.)) | 300 | .py(px(4.)) |