🔀 merge(A5): main (96094a2) into the import-policy branch
Browse files at this commit2 changed files +1182 -193
- crates/app/src/keymap.rs +41 -5
- crates/app/src/main.rs +1141 -188
crates/app/src/keymap.rsmodified+41 -5
| @@ -78,13 +78,14 @@ pub enum ActionId { | ||
| 78 | 78 | Speed, |
| 79 | 79 | Silence, |
| 80 | 80 | Mix, |
| 81 | + ToggleSnap, | |
| 81 | 82 | CancelExport, |
| 82 | 83 | } |
| 83 | 84 | |
| 84 | 85 | impl ActionId { |
| 85 | 86 | /// Display order everywhere -- the editor lists them in it and |
| 86 | 87 | /// [`Keymap::defaults`] binds them in it. |
| 87 | - pub const ALL: [ActionId; 39] = [ | |
| 88 | + pub const ALL: [ActionId; 40] = [ | |
| 88 | 89 | ActionId::Play, |
| 89 | 90 | ActionId::StepBack, |
| 90 | 91 | ActionId::StepForward, |
| @@ -123,6 +124,7 @@ impl ActionId { | ||
| 123 | 124 | ActionId::Speed, |
| 124 | 125 | ActionId::Silence, |
| 125 | 126 | ActionId::Mix, |
| 127 | + ActionId::ToggleSnap, | |
| 126 | 128 | ActionId::CancelExport, |
| 127 | 129 | ]; |
| 128 | 130 | |
| @@ -167,6 +169,7 @@ impl ActionId { | ||
| 167 | 169 | ActionId::Speed => "Speed (tape)…", |
| 168 | 170 | ActionId::Silence => "Silences: cut or speed up…", |
| 169 | 171 | ActionId::Mix => "Mix: track volumes and the limiter…", |
| 172 | + ActionId::ToggleSnap => "Snap on / off (edges, the playhead, the start)", | |
| 170 | 173 | ActionId::CancelExport => "Cancel export", |
| 171 | 174 | } |
| 172 | 175 | } |
| @@ -213,6 +216,7 @@ impl ActionId { | ||
| 213 | 216 | ActionId::Speed => "speed", |
| 214 | 217 | ActionId::Silence => "silence", |
| 215 | 218 | ActionId::Mix => "mix", |
| 219 | + ActionId::ToggleSnap => "toggle-snap", | |
| 216 | 220 | ActionId::CancelExport => "cancel-export", |
| 217 | 221 | } |
| 218 | 222 | } |
| @@ -265,6 +269,9 @@ impl ActionId { | ||
| 265 | 269 | | ActionId::AddVideoLane |
| 266 | 270 | | ActionId::AddAudioLane |
| 267 | 271 | | ActionId::RemoveVideoLane |
| 272 | + // Not a view setting despite being a pointer aid: it decides where | |
| 273 | + // a drag actually lands, which is an edit and not a magnification. | |
| 274 | + | ActionId::ToggleSnap | |
| 268 | 275 | | ActionId::RemoveAudioLane => Category::Editing, |
| 269 | 276 | ActionId::ToggleMute |
| 270 | 277 | | ActionId::VolumeUp |
| @@ -326,7 +333,7 @@ pub struct Fixed { | ||
| 326 | 333 | pub category: Category, |
| 327 | 334 | } |
| 328 | 335 | |
| 329 | -pub const FIXED: [Fixed; 21] = [ | |
| 336 | +pub const FIXED: [Fixed; 26] = [ | |
| 330 | 337 | // Not a chord at all but a way of pressing one, and the only place the |
| 331 | 338 | // editor can say so: holding a key that moves a *value* runs it, and |
| 332 | 339 | // holding anything else still does what one press did. |
| @@ -394,7 +401,7 @@ pub const FIXED: [Fixed; 21] = [ | ||
| 394 | 401 | // its own: a band nothing but a drag can reach is a band half the users of |
| 395 | 402 | // this editor cannot move at all. Card-local, so none of them is bindable. |
| 396 | 403 | Fixed { |
| 397 | - chord: "1–5", | |
| 404 | + chord: "1–9, 0", | |
| 398 | 405 | label: "Pick an equalizer band", |
| 399 | 406 | category: Category::Audio, |
| 400 | 407 | }, |
| @@ -408,6 +415,31 @@ pub const FIXED: [Fixed; 21] = [ | ||
| 408 | 415 | label: "Lower the picked band 1 dB", |
| 409 | 416 | category: Category::Audio, |
| 410 | 417 | }, |
| 418 | + Fixed { | |
| 419 | + chord: "← / →", | |
| 420 | + label: "Move the picked band down or up in frequency", | |
| 421 | + category: Category::Audio, | |
| 422 | + }, | |
| 423 | + Fixed { | |
| 424 | + chord: "shift ← / →", | |
| 425 | + label: "Widen or narrow the picked band (its Q)", | |
| 426 | + category: Category::Audio, | |
| 427 | + }, | |
| 428 | + Fixed { | |
| 429 | + chord: "a", | |
| 430 | + label: "Add an equalizer band beside the picked one", | |
| 431 | + category: Category::Audio, | |
| 432 | + }, | |
| 433 | + Fixed { | |
| 434 | + chord: "x", | |
| 435 | + label: "Remove the picked equalizer band", | |
| 436 | + category: Category::Audio, | |
| 437 | + }, | |
| 438 | + Fixed { | |
| 439 | + chord: "f", | |
| 440 | + label: "Flatten the picked band (double-click does the same)", | |
| 441 | + category: Category::Audio, | |
| 442 | + }, | |
| 411 | 443 | Fixed { |
| 412 | 444 | chord: "r", |
| 413 | 445 | label: "Flatten every band", |
| @@ -645,6 +677,9 @@ impl Keymap { | ||
| 645 | 677 | // machine's volume and not the project's -- two things one key |
| 646 | 678 | // must not mean. |
| 647 | 679 | b(ActionId::Mix, "f", false), |
| 680 | + // The snap takes "n", which is what every other editor toggles | |
| 681 | + // it with: free here, and nowhere near the two keys that delete. | |
| 682 | + b(ActionId::ToggleSnap, "n", false), | |
| 648 | 683 | b(ActionId::CancelExport, "escape", false), |
| 649 | 684 | ], |
| 650 | 685 | } |
| @@ -907,7 +942,7 @@ mod tests { | ||
| 907 | 942 | #[test] |
| 908 | 943 | fn every_default_stroke_reaches_its_action() { |
| 909 | 944 | let k = Keymap::defaults(); |
| 910 | - assert_eq!(k.entries().len(), 41); | |
| 945 | + assert_eq!(k.entries().len(), 42); | |
| 911 | 946 | assert_eq!(k.lookup("space", false), Some(ActionId::Play)); |
| 912 | 947 | // The seek keys: bare arrows a frame, ctrl arrows a second, and the two |
| 913 | 948 | // ends of the timeline. |
| @@ -1141,7 +1176,8 @@ mod tests { | ||
| 1141 | 1176 | assert_eq!(whole("edith-keys 1\n").display(ActionId::Cut), "unbound"); |
| 1142 | 1177 | // The label is the editor's column, and never the file's word for it. |
| 1143 | 1178 | assert_eq!(ActionId::CancelExport.label(), "Cancel export"); |
| 1144 | - assert_eq!(ActionId::ALL.len(), 39); | |
| 1179 | + assert_eq!(ActionId::ALL.len(), 40); | |
| 1180 | + assert_eq!(k.display(ActionId::ToggleSnap), "n"); | |
| 1145 | 1181 | assert_eq!(k.display(ActionId::ZoomIn), "ctrl+="); |
| 1146 | 1182 | } |
| 1147 | 1183 |
crates/app/src/main.rsmodified+1141 -188
| @@ -19,11 +19,11 @@ use engine::project::{Edge, Lane, LaneKind, Source, Speed}; | ||
| 19 | 19 | use engine::scale::FitPolicy; |
| 20 | 20 | use engine::{Clip, Codec, ExportHandle, Frame, PlaybackSession}; |
| 21 | 21 | use gpui::{ |
| 22 | - AnyElement, App, Application, Bounds, ClickEvent, Context, CursorStyle, Div, FocusHandle, | |
| 23 | - KeyDownEvent, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, PathBuilder, Pixels, | |
| 24 | - Point, RenderImage, ScrollDelta, ScrollWheelEvent, SharedString, Size, Stateful, TextAlign, | |
| 25 | - TitlebarOptions, Window, WindowBounds, WindowOptions, canvas, div, img, point, prelude::*, px, | |
| 26 | - relative, rgb, rgba, size, | |
| 22 | + AnyElement, App, Application, Bounds, ClickEvent, Context, CursorStyle, Div, DragMoveEvent, | |
| 23 | + FocusHandle, KeyDownEvent, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, | |
| 24 | + PathBuilder, Pixels, Point, RenderImage, ScrollDelta, ScrollWheelEvent, SharedString, Size, | |
| 25 | + Stateful, TextAlign, TitlebarOptions, Window, WindowBounds, WindowOptions, canvas, div, img, | |
| 26 | + point, prelude::*, px, relative, rgb, rgba, size, | |
| 27 | 27 | }; |
| 28 | 28 | |
| 29 | 29 | /// Editor chrome: three grays and one accent, all darker than the picture so the |
| @@ -85,6 +85,13 @@ const WAVE_BPS: u32 = 40; | ||
| 85 | 85 | /// Pixels per envelope column. Coarser than a pixel: the eye reads the shape, |
| 86 | 86 | /// and a path with a point per pixel is a path per repaint. |
| 87 | 87 | const WAVE_COL: f32 = 2.; |
| 88 | +/// The most columns one envelope is ever built from. A waveform is drawn into | |
| 89 | +/// the slice of its box that is on the bed ([`visible_slice`]), and a bed is a | |
| 90 | +/// screen wide, so nothing on screen ever reaches this -- it is the backstop for | |
| 91 | +/// a box laid out wider than any screen, whose path would otherwise cost a point | |
| 92 | +/// per two pixels of a width nobody can see and stall the repaint that was | |
| 93 | +/// meant to draw the wave. | |
| 94 | +const WAVE_COLS_MAX: usize = 4096; | |
| 88 | 95 | /// WCAG 2.5.8: nothing clickable is smaller than this. The scrub bar stays 6 px |
| 89 | 96 | /// to look at -- `RULER_HIT_H` is the strip that has to be hit. |
| 90 | 97 | const HIT_MIN: f32 = 24.; |
| @@ -281,6 +288,13 @@ struct AssetDrag(PathBuf, usize); | ||
| 281 | 288 | struct ClipDrag { |
| 282 | 289 | lane: Lane, |
| 283 | 290 | idx: usize, |
| 291 | + /// The clip that was picked up, so the drop can find it again: gpui freezes | |
| 292 | + /// the payload for the whole gesture, and an edit made *during* one -- a | |
| 293 | + /// stroke deletes, undoes or pastes, none of which a drag blocks -- ripples | |
| 294 | + /// the indices under it. The index alone would then name a different take at | |
| 295 | + /// the release, and the drag would move a clip nobody touched (see | |
| 296 | + /// [`live_idx`]). | |
| 297 | + clip: Clip, | |
| 284 | 298 | } |
| 285 | 299 | |
| 286 | 300 | /// A clip edge being dragged: which end of which clip, and the timeline frame |
| @@ -569,6 +583,36 @@ const EQ_FREQ_HIGH: f32 = 20_000.; | ||
| 569 | 583 | /// and short enough that the card still fits a 360 px window. |
| 570 | 584 | const EQ_GRAPH_H: f32 = 132.; |
| 571 | 585 | |
| 586 | +/// How wide the equalizer card is allowed to get. It is the one card that is a | |
| 587 | +/// *graph*: every pixel across is frequency resolution, and at the 320 px the | |
| 588 | +/// other cards use, a third of an octave was a couple of pixels. Past this the | |
| 589 | +/// curve stops gaining anything and the card starts reading as a wall. | |
| 590 | +const EQ_W_MAX: f32 = 720.; | |
| 591 | + | |
| 592 | +/// The gap the card leaves either side of it, so it reads as a card on a scrim | |
| 593 | +/// rather than as a second window: it takes the width it can get inside that. | |
| 594 | +const EQ_W_MARGIN: f32 = 32.; | |
| 595 | + | |
| 596 | +/// How many bands one clip's equalizer may carry from this card. Ten because | |
| 597 | +/// the keyboard picks a band with a digit and a keyboard has ten of them -- | |
| 598 | +/// past that a band would be reachable by pointer only. The engine itself caps | |
| 599 | +/// nothing (`EqParams::bands` is a plain `Vec`), so a file may still carry more | |
| 600 | +/// and this card will draw and edit every one it finds. | |
| 601 | +const EQ_BANDS_MAX: usize = 10; | |
| 602 | + | |
| 603 | +/// One press of the frequency keys, as a factor: a sixth of an octave, so a | |
| 604 | +/// band walks the whole axis in about sixty presses and still lands close | |
| 605 | +/// enough to a named frequency to aim at one. | |
| 606 | +const EQ_FREQ_STEP: f32 = 1.122_462; | |
| 607 | + | |
| 608 | +/// One press of the Q keys, as a factor, and the range they move in. Below the | |
| 609 | +/// bottom a peak is barely a peak any more; above the top it is a whistle on | |
| 610 | +/// one frequency. 0.707 -- the flat-shelf value, and the default -- sits inside | |
| 611 | +/// them, so nothing a file carries has to be dragged into range first. | |
| 612 | +const EQ_Q_STEP: f32 = 1.25; | |
| 613 | +const EQ_Q_LOW: f32 = 0.3; | |
| 614 | +const EQ_Q_HIGH: f32 = 12.; | |
| 615 | + | |
| 572 | 616 | /// How many points the curve is drawn from. One per ~3 px across the card: |
| 573 | 617 | /// past that the line is smooth and the extra biquad evaluations are wasted. |
| 574 | 618 | const EQ_CURVE_STEPS: usize = 96; |
| @@ -617,6 +661,11 @@ const EQ_SPECTRUM_INK: u32 = 0x7f95ad66; | ||
| 617 | 661 | /// its weight: it is what makes a boost read as a hill rather than as a wire. |
| 618 | 662 | const EQ_FILL_INK: u32 = 0x4a9eff26; |
| 619 | 663 | |
| 664 | +/// One band's own response, drawn under the sum: a dim thread per band, so a | |
| 665 | +/// boost pushed against a cut can be *seen* as two bands rather than as the | |
| 666 | +/// flat line their total makes. | |
| 667 | +const EQ_BELL_INK: u32 = 0x4a9eff66; | |
| 668 | + | |
| 620 | 669 | /// The colour card's four controls, in the order it lists them: what each is |
| 621 | 670 | /// called and the range it moves in. The order is `ColorParams`' own, which is |
| 622 | 671 | /// what [`color_band`] indexes. |
| @@ -790,6 +839,16 @@ struct Player { | ||
| 790 | 839 | /// the value being dragged, and stale between drags, which costs nothing -- |
| 791 | 840 | /// no drag starts without a press on the box it moves. |
| 792 | 841 | grab: u32, |
| 842 | + /// Whether a drag or a trim is pulled onto the edges near it. On by | |
| 843 | + /// default, because clips meeting exactly is what a timeline is for, and off | |
| 844 | + /// by one stroke ([`ActionId::ToggleSnap`]) for the frame-by-frame placement | |
| 845 | + /// no magnet may take away. | |
| 846 | + snap: bool, | |
| 847 | + /// The frame the live gesture is about to land on, or `None` while it is | |
| 848 | + /// over open bed: the line every lane draws so the snap is seen before it | |
| 849 | + /// happens rather than discovered after the release. Stale between gestures, | |
| 850 | + /// which costs nothing -- it is drawn only while one is live. | |
| 851 | + snap_cue: Option<u32>, | |
| 793 | 852 | last_scrub: Instant, |
| 794 | 853 | last_target: u32, |
| 795 | 854 | /// The running export. While it owns the UI the editor is read-only. |
| @@ -1133,12 +1192,26 @@ impl Player { | ||
| 1133 | 1192 | ActionId::Speed => self.open_speed(cx), |
| 1134 | 1193 | ActionId::Silence => self.open_silence(cx), |
| 1135 | 1194 | ActionId::Mix => self.open_mix(None, cx), |
| 1195 | + ActionId::ToggleSnap => self.toggle_snap(cx), | |
| 1136 | 1196 | // Nothing to cancel while nothing is exporting; the export guard in |
| 1137 | 1197 | // the key handler is what answers this one while there is. |
| 1138 | 1198 | ActionId::CancelExport => {} |
| 1139 | 1199 | } |
| 1140 | 1200 | } |
| 1141 | 1201 | |
| 1202 | + /// The magnet off and on again, in words: a snap that stops working | |
| 1203 | + /// silently reads as a bug, and one that starts working silently reads as | |
| 1204 | + /// one too. The line goes with it -- nothing is being promised any more. | |
| 1205 | + fn toggle_snap(&mut self, cx: &mut Context<Self>) { | |
| 1206 | + self.snap = !self.snap; | |
| 1207 | + self.snap_cue = None; | |
| 1208 | + self.notice = Some(match self.snap { | |
| 1209 | + true => "SNAP ON — drags land on clip edges, the playhead and the start".into(), | |
| 1210 | + false => "SNAP OFF — drags land exactly where the hand leaves them".into(), | |
| 1211 | + }); | |
| 1212 | + cx.notify(); | |
| 1213 | + } | |
| 1214 | + | |
| 1142 | 1215 | /// Whether the editor can be asked for `action` right now, and why not when |
| 1143 | 1216 | /// it cannot. `on` is the clip the question is about -- the one a clip menu |
| 1144 | 1217 | /// was opened on -- and `None` asks about the marked clip instead, which is |
| @@ -2010,41 +2083,78 @@ impl Player { | ||
| 2010 | 2083 | cx.notify(); |
| 2011 | 2084 | } |
| 2012 | 2085 | |
| 2013 | - /// Moves one band and says whether anything changed. Live only: the write | |
| 2014 | - /// is [`commit_eq`](Player::commit_eq)'s. | |
| 2015 | - fn set_band(&mut self, band: usize, gain_db: f32) -> bool { | |
| 2016 | - let gain_db = gain_db.clamp(-EQ_GAIN_LIMIT, EQ_GAIN_LIMIT); | |
| 2017 | - match self.eq_params.bands.get_mut(band) { | |
| 2018 | - Some(b) if b.gain_db != gain_db => { | |
| 2019 | - b.gain_db = gain_db; | |
| 2020 | - true | |
| 2021 | - } | |
| 2022 | - _ => false, | |
| 2086 | + /// Changes the picked band in place and says whether anything moved. Every | |
| 2087 | + /// edit of a band goes through here -- the drag, each key, each stepper | |
| 2088 | + /// button -- so the card has exactly one place that clamps a band into what | |
| 2089 | + /// the graph can draw, and no caller has to remember the limits. | |
| 2090 | + fn set_band(&mut self, change: impl FnOnce(&mut Band)) -> bool { | |
| 2091 | + let Some(band) = self.eq_params.bands.get_mut(self.eq_band) else { | |
| 2092 | + return false; | |
| 2093 | + }; | |
| 2094 | + let was = *band; | |
| 2095 | + change(band); | |
| 2096 | + band.freq_hz = band.freq_hz.clamp(EQ_FREQ_LOW, EQ_FREQ_HIGH); | |
| 2097 | + band.gain_db = band.gain_db.clamp(-EQ_GAIN_LIMIT, EQ_GAIN_LIMIT); | |
| 2098 | + band.q = band.q.clamp(EQ_Q_LOW, EQ_Q_HIGH); | |
| 2099 | + *band != was | |
| 2100 | + } | |
| 2101 | + | |
| 2102 | + /// The keyboard's and the buttons' version of a drag: one step on the picked | |
| 2103 | + /// band, committed straight away -- neither has a release to wait for. | |
| 2104 | + fn nudge_band(&mut self, change: impl FnOnce(&mut Band), cx: &mut Context<Self>) { | |
| 2105 | + if self.set_band(change) { | |
| 2106 | + self.commit_eq(cx); | |
| 2023 | 2107 | } |
| 2024 | 2108 | } |
| 2025 | 2109 | |
| 2026 | - /// The keyboard's version of a drag: one step on the picked band, committed | |
| 2027 | - /// straight away -- a keystroke has no release to wait for. | |
| 2028 | - fn nudge_band(&mut self, by: f32, cx: &mut Context<Self>) { | |
| 2029 | - let gain = self | |
| 2030 | - .eq_params | |
| 2031 | - .bands | |
| 2032 | - .get(self.eq_band) | |
| 2033 | - .map_or(0., |b| b.gain_db); | |
| 2034 | - if self.set_band(self.eq_band, gain + by) { | |
| 2035 | - self.commit_eq(cx); | |
| 2110 | + /// Where the pointer sits in the graph, as the picked band's frequency and | |
| 2111 | + /// gain: across is the frequency axis and down is the gain one, so the | |
| 2112 | + /// handle follows the hand both ways rather than sliding up a rail. Called | |
| 2113 | + /// on every pointer sample, so the curve bends under it; the write is the | |
| 2114 | + /// release's ([`commit_eq`](Player::commit_eq)). | |
| 2115 | + fn drag_band(&mut self, at: Point<Pixels>, cx: &mut Context<Self>) { | |
| 2116 | + let bounds = self.eq_graph.get(); | |
| 2117 | + let gain = (0.5 - frac_down(at.y, bounds)) * 2. * EQ_GAIN_LIMIT; | |
| 2118 | + let freq = eq_freq(frac_along(at.x, bounds)); | |
| 2119 | + if self.set_band(|b| { | |
| 2120 | + b.gain_db = gain; | |
| 2121 | + b.freq_hz = freq; | |
| 2122 | + }) { | |
| 2123 | + cx.notify(); | |
| 2124 | + } | |
| 2125 | + } | |
| 2126 | + | |
| 2127 | + /// A band added beside the picked one, at the frequency with the most room | |
| 2128 | + /// around it ([`inserted_band`]), and picked so the next keystroke moves the | |
| 2129 | + /// band that was just made. Refused rather than silently ignored at the cap. | |
| 2130 | + fn add_band(&mut self, cx: &mut Context<Self>) { | |
| 2131 | + if self.eq_params.bands.len() >= EQ_BANDS_MAX { | |
| 2132 | + self.notice = Some( | |
| 2133 | + format!( | |
| 2134 | + "EQUALIZER FULL — {EQ_BANDS_MAX} bands is all this card holds; move one instead" | |
| 2135 | + ) | |
| 2136 | + .into(), | |
| 2137 | + ); | |
| 2138 | + cx.notify(); | |
| 2139 | + return; | |
| 2036 | 2140 | } |
| 2141 | + let band = inserted_band(&self.eq_params.bands, self.eq_band); | |
| 2142 | + self.eq_band = (self.eq_band + 1).min(self.eq_params.bands.len()); | |
| 2143 | + self.eq_params.bands.insert(self.eq_band, band); | |
| 2144 | + self.commit_eq(cx); | |
| 2037 | 2145 | } |
| 2038 | 2146 | |
| 2039 | - /// Where the pointer sits down the graph, as a gain on the picked band: the | |
| 2040 | - /// middle is flat and the top and bottom edges are the limit either way. | |
| 2041 | - /// Called on every pointer sample, so the curve bends under the hand; the | |
| 2042 | - /// write is the release's ([`commit_eq`](Player::commit_eq)). | |
| 2043 | - fn drag_band(&mut self, y: Pixels, cx: &mut Context<Self>) { | |
| 2044 | - let gain = (0.5 - frac_down(y, self.eq_graph.get())) * 2. * EQ_GAIN_LIMIT; | |
| 2045 | - if self.set_band(self.eq_band, gain) { | |
| 2147 | + /// Takes the picked band out. The last one stays: an equalizer of no bands | |
| 2148 | + /// is a card with nothing to edit, and flattening is what "off" means here. | |
| 2149 | + fn remove_band(&mut self, cx: &mut Context<Self>) { | |
| 2150 | + if self.eq_params.bands.len() <= 1 { | |
| 2151 | + self.notice = Some("LAST BAND — flatten it instead (r), or close the card".into()); | |
| 2046 | 2152 | cx.notify(); |
| 2153 | + return; | |
| 2047 | 2154 | } |
| 2155 | + self.eq_params.bands.remove(self.eq_band); | |
| 2156 | + self.eq_band = self.eq_band.min(self.eq_params.bands.len() - 1); | |
| 2157 | + self.commit_eq(cx); | |
| 2048 | 2158 | } |
| 2049 | 2159 | |
| 2050 | 2160 | /// Which band a press on the graph grabs: the nearest one along the |
| @@ -2444,8 +2554,8 @@ impl Player { | ||
| 2444 | 2554 | if self.exporting().is_some() { |
| 2445 | 2555 | return; |
| 2446 | 2556 | } |
| 2447 | - let (Some(start), Some(was)) = ( | |
| 2448 | - self.drop_frame(from, idx, to, x), | |
| 2557 | + let (Some((start, _)), Some(was)) = ( | |
| 2558 | + self.drop_frame(from, idx, x), | |
| 2449 | 2559 | self.session |
| 2450 | 2560 | .as_ref() |
| 2451 | 2561 | .and_then(|session| session.lane_clips(from).get(idx).map(|c| c.start)), |
| @@ -2507,26 +2617,70 @@ impl Player { | ||
| 2507 | 2617 | /// the scroll clamp pins the bed's right edge to the duration, and the |
| 2508 | 2618 | /// pointer has no pixel past it. The upgrade is to let the scroll clamp |
| 2509 | 2619 | /// leave a screen of empty bed after the end, the way every NLE does. |
| 2510 | - fn drop_frame(&self, from: Lane, idx: usize, to: Lane, x: Pixels) -> Option<u32> { | |
| 2511 | - let session = self.session.as_ref()?; | |
| 2512 | - let clip = session.lane_clips(from).get(idx).copied()?; | |
| 2620 | + fn drop_frame(&self, from: Lane, idx: usize, x: Pixels) -> Option<(u32, Option<u32>)> { | |
| 2621 | + let clip = self.session.as_ref()?.lane_clips(from).get(idx).copied()?; | |
| 2513 | 2622 | let raw = self.frame_under(x).saturating_sub(self.grab); |
| 2514 | - // The edges worth landing on: both ends of every clip already on the | |
| 2515 | - // lane it is being let go over, the playhead, and the head of the | |
| 2516 | - // timeline. Never the group's own boxes -- a clip does not snap to | |
| 2517 | - // where it already is. | |
| 2518 | - let mut marks: Vec<u32> = session | |
| 2519 | - .lane_clips(to) | |
| 2520 | - .iter() | |
| 2521 | - .enumerate() | |
| 2522 | - .filter(|&(i, c)| { | |
| 2523 | - (to, i) != (from, idx) && !(clip.link.is_some() && c.link == clip.link) | |
| 2524 | - }) | |
| 2525 | - .flat_map(|(_, c)| [c.start, c.end()]) | |
| 2526 | - .collect(); | |
| 2527 | - marks.push(frame_at(session.now(), self.fps)); | |
| 2528 | - marks.push(0); | |
| 2529 | - Some(snapped(raw, clip.frames(), self.snap_frames(), &marks)) | |
| 2623 | + let marks = self.snap_targets(Some((from, idx))); | |
| 2624 | + Some(self.snap_to(raw, clip.frames(), &marks)) | |
| 2625 | + } | |
| 2626 | + | |
| 2627 | + /// Which index the clip in the hand is at *now*: [`live_idx`] against the | |
| 2628 | + /// lane the drag named, since a stroke during the gesture moves the indices | |
| 2629 | + /// gpui froze into the payload. Both halves of a drag ask it -- the line | |
| 2630 | + /// drawn in flight and the drop that commits -- so the promise and the | |
| 2631 | + /// landing are made about one clip. | |
| 2632 | + fn dragged(&self, drag: &ClipDrag) -> Option<usize> { | |
| 2633 | + let session = self.session.as_ref()?; | |
| 2634 | + live_idx(session.lane_clips(drag.lane), drag.idx, drag.clip) | |
| 2635 | + } | |
| 2636 | + | |
| 2637 | + /// The line while the clip is still in the hand: the very answer | |
| 2638 | + /// [`Player::drop_frame`] will commit, worked out on every move of the drag, | |
| 2639 | + /// so what the eye was promised is where the release puts it. A pointer that | |
| 2640 | + /// has wandered off the bed promises nothing. | |
| 2641 | + fn preview_drop(&mut self, from: Lane, idx: usize, x: Pixels, cx: &mut Context<Self>) { | |
| 2642 | + let cue = self.drop_frame(from, idx, x).and_then(|(_, cue)| cue); | |
| 2643 | + self.set_cue(cue, x, cx); | |
| 2644 | + } | |
| 2645 | + | |
| 2646 | + /// The same line for a library row on its way to a lane: it goes down at | |
| 2647 | + /// the frame it is let go on ([`Player::insert_source`]), so that frame is | |
| 2648 | + /// what snaps and what is drawn. No length to snap by -- the file's own is | |
| 2649 | + /// not known until the engine has placed it -- so only its head lands. | |
| 2650 | + fn preview_place(&mut self, x: Pixels, cx: &mut Context<Self>) { | |
| 2651 | + let marks = self.snap_targets(None); | |
| 2652 | + let cue = self.snap_to(self.frame_under(x), 0, &marks).1; | |
| 2653 | + self.set_cue(cue, x, cx); | |
| 2654 | + } | |
| 2655 | + | |
| 2656 | + /// Sets the line, or takes it away, and repaints only when it moved: a | |
| 2657 | + /// pointer dragged off the bed (up to the library, say) is not promising a | |
| 2658 | + /// landing any more. | |
| 2659 | + fn set_cue(&mut self, cue: Option<u32>, x: Pixels, cx: &mut Context<Self>) { | |
| 2660 | + let bed = self.ruler.get(); | |
| 2661 | + let cue = cue.filter(|_| x >= bed.left() && x <= bed.right()); | |
| 2662 | + if cue != self.snap_cue { | |
| 2663 | + self.snap_cue = cue; | |
| 2664 | + cx.notify(); | |
| 2665 | + } | |
| 2666 | + } | |
| 2667 | + | |
| 2668 | + /// Every edge this timeline offers a gesture: [`snap_marks`] over all of its | |
| 2669 | + /// lanes, so a clip meets a take one track over as readily as one beside it. | |
| 2670 | + fn snap_targets(&self, skip: Option<(Lane, usize)>) -> Vec<u32> { | |
| 2671 | + let Some(session) = &self.session else { | |
| 2672 | + return Vec::new(); | |
| 2673 | + }; | |
| 2674 | + let lanes = session.lanes(); | |
| 2675 | + let clips: Vec<&[Clip]> = lanes.iter().map(|&lane| session.lane_clips(lane)).collect(); | |
| 2676 | + let skip = skip.and_then(|(lane, idx)| Some((lanes.iter().position(|&l| l == lane)?, idx))); | |
| 2677 | + snap_marks(&clips, skip, frame_at(session.now(), self.fps)) | |
| 2678 | + } | |
| 2679 | + | |
| 2680 | + /// Where a gesture at `raw` lands and the mark that pulled it there, with | |
| 2681 | + /// the switch honoured: snapping off, nothing moves and no line is drawn. | |
| 2682 | + fn snap_to(&self, raw: u32, len: u32, marks: &[u32]) -> (u32, Option<u32>) { | |
| 2683 | + snap_cue(self.snap, raw, len, self.snap_frames(), marks) | |
| 2530 | 2684 | } |
| 2531 | 2685 | |
| 2532 | 2686 | /// [`SNAP_PX`] in timeline frames at the scale the bed is drawn at: the bed's |
| @@ -2590,14 +2744,25 @@ impl Player { | ||
| 2590 | 2744 | /// against the same duration the boxes are drawn to, so the edge tracks the |
| 2591 | 2745 | /// pointer exactly. |
| 2592 | 2746 | fn trim_to(&mut self, x: Pixels, cx: &mut Context<Self>) { |
| 2593 | - let at = self.frame_under(x); | |
| 2594 | - let (Some(trim), Some(session)) = (&mut self.trim, &self.session) else { | |
| 2747 | + let Some(trim) = self.trim else { | |
| 2595 | 2748 | return; |
| 2596 | 2749 | }; |
| 2597 | - let Some((lo, hi)) = session.trim_room(trim.lane, trim.idx, trim.edge) else { | |
| 2750 | + // The edge is pulled onto the same marks a whole clip is, by itself: | |
| 2751 | + // there is no other end travelling with it, so it snaps at length zero. | |
| 2752 | + let marks = self.snap_targets(Some((trim.lane, trim.idx))); | |
| 2753 | + let (at, cue) = self.snap_to(self.frame_under(x), 0, &marks); | |
| 2754 | + let Some((lo, hi)) = self | |
| 2755 | + .session | |
| 2756 | + .as_ref() | |
| 2757 | + .and_then(|session| session.trim_room(trim.lane, trim.idx, trim.edge)) | |
| 2758 | + else { | |
| 2598 | 2759 | return; |
| 2599 | 2760 | }; |
| 2600 | - trim.to = at.clamp(lo, hi); | |
| 2761 | + let to = at.clamp(lo, hi); | |
| 2762 | + // The line only stands where the edge actually stopped: a mark the | |
| 2763 | + // engine's own room clamped away was never reached. | |
| 2764 | + self.set_cue(cue.filter(|_| to == at), x, cx); | |
| 2765 | + self.trim = Some(Trim { to, ..trim }); | |
| 2601 | 2766 | cx.notify(); |
| 2602 | 2767 | } |
| 2603 | 2768 | |
| @@ -2639,39 +2804,13 @@ impl Player { | ||
| 2639 | 2804 | }) else { |
| 2640 | 2805 | return clip; |
| 2641 | 2806 | }; |
| 2642 | - match trim.edge { | |
| 2643 | - // A still grows forward from source frame 0 instead, exactly as | |
| 2644 | - // `Project::trim` writes it: with the in-point clamped at 0 the box | |
| 2645 | - // below would slide left rather than stretch, and the release would | |
| 2646 | - // then commit a wider clip than the drag drew. | |
| 2647 | - Edge::Start | |
| 2648 | - if self.session.as_ref().is_some_and(|session| { | |
| 2649 | - session | |
| 2650 | - .sources() | |
| 2651 | - .get(clip.source) | |
| 2652 | - .is_some_and(|s| engine::is_image(&s.path)) | |
| 2653 | - }) => | |
| 2654 | - { | |
| 2655 | - Clip { | |
| 2656 | - in_frame: 0, | |
| 2657 | - out_frame: clip.end().saturating_sub(trim.to).max(1), | |
| 2658 | - start: trim.to, | |
| 2659 | - ..clip | |
| 2660 | - } | |
| 2661 | - } | |
| 2662 | - // The in-point follows the head, exactly as `Project::trim` moves | |
| 2663 | - // it: what stays on screen plays what it always played. | |
| 2664 | - Edge::Start => Clip { | |
| 2665 | - in_frame: (i64::from(clip.in_frame) + i64::from(trim.to) - i64::from(clip.start)) | |
| 2666 | - .clamp(0, i64::from(clip.out_frame - 1)) as u32, | |
| 2667 | - start: trim.to, | |
| 2668 | - ..clip | |
| 2669 | - }, | |
| 2670 | - Edge::End => Clip { | |
| 2671 | - out_frame: clip.in_frame + trim.to.saturating_sub(clip.start).max(1), | |
| 2672 | - ..clip | |
| 2673 | - }, | |
| 2674 | - } | |
| 2807 | + let still = self.session.as_ref().is_some_and(|session| { | |
| 2808 | + session | |
| 2809 | + .sources() | |
| 2810 | + .get(clip.source) | |
| 2811 | + .is_some_and(|s| engine::is_image(&s.path)) | |
| 2812 | + }); | |
| 2813 | + trimmed_clip(clip, trim.edge, trim.to, still) | |
| 2675 | 2814 | } |
| 2676 | 2815 | |
| 2677 | 2816 | /// How long the timeline is *drawn* as: its own length, and while a tail is |
| @@ -2679,6 +2818,15 @@ impl Player { | ||
| 2679 | 2818 | /// at the last frame has nowhere to put a pointer that means "longer", so |
| 2680 | 2819 | /// without this the last clip on the timeline could be pulled in and never |
| 2681 | 2820 | /// let back out. |
| 2821 | + /// | |
| 2822 | + /// Scroll room only, now that a second is an absolute number of pixels | |
| 2823 | + /// ([`Scale`]): the extra length loosens [`View::settled`]'s clamp, which is | |
| 2824 | + /// where the pixels past the last frame come from, and moves no box by a | |
| 2825 | + /// pixel. It is still the *only* headroom at the tail -- zoomed in against | |
| 2826 | + /// the end, that clamp pins the bed's right edge to the duration and an | |
| 2827 | + /// End-trim of the last clip would have nowhere to be dragged to. What it | |
| 2828 | + /// must not do is be read as a length anyone is told: the timecode reads | |
| 2829 | + /// `PlaybackSession::timeline_duration` for exactly that reason. | |
| 2682 | 2830 | fn drawn_duration(&self) -> f64 { |
| 2683 | 2831 | let Some(session) = &self.session else { |
| 2684 | 2832 | return 0.; |
| @@ -3709,31 +3857,55 @@ impl Render for Player { | ||
| 3709 | 3857 | // cannot move at all, and every one of them is listed in the |
| 3710 | 3858 | // keys menu (keymap.rs `FIXED`) rather than being a secret. |
| 3711 | 3859 | if this.eq_open.is_some() { |
| 3860 | + // Shift makes the two horizontal keys Q instead of | |
| 3861 | + // frequency: both are the *width* of the same hump, so they | |
| 3862 | + // sit on the same axis rather than on two keys nobody would | |
| 3863 | + // guess. Wider is a lower Q, which is why left widens. | |
| 3864 | + let shift = event.keystroke.modifiers.shift; | |
| 3712 | 3865 | if key == ESCAPE { |
| 3713 | 3866 | // Nothing to undo: every change is already at the clip, |
| 3714 | 3867 | // and undo is undo's own key. |
| 3715 | 3868 | this.eq_open = None; |
| 3716 | 3869 | this.eq_dragging = false; |
| 3717 | 3870 | } else if key == "up" { |
| 3718 | - this.nudge_band(EQ_STEP, cx); | |
| 3871 | + this.nudge_band(|b| b.gain_db += EQ_STEP, cx); | |
| 3719 | 3872 | } else if key == "down" { |
| 3720 | - this.nudge_band(-EQ_STEP, cx); | |
| 3873 | + this.nudge_band(|b| b.gain_db -= EQ_STEP, cx); | |
| 3874 | + } else if key == "left" && shift { | |
| 3875 | + this.nudge_band(|b| b.q /= EQ_Q_STEP, cx); | |
| 3876 | + } else if key == "right" && shift { | |
| 3877 | + this.nudge_band(|b| b.q *= EQ_Q_STEP, cx); | |
| 3878 | + } else if key == "left" { | |
| 3879 | + this.nudge_band(|b| b.freq_hz /= EQ_FREQ_STEP, cx); | |
| 3880 | + } else if key == "right" { | |
| 3881 | + this.nudge_band(|b| b.freq_hz *= EQ_FREQ_STEP, cx); | |
| 3721 | 3882 | } else if key == "r" { |
| 3722 | 3883 | for band in &mut this.eq_params.bands { |
| 3723 | 3884 | band.gain_db = 0.; |
| 3724 | 3885 | } |
| 3725 | 3886 | this.commit_eq(cx); |
| 3887 | + } else if key == "f" { | |
| 3888 | + // This one band back to flat, which is the undo of one | |
| 3889 | + // hand movement -- `r` is the undo of the whole card. | |
| 3890 | + this.nudge_band(|b| b.gain_db = 0., cx); | |
| 3891 | + } else if key == "a" { | |
| 3892 | + this.add_band(cx); | |
| 3893 | + } else if key == "x" { | |
| 3894 | + this.remove_band(cx); | |
| 3726 | 3895 | } else if key == "s" { |
| 3727 | 3896 | // The analyser off and on. Nothing is committed: it is |
| 3728 | 3897 | // what the card *shows*, so it survives no further than |
| 3729 | 3898 | // this window. |
| 3730 | 3899 | this.eq_spectrum = !this.eq_spectrum; |
| 3731 | 3900 | } else if let Ok(digit) = key.parse::<usize>() { |
| 3732 | - // 1-based, as the rows are numbered on screen; a digit | |
| 3733 | - // past the last band picks nothing rather than panics. | |
| 3734 | - if let Some(band) = digit.checked_sub(1) | |
| 3735 | - && band < this.eq_params.bands.len() | |
| 3736 | - { | |
| 3901 | + // As the keys are laid out: 1-9 then 0 for the tenth, | |
| 3902 | + // which is the cap ([`EQ_BANDS_MAX`]). A digit past the | |
| 3903 | + // last band picks nothing rather than panics. | |
| 3904 | + let band = match digit { | |
| 3905 | + 0 => EQ_BANDS_MAX - 1, | |
| 3906 | + n => n - 1, | |
| 3907 | + }; | |
| 3908 | + if band < this.eq_params.bands.len() { | |
| 3737 | 3909 | this.eq_band = band; |
| 3738 | 3910 | } |
| 3739 | 3911 | } |
| @@ -3872,6 +4044,26 @@ impl Render for Player { | ||
| 3872 | 4044 | } |
| 3873 | 4045 | } |
| 3874 | 4046 | })) |
| 4047 | + // A drop event carries no path of its own -- gpui only tells the | |
| 4048 | + // target that something landed -- so the line that promises where | |
| 4049 | + // it will land is fed by the drag's own moves, which do carry the | |
| 4050 | + // pointer (gpui div.rs:282). On the root, because a drag crosses | |
| 4051 | + // the window: it starts on a clip or on a library row and ends over | |
| 4052 | + // a lane, and only an ancestor of both hears all of it. | |
| 4053 | + .on_drag_move(cx.listener(|this, event: &DragMoveEvent<ClipDrag>, _, cx| { | |
| 4054 | + // The clip the payload named, wherever an edit mid-drag has | |
| 4055 | + // since put it ([`Player::dragged`]): the line has to promise a | |
| 4056 | + // landing for the take actually in the hand. | |
| 4057 | + let drag = *event.drag(cx); | |
| 4058 | + if let Some(idx) = this.dragged(&drag) { | |
| 4059 | + this.preview_drop(drag.lane, idx, event.event.position.x, cx); | |
| 4060 | + } | |
| 4061 | + })) | |
| 4062 | + .on_drag_move( | |
| 4063 | + cx.listener(|this, event: &DragMoveEvent<AssetDrag>, _, cx| { | |
| 4064 | + this.preview_place(event.event.position.x, cx); | |
| 4065 | + }), | |
| 4066 | + ) | |
| 3875 | 4067 | // Scrubbing is tracked on the root because the pointer leaves the |
| 3876 | 4068 | // 6 px ruler on the first drag and its own listeners then stop |
| 3877 | 4069 | // firing; the root's hitbox is the whole window. |
| @@ -3880,7 +4072,7 @@ impl Render for Player { | ||
| 3880 | 4072 | // the equalizer drag is tracked here for the ruler's reason. |
| 3881 | 4073 | if this.eq_dragging { |
| 3882 | 4074 | if event.pressed_button == Some(MouseButton::Left) { |
| 3883 | - this.drag_band(event.position.y, cx); | |
| 4075 | + this.drag_band(event.position, cx); | |
| 3884 | 4076 | } else { |
| 3885 | 4077 | // Released outside the window: the up below never came, |
| 3886 | 4078 | // so this is where the gesture ends -- and it still owes |
| @@ -3950,7 +4142,7 @@ impl Render for Player { | ||
| 3950 | 4142 | if std::mem::take(&mut this.eq_dragging) { |
| 3951 | 4143 | // The release lands exactly, then the gesture is written |
| 3952 | 4144 | // once -- the append-only table's whole reason. |
| 3953 | - this.drag_band(event.position.y, cx); | |
| 4145 | + this.drag_band(event.position, cx); | |
| 3954 | 4146 | this.commit_eq(cx); |
| 3955 | 4147 | return; |
| 3956 | 4148 | } |
| @@ -4052,7 +4244,7 @@ impl Render for Player { | ||
| 4052 | 4244 | // column, and only one of the two is ever up. |
| 4053 | 4245 | .children(self.keys_overlay(cx)) |
| 4054 | 4246 | .children(self.export_card(window.viewport_size(), cx)) |
| 4055 | - .children(self.eq_card(cx)) | |
| 4247 | + .children(self.eq_card(window.viewport_size(), cx)) | |
| 4056 | 4248 | .children(self.color_card(cx)) |
| 4057 | 4249 | .children(self.speed_card(cx)) |
| 4058 | 4250 | .children(self.silence_card(cx)) |
| @@ -4637,6 +4829,25 @@ impl Player { | ||
| 4637 | 4829 | live, |
| 4638 | 4830 | cx.listener(|this, _: &ClickEvent, _, cx| this.zoom(ZOOM_STEP, None, cx)), |
| 4639 | 4831 | )) |
| 4832 | + // The magnet, beside the zoom for the zoom's own reason: it | |
| 4833 | + // changes nothing on the timeline, it changes how the hand | |
| 4834 | + // meets it. The label is the state, as the volume's is -- | |
| 4835 | + // a toggle that looks the same either way says nothing. | |
| 4836 | + .child(control( | |
| 4837 | + "snap", | |
| 4838 | + None, | |
| 4839 | + if self.snap { "Snap" } else { "No snap" }, | |
| 4840 | + format!( | |
| 4841 | + "{} — {}", | |
| 4842 | + key(ActionId::ToggleSnap), | |
| 4843 | + match self.snap { | |
| 4844 | + true => "drags and trims land on clip edges, the playhead and the start", | |
| 4845 | + false => "drags and trims land exactly where the hand leaves them", | |
| 4846 | + } | |
| 4847 | + ), | |
| 4848 | + live, | |
| 4849 | + cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_snap(cx)), | |
| 4850 | + )) | |
| 4640 | 4851 | // Import is not here: it belongs to the media list it adds |
| 4641 | 4852 | // to, and two doors into one action is a question about |
| 4642 | 4853 | // which one is the real one. |
| @@ -4709,10 +4920,20 @@ impl Player { | ||
| 4709 | 4920 | .gap(px(12.)) |
| 4710 | 4921 | // Fixed width and one line: changing digits must not push |
| 4711 | 4922 | // the row around, nor wrap and change its height. |
| 4923 | + // The timeline's own length, never the drawn one: a tail | |
| 4924 | + // being dragged inflates the bed to the room that edge has | |
| 4925 | + // ([`Player::drawn_duration`]), and for a still that room is | |
| 4926 | + // ten minutes -- a total that jumped to 10:00:00 the moment | |
| 4927 | + // a picture's edge was pressed, and back on release. | |
| 4712 | 4928 | .child(div().flex_none().w(px(TIME_W)).truncate().child(format!( |
| 4713 | 4929 | "{} / {}", |
| 4714 | 4930 | timecode(position, self.fps), |
| 4715 | - timecode(duration, self.fps) | |
| 4931 | + timecode( | |
| 4932 | + self.session | |
| 4933 | + .as_ref() | |
| 4934 | + .map_or(0., PlaybackSession::timeline_duration), | |
| 4935 | + self.fps | |
| 4936 | + ) | |
| 4716 | 4937 | ))) |
| 4717 | 4938 | .child( |
| 4718 | 4939 | div() |
| @@ -5492,20 +5713,28 @@ impl Player { | ||
| 5492 | 5713 | } |
| 5493 | 5714 | |
| 5494 | 5715 | /// The equalizer of one audio clip: its frequency response drawn as a |
| 5495 | - /// curve, a handle per band sitting on it, and a row that flattens them | |
| 5496 | - /// all. The curve is the clip's actual filter (`EqParams::response_db` | |
| 5497 | - /// reads the coefficients the samples go through), and it is redrawn on | |
| 5498 | - /// every pointer sample of a drag, so the shape bends under the hand. | |
| 5716 | + /// curve, a handle per band sitting on it, each band's own bell under the | |
| 5717 | + /// sum, and a row that reads and moves the picked band's three numbers. The | |
| 5718 | + /// curve is the clip's actual filter (`EqParams::response_db` reads the | |
| 5719 | + /// coefficients the samples go through), and it is redrawn on every pointer | |
| 5720 | + /// sample of a drag, so the shape bends under the hand. | |
| 5499 | 5721 | /// |
| 5500 | - /// The same scrim and width as the other two cards, and the same plain divs | |
| 5501 | - /// -- nothing here takes focus, so the root keeps the keyboard and the | |
| 5502 | - /// card's own strokes (`1`–`5`, up, down, `r`) reach it. | |
| 5722 | + /// Wider than the other cards and wider still on a bigger window | |
| 5723 | + /// ([`eq_card_w`]): every pixel across is frequency resolution, which none | |
| 5724 | + /// of the row-shaped cards have any use for. The same scrim and the same | |
| 5725 | + /// plain divs -- nothing here takes focus, so the root keeps the keyboard | |
| 5726 | + /// and the card's own strokes (a digit, the arrows, `a`, `x`, `f`, `r`, | |
| 5727 | + /// `s`) reach it. | |
| 5503 | 5728 | /// |
| 5504 | 5729 | /// Every change is written at the clip as it is made |
| 5505 | 5730 | /// ([`Player::commit_eq`]), so what the card shows is always what is |
| 5506 | 5731 | /// playing: there is no OK button to forget, and closing it changes |
| 5507 | 5732 | /// nothing. What takes a curve back off is undo, like every other edit. |
| 5508 | - fn eq_card(&self, cx: &mut Context<Self>) -> Option<impl IntoElement> { | |
| 5733 | + fn eq_card( | |
| 5734 | + &self, | |
| 5735 | + viewport: Size<Pixels>, | |
| 5736 | + cx: &mut Context<Self>, | |
| 5737 | + ) -> Option<impl IntoElement> { | |
| 5509 | 5738 | let (lane, idx) = self.eq_open?; |
| 5510 | 5739 | // The rate the engine filters this timeline at, so the drawn curve is |
| 5511 | 5740 | // the one those coefficients make -- near the top of the axis a 44.1 kHz |
| @@ -5559,13 +5788,20 @@ impl Player { | ||
| 5559 | 5788 | .bg(rgb(HOVER_DIM)) |
| 5560 | 5789 | .cursor_pointer() |
| 5561 | 5790 | // The press picks the band under it *and* is already the first |
| 5562 | - // sample of the drag, so a plain click sets a value. | |
| 5791 | + // sample of the drag, so a plain click sets a value. A second click | |
| 5792 | + // takes that band back to flat instead: the gesture that undoes one | |
| 5793 | + // handle, with no modifier to remember. | |
| 5563 | 5794 | .on_mouse_down( |
| 5564 | 5795 | MouseButton::Left, |
| 5565 | 5796 | cx.listener(|this, event: &MouseDownEvent, _, cx| { |
| 5566 | 5797 | this.eq_band = this.nearest_band(event.position.x); |
| 5798 | + if event.click_count >= 2 { | |
| 5799 | + this.eq_dragging = false; | |
| 5800 | + this.nudge_band(|b| b.gain_db = 0., cx); | |
| 5801 | + return; | |
| 5802 | + } | |
| 5567 | 5803 | this.eq_dragging = true; |
| 5568 | - this.drag_band(event.position.y, cx); | |
| 5804 | + this.drag_band(event.position, cx); | |
| 5569 | 5805 | }), |
| 5570 | 5806 | ) |
| 5571 | 5807 | .child(bounds_probe(self.eq_graph.clone())) |
| @@ -5657,7 +5893,7 @@ impl Player { | ||
| 5657 | 5893 | }) |
| 5658 | 5894 | .child( |
| 5659 | 5895 | div() |
| 5660 | - .w(px(KEYS_W)) | |
| 5896 | + .w(px(eq_card_w(f32::from(viewport.width)))) | |
| 5661 | 5897 | .flex() |
| 5662 | 5898 | .flex_col() |
| 5663 | 5899 | .gap(px(2.)) |
| @@ -5678,28 +5914,15 @@ impl Player { | ||
| 5678 | 5914 | .text_size(px(11.)) |
| 5679 | 5915 | .text_color(rgb(INK_DIM)) |
| 5680 | 5916 | .child(self.notice.clone().unwrap_or_else(|| { |
| 5681 | - "drag the curve, or 1–5 then up/down — s hides the spectrum, esc closes".into() | |
| 5917 | + "drag a handle, or a digit picks a band — ←→ moves it, ↑↓ its gain, shift+←→ its width; a adds, x removes, f flattens it, r all, s spectrum, esc closes".into() | |
| 5682 | 5918 | })), |
| 5683 | 5919 | ) |
| 5684 | 5920 | .child(graph) |
| 5685 | - // Which band the keyboard is holding and what it is set | |
| 5686 | - // to: the curve shows the sum, and a band pushed against | |
| 5687 | - // one pulling the other way is not readable off it. | |
| 5688 | - .child(div().flex_none().px(px(6.)).text_size(px(11.)).child( | |
| 5689 | - match picked { | |
| 5690 | - // Q as well as the two the curve shows: it is | |
| 5691 | - // how wide the hump under the handle is, and | |
| 5692 | - // nothing else on the card says so. | |
| 5693 | - Some(band) => format!( | |
| 5694 | - "{} {} {:+.1} dB — Q {:.2}", | |
| 5695 | - self.eq_band + 1, | |
| 5696 | - band_label(band), | |
| 5697 | - band.gain_db, | |
| 5698 | - band.q | |
| 5699 | - ), | |
| 5700 | - None => "no bands".into(), | |
| 5701 | - }, | |
| 5702 | - )) | |
| 5921 | + // Which band the keyboard is holding and every number it | |
| 5922 | + // is set to, each with the pair of buttons that moves it: | |
| 5923 | + // the curve shows the sum, and a band pushed against one | |
| 5924 | + // pulling the other way is not readable off it. | |
| 5925 | + .child(self.eq_numbers(picked, cx)) | |
| 5703 | 5926 | .child( |
| 5704 | 5927 | div() |
| 5705 | 5928 | .mt(px(4.)) |
| @@ -5723,7 +5946,45 @@ impl Player { | ||
| 5723 | 5946 | } |
| 5724 | 5947 | this.commit_eq(cx); |
| 5725 | 5948 | })) |
| 5726 | - .child("Flatten"), | |
| 5949 | + .child("Flatten all"), | |
| 5950 | + ) | |
| 5951 | + // The two that change how many bands there are. | |
| 5952 | + // The engine takes any cascade -- the count was | |
| 5953 | + // only ever fixed because this card had no way | |
| 5954 | + // to say otherwise. | |
| 5955 | + .child( | |
| 5956 | + div() | |
| 5957 | + .id("eq-add") | |
| 5958 | + .flex() | |
| 5959 | + .flex_1() | |
| 5960 | + .h(px(CONTROL_H)) | |
| 5961 | + .items_center() | |
| 5962 | + .justify_center() | |
| 5963 | + .rounded(px(3.)) | |
| 5964 | + .bg(rgb(CHROME)) | |
| 5965 | + .cursor_pointer() | |
| 5966 | + .hover(|s| s.bg(rgb(HOVER))) | |
| 5967 | + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { | |
| 5968 | + this.add_band(cx) | |
| 5969 | + })) | |
| 5970 | + .child("Add band"), | |
| 5971 | + ) | |
| 5972 | + .child( | |
| 5973 | + div() | |
| 5974 | + .id("eq-remove") | |
| 5975 | + .flex() | |
| 5976 | + .flex_1() | |
| 5977 | + .h(px(CONTROL_H)) | |
| 5978 | + .items_center() | |
| 5979 | + .justify_center() | |
| 5980 | + .rounded(px(3.)) | |
| 5981 | + .bg(rgb(CHROME)) | |
| 5982 | + .cursor_pointer() | |
| 5983 | + .hover(|s| s.bg(rgb(HOVER))) | |
| 5984 | + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { | |
| 5985 | + this.remove_band(cx) | |
| 5986 | + })) | |
| 5987 | + .child("Remove band"), | |
| 5727 | 5988 | ) |
| 5728 | 5989 | // The analyser's switch, next to the one other |
| 5729 | 5990 | // button the card has: `s` does the same, and a |
| @@ -5758,6 +6019,103 @@ impl Player { | ||
| 5758 | 6019 | ) |
| 5759 | 6020 | } |
| 5760 | 6021 | |
| 6022 | + /// The picked band's three numbers -- where it sits, how far it pushes and | |
| 6023 | + /// how wide it is -- each beside the pair of buttons that moves it. The | |
| 6024 | + /// arrows do the same three things, but a value only a key can change is a | |
| 6025 | + /// value a hand on the pointer cannot reach at all, which is the same reason | |
| 6026 | + /// [`Player::mbps_steppers`] exists. | |
| 6027 | + fn eq_numbers(&self, picked: Option<&Band>, cx: &mut Context<Self>) -> impl IntoElement { | |
| 6028 | + let row = div() | |
| 6029 | + .flex_none() | |
| 6030 | + .flex() | |
| 6031 | + .items_center() | |
| 6032 | + .gap(px(10.)) | |
| 6033 | + .px(px(6.)) | |
| 6034 | + .text_size(px(11.)); | |
| 6035 | + let Some(band) = picked.copied() else { | |
| 6036 | + return row.child("no bands — a adds one"); | |
| 6037 | + }; | |
| 6038 | + let step = |id: &'static str, | |
| 6039 | + label: &'static str, | |
| 6040 | + change: fn(&mut Band), | |
| 6041 | + cx: &mut Context<Self>| { | |
| 6042 | + div() | |
| 6043 | + .id(id) | |
| 6044 | + .flex() | |
| 6045 | + .w(px(HIT_MIN)) | |
| 6046 | + .h(px(HIT_MIN)) | |
| 6047 | + .items_center() | |
| 6048 | + .justify_center() | |
| 6049 | + .rounded(px(3.)) | |
| 6050 | + .bg(rgb(CHROME)) | |
| 6051 | + .cursor_pointer() | |
| 6052 | + .hover(|s| s.bg(rgb(HOVER))) | |
| 6053 | + .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | |
| 6054 | + this.nudge_band(change, cx) | |
| 6055 | + })) | |
| 6056 | + .child(label) | |
| 6057 | + }; | |
| 6058 | + let number = |value: String, | |
| 6059 | + ids: (&'static str, &'static str), | |
| 6060 | + by: (fn(&mut Band), fn(&mut Band)), | |
| 6061 | + cx: &mut Context<Self>| { | |
| 6062 | + div() | |
| 6063 | + .flex() | |
| 6064 | + .items_center() | |
| 6065 | + .gap(px(4.)) | |
| 6066 | + .child(div().child(value)) | |
| 6067 | + .child(step(ids.0, "−", by.0, cx)) | |
| 6068 | + .child(step(ids.1, "+", by.1, cx)) | |
| 6069 | + }; | |
| 6070 | + row.child(format!( | |
| 6071 | + "Band {} of {}", | |
| 6072 | + self.eq_band + 1, | |
| 6073 | + self.eq_params.bands.len() | |
| 6074 | + )) | |
| 6075 | + .child(number( | |
| 6076 | + band_label(&band), | |
| 6077 | + ("eq-freq-down", "eq-freq-up"), | |
| 6078 | + ( | |
| 6079 | + |b| b.freq_hz /= EQ_FREQ_STEP, | |
| 6080 | + |b| b.freq_hz *= EQ_FREQ_STEP, | |
| 6081 | + ), | |
| 6082 | + cx, | |
| 6083 | + )) | |
| 6084 | + .child(number( | |
| 6085 | + format!("{:+.1} dB", band.gain_db), | |
| 6086 | + ("eq-gain-down", "eq-gain-up"), | |
| 6087 | + (|b| b.gain_db -= EQ_STEP, |b| b.gain_db += EQ_STEP), | |
| 6088 | + cx, | |
| 6089 | + )) | |
| 6090 | + // Q is width, so its buttons are labelled by what they *do* to the | |
| 6091 | + // hump rather than by which way the number goes: a wider band is a | |
| 6092 | + // smaller Q, and nobody should have to know that to use the card. | |
| 6093 | + .child(number( | |
| 6094 | + format!("Q {:.2}", band.q), | |
| 6095 | + ("eq-q-wider", "eq-q-narrower"), | |
| 6096 | + (|b| b.q /= EQ_Q_STEP, |b| b.q *= EQ_Q_STEP), | |
| 6097 | + cx, | |
| 6098 | + )) | |
| 6099 | + .child( | |
| 6100 | + div() | |
| 6101 | + .id("eq-flat-band") | |
| 6102 | + .flex() | |
| 6103 | + .h(px(HIT_MIN)) | |
| 6104 | + .px(px(8.)) | |
| 6105 | + .items_center() | |
| 6106 | + .rounded(px(3.)) | |
| 6107 | + .bg(rgb(CHROME)) | |
| 6108 | + .cursor_pointer() | |
| 6109 | + .hover(|s| s.bg(rgb(HOVER))) | |
| 6110 | + .on_click( | |
| 6111 | + cx.listener(|this, _: &ClickEvent, _, cx| { | |
| 6112 | + this.nudge_band(|b| b.gain_db = 0., cx) | |
| 6113 | + }), | |
| 6114 | + ) | |
| 6115 | + .child("Flatten this"), | |
| 6116 | + ) | |
| 6117 | + } | |
| 6118 | + | |
| 5761 | 6119 | /// The colour card: the graded frame's histogram over a row per control, |
| 5762 | 6120 | /// each row a bar the pointer drags straight to a value -- no stepper |
| 5763 | 6121 | /// buttons, because a slider is a thing to pull, and the arrow keys still |
| @@ -6808,6 +7166,19 @@ impl Player { | ||
| 6808 | 7166 | // it, so all of them move together when it does. No bed width is needed |
| 6809 | 7167 | // to place them any more -- a second is so many pixels wherever it is. |
| 6810 | 7168 | let scale = self.scale; |
| 7169 | + // How much bed there is to be seen on, measured off the ruler's own | |
| 7170 | + // probe like every other question about it: what a box draws *inside* | |
| 7171 | + // itself is clipped to this ([`visible_slice`]), because a box at a deep | |
| 7172 | + // zoom is far wider than the strip it is being watched through. | |
| 7173 | + let bed = f32::from(self.ruler.get().size.width); | |
| 7174 | + // Where the snap line stands, in the same pixels every box is placed | |
| 7175 | + // through -- and only while a gesture is actually live: gpui drops a | |
| 7176 | + // drag without telling anyone, so this asks whether one is in flight | |
| 7177 | + // (`App::has_active_drag`) rather than remembering that one was. | |
| 7178 | + let cue = self | |
| 7179 | + .snap_cue | |
| 7180 | + .filter(|_| self.trim.is_some() || cx.has_active_drag()) | |
| 7181 | + .map(|frame| scale.px_at(f64::from(frame) / self.fps)); | |
| 6811 | 7182 | let clips = self |
| 6812 | 7183 | .session |
| 6813 | 7184 | .as_ref() |
| @@ -6954,7 +7325,12 @@ impl Player { | ||
| 6954 | 7325 | // the window, which took it from the release that fired |
| 6955 | 7326 | // this (gpui window.rs:3602). |
| 6956 | 7327 | .on_drop(cx.listener(move |this, drag: &AssetDrag, window, cx| { |
| 6957 | - let at = this.frame_under(window.mouse_position().x); | |
| 7328 | + // Onto the edges near it, exactly as a clip carried by | |
| 7329 | + // hand lands: the line drawn while it was in flight is | |
| 7330 | + // the frame it goes down on. | |
| 7331 | + let x = window.mouse_position().x; | |
| 7332 | + let marks = this.snap_targets(None); | |
| 7333 | + let (at, _) = this.snap_to(this.frame_under(x), 0, &marks); | |
| 6958 | 7334 | this.insert_source(&drag.0.clone(), drag.1, Some(lane), Some(at), cx) |
| 6959 | 7335 | })) |
| 6960 | 7336 | .drag_over::<AssetDrag>(|s, _, _, _| s.bg(rgb(HOVER_DIM))) |
| @@ -6963,10 +7339,21 @@ impl Player { | ||
| 6963 | 7339 | // to -- its own included, which is the drag that moves a |
| 6964 | 7340 | // take along its track. |
| 6965 | 7341 | .on_drop(cx.listener(move |this, drag: &ClipDrag, window, cx| { |
| 6966 | - this.move_clip(drag.lane, drag.idx, lane, window.mouse_position().x, cx) | |
| 7342 | + // Against the lane as it is *now* ([`Player::dragged`]), | |
| 7343 | + // and then snapped by `move_clip` like any other drop: | |
| 7344 | + // which clip is being moved and where it lands are two | |
| 7345 | + // questions, and this is the first one. | |
| 7346 | + let Some(idx) = this.dragged(drag) else { | |
| 7347 | + return; | |
| 7348 | + }; | |
| 7349 | + this.move_clip(drag.lane, idx, lane, window.mouse_position().x, cx) | |
| 6967 | 7350 | })) |
| 6968 | 7351 | .drag_over::<ClipDrag>(|s, _, _, _| s.bg(rgb(HOVER_DIM))) |
| 6969 | 7352 | .children(clips.iter().enumerate().map(|(i, clip)| { |
| 7353 | + // The clip as the lane holds it, for the drag payload: | |
| 7354 | + // what a drop looks itself up by has to be the placed | |
| 7355 | + // clip, never the preview an edge drag is drawing. | |
| 7356 | + let placed = *clip; | |
| 6970 | 7357 | // What a drag on an edge is showing, which is the clip |
| 6971 | 7358 | // itself while nothing is being dragged. |
| 6972 | 7359 | let clip = &self.trimmed(lane, i, *clip); |
| @@ -6992,15 +7379,30 @@ impl Player { | ||
| 6992 | 7379 | .unwrap_or(clip.source), |
| 6993 | 7380 | ); |
| 6994 | 7381 | let width = scale.width_px(len); |
| 7382 | + let left = scale.px_at(start); | |
| 7383 | + // The slice of this box that is on the bed: where its | |
| 7384 | + // name, its badge and its waveform go, so none of the | |
| 7385 | + // three is drawn out at a zoomed-in box's own edges. | |
| 7386 | + let (vis_x, vis_w) = visible_slice(left, width, bed); | |
| 6995 | 7387 | let label = sources.get(clip.source).map(|s| file_name(&s.path)); |
| 6996 | 7388 | let wave = sources |
| 6997 | 7389 | .get(clip.source) |
| 6998 | 7390 | .and_then(|s| self.waves.get(&(s.path.clone(), s.audio_stream))) |
| 6999 | 7391 | .cloned(); |
| 7000 | - let (from, to) = ( | |
| 7001 | - f64::from(clip.in_frame) / self.fps, | |
| 7002 | - f64::from(clip.out_frame) / self.fps, | |
| 7003 | - ); | |
| 7392 | + // The source seconds that slice plays -- not the clip's | |
| 7393 | + // whole range: the envelope is drawn for the part of the | |
| 7394 | + // box that can be seen, at the resolution of the pixels | |
| 7395 | + // it actually has, and never one column per two pixels | |
| 7396 | + // of a box millions of pixels wide. | |
| 7397 | + let along = |x: f32| match width > 0. { | |
| 7398 | + true => { | |
| 7399 | + f64::from(clip.in_frame) | |
| 7400 | + + f64::from(clip.out_frame - clip.in_frame) | |
| 7401 | + * f64::from(x / width) | |
| 7402 | + } | |
| 7403 | + false => f64::from(clip.in_frame), | |
| 7404 | + }; | |
| 7405 | + let (from, to) = (along(vis_x) / self.fps, along(vis_x + vis_w) / self.fps); | |
| 7004 | 7406 | let tip = tip.clone(); |
| 7005 | 7407 | // What the pointer carries on the way to another lane: |
| 7006 | 7408 | // the file the box is showing, the same ghost a library |
| @@ -7023,7 +7425,7 @@ impl Player { | ||
| 7023 | 7425 | // off the left edge: the bed clips what hangs out |
| 7024 | 7426 | // of it, so a half-visible clip is drawn as the |
| 7025 | 7427 | // half of itself that is on screen. |
| 7026 | - .left(px(scale.px_at(start))) | |
| 7428 | + .left(px(left)) | |
| 7027 | 7429 | .w(px(width)) |
| 7028 | 7430 | .overflow_hidden() |
| 7029 | 7431 | .rounded(px(3.)) |
| @@ -7044,9 +7446,14 @@ impl Player { | ||
| 7044 | 7446 | // starts the drag still selects, so picking a clip |
| 7045 | 7447 | // up and putting it back down where it was is |
| 7046 | 7448 | // exactly a click. |
| 7047 | - .on_drag(ClipDrag { lane, idx: i }, move |_, _, _, cx| { | |
| 7048 | - cx.new(|_| Tip(ghost.clone())) | |
| 7049 | - }) | |
| 7449 | + .on_drag( | |
| 7450 | + ClipDrag { | |
| 7451 | + lane, | |
| 7452 | + idx: i, | |
| 7453 | + clip: placed, | |
| 7454 | + }, | |
| 7455 | + move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())), | |
| 7456 | + ) | |
| 7050 | 7457 | .on_mouse_down( |
| 7051 | 7458 | MouseButton::Left, |
| 7052 | 7459 | cx.listener(move |this, event: &MouseDownEvent, _, cx| { |
| @@ -7105,7 +7512,7 @@ impl Player { | ||
| 7105 | 7512 | zone |
| 7106 | 7513 | })) |
| 7107 | 7514 | // Under the label row, never through it. |
| 7108 | - .children(wave.filter(|_| audio).and_then(|wave| { | |
| 7515 | + .children(wave.filter(|_| audio && vis_w > 0.).and_then(|wave| { | |
| 7109 | 7516 | let inner: AnyElement = match wave { |
| 7110 | 7517 | Wave::Peaks(peaks) => { |
| 7111 | 7518 | waveform(peaks, from, to).into_any_element() |
| @@ -7141,8 +7548,8 @@ impl Player { | ||
| 7141 | 7548 | Some( |
| 7142 | 7549 | div() |
| 7143 | 7550 | .absolute() |
| 7144 | - .left_0() | |
| 7145 | - .right_0() | |
| 7551 | + .left(px(vis_x)) | |
| 7552 | + .w(px(vis_w)) | |
| 7146 | 7553 | .top(px(LABEL_H)) |
| 7147 | 7554 | .bottom_0() |
| 7148 | 7555 | .child(inner), |
| @@ -7153,24 +7560,44 @@ impl Player { | ||
| 7153 | 7560 | // cannot say whether a short clip is a trim or a |
| 7154 | 7561 | // clip at 4x, and that is the difference between a |
| 7155 | 7562 | // cut and a re-time. |
| 7156 | - .when(!clip.speed.is_normal(), |d| { | |
| 7563 | + // Against the right edge of what is *visible* of the | |
| 7564 | + // box, not of the box: zoomed in, the box's own | |
| 7565 | + // right edge is off the screen and the badge with | |
| 7566 | + // it, which is a clip that stops saying it is | |
| 7567 | + // speeded exactly when it is being looked at | |
| 7568 | + // closely. | |
| 7569 | + .when(!clip.speed.is_normal() && vis_w > 0., |d| { | |
| 7157 | 7570 | d.child( |
| 7158 | 7571 | div() |
| 7159 | 7572 | .absolute() |
| 7160 | 7573 | .top_0() |
| 7161 | - .right_0() | |
| 7162 | - .px(px(3.)) | |
| 7163 | - .rounded(px(3.)) | |
| 7164 | - .bg(rgb(ACCENT)) | |
| 7165 | - .text_size(px(9.)) | |
| 7166 | - .text_color(rgb(SURFACE)) | |
| 7167 | - .child(format!("{}", clip.speed)), | |
| 7574 | + .left(px(vis_x)) | |
| 7575 | + .w(px(vis_w)) | |
| 7576 | + .flex() | |
| 7577 | + .justify_end() | |
| 7578 | + .overflow_hidden() | |
| 7579 | + .child( | |
| 7580 | + div() | |
| 7581 | + .flex_none() | |
| 7582 | + .px(px(3.)) | |
| 7583 | + .rounded(px(3.)) | |
| 7584 | + .bg(rgb(ACCENT)) | |
| 7585 | + .text_size(px(9.)) | |
| 7586 | + .text_color(rgb(SURFACE)) | |
| 7587 | + .child(format!("{}", clip.speed)), | |
| 7588 | + ), | |
| 7168 | 7589 | ) |
| 7169 | 7590 | }) |
| 7170 | - .when_some(label.filter(|_| show_label(width)), |d, label| { | |
| 7591 | + // ...and the name sits at the left edge of the same | |
| 7592 | + // slice, for the same reason: a box scrolled half | |
| 7593 | + // off names itself on the half that is on screen. | |
| 7594 | + .when_some(label.filter(|_| show_label(vis_w)), |d, label| { | |
| 7171 | 7595 | d.child( |
| 7172 | 7596 | div() |
| 7173 | - .relative() | |
| 7597 | + .absolute() | |
| 7598 | + .top_0() | |
| 7599 | + .left(px(vis_x)) | |
| 7600 | + .w(px(vis_w)) | |
| 7174 | 7601 | .h(px(LABEL_H)) |
| 7175 | 7602 | .px(px(4.)) |
| 7176 | 7603 | .truncate() |
| @@ -7198,6 +7625,20 @@ impl Player { | ||
| 7198 | 7625 | .bg(rgba(0x4a9effaa)) |
| 7199 | 7626 | }), |
| 7200 | 7627 | ) |
| 7628 | + // What the gesture in flight is about to land on, drawn on | |
| 7629 | + // every lane so a clip lining up with a take one track over | |
| 7630 | + // can be seen to line up with it. Under the playhead's line | |
| 7631 | + // and in another colour, since the two mean different | |
| 7632 | + // things and often stand on the same pixel. | |
| 7633 | + .children(cue.map(|x| { | |
| 7634 | + div() | |
| 7635 | + .absolute() | |
| 7636 | + .top_0() | |
| 7637 | + .h_full() | |
| 7638 | + .left(px(x)) | |
| 7639 | + .w(px(1.)) | |
| 7640 | + .bg(rgb(INK)) | |
| 7641 | + })) | |
| 7201 | 7642 | // Last, so it is over the clips: the same fraction in both |
| 7202 | 7643 | // lanes, which is the playhead being one line. |
| 7203 | 7644 | .child( |
| @@ -7422,6 +7863,36 @@ fn eq_x(freq_hz: f32) -> f32 { | ||
| 7422 | 7863 | ((freq_hz.max(1.) / EQ_FREQ_LOW).log10() / span).clamp(0., 1.) |
| 7423 | 7864 | } |
| 7424 | 7865 | |
| 7866 | +/// The frequency at a fraction across the graph -- [`eq_x`] backwards, which is | |
| 7867 | +/// how a drag and the curve's own sample points read one. Clamped to the axis | |
| 7868 | +/// either way, so a pointer that leaves the box stops at 20 Hz or 20 kHz. | |
| 7869 | +fn eq_freq(along: f32) -> f32 { | |
| 7870 | + EQ_FREQ_LOW * (EQ_FREQ_HIGH / EQ_FREQ_LOW).powf(along.clamp(0., 1.)) | |
| 7871 | +} | |
| 7872 | + | |
| 7873 | +/// The band an "add" makes: a flat peak half way -- in octaves, which is what | |
| 7874 | +/// the log axis draws -- between the picked band and whatever sits above it, so | |
| 7875 | +/// a new band lands in the gap on screen rather than on top of its neighbour. | |
| 7876 | +/// Above the topmost band the gap is the rest of the axis. | |
| 7877 | +fn inserted_band(bands: &[Band], after: usize) -> Band { | |
| 7878 | + let below = bands.get(after).map_or(1000., |b| b.freq_hz); | |
| 7879 | + let above = bands | |
| 7880 | + .iter() | |
| 7881 | + .map(|b| b.freq_hz) | |
| 7882 | + .filter(|f| *f > below) | |
| 7883 | + .min_by(f32::total_cmp) | |
| 7884 | + .unwrap_or(EQ_FREQ_HIGH); | |
| 7885 | + Band { | |
| 7886 | + freq_hz: (below * above).sqrt().clamp(EQ_FREQ_LOW, EQ_FREQ_HIGH), | |
| 7887 | + gain_db: 0., | |
| 7888 | + // A shade narrower than the flat-shelf 0.707 the defaults use: a band | |
| 7889 | + // someone asked for is a band they mean to aim, and a wide one aimed at | |
| 7890 | + // 300 Hz is really a band at everything. | |
| 7891 | + q: 1., | |
| 7892 | + kind: BandKind::Peak, | |
| 7893 | + } | |
| 7894 | +} | |
| 7895 | + | |
| 7425 | 7896 | /// Where a gain sits *down* the graph, 0..1 from the top: flat is the middle, |
| 7426 | 7897 | /// so a cut reads as a dip below the line it is a cut from. The inverse of |
| 7427 | 7898 | /// [`Player::drag_band`]'s reading of the pointer, and clamped like it, so a |
| @@ -7431,14 +7902,24 @@ fn eq_y(gain_db: f32) -> f32 { | ||
| 7431 | 7902 | 0.5 - (gain_db / EQ_GAIN_LIMIT).clamp(-1., 1.) / 2. |
| 7432 | 7903 | } |
| 7433 | 7904 | |
| 7905 | +/// A frequency as the card writes it. Two decimals of a kHz at most, with the | |
| 7906 | +/// zeroes trimmed, so "1 kHz" stays "1 kHz" and a band nudged off it reads as | |
| 7907 | +/// 1.12 kHz rather than as the same "1 kHz" it was before the keystroke -- a | |
| 7908 | +/// number that does not move under an edit is worse than no number. | |
| 7909 | +fn eq_freq_label(freq_hz: f32) -> String { | |
| 7910 | + if freq_hz < 1000. { | |
| 7911 | + return format!("{freq_hz:.0} Hz"); | |
| 7912 | + } | |
| 7913 | + let khz = format!("{:.2}", freq_hz / 1000.); | |
| 7914 | + let khz = khz.trim_end_matches('0').trim_end_matches('.'); | |
| 7915 | + format!("{khz} kHz") | |
| 7916 | +} | |
| 7917 | + | |
| 7434 | 7918 | /// What a band row calls itself: the corner or centre frequency, and for a |
| 7435 | 7919 | /// shelf the fact that it tilts everything past it -- which is the difference |
| 7436 | 7920 | /// between "12 kHz" moving the last octave and moving one band inside it. |
| 7437 | 7921 | fn band_label(band: &Band) -> String { |
| 7438 | - let freq = match band.freq_hz >= 1000. { | |
| 7439 | - true => format!("{:.0} kHz", band.freq_hz / 1000.), | |
| 7440 | - false => format!("{:.0} Hz", band.freq_hz), | |
| 7441 | - }; | |
| 7922 | + let freq = eq_freq_label(band.freq_hz); | |
| 7442 | 7923 | match band.kind { |
| 7443 | 7924 | BandKind::LowShelf => format!("{freq} low shelf"), |
| 7444 | 7925 | BandKind::HighShelf => format!("{freq} high shelf"), |
| @@ -7793,6 +8274,15 @@ fn unusable(info: &StreamInfo, timeline_audio: Option<(u32, u16)>) -> Option<Str | ||
| 7793 | 8274 | }) |
| 7794 | 8275 | } |
| 7795 | 8276 | |
| 8277 | +/// How wide the equalizer card is drawn in a window this wide: all of it bar a | |
| 8278 | +/// margin, up to [`EQ_W_MAX`]. The card is a graph, and a graph of twenty | |
| 8279 | +/// thousand hertz on 320 px spends four pixels on the octave below middle C -- | |
| 8280 | +/// so it takes the room a big window has and stays inside a small one. Floored | |
| 8281 | +/// at the other cards' width, which is the last size the rows still read at. | |
| 8282 | +fn eq_card_w(window_w: f32) -> f32 { | |
| 8283 | + (window_w - EQ_W_MARGIN).clamp(KEYS_W, EQ_W_MAX) | |
| 8284 | +} | |
| 8285 | + | |
| 7796 | 8286 | /// What the media list is given of the window. A share of it, so a narrow |
| 7797 | 8287 | /// window gives the panel less rather than giving the picture nothing, floored |
| 7798 | 8288 | /// where a name stops being readable and capped at a third of the window -- |
| @@ -8660,6 +9150,97 @@ fn show_label(w: f32) -> bool { | ||
| 8660 | 9150 | w >= LABEL_MIN_W |
| 8661 | 9151 | } |
| 8662 | 9152 | |
| 9153 | +/// The clip a trim is *showing*, worked out the way `Project::trim` will write | |
| 9154 | +/// it: the timeline room the edge leaves is turned into source frames by the one | |
| 9155 | +/// conversion that exists for it ([`Speed::fit`]), and the box is drawn from | |
| 9156 | +/// that. The preview and the commit are then the same arithmetic -- a box let go | |
| 9157 | +/// of stays where the hand left it at every rate. Assigning the timeline count | |
| 9158 | +/// straight to the source field, as this used to, drew a speeded clip's tail | |
| 9159 | +/// moving at the wrong rate (it snapped on release) and drew a *head* trim | |
| 9160 | +/// moving the clip's other edge, since the length it implied was not the length | |
| 9161 | +/// the release would commit. | |
| 9162 | +/// | |
| 9163 | +/// A still grows forward from source frame 0 instead: every frame of it is the | |
| 9164 | +/// same picture, so there is no earlier one for an in-point to walk back to. | |
| 9165 | +/// | |
| 9166 | +/// Room too narrow to hold one source frame is the edit the engine refuses, and | |
| 9167 | +/// the box is drawn unchanged rather than as something that will not be | |
| 9168 | +/// committed. | |
| 9169 | +fn trimmed_clip(clip: Clip, edge: Edge, to: u32, still: bool) -> Clip { | |
| 9170 | + // An edge that has not moved is not an edit, and `Project::trim` refuses it | |
| 9171 | + // as one: the press that starts a drag must draw the clip it pressed, not a | |
| 9172 | + // clip a rounding narrower. | |
| 9173 | + if to | |
| 9174 | + == match edge { | |
| 9175 | + Edge::Start => clip.start, | |
| 9176 | + Edge::End => clip.end(), | |
| 9177 | + } | |
| 9178 | + { | |
| 9179 | + return clip; | |
| 9180 | + } | |
| 9181 | + match edge { | |
| 9182 | + Edge::Start => { | |
| 9183 | + // What survives is measured from the *end* -- the frames that stay | |
| 9184 | + // play what they always played, which is what makes this a trim. | |
| 9185 | + let Some(keep) = clip.speed.fit(clip.end().saturating_sub(to)) else { | |
| 9186 | + return clip; | |
| 9187 | + }; | |
| 9188 | + match still { | |
| 9189 | + true => Clip { | |
| 9190 | + in_frame: 0, | |
| 9191 | + out_frame: keep, | |
| 9192 | + start: to, | |
| 9193 | + ..clip | |
| 9194 | + }, | |
| 9195 | + false => Clip { | |
| 9196 | + in_frame: clip.out_frame - keep.min(clip.out_frame), | |
| 9197 | + start: to, | |
| 9198 | + ..clip | |
| 9199 | + }, | |
| 9200 | + } | |
| 9201 | + } | |
| 9202 | + Edge::End => match clip.speed.fit(to.saturating_sub(clip.start)) { | |
| 9203 | + Some(keep) => Clip { | |
| 9204 | + out_frame: clip.in_frame + keep, | |
| 9205 | + ..clip | |
| 9206 | + }, | |
| 9207 | + None => clip, | |
| 9208 | + }, | |
| 9209 | + } | |
| 9210 | +} | |
| 9211 | + | |
| 9212 | +/// Which index on its own lane a dragged clip is at *now*: the one it was picked | |
| 9213 | +/// up at while nothing has moved, and wherever the clip itself has slid to when | |
| 9214 | +/// an edit during the drag rippled the lane's indices -- a delete, an undo or a | |
| 9215 | +/// paste from a stroke, none of which gpui's frozen drag payload hears about. | |
| 9216 | +/// `None` when the clip is gone altogether, and then the drop is not an edit at | |
| 9217 | +/// all: moving whatever slid into its place is the one thing the hand did not | |
| 9218 | +/// ask for. A lane's clips are disjoint and sorted, so at most one of them can | |
| 9219 | +/// be the clip that was picked up. | |
| 9220 | +fn live_idx(clips: &[Clip], idx: usize, clip: Clip) -> Option<usize> { | |
| 9221 | + match clips.get(idx) { | |
| 9222 | + Some(&at) if at == clip => Some(idx), | |
| 9223 | + _ => clips.iter().position(|&c| c == clip), | |
| 9224 | + } | |
| 9225 | +} | |
| 9226 | + | |
| 9227 | +/// The part of a clip's box that is on the bed, in the box's own pixels: | |
| 9228 | +/// `(left, width)` of its intersection with the visible strip. Everything drawn | |
| 9229 | +/// *inside* a box -- its waveform, its name, its speed badge -- is placed in | |
| 9230 | +/// here rather than at the box's own edges, which at a deep zoom sit thousands | |
| 9231 | +/// of pixels off either side of the screen: a label out there is a label nobody | |
| 9232 | +/// can read, and a waveform out there is a path with a point per two pixels of a | |
| 9233 | +/// width nobody can see. A bed that has not been measured yet answers with the | |
| 9234 | +/// whole box, which is what was drawn before there was a bed to clip to. | |
| 9235 | +fn visible_slice(left: f32, width: f32, bed: f32) -> (f32, f32) { | |
| 9236 | + if bed <= 0. { | |
| 9237 | + return (0., width); | |
| 9238 | + } | |
| 9239 | + let from = (-left).clamp(0., width); | |
| 9240 | + let to = (bed - left).clamp(from, width); | |
| 9241 | + (from, to - from) | |
| 9242 | +} | |
| 9243 | + | |
| 8663 | 9244 | /// Scales an envelope to its own loudest sample, so a quietly mastered source |
| 8664 | 9245 | /// still draws as a shape. The fixtures peak around an eighth of full scale, and |
| 8665 | 9246 | /// an eighth of a 30 px lane is a flat line -- which says "silent" about a file |
| @@ -8684,7 +9265,7 @@ fn envelope(peaks: &[(f32, f32)], from: f64, to: f64, w: f32, h: f32) -> Vec<(f3 | ||
| 8684 | 9265 | if peaks.is_empty() || w <= 0. || h <= 0. { |
| 8685 | 9266 | return Vec::new(); |
| 8686 | 9267 | } |
| 8687 | - let cols = (w / WAVE_COL).ceil().max(1.) as usize; | |
| 9268 | + let cols = ((w / WAVE_COL).ceil().max(1.) as usize).min(WAVE_COLS_MAX); | |
| 8688 | 9269 | let mid = h / 2.; |
| 8689 | 9270 | (0..=cols) |
| 8690 | 9271 | .map(|col| { |
| @@ -8937,6 +9518,56 @@ fn snapped(raw: u32, len: u32, tol: u32, marks: &[u32]) -> u32 { | ||
| 8937 | 9518 | best.map_or(raw, |(_, start)| start) |
| 8938 | 9519 | } |
| 8939 | 9520 | |
| 9521 | +/// The edges worth landing on, off *every* lane: both ends of every clip on the | |
| 9522 | +/// timeline, less `skip` -- the clip being dragged, which does not snap to where | |
| 9523 | +/// it already is -- and less the other halves of its group, which travel with | |
| 9524 | +/// it. `skip` is a lane's place in `lanes` and an index into it. The playhead | |
| 9525 | +/// and the head of the timeline go on the end: a clip meets the cursor and the | |
| 9526 | +/// start of the show as readily as it meets another take. | |
| 9527 | +/// | |
| 9528 | +/// All lanes rather than the one being dropped on, because a cut is made across | |
| 9529 | +/// the timeline: a title on V2 lines up with the shot under it, and a sound | |
| 9530 | +/// effect lines up with the frame it belongs to. | |
| 9531 | +fn snap_marks(lanes: &[&[Clip]], skip: Option<(usize, usize)>, playhead: u32) -> Vec<u32> { | |
| 9532 | + let link = skip | |
| 9533 | + .and_then(|(lane, idx)| lanes.get(lane)?.get(idx)) | |
| 9534 | + .and_then(|clip| clip.link); | |
| 9535 | + let mut marks: Vec<u32> = lanes | |
| 9536 | + .iter() | |
| 9537 | + .enumerate() | |
| 9538 | + .flat_map(|(lane, clips)| { | |
| 9539 | + clips | |
| 9540 | + .iter() | |
| 9541 | + .enumerate() | |
| 9542 | + .filter(move |&(idx, clip)| { | |
| 9543 | + Some((lane, idx)) != skip && !(link.is_some() && clip.link == link) | |
| 9544 | + }) | |
| 9545 | + .flat_map(|(_, clip)| [clip.start, clip.end()]) | |
| 9546 | + }) | |
| 9547 | + .collect(); | |
| 9548 | + marks.push(playhead); | |
| 9549 | + marks.push(0); | |
| 9550 | + marks | |
| 9551 | +} | |
| 9552 | + | |
| 9553 | +/// [`snapped`], and the mark that pulled it there -- the line the bed draws | |
| 9554 | +/// while the hand is still moving. `None` when nothing was near enough: a line | |
| 9555 | +/// standing over open bed would promise a landing that is not going to happen. | |
| 9556 | +/// The head is read before the tail, exactly as [`snapped`] prefers it. | |
| 9557 | +/// | |
| 9558 | +/// `on` is the switch ([`ActionId::ToggleSnap`]): off, the gesture lands raw and | |
| 9559 | +/// draws no line at all, which is the whole point of being able to turn it off. | |
| 9560 | +fn snap_cue(on: bool, raw: u32, len: u32, tol: u32, marks: &[u32]) -> (u32, Option<u32>) { | |
| 9561 | + if !on { | |
| 9562 | + return (raw, None); | |
| 9563 | + } | |
| 9564 | + let start = snapped(raw, len, tol, marks); | |
| 9565 | + let mark = [start, start.saturating_add(len)] | |
| 9566 | + .into_iter() | |
| 9567 | + .find(|mark| marks.contains(mark)); | |
| 9568 | + (start, mark) | |
| 9569 | +} | |
| 9570 | + | |
| 8940 | 9571 | /// Where down an element a pointer sits, 0..1 from the top: the vertical twin |
| 8941 | 9572 | /// of [`frac_along`], for the equalizer, whose gain axis is the y one. An |
| 8942 | 9573 | /// element that was never painted reads as its middle -- flat, the one answer |
| @@ -9140,11 +9771,15 @@ fn eq_spectrum_curve(levels: Vec<f32>) -> impl IntoElement { | ||
| 9140 | 9771 | .size_full() |
| 9141 | 9772 | } |
| 9142 | 9773 | |
| 9143 | -/// The cascade's frequency response, drawn as one line across the graph. | |
| 9774 | +/// The cascade's frequency response, drawn as one line across the graph, with | |
| 9775 | +/// each band's own response threaded dimly under it. | |
| 9144 | 9776 | /// |
| 9145 | 9777 | /// Every point comes from `EqParams::response_db`, which reads the very |
| 9146 | 9778 | /// coefficients the samples are filtered through: the curve cannot drift from |
| 9147 | -/// what is heard, because there is no second copy of the maths. | |
| 9779 | +/// what is heard, because there is no second copy of the maths. A single band's | |
| 9780 | +/// thread is that same call on a cascade of one, so the two cannot disagree | |
| 9781 | +/// either -- and it is what makes a boost sitting inside a cut visible at all, | |
| 9782 | +/// where the sum alone would draw a flat line and say nothing. | |
| 9148 | 9783 | /// |
| 9149 | 9784 | /// ponytail: bands that overlap can sum past the ±`EQ_GAIN_LIMIT` axis and the |
| 9150 | 9785 | /// curve then rides the edge of the box; upgrade = a wider dB axis with the |
| @@ -9154,16 +9789,37 @@ fn eq_curve(params: EqParams, sample_rate: u32) -> impl IntoElement { | ||
| 9154 | 9789 | |_, _, _| (), |
| 9155 | 9790 | move |bounds, _, window, _| { |
| 9156 | 9791 | let (o, s) = (bounds.origin, bounds.size); |
| 9157 | - let points: Vec<_> = (0..=EQ_CURVE_STEPS) | |
| 9158 | - .map(|step| { | |
| 9159 | - let along = step as f32 / EQ_CURVE_STEPS as f32; | |
| 9160 | - let freq = EQ_FREQ_LOW * (EQ_FREQ_HIGH / EQ_FREQ_LOW).powf(along); | |
| 9161 | - point( | |
| 9162 | - o.x + s.width * along, | |
| 9163 | - o.y + s.height * eq_y(params.response_db(freq, sample_rate)), | |
| 9164 | - ) | |
| 9792 | + let line = |of: &EqParams| -> Vec<_> { | |
| 9793 | + (0..=EQ_CURVE_STEPS) | |
| 9794 | + .map(|step| { | |
| 9795 | + let along = step as f32 / EQ_CURVE_STEPS as f32; | |
| 9796 | + point( | |
| 9797 | + o.x + s.width * along, | |
| 9798 | + o.y + s.height | |
| 9799 | + * eq_y(of.response_db(eq_freq(along), sample_rate)), | |
| 9800 | + ) | |
| 9801 | + }) | |
| 9802 | + .collect() | |
| 9803 | + }; | |
| 9804 | + // One thread per band, first, so the sum is drawn over them. | |
| 9805 | + for band in ¶ms.bands { | |
| 9806 | + let mut bell = PathBuilder::stroke(px(1.)); | |
| 9807 | + for (step, at) in line(&EqParams { | |
| 9808 | + bands: vec![*band], | |
| 9165 | 9809 | }) |
| 9166 | - .collect(); | |
| 9810 | + .into_iter() | |
| 9811 | + .enumerate() | |
| 9812 | + { | |
| 9813 | + match step { | |
| 9814 | + 0 => bell.move_to(at), | |
| 9815 | + _ => bell.line_to(at), | |
| 9816 | + } | |
| 9817 | + } | |
| 9818 | + if let Ok(bell) = bell.build() { | |
| 9819 | + window.paint_path(bell, rgba(EQ_BELL_INK)); | |
| 9820 | + } | |
| 9821 | + } | |
| 9822 | + let points = line(¶ms); | |
| 9167 | 9823 | // The area between the curve and 0 dB, closed along that line: a |
| 9168 | 9824 | // boost and a cut wind opposite ways around it, which is exactly |
| 9169 | 9825 | // what makes both of them fill and the flat parts stay empty. |
| @@ -9265,26 +9921,31 @@ fn timecode(t: f64, fps: f64) -> String { | ||
| 9265 | 9921 | #[cfg(test)] |
| 9266 | 9922 | mod tests { |
| 9267 | 9923 | use super::{ |
| 9268 | - ACCENT, COLOR_BANDS, COLOR_BAR_W, COLOR_STEP, COLOR_W, CONTROL_H, Clip, Ctx, | |
| 9269 | - EQ_CURVE_STEPS, EQ_FFT, EQ_FREQ_HIGH, EQ_FREQ_LOW, EQ_GAIN_LIMIT, EQ_GRAPH_H, EQ_HANDLE, | |
| 9270 | - EQ_SPECTRUM_DB, EQ_TICKS, ESCAPE, EXPORT_FIXED_H, EXPORT_ROWS_H, EXPORT_W, Enable, FORMATS, | |
| 9924 | + ACCENT, COLOR_BANDS, COLOR_BAR_W, COLOR_STEP, COLOR_W, CONTROL_H, Clip, Ctx, EQ_BANDS_MAX, | |
| 9925 | + EQ_CURVE_STEPS, EQ_FFT, EQ_FREQ_HIGH, EQ_FREQ_LOW, EQ_FREQ_STEP, EQ_GAIN_LIMIT, EQ_GRAPH_H, | |
| 9926 | + EQ_HANDLE, EQ_Q_HIGH, EQ_Q_LOW, EQ_Q_STEP, EQ_SPECTRUM_DB, EQ_TICKS, EQ_W_MAX, ESCAPE, | |
| 9927 | + EXPORT_FIXED_H, EXPORT_ROWS_H, EXPORT_W, Enable, FORMATS, | |
| 9271 | 9928 | Format, HEADER_GAP, HEADER_H, HEADER_W, HIST_BINS, HIST_H, HIST_SAMPLES, HIT_MIN, INK, |
| 9272 | 9929 | INK_DIM, KEYS_ROW_H, KEYS_ROWS_H, KEYS_W, KeyRow, LABEL_H, LABEL_MIN_W, LANE_H, LANES_MAX, |
| 9273 | 9930 | LETTERBOX, LIBRARY_MAX_W, LIBRARY_MIN_W, Lane, MENU_ITEMS, MENU_PAD, MENU_ROW_H, |
| 9274 | 9931 | MENU_ROWS_H, MENU_W, NO_FILE, PANEL_H, Quality, ROW_H, RULER_HIT_H, SELECTED, SILENCE_ROWS, |
| 9275 | 9932 | SOURCE_TINTS, SPEED_PRESETS, SPEED_STEP, SURFACE, SWATCH_W, Source, Speed, StreamInfo, |
| 9276 | - Transport, VOLUME_W, Volume, WAVE_BPS, WAVE_COL, Wave, band_label, bitrate_refusal, | |
| 9277 | - can_add, cancels_export, clipboard_after_remove, color_snap, containers, enable, envelope, | |
| 9278 | - eq_spectrum, eq_x, eq_y, estimated_mb, export_path, export_settings, format_key, | |
| 9933 | + Transport, VOLUME_W, Volume, WAVE_BPS, WAVE_COL, WAVE_COLS_MAX, Wave, band_label, | |
| 9934 | + bitrate_refusal, can_add, cancels_export, clipboard_after_remove, color_snap, containers, | |
| 9935 | + enable, envelope, eq_card_w, eq_freq, eq_freq_label, eq_spectrum, eq_x, eq_y, | |
| 9936 | + estimated_mb, export_path, export_settings, format_key, | |
| 9279 | 9937 | format_line, format_refusal, fps_label, frac_along, frac_down, frame_at, histogram, |
| 9280 | - is_bare_modifier, is_project, keymap, keys_rows, lanes_h, marked, menu_at, next_container, | |
| 9938 | + inserted_band, is_bare_modifier, is_project, keymap, keys_rows, lanes_h, marked, menu_at, | |
| 9939 | + next_container, | |
| 9281 | 9940 | normalise, nothing_to_play, panel_h, project_path, push_digit, retarget, scrub_due, |
| 9282 | - show_label, silence_rate, snapped, source_tint, span_partner, speed_at, summary_head, | |
| 9283 | - summary_tail, timecode, transport, unseen_paths, unseen_sources, whole_take, window_title, | |
| 9941 | + show_label, silence_rate, snap_cue, snap_marks, snapped, source_tint, span_partner, | |
| 9942 | + speed_at, summary_head, summary_tail, timecode, transport, unseen_paths, unseen_sources, | |
| 9943 | + whole_take, window_title, | |
| 9284 | 9944 | }; |
| 9285 | 9945 | use super::{ |
| 9286 | - LaneKind, PPS_DEFAULT, Repeat, Scale, View, ZOOM_MAX_SECONDS, ZOOM_MIN_FRAMES, ZOOM_STEP, | |
| 9287 | - file_name, file_uri, library_rows, px_along, repeats, span_label, unscannable, | |
| 9946 | + Edge, LaneKind, PPS_DEFAULT, Repeat, Scale, View, ZOOM_MAX_SECONDS, ZOOM_MIN_FRAMES, | |
| 9947 | + ZOOM_STEP, file_name, file_uri, library_rows, live_idx, px_along, repeats, span_label, | |
| 9948 | + trimmed_clip, unscannable, visible_slice, | |
| 9288 | 9949 | }; |
| 9289 | 9950 | |
| 9290 | 9951 | /// What the file manager is handed: the parts a path keeps as they are, and |
| @@ -9783,6 +10444,10 @@ mod tests { | ||
| 9783 | 10444 | "{action:?} is reachable by keyboard only" |
| 9784 | 10445 | ); |
| 9785 | 10446 | } |
| 10447 | + // The snap has a door of its own as well as its row on the card: the | |
| 10448 | + // button beside the zoom, which says which way it is set as well as | |
| 10449 | + // setting it. | |
| 10450 | + assert!(element("snap"), "no snap button beside the zoom"); | |
| 9786 | 10451 | // And the card is a door the pointer can open: the panel's own button. |
| 9787 | 10452 | assert!(element("keys"), "no way to open the actions card"); |
| 9788 | 10453 | // The card-local strokes have the same rule, and each of them is a thing |
| @@ -10466,6 +11131,62 @@ mod tests { | ||
| 10466 | 11131 | assert_eq!(snapped(2, 40, 4, &marks), 0); |
| 10467 | 11132 | } |
| 10468 | 11133 | |
| 11134 | + /// Where those edges come from: every lane, not the one being dropped on -- | |
| 11135 | + /// and never the clip in the hand or the half of it one track down. | |
| 11136 | + #[test] | |
| 11137 | + fn the_marks_are_every_lane_the_playhead_and_the_start() { | |
| 11138 | + let clip = |start: u32, frames: u32, link| Clip { | |
| 11139 | + start, | |
| 11140 | + in_frame: 0, | |
| 11141 | + out_frame: frames, | |
| 11142 | + source: 0, | |
| 11143 | + link, | |
| 11144 | + eq: None, | |
| 11145 | + color: None, | |
| 11146 | + fit: Default::default(), | |
| 11147 | + speed: Default::default(), | |
| 11148 | + }; | |
| 11149 | + // A grouped take across two lanes at 100..160, and a lone one on the | |
| 11150 | + // audio lane at 400..430. | |
| 11151 | + let video = [clip(100, 60, Some(7))]; | |
| 11152 | + let audio = [clip(100, 60, Some(7)), clip(400, 30, None)]; | |
| 11153 | + let lanes: [&[Clip]; 2] = [&video, &audio]; | |
| 11154 | + | |
| 11155 | + // Nothing in the hand: both lanes' edges, the playhead, and 0. | |
| 11156 | + let mut all = snap_marks(&lanes, None, 300); | |
| 11157 | + all.sort_unstable(); | |
| 11158 | + assert_eq!(all, [0, 100, 100, 160, 160, 300, 400, 430]); | |
| 11159 | + | |
| 11160 | + // The video half in the hand: its own edges are gone, and so are its | |
| 11161 | + // group's on the other lane -- both boxes travel with the drag. The | |
| 11162 | + // lone audio clip is still a target, which is the whole point: a take | |
| 11163 | + // being carried on V1 lands flush with a sound on A1. | |
| 11164 | + let mut carried = snap_marks(&lanes, Some((0, 0)), 300); | |
| 11165 | + carried.sort_unstable(); | |
| 11166 | + assert_eq!(carried, [0, 300, 400, 430]); | |
| 11167 | + | |
| 11168 | + // An index that names no clip skips nothing and still answers. | |
| 11169 | + assert_eq!(snap_marks(&[], Some((3, 9)), 0), [0, 0]); | |
| 11170 | + } | |
| 11171 | + | |
| 11172 | + /// The line the bed draws, and the switch that turns the whole thing off. | |
| 11173 | + #[test] | |
| 11174 | + fn the_snap_names_the_mark_it_landed_on_unless_it_is_switched_off() { | |
| 11175 | + let marks = [100, 160, 300, 0]; | |
| 11176 | + // Pulled by the tail: the clip lands at 60 and the line stands on the | |
| 11177 | + // edge its *tail* met, 100 -- not on the head it happens to have. | |
| 11178 | + assert_eq!(snap_cue(true, 62, 40, 4, &marks), (60, Some(100))); | |
| 11179 | + // Pulled by the head: line and landing are the same frame. | |
| 11180 | + assert_eq!(snap_cue(true, 158, 40, 4, &marks), (160, Some(160))); | |
| 11181 | + // A trim carries no length, so only its own edge lands. | |
| 11182 | + assert_eq!(snap_cue(true, 298, 0, 4, &marks), (300, Some(300))); | |
| 11183 | + // Open bed: nothing moves and nothing is drawn. | |
| 11184 | + assert_eq!(snap_cue(true, 200, 40, 4, &marks), (200, None)); | |
| 11185 | + // Switched off, a gesture that would have snapped lands raw and draws | |
| 11186 | + // no line -- the frame-by-frame placement the toggle is for. | |
| 11187 | + assert_eq!(snap_cue(false, 158, 40, 4, &marks), (158, None)); | |
| 11188 | + } | |
| 11189 | + | |
| 10469 | 11190 | #[test] |
| 10470 | 11191 | fn timecode_counts_frames_inside_the_second() { |
| 10471 | 11192 | assert_eq!(timecode(0., 30.), "00:00:00:00"); |
| @@ -11046,6 +11767,9 @@ mod tests { | ||
| 11046 | 11767 | "12 kHz high shelf" |
| 11047 | 11768 | ] |
| 11048 | 11769 | ); |
| 11770 | + // A band moved off a round number reads as where it *is*: a keystroke | |
| 11771 | + // that changes the filter and not the number on the card is a keystroke | |
| 11772 | + // nobody can aim. | |
| 11049 | 11773 | assert_eq!( |
| 11050 | 11774 | band_label(&Band { |
| 11051 | 11775 | freq_hz: 2600., |
| @@ -11053,23 +11777,38 @@ mod tests { | ||
| 11053 | 11777 | q: 1., |
| 11054 | 11778 | kind: BandKind::Peak |
| 11055 | 11779 | }), |
| 11056 | - "3 kHz", | |
| 11057 | - "rounded, because a band label is not a measurement" | |
| 11780 | + "2.6 kHz" | |
| 11781 | + ); | |
| 11782 | + assert_eq!(eq_freq_label(1122.), "1.12 kHz"); | |
| 11783 | + assert_eq!(eq_freq_label(12000.), "12 kHz", "no zeroes to read past"); | |
| 11784 | + assert_eq!(eq_freq_label(80.), "80 Hz"); | |
| 11785 | + | |
| 11786 | + // The card fits the smallest window and takes the room a bigger one has | |
| 11787 | + // -- it is a graph, and the width *is* the frequency resolution. | |
| 11788 | + assert!(eq_card_w(640.) <= 640. - 24., "card too wide for 640"); | |
| 11789 | + assert!(eq_card_w(1280.) > eq_card_w(640.), "card ignores the window"); | |
| 11790 | + assert_eq!(eq_card_w(1920.), EQ_W_MAX, "card grows without end"); | |
| 11791 | + assert!(eq_card_w(320.) >= KEYS_W, "card narrower than a row of text"); | |
| 11792 | + // At the smallest window the graph is still a graph: three across for | |
| 11793 | + // one down, so an octave is wide enough to put a handle in. | |
| 11794 | + assert!( | |
| 11795 | + eq_card_w(640.) - 24. >= 3. * EQ_GRAPH_H, | |
| 11796 | + "graph too square to aim at" | |
| 11058 | 11797 | ); |
| 11059 | 11798 | |
| 11060 | 11799 | // The same shape as the other two cards, so it fits where they do: the |
| 11061 | 11800 | // graph stands where the export card's rows do, and is shorter than |
| 11062 | - // they are. | |
| 11063 | - let (title, status, readout, gaps, padding) = (17., 28., 17., 4. * 2., 24.); | |
| 11801 | + // they are. The numbers row is a row of buttons now, so it is one of | |
| 11802 | + // those tall rather than one line of text. | |
| 11803 | + let (title, status, gaps, padding) = (17., 28., 4. * 2., 24.); | |
| 11064 | 11804 | assert!( |
| 11065 | - title + status + EQ_GRAPH_H + readout + gaps + padding + CONTROL_H <= 360., | |
| 11805 | + title + status + EQ_GRAPH_H + HIT_MIN + gaps + padding + CONTROL_H <= 360., | |
| 11066 | 11806 | "card too tall" |
| 11067 | 11807 | ); |
| 11068 | 11808 | assert!( |
| 11069 | 11809 | EQ_GRAPH_H <= EXPORT_ROWS_H, |
| 11070 | 11810 | "graph taller than a card of rows" |
| 11071 | 11811 | ); |
| 11072 | - assert!(KEYS_W <= 640., "card too wide"); | |
| 11073 | 11812 | // What is dragged is the whole graph -- the handle is a 10 px dot, but |
| 11074 | 11813 | // a press anywhere in the box takes the band nearest it -- so WCAG |
| 11075 | 11814 | // 2.5.8 is satisfied by the box, which is far past the minimum. |
| @@ -11081,6 +11820,83 @@ mod tests { | ||
| 11081 | 11820 | assert!(KEYS_ROW_H >= HIT_MIN); |
| 11082 | 11821 | } |
| 11083 | 11822 | |
| 11823 | + /// Editing a band, which is what the card is *for*: the pointer reads a | |
| 11824 | + /// frequency off the axis the same way the axis draws one, a new band lands | |
| 11825 | + /// in the gap beside the picked one rather than on top of it, and every band | |
| 11826 | + /// the card will hold has a digit that picks it. | |
| 11827 | + #[test] | |
| 11828 | + fn a_band_can_be_moved_added_and_reached() { | |
| 11829 | + use engine::eq::{Band, BandKind, EqParams}; | |
| 11830 | + // Across the graph and back: a drag sets the frequency the handle is | |
| 11831 | + // then drawn at, so the two mappings have to be one another's inverse or | |
| 11832 | + // the handle walks away from the pointer. | |
| 11833 | + for freq in [20., 80., 250., 1000., 4000., 12000., 20000.] { | |
| 11834 | + let read = eq_freq(eq_x(freq)); | |
| 11835 | + assert!( | |
| 11836 | + (read / freq - 1.).abs() < 1e-3, | |
| 11837 | + "{freq} Hz read back as {read}" | |
| 11838 | + ); | |
| 11839 | + } | |
| 11840 | + // Off the box either end stops at the axis, never past it. | |
| 11841 | + assert_eq!(eq_freq(-1.), EQ_FREQ_LOW); | |
| 11842 | + assert_eq!(eq_freq(2.), EQ_FREQ_HIGH); | |
| 11843 | + | |
| 11844 | + // A step of the frequency keys is a real move on screen -- a keystroke | |
| 11845 | + // that changes nothing visible is a keystroke that reads as broken -- | |
| 11846 | + // and small enough to aim with. | |
| 11847 | + let step = eq_x(1000. * EQ_FREQ_STEP) - eq_x(1000.); | |
| 11848 | + assert!(step > 0.01 && step < 0.06, "frequency key steps {step}"); | |
| 11849 | + | |
| 11850 | + // A new band lands between the picked one and the next one up, in | |
| 11851 | + // octaves: 250 Hz and 1 kHz put it at 500, which is a gap on screen. | |
| 11852 | + let bands = EqParams::default_layout().bands; | |
| 11853 | + let added = inserted_band(&bands, 1); | |
| 11854 | + assert!((added.freq_hz - 500.).abs() < 1., "landed at {added:?}"); | |
| 11855 | + assert_eq!(added.gain_db, 0., "a new band changes nothing until moved"); | |
| 11856 | + assert_eq!(added.kind, BandKind::Peak, "a new band is not a shelf"); | |
| 11857 | + assert!(eq_x(added.freq_hz) - eq_x(bands[1].freq_hz) > 0.1); | |
| 11858 | + // Above the topmost band the gap is the rest of the axis, and the band | |
| 11859 | + // still lands on it rather than off the end. | |
| 11860 | + let top = inserted_band(&bands, bands.len() - 1); | |
| 11861 | + assert!( | |
| 11862 | + top.freq_hz > bands[4].freq_hz && top.freq_hz <= EQ_FREQ_HIGH, | |
| 11863 | + "landed at {top:?}" | |
| 11864 | + ); | |
| 11865 | + // Bands out of frequency order (a drag may cross two over) still get a | |
| 11866 | + // sane neighbour: the next one *up*, not the next one along the list. | |
| 11867 | + let crossed = vec![ | |
| 11868 | + Band { | |
| 11869 | + freq_hz: 4000., | |
| 11870 | + gain_db: 0., | |
| 11871 | + q: 1., | |
| 11872 | + kind: BandKind::Peak, | |
| 11873 | + }, | |
| 11874 | + Band { | |
| 11875 | + freq_hz: 100., | |
| 11876 | + gain_db: 0., | |
| 11877 | + q: 1., | |
| 11878 | + kind: BandKind::Peak, | |
| 11879 | + }, | |
| 11880 | + ]; | |
| 11881 | + let between = inserted_band(&crossed, 1); | |
| 11882 | + assert!( | |
| 11883 | + (between.freq_hz - 632.).abs() < 2., | |
| 11884 | + "landed at {between:?}, not between 100 and 4000" | |
| 11885 | + ); | |
| 11886 | + | |
| 11887 | + // Every band the card will hold is one digit away: the keyboard has ten | |
| 11888 | + // digits, which is exactly why the cap is what it is. | |
| 11889 | + assert!( | |
| 11890 | + EQ_BANDS_MAX <= 10, | |
| 11891 | + "a band past the tenth has no key that picks it" | |
| 11892 | + ); | |
| 11893 | + assert!(EQ_BANDS_MAX > EqParams::default_layout().bands.len()); | |
| 11894 | + // The Q range holds the default, so a file's band never opens out of | |
| 11895 | + // range and needs dragging back in before it can be edited. | |
| 11896 | + assert!((EQ_Q_LOW..=EQ_Q_HIGH).contains(&0.707)); | |
| 11897 | + assert!(EQ_Q_STEP > 1.); | |
| 11898 | + } | |
| 11899 | + | |
| 11084 | 11900 | /// The analyser drawn behind the curve: a tone has to land on its own |
| 11085 | 11901 | /// frequency, or the backdrop is a decoration rather than a reading of what |
| 11086 | 11902 | /// is playing -- and someone shaping a band against it would be aiming at |
| @@ -12090,6 +12906,141 @@ mod tests { | ||
| 12090 | 12906 | assert!(!envelope(&peaks, 0., 99., w, h).is_empty()); |
| 12091 | 12907 | } |
| 12092 | 12908 | |
| 12909 | + /// A box laid out wider than any screen -- a long clip at a deep zoom -- is | |
| 12910 | + /// still one screen's worth of columns: the path a repaint has to build is | |
| 12911 | + /// bounded by what can be seen, not by what the layout says the box is. | |
| 12912 | + /// Unbounded, a 5 s clip zoomed to the frame is a path of millions of points | |
| 12913 | + /// per frame, and the repaint that stalls on it is the waveform that | |
| 12914 | + /// "disappeared". | |
| 12915 | + #[test] | |
| 12916 | + fn an_envelope_never_costs_more_points_than_a_screen_can_show() { | |
| 12917 | + let peaks: Vec<(f32, f32)> = (0..200).map(|i| (-(i as f32) / 199., 1.)).collect(); | |
| 12918 | + // The width a 5 s clip is laid out at when the bed shows 8 frames of it. | |
| 12919 | + let huge = 5. * 30. / 8. * 1200.; | |
| 12920 | + let cols = envelope(&peaks, 0., 5., huge, 30.); | |
| 12921 | + assert!( | |
| 12922 | + cols.len() <= WAVE_COLS_MAX + 1, | |
| 12923 | + "{} columns for a {huge} px box", | |
| 12924 | + cols.len() | |
| 12925 | + ); | |
| 12926 | + // ...and the slice actually painted is the part of the box on the bed, | |
| 12927 | + // which is where that width stops mattering: a column per two visible | |
| 12928 | + // pixels, at every zoom. | |
| 12929 | + let (x, w) = visible_slice(-huge / 2., huge, 1200.); | |
| 12930 | + assert_eq!((x, w), (huge / 2., 1200.)); | |
| 12931 | + assert_eq!(envelope(&peaks, 0., 5., w, 30.).len(), 601); | |
| 12932 | + // A box entirely off the bed has no slice, and one that has never been | |
| 12933 | + // measured is drawn whole -- what was drawn before there was a bed. | |
| 12934 | + assert_eq!(visible_slice(2000., 500., 1200.), (0., 0.)); | |
| 12935 | + assert_eq!(visible_slice(-3000., 500., 1200.), (500., 0.)); | |
| 12936 | + assert_eq!(visible_slice(-40., 500., 0.), (0., 500.)); | |
| 12937 | + // Half on, at either edge. | |
| 12938 | + assert_eq!(visible_slice(-100., 500., 1200.), (100., 400.)); | |
| 12939 | + assert_eq!(visible_slice(1000., 500., 1200.), (0., 200.)); | |
| 12940 | + } | |
| 12941 | + | |
| 12942 | + /// The box a trim draws is the box its release commits, at every speed. The | |
| 12943 | + /// preview used to hand the *timeline* frame count to a source-frame field: | |
| 12944 | + /// at 2x a tail moved twice as fast as the pointer and snapped back on | |
| 12945 | + /// release, and a head drag moved the clip's other edge. | |
| 12946 | + #[test] | |
| 12947 | + fn a_trim_preview_lands_where_the_release_commits() { | |
| 12948 | + let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture"); | |
| 12949 | + session.set_gain(0.0); | |
| 12950 | + for permille in SPEED_PRESETS { | |
| 12951 | + // Live, so the loop owes it no undo step: the speeds are the axis | |
| 12952 | + // this walks, and the trims below are what is undone. | |
| 12953 | + session | |
| 12954 | + .set_speed_live(Lane::V1, 0, Speed::from_permille(permille)) | |
| 12955 | + .expect("a clip alone on its lane may be speeded"); | |
| 12956 | + for edge in [Edge::Start, Edge::End] { | |
| 12957 | + let clip = session.lane_clips(Lane::V1)[0]; | |
| 12958 | + let (lo, hi) = session | |
| 12959 | + .trim_room(Lane::V1, 0, edge) | |
| 12960 | + .expect("clip 0 is there"); | |
| 12961 | + // Both walls and the middle of the room: the whole range a | |
| 12962 | + // pointer can be clamped to. | |
| 12963 | + for to in [lo, (lo + hi) / 2, hi] { | |
| 12964 | + let preview = trimmed_clip(clip, edge, to, false); | |
| 12965 | + // The drag is one edit and one undo step, so the next `to` | |
| 12966 | + // is measured from the same clip this one was. | |
| 12967 | + if session.trim_clip(Lane::V1, 0, edge, to) { | |
| 12968 | + assert_eq!( | |
| 12969 | + preview, | |
| 12970 | + session.lane_clips(Lane::V1)[0], | |
| 12971 | + "{edge:?} to {to} at {permille} per mille" | |
| 12972 | + ); | |
| 12973 | + assert!(session.undo(), "the trim is one undo step"); | |
| 12974 | + } else { | |
| 12975 | + // An edge already where it was asked to go is not an | |
| 12976 | + // edit, and the preview draws the clip unchanged. | |
| 12977 | + assert_eq!(preview, clip, "{edge:?} to {to} at {permille} per mille"); | |
| 12978 | + } | |
| 12979 | + assert_eq!(session.lane_clips(Lane::V1)[0], clip, "back where it was"); | |
| 12980 | + } | |
| 12981 | + } | |
| 12982 | + } | |
| 12983 | + } | |
| 12984 | + | |
| 12985 | + /// A still trims the same way, and the preview knows it: its head grows | |
| 12986 | + /// forward from source frame 0 -- every frame of it is the same picture -- | |
| 12987 | + /// so the box stretches instead of sliding left. | |
| 12988 | + #[test] | |
| 12989 | + fn a_stills_trim_preview_grows_forward_like_the_commit() { | |
| 12990 | + let mut session = PlaybackSession::open(asset("test_still.png")).expect("a picture opens"); | |
| 12991 | + for edge in [Edge::Start, Edge::End] { | |
| 12992 | + let clip = session.lane_clips(Lane::V1)[0]; | |
| 12993 | + let (lo, hi) = session | |
| 12994 | + .trim_room(Lane::V1, 0, edge) | |
| 12995 | + .expect("clip 0 is there"); | |
| 12996 | + for to in [lo, (lo + hi) / 2, hi] { | |
| 12997 | + let preview = trimmed_clip(clip, edge, to, true); | |
| 12998 | + match session.trim_clip(Lane::V1, 0, edge, to) { | |
| 12999 | + true => { | |
| 13000 | + assert_eq!( | |
| 13001 | + preview, | |
| 13002 | + session.lane_clips(Lane::V1)[0], | |
| 13003 | + "a still {edge:?} to {to}" | |
| 13004 | + ); | |
| 13005 | + assert!(session.undo(), "the trim is one undo step"); | |
| 13006 | + } | |
| 13007 | + false => assert_eq!(preview, clip, "a still {edge:?} to {to}"), | |
| 13008 | + } | |
| 13009 | + assert_eq!(session.lane_clips(Lane::V1)[0], clip, "back where it was"); | |
| 13010 | + } | |
| 13011 | + } | |
| 13012 | + } | |
| 13013 | + | |
| 13014 | + /// gpui freezes a drag's payload for the whole gesture, and nothing stops a | |
| 13015 | + /// stroke from editing the lane under it: the drop has to find the clip that | |
| 13016 | + /// was picked up, not whatever slid into its index. | |
| 13017 | + #[test] | |
| 13018 | + fn a_drop_moves_the_clip_that_was_picked_up_not_its_old_index() { | |
| 13019 | + let at = |start: u32| Clip { | |
| 13020 | + start, | |
| 13021 | + in_frame: 0, | |
| 13022 | + out_frame: 30, | |
| 13023 | + source: 0, | |
| 13024 | + link: None, | |
| 13025 | + eq: None, | |
| 13026 | + color: None, | |
| 13027 | + fit: FitPolicy::Fit, | |
| 13028 | + speed: Speed::NORMAL, | |
| 13029 | + }; | |
| 13030 | + let lane = [at(0), at(30), at(60)]; | |
| 13031 | + let dragged = lane[2]; | |
| 13032 | + assert_eq!(live_idx(&lane, 2, dragged), Some(2), "nothing moved"); | |
| 13033 | + // A delete in front of it: the clip is now index 1, and the index the | |
| 13034 | + // drag froze names a clip nobody grabbed. | |
| 13035 | + let after = [at(0), at(60)]; | |
| 13036 | + assert_eq!(live_idx(&after, 2, dragged), Some(1)); | |
| 13037 | + assert_eq!(live_idx(&after, 1, dragged), Some(1)); | |
| 13038 | + // Deleted mid-drag: there is nothing to move, and moving its neighbour | |
| 13039 | + // instead is exactly the bug this exists for. | |
| 13040 | + assert_eq!(live_idx(&[at(0)], 2, dragged), None); | |
| 13041 | + assert_eq!(live_idx(&[], 0, dragged), None); | |
| 13042 | + } | |
| 13043 | + | |
| 12093 | 13044 | #[test] |
| 12094 | 13045 | fn a_quiet_source_still_draws_as_a_shape() { |
| 12095 | 13046 | // An eighth of full scale, which is about where the fixtures sit. |
| @@ -12437,6 +13388,8 @@ fn main() { | ||
| 12437 | 13388 | scrubbing: false, |
| 12438 | 13389 | trim: None, |
| 12439 | 13390 | grab: 0, |
| 13391 | + snap: true, | |
| 13392 | + snap_cue: None, | |
| 12440 | 13393 | last_scrub: Instant::now(), |
| 12441 | 13394 | last_target: 0, |
| 12442 | 13395 | export: None, |