forge
Explore
Log in

Don't you dare go Hollow

wip(export): moment rebuild, capped mid-work — NOT green

Browse files at this commit

e5fd61080cfc8a34c981dd0537058d9fbfa95da6Ahmet Kaan GümüşParent: 2bf7f4a

14 changed files +816 -1910

crates/app/src/export_ui.rsmodified+132 -332
@@ -66,156 +66,6 @@ pub(crate) fn sample_rate_choices(current: Option<u32>) -> Vec<ChoiceRow> {
66 rows66 rows
67 }67 }
68 68
69-/// What the export card offers, top to bottom. Bitrate is the only thing the
70-/// encoder actually takes: the codec and the container are what this program
71-/// can write and nothing else, so the card states them rather than offering
72-/// them.
73-#[derive(Clone, Copy, PartialEq, Debug)]
74-pub(crate) enum Quality {
75- Exact,
76- Auto,
77- Low,
78- Medium,
79- High,
80- Custom,
81-}
82-
83-impl Quality {
84- pub(crate) const ALL: [Quality; 6] = [
85- Quality::Exact,
86- Quality::Auto,
87- Quality::Low,
88- Quality::Medium,
89- Quality::High,
90- Quality::Custom,
91- ];
92-
93- pub(crate) fn label(self) -> &'static str {
94- match self {
95- Quality::Exact => "Exact",
96- Quality::Auto => "Auto",
97- Quality::Low => "Low",
98- Quality::Medium => "Medium",
99- Quality::High => "High",
100- Quality::Custom => "Custom",
101- }
102- }
103-
104- /// The figure the row stands for, said in the units the row is chosen by.
105- pub(crate) fn detail(self, custom_mbps: u32) -> String {
106- match self {
107- // corner-cut: worded without naming the mechanism (which codec,
108- // which container) -- DESIGN.md §8 keeps a card's detail line a
109- // fact about the *output*, not an instruction about how to get
110- // there; [`exact_refusal`] is where the mechanism's own limits
111- // are said, once the row has actually been picked.
112- Quality::Exact => "input quality — copy where cuts allow".to_string(),
113- Quality::Auto => "from the picture size and frame rate".to_string(),
114- Quality::Custom => {
115- format!("{custom_mbps} Mbps — wheel or ± steps, n types one, {MBPS_MIN}–{MBPS_MAX}")
116- }
117- other => format!(
118- "{} Mbps",
119- export_settings(other, 0, Format::Mp4, DEFAULT_AUDIO_KBPS, EncoderSeat::Auto)
120- .bitrate
121- .unwrap_or_default()
122- / 1_000_000
123- ),
124- }
125- }
126-}
127-
128-/// The primary pane's one row: the format-and-quality bundles most exports
129-/// actually are, named the way a person asks for one rather than by codec and
130-/// megabits apart. Every bundle is still exactly a [`Format`] and a
131-/// [`Quality`] the Advanced pane's own rows already know how to set -- this
132-/// is a shortcut to the pair, not a third setting kept beside them, so a
133-/// bundle picked here and a codec picked below never disagree about what is
134-/// in force. `Custom` sets nothing; it only opens the Advanced pane, for a
135-/// combination none of the bundles name.
136-#[derive(Clone, Copy, PartialEq, Debug)]
137-pub(crate) enum ExportPreset {
138- Web,
139- Small,
140- Master,
141- AudioOnly,
142- Custom,
143-}
144-
145-impl ExportPreset {
146- pub(crate) const ALL: [ExportPreset; 5] = [
147- ExportPreset::Web,
148- ExportPreset::Small,
149- ExportPreset::Master,
150- ExportPreset::AudioOnly,
151- ExportPreset::Custom,
152- ];
153-
154- pub(crate) fn label(self) -> &'static str {
155- match self {
156- ExportPreset::Web => "Web",
157- ExportPreset::Small => "Small file",
158- ExportPreset::Master => "Master",
159- ExportPreset::AudioOnly => "Audio only",
160- ExportPreset::Custom => "Custom",
161- }
162- }
163-
164- /// The key that picks this row, none of the sixteen the card's other rows
165- /// already own (`n`, the digits, the codec row's `m/a/h/w/f/p/o`, and
166- /// `c/q/b/e/d/g/r/s`): a letter out of the name itself where its initial is
167- /// one of those (`smaLl`, `masTer`, `aUdio`), and a free one where every
168- /// letter in the name already belongs to another row (`Web`'s w, e and b
169- /// all are). `Custom` shares Advanced's own `s` -- the row does exactly what
170- /// that key already does, not a second name for a third thing.
171- pub(crate) fn key(self) -> &'static str {
172- match self {
173- ExportPreset::Web => "v",
174- ExportPreset::Small => "l",
175- ExportPreset::Master => "t",
176- ExportPreset::AudioOnly => "u",
177- ExportPreset::Custom => "s",
178- }
179- }
180-
181- pub(crate) fn detail(self) -> &'static str {
182- match self {
183- ExportPreset::Web => "H.264 · MP4 · medium quality — plays everywhere",
184- ExportPreset::Small => "AV1 · MP4 · low quality — smallest file",
185- ExportPreset::Master => "HEVC · MP4 · high quality — intra-only, for re-editing later",
186- ExportPreset::AudioOnly => "FLAC — lossless sound, no picture",
187- ExportPreset::Custom => "no fixed codec or quality",
188- }
189- }
190-
191- /// The format and quality this bundle sets, or `None` for `Custom` --
192- /// which changes nothing itself, it only opens the pane where the two are
193- /// set apart.
194- pub(crate) fn bundle(self) -> Option<(Format, Quality)> {
195- match self {
196- ExportPreset::Web => Some((Format::Mp4, Quality::Medium)),
197- ExportPreset::Small => Some((Format::Av1Mp4, Quality::Low)),
198- // HEVC, not H.264: a master is for cutting again later, and HEVC's
199- // intra-only rows say why that is the one that keeps its promise --
200- // every frame already a cut point, where H.264's are not.
201- ExportPreset::Master => Some((Format::HevcMp4, Quality::High)),
202- ExportPreset::AudioOnly => Some((Format::Flac, Quality::Auto)),
203- ExportPreset::Custom => None,
204- }
205- }
206-
207- /// Which bundle the card's current format and quality already are, or
208- /// `Custom` where they match none of them -- so the primary pane always
209- /// says something true about what is actually going to be written rather
210- /// than defaulting to a bundle nobody picked.
211- pub(crate) fn from_state(format: Format, quality: Quality) -> ExportPreset {
212- ExportPreset::ALL
213- .into_iter()
214- .find(|p| p.bundle() == Some((format, quality)))
215- .unwrap_or(ExportPreset::Custom)
216- }
217-}
218-
219 /// The export card's format rows: the key that picks one, its name, and what it69 /// The export card's format rows: the key that picks one, its name, and what it
220 /// writes -- or, where this program cannot write it, the reason it cannot. A70 /// writes -- or, where this program cannot write it, the reason it cannot. A
221 /// format with no entry at all would read as an oversight, and a menu of three71 /// format with no entry at all would read as an oversight, and a menu of three
@@ -273,6 +123,10 @@ pub(crate) const FORMATS: [(&[Format], &str, &str, &str); 8] = [
273 123
274 /// The boxes one codec may be written into, in the order its container row124 /// The boxes one codec may be written into, in the order its container row
275 /// cycles them. Empty for a codec this program cannot write at all.125 /// cycles them. Empty for a codec this program cannot write at all.
126+/// Not on the export moment any more: the Settings surface is what shows
127+/// this (`ui::settings_stance`). Kept and named rather than deleted -- the
128+/// state and its setter are the same ones the moment used to drive.
129+#[allow(dead_code)]
276 pub(crate) fn containers(format: Format) -> &'static [Format] {130 pub(crate) fn containers(format: Format) -> &'static [Format] {
277 FORMATS131 FORMATS
278 .into_iter()132 .into_iter()
@@ -284,6 +138,10 @@ pub(crate) fn containers(format: Format) -> &'static [Format] {
284 /// This row's format under the container `current` is already in, or the row's138 /// This row's format under the container `current` is already in, or the row's
285 /// first when it has no such box: an AV1 picked from a WAV lands in Matroska,139 /// first when it has no such box: an AV1 picked from a WAV lands in Matroska,
286 /// and picked from an mp4 stays in the mp4.140 /// and picked from an mp4 stays in the mp4.
141+/// Not on the export moment any more: the Settings surface is what shows
142+/// this (`ui::settings_stance`). Kept and named rather than deleted -- the
143+/// state and its setter are the same ones the moment used to drive.
144+#[allow(dead_code)]
287 pub(crate) fn same_box(row: &[Format], current: Format) -> Option<Format> {145 pub(crate) fn same_box(row: &[Format], current: Format) -> Option<Format> {
288 row.iter()146 row.iter()
289 .copied()147 .copied()
@@ -294,6 +152,10 @@ pub(crate) fn same_box(row: &[Format], current: Format) -> Option<Format> {
294 /// The next box for the same codec, wrapping -- what the container row's key152 /// The next box for the same codec, wrapping -- what the container row's key
295 /// does. The format itself for a codec with only one, so the stroke cannot153 /// does. The format itself for a codec with only one, so the stroke cannot
296 /// change what it is not offering.154 /// change what it is not offering.
155+/// Not on the export moment any more: the Settings surface is what shows
156+/// this (`ui::settings_stance`). Kept and named rather than deleted -- the
157+/// state and its setter are the same ones the moment used to drive.
158+#[allow(dead_code)]
297 pub(crate) fn next_container(format: Format) -> Format {159 pub(crate) fn next_container(format: Format) -> Format {
298 let row = containers(format);160 let row = containers(format);
299 let at = row.iter().position(|&f| f == format).unwrap_or(0);161 let at = row.iter().position(|&f| f == format).unwrap_or(0);
@@ -302,26 +164,6 @@ pub(crate) fn next_container(format: Format) -> Format {
302 .unwrap_or(format)164 .unwrap_or(format)
303 }165 }
304 166
305-/// Why the quality rows say nothing about this format, or `None` where they
306-/// decide the picture. Only a picture encoder is given a bitrate here: the two
307-/// lossless audio formats have none to give and MP3 is written at one fixed
308-/// figure, so a live row over either would be a control that changes nothing.
309-pub(crate) fn bitrate_refusal(format: Format) -> Option<&'static str> {
310- match format {
311- Format::Wav | Format::Flac => Some("lossless audio — no bitrate to pick"),
312- Format::Mp3 => Some("sound only — its rate is the Sound row"),
313- // The guard is the question and not a list of names: an audio format
314- // added without a line of its own above would otherwise show live
315- // quality rows over a file that has no picture to spend a bitrate on.
316- // OGG is exactly that format -- and it wants this sentence rather than
317- // one of its own, because its *Sound* row already says the Vorbis half
318- // ("quality-coded — Vorbis holds no rate to pick") and two rows saying
319- // the same thing is one of them wasted.
320- _ if !format.has_video() => Some("sound only — no picture to spend a bitrate on"),
321- _ => None,
322- }
323-}
324-
325 /// What one of the colour card's own strokes does. Its keys are card-local --167 /// What one of the colour card's own strokes does. Its keys are card-local --
326 /// they mean nothing outside it -- so they are a table here rather than keymap168 /// they mean nothing outside it -- so they are a table here rather than keymap
327 /// bindings, exactly as the export card's format initials are. Listed in169 /// bindings, exactly as the export card's format initials are. Listed in
@@ -680,6 +522,10 @@ pub(crate) fn encoder_choices(current: EncoderSeat) -> Vec<ChoiceRow> {
680 /// vendored AV1 encoder (2026-08-10), so the pick is theirs to make and the522 /// vendored AV1 encoder (2026-08-10), so the pick is theirs to make and the
681 /// risk is theirs to be told about. `None` for every other pair, which is what523 /// risk is theirs to be told about. `None` for every other pair, which is what
682 /// keeps this from becoming a row nobody reads.524 /// keeps this from becoming a row nobody reads.
525+/// Not on the export moment any more: the Settings surface is what shows
526+/// this (`ui::settings_stance`). Kept and named rather than deleted -- the
527+/// state and its setter are the same ones the moment used to drive.
528+#[allow(dead_code)]
683 pub(crate) fn av1_hw_warning(format: Format, seat: EncoderSeat) -> Option<&'static str> {529 pub(crate) fn av1_hw_warning(format: Format, seat: EncoderSeat) -> Option<&'static str> {
684 (seat == EncoderSeat::Hardware && matches!(format, Format::Av1 | Format::Av1Mp4))530 (seat == EncoderSeat::Hardware && matches!(format, Format::Av1 | Format::Av1Mp4))
685 .then_some("AV1 on the GPU reset this machine's driver once — Software is the safe seat")531 .then_some("AV1 on the GPU reset this machine's driver once — Software is the safe seat")
@@ -731,45 +577,6 @@ pub(crate) fn next_resolution(current: (u32, u32), native: (u32, u32)) -> (u32,
731 sizes[at.map_or(0, |at| (at + 1) % sizes.len())]577 sizes[at.map_or(0, |at| (at + 1) % sizes.len())]
732 }578 }
733 579
734-/// The first of the two lines the card keeps above its button: what will be
735-/// *inside* the file. [`format_line`]'s codec and box, then the project's own
736-/// picture size and rate -- which is what a video export is written at however
737-/// many sizes and rates the media on the timeline are -- and last what the
738-/// sound will be, or that there is none. Every field here is one `ffprobe`
739-/// reads back off the finished file, so the line is checkable rather than a
740-/// promise.
741-pub(crate) fn summary_head(
742- format: Format,
743- picture: Option<((u32, u32), f64)>,
744- audio: &str,
745-) -> String {
746- let line = match picture.filter(|_| format.has_video()) {
747- Some(((w, h), fps)) => {
748- format!("{} · {w}x{h} · {} fps", format_line(format), fps_label(fps))
749- }
750- None => format_line(format).to_string(),
751- };
752- join_detail(&line, audio)
753-}
754-
755-/// The second: where it lands, roughly how big, and what will encode the
756-/// picture -- the seat as the probe found it (`…` until it lands, never a
757-/// guess), which is what the running export then names on its progress line.
758-pub(crate) fn summary_tail(
759- path: &Path,
760- bytes: Option<u64>,
761- seat: Option<&'static str>,
762- video: bool,
763-) -> String {
764- let size = bytes.map_or_else(String::new, |bytes| format!("≈ {}", size_label(bytes)));
765- let seat = match (video, seat) {
766- (true, Some(seat)) => seat,
767- (true, None) => "encoder …",
768- (false, _) => "",
769- };
770- join_detail(&join_detail(&file_name(path), &size), seat)
771-}
772-
773 /// A frame rate as a person writes it: `30`, not `30.000`, and `23.976` for the580 /// A frame rate as a person writes it: `30`, not `30.000`, and `23.976` for the
774 /// rate that is a ratio.581 /// rate that is a ratio.
775 pub(crate) fn fps_label(fps: f64) -> String {582 pub(crate) fn fps_label(fps: f64) -> String {
@@ -782,48 +589,26 @@ pub(crate) fn fps_label(fps: f64) -> String {
782 }589 }
783 }590 }
784 591
785-/// About how big a *chosen* bitrate makes the file: the picture's bits over the592+/// About how big the budget makes the file: every bit that is written --
786-/// timeline's length, in bytes -- the unit the line is written in is593+/// the picture's rate and the sound's -- over the exported range, in bytes.
787-/// [`size_label`]'s to pick. `None` for `Auto`, whose figure is the encoder's to594+/// The container's own overhead is not in it, which is why the row says "≈".
788-/// decide, and for a format with no bitrate at all -- a number nobody picked is595+pub(crate) fn estimated_bytes(bps: u64, seconds: f64) -> u64 {
789-/// not an estimate. The sound and the container's own overhead are not in it,596+ ((bps as f64) * seconds.max(0.) / 8.).round() as u64
790-/// which is why the card says "≈".
791-pub(crate) fn estimated_bytes(bitrate: Option<u64>, duration: f64) -> Option<u64> {
792- let bitrate = bitrate.filter(|&b| b > 0 && duration > 0.)?;
793- Some((bitrate as f64 * duration / 8.).round() as u64)
794 }597 }
795 598
796-/// A size in the largest unit that can state it, [`rate_scale`]'s rule:599+/// A size as the budget row says it: gigabytes with two decimals once the
797-/// megabytes for an export of any length, kilobytes below the one a whole600+/// file is one, whole megabytes under that. Never a decimal megabyte -- the
798-/// megabyte rounds away. A three second clip at the floor bitrate really is601+/// estimate is an "≈" and a tenth of a megabyte is precision it does not have.
799-/// 375 kB, and "≈ 0 MB" would be this line saying the file it is about to write
800-/// is empty -- the one thing the size field is there to deny. Never "0 kB"
801-/// either: an estimate that exists is at least a kilobyte of file.
802 pub(crate) fn size_label(bytes: u64) -> String {602 pub(crate) fn size_label(bytes: u64) -> String {
803- match (bytes as f64 / 1e6).round() as u64 {603+ match bytes >= 1_000_000_000 {
804- 0 => format!("{} kB", (bytes as f64 / 1e3).round().max(1.) as u64),604+ true => format!("{:.2} GB", bytes as f64 / 1e9),
805- mb => format!("{mb} MB"),605+ false => format!("{} MB", (bytes as f64 / 1e6).round() as u64),
806 }606 }
807 }607 }
808 608
809-/// What is in the file and what box it is in, which is the head of the summary.609+/// The budget itself, in Mbps to one decimal: the number the lever reads.
810-/// Terse on purpose: the fields after it (size, rate, sound) are what the line610+pub(crate) fn rate_label(bps: u64) -> String {
811-/// is *for*, and a head that spent its width on prose used to push the whole611+ format!("{:.1}", bps as f64 / 1e6)
812-/// summary onto a second line -- what each codec means is on its row.
813-pub(crate) fn format_line(format: Format) -> &'static str {
814- match format {
815- Format::Mp4 => "H.264 · MP4",
816- Format::Av1 => "AV1 · MKV",
817- Format::Av1Mp4 => "AV1 · MP4",
818- Format::Hevc => "HEVC intra · MKV",
819- Format::HevcMp4 => "HEVC intra · MP4",
820- // The three whose codec *is* their box: naming it twice would be the
821- // only field on this line that says nothing.
822- Format::Wav => "16-bit PCM · WAV",
823- Format::Flac => "FLAC · lossless",
824- Format::Mp3 => "MP3 · lossy",
825- Format::Ogg => "Vorbis · OGG",
826- }
827 }612 }
828 613
829 /// The row a format is picked by, which is what a refusal calls it: the codec,614 /// The row a format is picked by, which is what a refusal calls it: the codec,
@@ -845,77 +630,127 @@ pub(crate) fn retarget(path: &std::path::Path, format: Format) -> PathBuf {
845 path630 path
846 }631 }
847 632
848-/// The card's rows as the engine takes them. `Auto` leaves the bitrate to the633+/// The moment's one number as the engine takes it. The budget is always
849-/// exporter, which derives it from the picture; the fixed rows are figures that634+/// explicit now -- the lever opens on the engine's own automatic figure
850-/// hold from 720p to 1080p, and a typed one is passed exactly as typed -- the635+/// ([`auto_bps`]) rather than on nothing, so there is no "Auto" left to send
851-/// engine clamps every explicit bitrate to 1..50 Mbps (`MAX_EXPLICIT_BITRATE`), so this636+/// as `None` -- and the engine clamps it to `MIN_BITRATE..MAX_EXPLICIT_BITRATE`
852-/// must not clamp it a second time and disagree about where the edge is.637+/// exactly where [`BPS_MIN`]/[`BPS_MAX`] do, so neither can disagree about the
638+/// edges.
853 ///639 ///
854 /// The bitrate travels even for an audio format, where the engine ignores it:640 /// The bitrate travels even for an audio format, where the engine ignores it:
855-/// one settings value, and a row the card has dimmed cannot have been changed.641+/// one settings value, and a row the moment does not show cannot have been
642+/// changed.
856 pub(crate) fn export_settings(643 pub(crate) fn export_settings(
857- quality: Quality,644+ bitrate: u64,
858- custom_mbps: u32,
859 format: Format,645 format: Format,
860 audio_kbps: u32,646 audio_kbps: u32,
861 seat: EncoderSeat,647 seat: EncoderSeat,
862 ) -> ExportSettings {648 ) -> ExportSettings {
863 ExportSettings {649 ExportSettings {
864 format,650 format,
865- // Always travels, exactly as the picture's bitrate does above: the
866- // engine ignores it where nothing encodes the sound, and a row the card
867- // has dimmed cannot have been changed.
868 audio_kbps: Some(audio_kbps),651 audio_kbps: Some(audio_kbps),
869- bitrate: match quality {652+ bitrate: Some(bitrate),
870- // A copied span carries its source's own bits, and a fallback653+ // The copy path (the old `Quality::Exact`) is off this surface: the
871- // re-encode -- the only case `bitrate` reaches an encoder under654+ // moment is one budget, and a copy is the absence of one.
872- // Exact -- is the automatic figure ([`engine::export::run`]),655+ // `engine::export` keeps the path and its own tests; nothing in the
873- // not a preset's, so this asks for neither.656+ // app asks for it.
874- Quality::Exact | Quality::Auto => None,657+ exact: false,
875- Quality::Low => Some(2_000_000),
876- Quality::Medium => Some(6_000_000),
877- Quality::High => Some(12_000_000),
878- Quality::Custom => Some(u64::from(custom_mbps) * 1_000_000),
879- },
880- exact: quality == Quality::Exact,
881- // The card's own row now ([`encoder_choices`]), kept with the project:
882- // it was a `VE_SW_ENC` env pin and nothing else, which is a switch
883- // nobody exporting a film would ever find.
884 seat,658 seat,
885- // The picked track is put on by `start_export`, which is the only
886- // caller that writes a file; the rest of them are asking about the
887- // bitrate and the format.
888 subtitles: Vec::new(),659 subtitles: Vec::new(),
889- // Neither is a delivery setting: both belong to the stand-ins
890- // [`engine::proxy`] writes -- every frame a key frame costs bits
891- // nobody delivering wants, and a file kept in its source's colour
892- // space is one for this editor to read back rather than to hand
893- // anybody.
894 intra_only: false,660 intra_only: false,
895 keep_source_colour: false,661 keep_source_colour: false,
896- // Set by `start_export`, which knows the player's mark; this helper is
897- // also asked for the estimate alone, which has no range to give.
898 range: None,662 range: None,
899 }663 }
900 }664 }
901 665
902-/// What the engine will code an explicit bitrate at, in whole Mbps: outside666+/// The budget's bounds, the engine's own (`engine::export`'s `MIN_BITRATE`
903-/// this it clamps (`export.rs` `MIN_BITRATE`/`MAX_EXPLICIT_BITRATE`), so a667+/// and `MAX_EXPLICIT_BITRATE`): a number outside them would be written as a
904-/// number typed past either end would be written as a different one. The field668+/// different one, so the lever and the field clamp to exactly these.
905-/// refuses it instead of clamping quietly -- a card that changes the user's669+pub(crate) const BPS_MIN: u64 = 1_000_000;
906-/// number without saying so is the one thing a field like this must never do.670+pub(crate) const BPS_MAX: u64 = 50_000_000;
671+
672+/// A wheel notch, and a notch with shift held: 0.1 and 1 Mbps. Fifty presses
673+/// is not a way across this range, and a tenth is the smallest step the row's
674+/// own readout can show.
675+pub(crate) const BPS_FINE: u64 = 100_000;
676+pub(crate) const BPS_COARSE: u64 = 1_000_000;
677+
678+/// The engine's automatic figure for a picture of this size and rate
679+/// (`engine::export`'s `BITS_PER_PIXEL` rule and the range it clamps the
680+/// derived number into), which is what the lever opens on before anybody has
681+/// chosen: a budget row reading 0 Mbps -- the old `custom_mbps: 0` default --
682+/// was a promise to write an empty file.
683+const BITS_PER_PIXEL: f64 = 0.1;
684+const BPS_AUTO_MAX: u64 = 20_000_000;
685+
686+pub(crate) fn auto_bps(width: u32, height: u32, fps: f64) -> u64 {
687+ let raw = f64::from(width) * f64::from(height) * fps * BITS_PER_PIXEL;
688+ (raw as u64).clamp(BPS_MIN, BPS_AUTO_MAX)
689+}
690+
691+/// What was typed into the budget field, as a rate. Four ways to say one:
692+/// `850k` and `6.5M` are rates in their own units, a bare `6.5` is Mbps (the
693+/// unit the row reads in), and `1.2G` is a *file size* -- the one thing a
694+/// person actually wants to hit -- converted through the exported range and
695+/// the sound's own rate into the picture rate that lands there.
907 ///696 ///
908-/// The ceiling was 20, which was never a limit of any encoder here: it was the697+/// Clamped to the engine's bounds rather than refused: the moment shows the
909-/// top of the range the exporter *derives* an automatic bitrate in, borrowed as698+/// parsed number immediately, so a clamp is visible in the same keystroke.
910-/// the cap on a typed one. A 1080p master or a 4K edit wants more than that, so699+/// `None` is only ever "that is not a number".
911-/// the asked-for rate has its own ceiling now and this is it.700+pub(crate) fn parse_budget(text: &str, seconds: f64, audio_bps: u64) -> Option<u64> {
912-pub(crate) const MBPS_MIN: u32 = 1;701+ let text = text.trim().to_ascii_lowercase();
913-pub(crate) const MBPS_MAX: u32 = 50;702+ let text = text.trim_end_matches("bps").trim_end_matches('b').trim_end();
914-703+ let (digits, unit) = match text.chars().last()? {
915-/// How many digits the field takes. Two reach the ceiling; the third is there so704+ c @ ('k' | 'm' | 'g') => (&text[..text.len() - c.len_utf8()], c),
916-/// a number *past* it can be typed whole and refused in its own words, rather705+ _ => (text, 'm'),
917-/// than being dropped keystroke by keystroke.706+ };
918-pub(crate) const MBPS_DIGITS: usize = 3;707+ let n: f64 = digits.trim().parse().ok()?;
708+ if !n.is_finite() || n <= 0. {
709+ return None;
710+ }
711+ let bps = match unit {
712+ 'k' => n * 1e3,
713+ 'm' => n * 1e6,
714+ _ => {
715+ if seconds <= 0. {
716+ return None;
717+ }
718+ (n * 1e9 * 8. / seconds) - audio_bps as f64
719+ }
720+ };
721+ Some((bps.max(0.) as u64).clamp(BPS_MIN, BPS_MAX))
722+}
723+
724+/// The faintest line on the moment: what the export resolved to on its own --
725+/// the codec, the sound, whether it is the whole film or the marked span, and
726+/// which seat writes the picture. A readout, never a control: everything in it
727+/// is set in Settings now.
728+pub(crate) fn plan_line(
729+ format: Format,
730+ audio: &str,
731+ marks: Option<&str>,
732+ hardware: bool,
733+) -> String {
734+ let mut parts: Vec<String> = Vec::new();
735+ if format.has_video() {
736+ parts.push(format_label(format).to_string());
737+ }
738+ if !audio.is_empty() {
739+ parts.push(audio.to_string());
740+ }
741+ parts.push(match (marks, format.has_video()) {
742+ (Some(marks), _) => format!("marks {marks}"),
743+ (None, true) => "whole film".to_string(),
744+ (None, false) => "sound only".to_string(),
745+ });
746+ if format.has_video() {
747+ parts.push(match hardware {
748+ true => "GPU".to_string(),
749+ false => "SW".to_string(),
750+ });
751+ }
752+ parts.join(" · ")
753+}
919 754
920 /// A clip's share of the lane. A timeline with no length reads as one full-width755 /// A clip's share of the lane. A timeline with no length reads as one full-width
921 /// box rather than as NaN, which gpui would carry into layout.756 /// box rather than as NaN, which gpui would carry into layout.
@@ -932,41 +767,6 @@ pub(crate) const MBPS_DIGITS: usize = 3;
932 /// cannot say what the timeline says (`export::copy_audio`), so none of them is767 /// cannot say what the timeline says (`export::copy_audio`), so none of them is
933 /// a refusal any more -- and every video format carries the sound, so there is768 /// a refusal any more -- and every video format carries the sound, so there is
934 /// nothing here that is one format's alone.769 /// nothing here that is one format's alone.
935-/// Why the Exact row would refuse this project's own picked format right
936-/// now, asked before the button is pressed rather than minutes into a
937-/// worker -- [`engine::export::exact_refusal`] is the same gate `start`
938-/// checks again, so a caller here and the worker can never disagree about
939-/// whether Exact is honoured. `None` for every quality but `Exact` itself,
940-/// since nothing else has anything to refuse.
941-pub(crate) fn exact_refusal(
942- session: &PlaybackSession,
943- format: Format,
944- quality: Quality,
945-) -> Option<String> {
946- if quality != Quality::Exact {
947- return None;
948- }
949- let (project, meta) = session.export_snapshot();
950- let settings = export_settings(quality, 0, format, DEFAULT_AUDIO_KBPS, EncoderSeat::Auto);
951- engine::export::exact_refusal(&project, &meta, &settings)
952-}
953-
954-/// Which format picking Exact should set, from the source's own codec --
955-/// "the input's own quality" means the input's own codec, so this is what
956-/// `Player::pick_quality` derives the format from rather than leaving
957-/// whatever format a previous pick left behind. `None` for a codec Exact has
958-/// no copy path for at all (h264); the row itself still refuses through
959-/// [`exact_refusal`] in that case, since a mixed-source project can fail the
960-/// same way after the format is set.
961-pub(crate) fn exact_format(session: &PlaybackSession) -> Option<Format> {
962- let (_, meta) = session.export_snapshot();
963- match meta.codec {
964- engine::demux::Codec::Hevc => Some(Format::Hevc),
965- engine::demux::Codec::Av1 => Some(Format::Av1),
966- _ => None,
967- }
968-}
969-
970 pub(crate) fn format_refusal(session: &PlaybackSession, format: Format) -> Option<String> {770 pub(crate) fn format_refusal(session: &PlaybackSession, format: Format) -> Option<String> {
971 if !format.has_video() {771 if !format.has_video() {
972 return None;772 return None;
crates/app/src/keymap.rsmodified+13 -130
@@ -613,31 +613,7 @@ pub enum Reach {
613 Gesture,613 Gesture,
614 }614 }
615 615
616-/// The codec row's keys, from the export card's own table. Typed out here once,616+pub static FIXED: std::sync::LazyLock<[Fixed; 27]> = std::sync::LazyLock::new(|| {
617-/// it named six of the seven codecs the same row's label advertised -- OGG had
618-/// a key (`o`) that this card never said.
619-fn codec_chord() -> String {
620- crate::FORMATS
621- .iter()
622- .map(|(_, stroke, ..)| *stroke)
623- .filter(|stroke| !stroke.is_empty())
624- .collect::<Vec<_>>()
625- .join(" / ")
626-}
627-
628-/// The preset row's keys, from [`crate::ExportPreset::key`] -- `Custom`
629-/// excepted, which shares Advanced's own `s` and so is that row's line, not a
630-/// second one here.
631-fn preset_chord() -> String {
632- crate::ExportPreset::ALL
633- .into_iter()
634- .filter(|p| *p != crate::ExportPreset::Custom)
635- .map(|p| p.key())
636- .collect::<Vec<_>>()
637- .join(" / ")
638-}
639-
640-pub static FIXED: std::sync::LazyLock<[Fixed; 35]> = std::sync::LazyLock::new(|| {
641 [617 [
642 // Not a chord at all but a way of pressing one, and the only place the618 // Not a chord at all but a way of pressing one, and the only place the
643 // editor can say so: holding a key that moves a *value* runs it, and619 // editor can say so: holding a key that moves a *value* runs it, and
@@ -665,50 +641,27 @@ pub static FIXED: std::sync::LazyLock<[Fixed; 35]> = std::sync::LazyLock::new(||
665 },641 },
666 Fixed {642 Fixed {
667 chord: "n".into(),643 chord: "n".into(),
668- label: "Open the custom export bitrate field — ↑↓ step it",644+ label: "Say the export budget: 850k, 6.5M, 6.5 or 1.2G of file",
669- category: Category::File,
670- reach: Reach::Click("quality"),
671- },
672- Fixed {
673- chord: "0–9".into(),
674- label: "Type into that field — nothing outside it",
675- category: Category::File,
676- reach: Reach::Click("mbps-up"),
677- },
678- Fixed {
679- chord: codec_chord(),
680- label: "Pick the export codec: H.264, AV1, HEVC, WAV, FLAC, MP3 or OGG",
681- category: Category::File,
682- reach: Reach::Click("format"),
683- },
684- // The rest of the export card's own rows, each on the letter its row is
685- // named after. They shadow the clip keys of the same letter while the card
686- // is up, exactly as its digits shadow nothing and its arrows would: a modal
687- // card owns the keyboard, and cutting a clip under it is not a thing that
688- // can happen anyway.
689- Fixed {
690- chord: "c".into(),
691- label: "Switch the export container: Matroska or MP4",
692 category: Category::File,645 category: Category::File,
693- reach: Reach::Click("container"),646+ reach: Reach::Click("budget"),
694 },647 },
695 Fixed {648 Fixed {
696- chord: "q".into(),649+ chord: "− / + / ← →".into(),
697- label: "Step through the export quality rows",650+ label: "Move the export budget — shift steps whole megabits",
698 category: Category::File,651 category: Category::File,
699- reach: Reach::Click("quality"),652+ reach: Reach::Click("budget-track"),
700 },653 },
701 Fixed {654 Fixed {
702- chord: "b".into(),655+ chord: "0–9".into(),
703- label: "Step through the export sound bitrates",656+ label: "Type into an open field — the budget, or a clip's duration",
704 category: Category::File,657 category: Category::File,
705- reach: Reach::Click("sound"),658+ reach: Reach::Click("budget"),
706 },659 },
707 Fixed {660 Fixed {
708- chord: "e".into(),661+ chord: "backspace".into(),
709- label: "Step the export encoder seat: Auto, Hardware or Software",662+ label: "Erase a character in the budget or duration field",
710 category: Category::File,663 category: Category::File,
711- reach: Reach::Click("encoder"),664+ reach: Reach::Click("budget"),
712 },665 },
713 Fixed {666 Fixed {
714 chord: "d".into(),667 chord: "d".into(),
@@ -716,42 +669,12 @@ pub static FIXED: std::sync::LazyLock<[Fixed; 35]> = std::sync::LazyLock::new(||
716 category: Category::File,669 category: Category::File,
717 reach: Reach::Click("destination"),670 reach: Reach::Click("destination"),
718 },671 },
719- Fixed {
720- chord: preset_chord(),
721- label: "Pick an export bundle: Web, Small file, Master or Audio only",
722- category: Category::File,
723- reach: Reach::Click("preset"),
724- },
725- Fixed {
726- chord: "s".into(),
727- label: "Export card: open or close the Advanced pane",
728- category: Category::File,
729- reach: Reach::Click("export-advanced"),
730- },
731- Fixed {
732- chord: "g".into(),
733- label: "Export card: sections or one flat list",
734- category: Category::File,
735- reach: Reach::Click("export-layout"),
736- },
737- Fixed {
738- chord: "r".into(),
739- label: "Export card: the formats with no encoder as rows or as one line",
740- category: Category::File,
741- reach: Reach::Click("export-refusals"),
742- },
743 Fixed {672 Fixed {
744 chord: "enter".into(),673 chord: "enter".into(),
745- label: "Start the export — or commit the bitrate field",674+ label: "Start the export — or take the budget being typed",
746 category: Category::File,675 category: Category::File,
747 reach: Reach::Click("export-confirm"),676 reach: Reach::Click("export-confirm"),
748 },677 },
749- Fixed {
750- chord: "backspace".into(),
751- label: "Erase a digit in the bitrate field",
752- category: Category::File,
753- reach: Reach::Click("mbps-down"),
754- },
755 // The equalizer card's own input, for the same reason the export card has678 // The equalizer card's own input, for the same reason the export card has
756 // its own: a band nothing but a drag can reach is a band half the users of679 // its own: a band nothing but a drag can reach is a band half the users of
757 // this editor cannot move at all. Card-local, so none of them is bindable.680 // this editor cannot move at all. Card-local, so none of them is bindable.
@@ -1772,46 +1695,6 @@ mod tests {
1772 assert_eq!(whole("edith-keys 1\n").chord(ActionId::Cut), "--");1695 assert_eq!(whole("edith-keys 1\n").chord(ActionId::Cut), "--");
1773 }1696 }
1774 1697
1775- /// The one row of [`FIXED`] that speaks for a whole table elsewhere: it
1776- /// named six keys for seven codecs, and OGG's `o` was a stroke the card
1777- /// never mentioned. The chord is generated from `FORMATS` now, and this
1778- /// holds the *label* to the same table -- a codec added there with no name
1779- /// in this row fails here rather than in a user's hands.
1780- #[test]
1781- fn the_codec_row_says_every_codec_the_export_card_offers() {
1782- let row = super::FIXED
1783- .iter()
1784- .find(|f| f.label.starts_with("Pick the export codec"))
1785- .expect("the codec row");
1786- let keys: Vec<&str> = row.chord.split(" / ").collect();
1787- for (boxes, stroke, label, _) in crate::FORMATS {
1788- if stroke.is_empty() {
1789- // A codec this program cannot write at all has no key and no
1790- // business in this row.
1791- assert!(boxes.is_empty(), "{label} has a box but no stroke");
1792- assert!(!keys.contains(&stroke));
1793- continue;
1794- }
1795- assert!(
1796- keys.contains(&stroke),
1797- "{label}'s key {stroke:?} is not in {:?}",
1798- row.chord
1799- );
1800- assert!(
1801- row.label.contains(label),
1802- "{label} is not named in {:?}",
1803- row.label
1804- );
1805- }
1806- assert_eq!(
1807- keys.len(),
1808- crate::FORMATS
1809- .iter()
1810- .filter(|(_, s, ..)| !s.is_empty())
1811- .count()
1812- );
1813- }
1814-
1815 #[test]1698 #[test]
1816 fn a_saved_keymap_comes_back_off_the_disk() {1699 fn a_saved_keymap_comes_back_off_the_disk() {
1817 // Its own directory, never the real config one: this test writes.1700 // Its own directory, never the real config one: this test writes.
crates/app/src/layout.rsmodified+8 -3
@@ -78,10 +78,14 @@ pub(crate) const KEYS_ROW_H: f32 = HIT_MIN;
78 /// the whole file. At `KEYS_W` every one of those wrapped to two lines, which is78 /// the whole file. At `KEYS_W` every one of those wrapped to two lines, which is
79 /// the card the user called unfriendly. Still inside the 640 px floor with the79 /// the card the user called unfriendly. Still inside the 640 px floor with the
80 /// scrim showing either side of it.80 /// scrim showing either side of it.
81+/// The export moment's height (the approved artboard's 200px): three rows,
82+/// never a scroll -- the card it replaced grew a capped, scrolling list.
83+pub(crate) const EXPORT_MOMENT_H: f32 = 200.;
84+
81 pub(crate) const EXPORT_W: f32 = 420.;85 pub(crate) const EXPORT_W: f32 = 420.;
82-/// The column the key of a row is printed in, wide enough for `0–9`: every row86+
83-/// in the export card says what picks it, so the card is drivable by keyboard87+/// The column a key is printed in, wide enough for `0-9` -- the width the
84-/// without a legend to memorise.88+/// subtitle plan line is still measured against ([`SUB_PLAN_CHARS`]).
85 pub(crate) const EXPORT_KEY_W: f32 = 26.;89 pub(crate) const EXPORT_KEY_W: f32 = 26.;
86 /// The menu a right-click on a clip opens: wide enough for the longest label90 /// The menu a right-click on a clip opens: wide enough for the longest label
87 /// beside the stroke that does the same thing, with the click targets `HIT_MIN`91 /// beside the stroke that does the same thing, with the click targets `HIT_MIN`
@@ -128,6 +132,7 @@ pub(crate) const LIST_CHAR_W: f32 = 6.;
128 /// in front of the value. Not a track count -- what walks the Destination row132 /// in front of the value. Not a track count -- what walks the Destination row
129 /// off the bottom of the card is the *wrapping*, and thirty-five one-word133 /// off the bottom of the card is the *wrapping*, and thirty-five one-word
130 /// labels wrap less than three long ones.134 /// labels wrap less than three long ones.
135+#[allow(dead_code)] // the subtitle plan line lives in Settings now
131 pub(crate) const SUB_PLAN_CHARS: usize = (3.136 pub(crate) const SUB_PLAN_CHARS: usize = (3.
132 * (EXPORT_W - 12. - 12. - (10. + 8. + EXPORT_KEY_W + 8. + 9. * LIST_CHAR_W))137 * (EXPORT_W - 12. - 12. - (10. + 8. + EXPORT_KEY_W + 8. + 9. * LIST_CHAR_W))
133 / LIST_CHAR_W) as usize;138 / LIST_CHAR_W) as usize;
crates/app/src/main.rsmodified+22 -41
@@ -539,36 +539,22 @@ struct Player {
539 /// time -- opening either closes the other, since both are the whole window539 /// time -- opening either closes the other, since both are the whole window
540 /// and two stacked scrims say nothing about which one is listening.540 /// and two stacked scrims say nothing about which one is listening.
541 export_open: bool,541 export_open: bool,
542- /// How the card lays its rows out, and where the formats this program542+ /// The export budget, in bits per second -- the moment's one number, and
543- /// cannot write are said. Two shapes of the same card, kept behind `g` and543+ /// the only thing the encoder actually takes. Zero means nobody has
544- /// `r` so the choice between them can be made by looking at both rather544+ /// chosen: the lever then reads the engine's own automatic figure for
545- /// than by argument: sections with headers against one flat list, and a545+ /// this picture ([`Player::budget_bps`]), which is what keeps it off the
546- /// collapsed "cannot write" footer against a dimmed row each. The defaults546+ /// "0 Mbps" the old `custom_mbps: 0` default put on screen.
547- /// are grouped and collapsed -- the five dead rows used to eat the fold.547+ custom_bps: u64,
548- /// Not persisted: this is a look, not a setting.548+ /// The budget *while it is being typed*, or `None` when nobody is typing.
549- export_grouped: bool,549+ /// Free text and not digits: `850k`, `6.5M`, `6.5` and `1.2G` are all
550- export_refusals_inline: bool,550+ /// ways of saying one budget ([`parse_budget`]). Nothing on this surface
551- /// Whether the card's Advanced pane -- codec, container, quality,551+ /// takes gpui focus (the root keeps the keyboard), so the field is a
552- /// sound, encoder, subtitles, this machine -- is open under the primary552+ /// modal state on the player and the root's handler types into it.
553- /// pane's destination and preset rows. Closed by default: most exports553+ budget_edit: Option<String>,
554- /// are one of the bundled presets, and the fifteen-odd rows under them554+ /// The budget track's box, recorded at prepaint -- [`Self::color_bars`]'
555- /// are what a person who is not one of those goes looking for, kept555+ /// own reason: a mouse listener is handed the window position only, and
556- /// behind one row rather than eaten by the fold. Not persisted, like the556+ /// [`frac_along`] is what turns it into a rate.
557- /// two switches above it -- this is a look, not a setting.557+ budget_bar: Rc<Cell<Bounds<Pixels>>>,
558- export_advanced_open: bool,
559- /// Which quality row the card has picked, and the megabits typed against
560- /// the custom one. Kept across closes, so a second export offers what the
561- /// first one chose.
562- quality: Quality,
563- custom_mbps: u32,
564- /// The custom row's number *while it is being typed*, or `None` when nobody
565- /// is typing one. A field with a caret in it and not a key capture: digits
566- /// used to change the bitrate from anywhere in the card, with no caret to
567- /// say where they were landing and nothing to look at before the number
568- /// took effect. Nothing in this card takes gpui focus (the root keeps the
569- /// keyboard), so the field is a modal state on the player exactly as a
570- /// waiting rebind row is, and the root's handler is what types into it.
571- mbps_edit: Option<NumberEdit>,
572 /// The Clip tab's transition duration row, the same way (DEBT #111):558 /// The Clip tab's transition duration row, the same way (DEBT #111):
573 /// the anchor clip's frame count while it is being typed, `None` when559 /// the anchor clip's frame count while it is being typed, `None` when
574 /// nobody is. Opened on the row's own click, closed on the same field's560 /// nobody is. Opened on the row's own click, closed on the same field's
@@ -978,9 +964,6 @@ fn main() {
978 lanes_scroll: ScrollHandle::new(),964 lanes_scroll: ScrollHandle::new(),
979 eq_scroll: ScrollHandle::new(),965 eq_scroll: ScrollHandle::new(),
980 export_open: false,966 export_open: false,
981- export_grouped: true,
982- export_refusals_inline: false,
983- export_advanced_open: false,
984 eq_open: None,967 eq_open: None,
985 card_maximized: ui::dock_stance::load_maximized(),968 card_maximized: ui::dock_stance::load_maximized(),
986 // Replaced by the clip's own curve the moment the card969 // Replaced by the clip's own curve the moment the card
@@ -1030,14 +1013,12 @@ fn main() {
1030 // Empty until the first frame is pumped, which draws as a1013 // Empty until the first frame is pumped, which draws as a
1031 // flat line rather than as a shape nothing measured.1014 // flat line rather than as a shape nothing measured.
1032 histogram: [[0; HIST_BINS]; 3],1015 histogram: [[0; HIST_BINS]; 3],
1033- // What an export is until someone says otherwise: the Web1016+ // Nobody has chosen a budget yet, which is not the same
1034- // bundle, so `ExportPreset::from_state` opens on a real1017+ // as a budget of nothing: the lever opens on the engine's
1035- // preset rather than a `Custom` nobody picked -- `Auto`1018+ // own automatic figure for the picture that is open.
1036- // paired with `Format::default()`'s MP4 matched no bundle1019+ custom_bps: 0,
1037- // at all.1020+ budget_edit: None,
1038- quality: Quality::Medium,1021+ budget_bar: Rc::default(),
1039- custom_mbps: 0,
1040- mbps_edit: None,
1041 transition_edit: None,1022 transition_edit: None,
1042 // ...and the rate the sound has always been written at.1023 // ...and the rate the sound has always been written at.
1043 audio_kbps: DEFAULT_AUDIO_KBPS,1024 audio_kbps: DEFAULT_AUDIO_KBPS,
crates/app/src/menus.rsmodified+2 -0
@@ -70,6 +70,7 @@ pub(crate) enum Pick {
70 Fit(Lane, usize),70 Fit(Lane, usize),
71 /// What the export's *sound* is coded at. Opened from the card's Sound row,71 /// What the export's *sound* is coded at. Opened from the card's Sound row,
72 /// which is the only place it means anything.72 /// which is the only place it means anything.
73+ #[allow(dead_code)] // opened from Settings now
73 AudioRate,74 AudioRate,
74 /// Which HDR-to-SDR rendition the project is watched and exported in75 /// Which HDR-to-SDR rendition the project is watched and exported in
75 /// ([`engine::tonemap::Preset`]). Opened from the panel, beside the two76 /// ([`engine::tonemap::Preset`]). Opened from the panel, beside the two
@@ -82,6 +83,7 @@ pub(crate) enum Pick {
82 /// Which encoder an export writes the picture with83 /// Which encoder an export writes the picture with
83 /// ([`engine::export::EncoderSeat`]). Opened from the card's Encoder row,84 /// ([`engine::export::EncoderSeat`]). Opened from the card's Encoder row,
84 /// which is the only place it means anything.85 /// which is the only place it means anything.
86+ #[allow(dead_code)] // opened from Settings now
85 Encoder,87 Encoder,
86 }88 }
87 89
crates/app/src/player/actions.rsmodified+1 -1
@@ -443,7 +443,7 @@ impl Player {
443 // A number being typed is a value under the arrows, exactly as a card's443 // A number being typed is a value under the arrows, exactly as a card's
444 // slider is -- so a held arrow runs it. Asked before the export card444 // slider is -- so a held arrow runs it. Asked before the export card
445 // below, which otherwise repeats nothing.445 // below, which otherwise repeats nothing.
446- if self.mbps_edit.is_some() {446+ if self.budget_edit.is_some() {
447 Repeat::Card447 Repeat::Card
448 } else if self.keys_open || self.export_open || self.exporting().is_some() {448 } else if self.keys_open || self.export_open || self.exporting().is_some() {
449 Repeat::Nothing449 Repeat::Nothing
crates/app/src/player/cards.rsmodified+9 -26
@@ -1314,9 +1314,9 @@ impl Player {
1314 self.keys_open = false;1314 self.keys_open = false;
1315 self.settings_open = false;1315 self.settings_open = false;
1316 self.export_open = false;1316 self.export_open = false;
1317- // The two things typed *into* the export card go with it: a field left1317+ // The two things typed *into* the export moment go with it: a field
1318- // open would take the next keystroke for a card that is gone.1318+ // left open would take the next keystroke for a card that is gone.
1319- self.mbps_edit = None;1319+ self.budget_edit = None;
1320 self.picker = None;1320 self.picker = None;
1321 self.eq_open = None;1321 self.eq_open = None;
1322 self.eq_dragging = false;1322 self.eq_dragging = false;
@@ -1788,29 +1788,12 @@ impl Player {
1788 }1788 }
1789 return true;1789 return true;
1790 }1790 }
1791- // The export card's custom bitrate field: the mouse door is the1791+ // The export moment: its own chords, and every other stroke
1792- // steppers and the row's own click (`Player::edit_mbps`), but the1792+ // swallowed while it is up -- a chord this surface consumes must
1793- // `0–9`/backspace/enter/esc chords `keymap::FIXED` already1793+ // never also reach the room's keymap underneath it
1794- // advertises need a keyboard door too, or a hand with no mouse1794+ // ([`Player::export_moment_key`]).
1795- // could open the field and never fill it in.1795+ if self.export_moment_key(key, shift, cx) {
1796- if self.export_open {1796+ return true;
1797- if let Some(edit) = &mut self.mbps_edit {
1798- if key == ESCAPE {
1799- self.mbps_edit = None;
1800- } else if key == "enter" {
1801- if let Some(mbps) = edit.commit() {
1802- self.custom_mbps = mbps;
1803- self.mbps_edit = None;
1804- }
1805- } else if key == "backspace" {
1806- edit.backspace();
1807- } else if let Ok(digit) = key.parse::<u32>() {
1808- edit.digit(digit);
1809- } else {
1810- return false;
1811- }
1812- return true;
1813- }
1814 }1797 }
1815 false1798 false
1816 }1799 }
crates/app/src/player/export.rsmodified+132 -93
@@ -1,7 +1,6 @@
1 //! What is cached about the media and the machine, and the export the1 //! What is cached about the media and the machine, and the export the
2 //! two of them decide.2 //! two of them decide.
3 3
4-use crate::ui::widgets::NumberEdit;
5 use crate::*;4 use crate::*;
6 5
7 impl Player {6 impl Player {
@@ -353,8 +352,7 @@ impl Player {
353 return;352 return;
354 };353 };
355 let settings = export_settings(354 let settings = export_settings(
356- self.quality,355+ self.budget_bps(),
357- self.custom_mbps,
358 self.format,356 self.format,
359 self.audio_kbps,357 self.audio_kbps,
360 self.encoder_seat(),358 self.encoder_seat(),
@@ -460,18 +458,19 @@ impl Player {
460 // was waiting in. Nor may a half-typed number: the card opens on the458 // was waiting in. Nor may a half-typed number: the card opens on the
461 // bitrate it will write, never on digits left behind by a closed one.459 // bitrate it will write, never on digits left behind by a closed one.
462 self.keys_open = false;460 self.keys_open = false;
463- self.mbps_edit = None;461+ self.budget_edit = None;
464 cx.notify();462 cx.notify();
465 }463 }
466 464
467- /// A format row was clicked. The destination follows it at once -- a WAV465+ /// A format row, from Settings. The destination follows it at once -- a
468- /// written to a path ending in `.mp4` is a file every player will lie466+ /// WAV written to a path ending in `.mp4` is a file every player will lie
469- /// about -- keeping whatever stem the save dialog last left there. `false`467+ /// about -- keeping whatever stem the save dialog last left there.
470- /// on a refusal, so a caller that has more than the format to write (a468+ /// `false` on a refusal, so a caller with more than the format to write
471- /// preset's own quality) knows not to write the rest of it either.469+ /// knows not to write the rest of it either.
470+ #[allow(dead_code)] // shown by Settings now, not by the moment
472 pub(crate) fn set_format(&mut self, format: Format) -> bool {471 pub(crate) fn set_format(&mut self, format: Format) -> bool {
473- // The one door both the row and its initial go through, so a format the472+ // The one door both the row and its initial go through, so a format
474- // card greys out cannot be picked by keyboard either.473+ // the room greys out cannot be picked by keyboard either.
475 if let Some(why) = self474 if let Some(why) = self
476 .session475 .session
477 .as_ref()476 .as_ref()
@@ -485,46 +484,11 @@ impl Player {
485 true484 true
486 }485 }
487 486
488- /// A preset row, by click or by its own key. `Custom` opens the pane where
489- /// the codec and the quality are picked apart and changes nothing itself;
490- /// the rest are exactly the bundle they name -- and nothing at all on a
491- /// refusal, because [`set_format`](Self::set_format) already fired the
492- /// banner and a quality written after it declined would be a row that
493- /// looks picked over a format that was not.
494- pub(crate) fn pick_preset(&mut self, preset: ExportPreset) {
495- match preset.bundle() {
496- Some((format, quality)) => {
497- if self.set_format(format) {
498- self.quality = quality;
499- }
500- }
501- None => self.export_advanced_open = true,
502- }
503- }
504-
505- /// A quality row, by click or by its own key (`Custom` goes through
506- /// [`Self::edit_mbps`] instead). Exact is the one row that is also a
507- /// format decision -- "the input's own quality" means the input's own
508- /// codec, so picking it derives the container from the source rather
509- /// than leaving whatever format a previous pick left behind for
510- /// [`exact_refusal`] to refuse minutes later. A source this cannot copy
511- /// (h264, mixed sources) leaves the format alone; the row itself
512- /// ([`crate::ui::cards`]'s quality list) already says why.
513- pub(crate) fn pick_quality(&mut self, quality: Quality) {
514- self.quality = quality;
515- if quality != Quality::Exact {
516- return;
517- }
518- let Some(format) = self.session.as_ref().and_then(exact_format) else {
519- return;
520- };
521- self.set_format(format);
522- }
523-
524 /// The container row: the same codec in the other box, which retargets the487 /// The container row: the same codec in the other box, which retargets the
525 /// destination exactly as picking a codec does -- and does nothing at all488 /// destination exactly as picking a codec does -- and does nothing at all
526 /// for a codec with only one box, so the stroke cannot invent a choice the489 /// for a codec with only one box, so the stroke cannot invent a choice the
527 /// card is not offering.490 /// card is not offering.
491+ #[allow(dead_code)] // shown by Settings now, not by the moment
528 pub(crate) fn cycle_container(&mut self) {492 pub(crate) fn cycle_container(&mut self) {
529 self.set_format(next_container(self.format));493 self.set_format(next_container(self.format));
530 }494 }
@@ -561,51 +525,134 @@ impl Player {
561 }525 }
562 }526 }
563 527
564- /// The custom bitrate by pointer: the typed digits were the only control in528+ /// The budget in force: what was chosen, or -- before anybody has chosen
565- /// this card a mouse could not reach. Clamped to the range the row states529+ /// -- the engine's own automatic figure for the picture that is open
566- /// (the engine's own 1..50 Mbps), and picking the row is part of the step --530+ /// ([`auto_bps`], its `BITS_PER_PIXEL` rule). Never zero, which is the
567- /// a stepper that moves a number nobody is using would move nothing.531+ /// whole point: the lever it feeds is a promise about the file.
568- pub(crate) fn nudge_mbps(&mut self, step: i32) {532+ pub(crate) fn budget_bps(&self) -> u64 {
569- self.custom_mbps =533+ if self.custom_bps > 0 {
570- (self.custom_mbps as i32 + step).clamp(MBPS_MIN as i32, MBPS_MAX as i32) as u32;534+ return self.custom_bps;
571- self.quality = Quality::Custom;535+ }
536+ self.session.as_ref().map_or(BPS_MIN * 6, |s| {
537+ let (w, h) = s.resolution();
538+ auto_bps(w, h, s.meta().frame_rate)
539+ })
572 }540 }
573 541
574- /// The same number under the wheel, one step a notch, up for more: fifty542+ /// What the sound costs over the same span, in bits per second -- the
575- /// presses of a stepper is not a way to reach the top of this range, and the543+ /// other half of "how big is it": zero for a format that writes no sound
576- /// wheel is what this editor already moves a value with (the timeline's544+ /// and for a timeline that has none.
577- /// zoom and scroll are the same gesture). Hold-to-run stays the keyboard's,545+ pub(crate) fn audio_bps(&self) -> u64 {
578- /// as it is on every other card here -- a button that repeats while held is546+ match self.audio_rate_refusal().is_none() {
579- /// not a thing this program has.547+ true => u64::from(self.audio_kbps) * 1_000,
580- ///548+ false => 0,
581- /// It moves the *field* while one is open, exactly as ↑↓ do, so the two549+ }
582- /// ways in never disagree about which number is being changed.550+ }
583- pub(crate) fn wheel_mbps(&mut self, event: &ScrollWheelEvent) {551+
552+ /// How many seconds of film the export writes: the marked span where
553+ /// there is one, the whole timeline otherwise. The size on the budget row
554+ /// is this times the rate.
555+ pub(crate) fn export_seconds(&self) -> f64 {
556+ self.session.as_ref().map_or(0., |s| match self.range {
557+ Some((start, end)) => f64::from(end - start) / s.meta().frame_rate,
558+ None => s.timeline_duration(),
559+ })
560+ }
561+
562+ /// The lever by `steps` notches -- a tenth of a Mbps each, a whole Mbps
563+ /// with shift. Clamped to the engine's own bounds, so the number on the
564+ /// row is the number the encoder is given.
565+ pub(crate) fn nudge_budget(&mut self, steps: i32, coarse: bool) {
566+ let step = i64::from(steps)
567+ * match coarse {
568+ true => BPS_COARSE as i64,
569+ false => BPS_FINE as i64,
570+ };
571+ let at = self.budget_bps() as i64 + step;
572+ self.custom_bps = (at.max(0) as u64).clamp(BPS_MIN, BPS_MAX);
573+ }
574+
575+ /// The same number under the wheel, a notch a step, up for more -- the
576+ /// gesture this editor already moves a value with. Shift takes whole
577+ /// megabits: fifty tenths is not a way across this range.
578+ pub(crate) fn wheel_budget(&mut self, event: &ScrollWheelEvent) {
584 let by = wheel_delta(event);579 let by = wheel_delta(event);
585 if by == 0. {580 if by == 0. {
586 return;581 return;
587 }582 }
588- let by = by.signum() as i32;583+ self.nudge_budget(by.signum() as i32, event.modifiers.shift);
589- match &mut self.mbps_edit {584+ }
590- Some(edit) => edit.step(by),585+
591- None => self.nudge_mbps(by),586+ /// A press or a drag on the track, read against the box the last paint
587+ /// recorded ([`Self::budget_bar`]): linear across the engine's range,
588+ /// which is what the fill and the knob draw.
589+ pub(crate) fn drag_budget(&mut self, x: Pixels) {
590+ let along = frac_along(x, self.budget_bar.get());
591+ let span = (BPS_MAX - BPS_MIN) as f32;
592+ self.custom_bps = (BPS_MIN as f32 + along * span).round() as u64;
593+ self.custom_bps = self.custom_bps.clamp(BPS_MIN, BPS_MAX);
594+ }
595+
596+ /// Opens the budget's field, empty: `n` is a way to *say* a budget
597+ /// (`850k`, `6.5M`, `6.5`, `1.2G` of file), not a way to edit digits, and
598+ /// the number in force is still on the row until enter takes the new one.
599+ pub(crate) fn edit_budget(&mut self) {
600+ self.budget_edit = Some(String::new());
601+ }
602+
603+ /// Takes what was typed, or says nothing and keeps the field open: a
604+ /// number that parses is clamped into the engine's range (and shown
605+ /// clamped, in the same keystroke), and one that does not is left to be
606+ /// fixed in place.
607+ pub(crate) fn commit_budget(&mut self) {
608+ let Some(text) = self.budget_edit.clone() else {
609+ return;
610+ };
611+ let (seconds, audio) = (self.export_seconds(), self.audio_bps());
612+ if let Some(bps) = parse_budget(&text, seconds, audio) {
613+ self.custom_bps = bps;
614+ self.budget_edit = None;
592 }615 }
593 }616 }
594 617
595- /// Opens the custom bitrate's field on the number the row is carrying, and618+ /// Every stroke the moment answers, and the reason it answers *all* of
596- /// picks the row while it is at it: a field typed into is the row being619+ /// them: a chord this surface consumes must never also reach the room's
597- /// chosen, and a number nobody is using would be a number typed at nothing.620+ /// keymap underneath it (the shipped defect where `n` opened the field
598- /// Nothing is committed here -- until enter, the card still exports at the621+ /// *and* toggled the timeline snap). While the moment is up it owns the
599- /// bitrate it had.622+ /// keyboard -- `d`, `n`, `e`/`↵`, `−`/`+`/arrows, escape do their thing,
600- pub(crate) fn edit_mbps(&mut self) {623+ /// and everything else is swallowed rather than falling through.
601- self.quality = Quality::Custom;624+ ///
602- self.mbps_edit = Some(NumberEdit::new(625+ /// Escape retreats one step at a time (DESIGN.md:146): the field first,
603- self.custom_mbps,626+ /// the moment second.
604- MBPS_MIN,627+ pub(crate) fn export_moment_key(&mut self, key: &str, shift: bool, cx: &mut Context<Self>) -> bool {
605- MBPS_MAX,628+ if !self.export_open {
606- MBPS_DIGITS,629+ return false;
607- "Mbps",630+ }
608- ));631+ if let Some(text) = &mut self.budget_edit {
632+ match key {
633+ ESCAPE => self.budget_edit = None,
634+ "enter" => self.commit_budget(),
635+ "backspace" => {
636+ text.pop();
637+ }
638+ "up" | "right" => self.nudge_budget(1, shift),
639+ "down" | "left" => self.nudge_budget(-1, shift),
640+ // One character a stroke, which is all a rate is made of.
641+ k if k.chars().count() == 1 => text.push_str(k),
642+ _ => {}
643+ }
644+ return true;
645+ }
646+ match key {
647+ ESCAPE => self.close_card(),
648+ "d" => self.pick_destination(cx),
649+ "n" => self.edit_budget(),
650+ "e" | "enter" => self.start_export(cx),
651+ "up" | "right" | "+" | "=" => self.nudge_budget(1, shift),
652+ "down" | "left" | "-" => self.nudge_budget(-1, shift),
653+ _ => {}
654+ }
655+ true
609 }656 }
610 657
611 /// The card's Destination row: the desktop's save dialog, on a background658 /// The card's Destination row: the desktop's save dialog, on a background
@@ -683,6 +730,7 @@ impl Player {
683 /// That list in the card's words ([`subtitle_plan`]): what travels, and the730 /// That list in the card's words ([`subtitle_plan`]): what travels, and the
684 /// reason beside every track that does not -- including the ones731 /// reason beside every track that does not -- including the ones
685 /// [`Self::export_subs`] filtered out before the engine ever saw them.732 /// [`Self::export_subs`] filtered out before the engine ever saw them.
733+ #[allow(dead_code)] // shown by Settings now, not by the moment
686 pub(crate) fn subtitle_line(&self) -> String {734 pub(crate) fn subtitle_line(&self) -> String {
687 let Some(session) = self.session.as_ref() else {735 let Some(session) = self.session.as_ref() else {
688 return "none".to_string();736 return "none".to_string();
@@ -709,8 +757,7 @@ impl Player {
709 return;757 return;
710 }758 }
711 let mut settings = export_settings(759 let mut settings = export_settings(
712- self.quality,760+ self.budget_bps(),
713- self.custom_mbps,
714 self.format,761 self.format,
715 self.audio_kbps,762 self.audio_kbps,
716 self.encoder_seat(),763 self.encoder_seat(),
@@ -745,14 +792,6 @@ impl Player {
745 cx.notify();792 cx.notify();
746 return;793 return;
747 }794 }
748- // Exact asks the same question format_refusal just did, for the same
749- // reason: the row can be picked, then the cut or the format changed
750- // under it, and this is the fence with a keystroke to blame.
751- if let Some(why) = exact_refusal(session, self.format, self.quality) {
752- self.notify_user(format!("NOT EXPORTED — {why}").into());
753- cx.notify();
754- return;
755- }
756 session.pause();795 session.pause();
757 self.export = Some(session.export_to_with(&self.export_path, &settings));796 self.export = Some(session.export_to_with(&self.export_path, &settings));
758 // The clock starts with the worker, not with the first repaint that797 // The clock starts with the worker, not with the first repaint that
crates/app/src/subs.rsmodified+1 -0
@@ -426,6 +426,7 @@ pub(crate) fn subtitle_detail(track: &engine::subtitle::SubtitleTrack) -> String
426 /// string verbatim, would say it correctly meanwhile. Upgrade path: reasons out426 /// string verbatim, would say it correctly meanwhile. Upgrade path: reasons out
427 /// of `planned_subtitles` as data rather than as one sentence, which is an427 /// of `planned_subtitles` as data rather than as one sentence, which is an
428 /// engine change.428 /// engine change.
429+#[allow(dead_code)] // read by `Player::subtitle_line`, which Settings shows
429 pub(crate) fn subtitle_plan(430 pub(crate) fn subtitle_plan(
430 plan: String,431 plan: String,
431 tracks: &[engine::subtitle::SubtitleTrack],432 tracks: &[engine::subtitle::SubtitleTrack],
crates/app/src/tests/cards.rsmodified+155 -321
@@ -875,83 +875,167 @@ fn the_volume_stops_at_both_ends() {
875 }875 }
876 876
877 #[test]877 #[test]
878-fn a_quality_row_is_the_bitrate_it_promises() {878+fn the_budget_is_the_one_number_the_engine_gets() {
879- // Auto is the one row that says nothing: the exporter derives it, and879+ // One explicit rate, always: the Auto/Low/Medium/High/Exact ladder is
880- // a number typed against the custom row must not leak into it.880+ // gone, so there is nothing left that sends `None` and lets the encoder
881- let mp4 = Format::Mp4;881+ // pick a figure the row never showed.
882- assert_eq!(882+ let settings = export_settings(6_500_000, Format::Mp4, DEFAULT_AUDIO_KBPS, EncoderSeat::Auto);
883- export_settings(Quality::Auto, 7, mp4, DEFAULT_AUDIO_KBPS, EncoderSeat::Auto).bitrate,883+ assert_eq!(settings.bitrate, Some(6_500_000));
884- None884+ assert!(!settings.exact, "the copy path is off this surface");
885- );885+ assert_eq!(settings.audio_kbps, Some(DEFAULT_AUDIO_KBPS));
886- assert_eq!(886+ assert_eq!(settings.seat, EncoderSeat::Auto);
887- export_settings(Quality::Low, 0, mp4, DEFAULT_AUDIO_KBPS, EncoderSeat::Auto).bitrate,887+ // The picked format travels, or the moment would be a picture of a
888- Some(2_000_000)
889- );
890- assert_eq!(
891- export_settings(
892- Quality::Medium,
893- 0,
894- mp4,
895- DEFAULT_AUDIO_KBPS,
896- EncoderSeat::Auto
897- )
898- .bitrate,
899- Some(6_000_000)
900- );
901- assert_eq!(
902- export_settings(Quality::High, 0, mp4, DEFAULT_AUDIO_KBPS, EncoderSeat::Auto).bitrate,
903- Some(12_000_000)
904- );
905- // Megabits as typed, and as the row says it back.
906- assert_eq!(
907- export_settings(
908- Quality::Custom,
909- 7,
910- mp4,
911- DEFAULT_AUDIO_KBPS,
912- EncoderSeat::Auto
913- )
914- .bitrate,
915- Some(7_000_000)
916- );
917- assert_eq!(Quality::Low.detail(0), "2 Mbps");
918- // The picked format travels, or the card's rows would be a picture of a
919 // choice the engine never hears about.888 // choice the engine never hears about.
920 for format in [Format::Mp4, Format::Wav, Format::Flac] {889 for format in [Format::Mp4, Format::Wav, Format::Flac] {
921 assert_eq!(890 assert_eq!(
922- export_settings(891+ export_settings(BPS_MIN, format, DEFAULT_AUDIO_KBPS, EncoderSeat::Auto).format,
923- Quality::Auto,
924- 0,
925- format,
926- DEFAULT_AUDIO_KBPS,
927- EncoderSeat::Auto
928- )
929- .format,
930 format892 format
931 );893 );
932 }894 }
933- // Every fixed row sits inside the engine's clamp895+ // The lever's bounds are the engine's own (`MIN_BITRATE`,
934- // (`MAX_EXPLICIT_BITRATE`), so no row can promise a bitrate the exporter896+ // `MAX_EXPLICIT_BITRATE`), so no reachable number is silently rewritten.
935- // silently changes -- the ceiling row included, which is the one a897+ assert_eq!(BPS_MIN, 1_000_000);
936- // raised cap could have walked out past.898+ assert_eq!(BPS_MAX, 50_000_000);
937- for quality in Quality::ALL {899+ // The default the lever opens on is the engine's automatic figure for
938- let settings = export_settings(900+ // the picture that is open -- never the 0 Mbps the old `custom_mbps: 0`
939- quality,901+ // put on screen.
940- MBPS_MAX,902+ assert_eq!(auto_bps(1920, 1080, 30.), 6_220_800);
941- mp4,903+ assert!(auto_bps(320, 240, 30.) >= BPS_MIN, "a tiny picture floors");
942- DEFAULT_AUDIO_KBPS,904+ assert!(auto_bps(7680, 4320, 60.) <= 20_000_000, "and a huge one caps");
943- EncoderSeat::Auto,905+ for bps in [auto_bps(1920, 1080, 30.), auto_bps(320, 240, 24.)] {
944- );906+ assert!((BPS_MIN..=BPS_MAX).contains(&bps));
945- if let Some(bitrate) = settings.bitrate {907+ }
946- assert!(908+}
947- (u64::from(MBPS_MIN) * 1_000_000..=u64::from(MBPS_MAX) * 1_000_000)909+
948- .contains(&bitrate),910+#[test]
949- "{quality:?} outside the engine clamp"911+fn a_budget_is_said_four_ways_and_lands_inside_the_engines_range() {
950- );912+ // A minute of film with 256 kbps of sound under it: the span and the
913+ // sound are what a *size* has to be converted through.
914+ let (seconds, audio) = (60., 256_000);
915+ // A rate in its own units, and a bare number in the row's (Mbps).
916+ assert_eq!(parse_budget("6.5M", seconds, audio), Some(6_500_000));
917+ assert_eq!(parse_budget("6.5", seconds, audio), Some(6_500_000));
918+ assert_eq!(parse_budget("6.5 mbps", seconds, audio), Some(6_500_000));
919+ assert_eq!(parse_budget("12M", seconds, audio), Some(12_000_000));
920+ // 850 kbps is under the engine's floor, so it lands *on* the floor --
921+ // clamped, and shown clamped in the same keystroke.
922+ assert_eq!(parse_budget("850k", seconds, audio), Some(BPS_MIN));
923+ assert_eq!(parse_budget("2500k", seconds, audio), Some(2_500_000));
924+ // `G` is a target file size: 1.2 GB over a minute is 160 Mbit/s of file,
925+ // less the sound -- past the ceiling, so the ceiling is what is written.
926+ assert_eq!(parse_budget("1.2G", seconds, audio), Some(BPS_MAX));
927+ // ...and over an hour of film the same size is a rate that fits: the
928+ // sound's own bits come out of it, which is why it is not 2.67 Mbps.
929+ let hour = parse_budget("1.2G", 3600., audio).expect("a size over an hour");
930+ assert_eq!(hour, (1.2e9 * 8. / 3600.) as u64 - audio);
931+ // A size with no film to spread it over is not a rate.
932+ assert_eq!(parse_budget("1.2G", 0., audio), None);
933+ // Everything else is refused rather than guessed at, and the field stays
934+ // open on it.
935+ for text in ["", " ", "abc", "-4", "0", "M", "6.5.5"] {
936+ assert_eq!(parse_budget(text, seconds, audio), None, "{text}");
937+ }
938+ // Whatever is typed, what comes out is inside the engine's clamp.
939+ for text in ["1k", "999G", "50M", "51M", "0.5"] {
940+ if let Some(bps) = parse_budget(text, seconds, audio) {
941+ assert!((BPS_MIN..=BPS_MAX).contains(&bps), "{text} -> {bps}");
951 }942 }
952- // The seat travels exactly as it was picked, and an unpicked project943+ }
953- // exports on the seat this machine has.944+}
954- assert_eq!(settings.seat, EncoderSeat::Auto);945+
946+#[test]
947+fn the_budget_lever_steps_by_a_tenth_and_a_whole_megabit() {
948+ // A notch is 0.1 Mbps and a notch with shift is 1 -- the readout has one
949+ // decimal, so the fine step is the smallest move it can show.
950+ assert_eq!(BPS_FINE, 100_000);
951+ assert_eq!(BPS_COARSE, 1_000_000);
952+ assert_eq!(rate_label(6_000_000 + BPS_FINE), "6.1");
953+ assert_eq!(rate_label(6_000_000 + BPS_COARSE), "7.0");
954+ // Fifty notches of the coarse step crosses the whole range, which is
955+ // what a wheel is for; the fine one would take five hundred.
956+ assert_eq!((BPS_MAX - BPS_MIN) / BPS_COARSE, 49);
957+ // The step arithmetic itself, as `Player::nudge_budget` does it: a
958+ // saturating walk that stops at both ends rather than wrapping.
959+ let step = |at: u64, steps: i32, coarse: bool| {
960+ let by = i64::from(steps) * if coarse { BPS_COARSE } else { BPS_FINE } as i64;
961+ ((at as i64 + by).max(0) as u64).clamp(BPS_MIN, BPS_MAX)
962+ };
963+ assert_eq!(step(6_000_000, 5, false), 6_500_000);
964+ assert_eq!(step(6_000_000, -1, true), 5_000_000);
965+ assert_eq!(step(BPS_MIN, -9, true), BPS_MIN, "the floor holds");
966+ assert_eq!(step(BPS_MAX, 9, true), BPS_MAX, "and so does the ceiling");
967+}
968+
969+/// The moment itself, read off its own source: three rows, no scrolling
970+/// list, no second pane, and exactly one boxed chip in the room (DESIGN §4).
971+/// A source scan, like the stance guards above it -- this binary has no
972+/// `TestAppContext` to render a card and measure it.
973+#[test]
974+fn the_export_moment_is_three_rows_one_chip_and_no_list() {
975+ let body = fn_body("export_card");
976+ assert!(
977+ !body.contains("overflow_y_scroll"),
978+ "the export moment scrolls again -- it is three rows and a fixed height"
979+ );
980+ assert_eq!(
981+ body.matches(".border_1()").count(),
982+ 2,
983+ "one border for the plate and one for the chip: §4's single boxed chip"
984+ );
985+ for gone in ["Advanced", "preset", "Quality", "Subtitles", "GPU: ", "Built in"] {
986+ assert!(!body.contains(gone), "the old card's {gone} is still here");
987+ }
988+ // Its three rows, each reachable by pointer as well as by chord.
989+ for id in ["destination", "budget", "budget-track", "export-confirm"] {
990+ assert!(body.contains(&format!("\"{id}\"")), "{id} is on no row");
991+ }
992+ // 200px, and it fits the smallest window this editor draws with the
993+ // room's own chrome above and below it.
994+ assert_eq!(EXPORT_MOMENT_H, 200.);
995+ assert!(EXPORT_MOMENT_H + crate::ui::stance::TIME_BAND_H + CONTROL_H <= 360.);
996+ // The clickable rows are `HIT_MIN` tall (WCAG 2.5.8) -- the track is
997+ // drawn 1px and grabbed a whole row.
998+ assert!(KEYS_ROW_H >= HIT_MIN);
999+}
1000+
1001+/// The shipped defect: a chord the export surface answers (`n`) also reached
1002+/// the room's keymap under it and toggled the timeline snap. The fix is that
1003+/// the moment owns the keyboard while it is up -- every stroke is consumed,
1004+/// and escape retreats one step at a time (the field, then the moment).
1005+#[test]
1006+fn a_chord_the_export_moment_answers_never_reaches_the_room() {
1007+ // The leak was real: `n` is the room's own snap chord.
1008+ let keymap = keymap::Keymap::defaults();
1009+ assert_eq!(keymap.display(keymap::ActionId::ToggleSnap), "n");
1010+ // One door, and it is asked *before* the stance's modal guard.
1011+ let cards = src_text("player/cards.rs");
1012+ assert!(
1013+ cards.contains("if self.export_moment_key(key, shift, cx)"),
1014+ "param_card_key no longer routes the moment's own strokes"
1015+ );
1016+ let body = fn_body("export_moment_key");
1017+ let (guard, rest) = body
1018+ .split_once("return false;")
1019+ .expect("the one early out is `the moment is not open`");
1020+ assert!(
1021+ guard.contains("!self.export_open"),
1022+ "the only way out of this handler must be that no moment is up"
1023+ );
1024+ assert!(
1025+ !rest.contains("return false"),
1026+ "a stroke fell through to the room's keymap again -- that is the `n` \
1027+ toggling snap defect"
1028+ );
1029+ // Escape retreats one step at a time (DESIGN.md:146): the field is
1030+ // closed inside the typing branch, the moment only once it is shut.
1031+ let (typing, closed) = rest
1032+ .split_once("return true;")
1033+ .expect("the typing branch returns before the chords below it");
1034+ assert!(typing.contains("self.budget_edit = None"), "esc leaves the field");
1035+ assert!(closed.contains("self.close_card()"), "then esc closes the moment");
1036+ // Its chords, all of them consumed here rather than by the keymap.
1037+ for chord in ["\"d\"", "\"n\"", "\"e\"", "\"enter\"", "\"up\"", "\"down\""] {
1038+ assert!(closed.contains(chord), "{chord} is not the moment's own");
955 }1039 }
956 }1040 }
957 1041
@@ -972,7 +1056,7 @@ fn the_sound_row_carries_its_rate_into_both_kinds_of_file() {
972 for format in [Format::Mp4, Format::Av1, Format::Hevc, Format::Mp3] {1056 for format in [Format::Mp4, Format::Av1, Format::Hevc, Format::Mp3] {
973 for kbps in AUDIO_KBPS {1057 for kbps in AUDIO_KBPS {
974 assert_eq!(1058 assert_eq!(
975- export_settings(Quality::Auto, 0, format, kbps, EncoderSeat::Auto).audio_kbps,1059+ export_settings(BPS_MIN, format, kbps, EncoderSeat::Auto).audio_kbps,
976 Some(kbps),1060 Some(kbps),
977 "{format:?} at {kbps} kbps"1061 "{format:?} at {kbps} kbps"
978 );1062 );
@@ -994,105 +1078,6 @@ fn the_sound_row_carries_its_rate_into_both_kinds_of_file() {
994 assert!(audio_rate_choices(7).iter().all(|(.., picked)| !picked));1078 assert!(audio_rate_choices(7).iter().all(|(.., picked)| !picked));
995 }1079 }
996 1080
997-/// The shape [`NumberEdit`] is opened in for a bitrate: `(value, MBPS_MIN,
998-/// MBPS_MAX, MBPS_DIGITS, "Mbps")`, same as `Player::edit_mbps`.
999-fn mbps_edit(value: u32) -> NumberEdit {
1000- NumberEdit::new(value, MBPS_MIN, MBPS_MAX, MBPS_DIGITS, "Mbps")
1001-}
1002-
1003-#[test]
1004-fn a_typed_bitrate_is_a_field_and_not_a_key_capture() {
1005- // It opens on the number in force, so backspace edits that number
1006- // rather than the field starting empty over a bitrate still being used.
1007- let mut edit = mbps_edit(12);
1008- assert_eq!(edit.text, "12");
1009- edit.backspace();
1010- edit.digit(8);
1011- assert_eq!(edit.text, "18");
1012- assert_eq!(edit.commit(), Some(18));
1013- // A card nobody has typed a number into opens empty: zero is not a
1014- // bitrate anyone chose.
1015- assert_eq!(mbps_edit(0).text, "");
1016-
1017- // Out of range is refused *in words* and the digits stay put: clamping
1018- // 55 to 50 would write a bitrate the user never typed.
1019- let mut edit = mbps_edit(0);
1020- for digit in [5, 5] {
1021- edit.digit(digit);
1022- }
1023- assert_eq!(edit.commit(), None);
1024- assert_eq!(edit.text, "55", "a refusal keeps what was typed");
1025- let refusal = edit.refusal.clone().expect("a refusal says why");
1026- assert!(refusal.contains(&MBPS_MAX.to_string()), "{refusal}");
1027- assert!(edit.detail().starts_with("55▏"), "{}", edit.detail());
1028- assert!(edit.detail().contains(&refusal));
1029- // And is fixable in place, which is the whole point of a field.
1030- edit.backspace();
1031- assert_eq!(edit.refusal, None, "the reason went with the digit");
1032- assert_eq!(edit.commit(), Some(5));
1033-
1034- // Empty, zero, and past the digit cap: each its own reason, none of
1035- // them silent -- asserted on the widget itself, the door the card uses.
1036- let mut edit = mbps_edit(0);
1037- assert_eq!(edit.commit(), None, "empty is not a number");
1038- let mut edit = mbps_edit(0);
1039- edit.digit(0);
1040- assert_eq!(edit.commit(), None);
1041- assert!(
1042- edit.refusal
1043- .clone()
1044- .expect("zero says why")
1045- .contains("0 is not a value")
1046- );
1047- assert_eq!(mbps_edit(MBPS_MIN).commit(), Some(MBPS_MIN));
1048- assert_eq!(mbps_edit(MBPS_MAX).commit(), Some(MBPS_MAX));
1049- let mut edit = mbps_edit(0);
1050- for digit in [5, 1] {
1051- edit.digit(digit);
1052- }
1053- assert_eq!(edit.commit(), None, "51 is past the ceiling");
1054- let mut edit = mbps_edit(0);
1055- for digit in [9, 9, 9, 9] {
1056- edit.digit(digit);
1057- }
1058- assert_eq!(edit.text, "999", "the cap holds");
1059- assert!(edit.refusal.is_some(), "and says it is holding");
1060- // Never past what a u64 bitrate can be built from -- the committed
1061- // number is the only one that reaches the engine, and it is bounded.
1062- assert!(u64::from(MBPS_MAX) * 1_000_000 < u64::from(u32::MAX));
1063- assert_eq!(MBPS_DIGITS, 3);
1064-
1065- // The arrows step inside the range and stop at both ends: a walk
1066- // through the legal numbers, never a way out of them.
1067- let mut edit = mbps_edit(0);
1068- edit.step(1);
1069- assert_eq!(edit.text, MBPS_MIN.to_string(), "empty starts at the floor");
1070- edit.step(-1);
1071- assert_eq!(edit.text, MBPS_MIN.to_string());
1072- let mut edit = mbps_edit(MBPS_MAX);
1073- edit.step(1);
1074- assert_eq!(edit.text, MBPS_MAX.to_string());
1075- edit.step(-1);
1076- assert_eq!(edit.text, (MBPS_MAX - 1).to_string());
1077- // A step past a refused number clears the refusal with it.
1078- let mut edit = mbps_edit(0);
1079- edit.digit(5);
1080- edit.digit(5);
1081- assert_eq!(edit.commit(), None);
1082- edit.step(-1);
1083- assert_eq!(edit.refusal, None);
1084- assert_eq!(edit.text, MBPS_MAX.to_string(), "back inside the range");
1085-
1086- // The hint the field shows when there is nothing to refuse names both
1087- // ways out of it.
1088- let detail = mbps_edit(6).detail();
1089- assert!(
1090- detail.contains("enter") && detail.contains("esc"),
1091- "{detail}"
1092- );
1093- assert!(detail.starts_with("6▏"), "{detail}");
1094-}
1095-
1096 /// DEBT #111: the transition duration row's field is the same [`NumberEdit`]1081 /// DEBT #111: the transition duration row's field is the same [`NumberEdit`]
1097 /// opened `(frames, 0, cap, ..)`, the shape [`Player::edit_transition`]1082 /// opened `(frames, 0, cap, ..)`, the shape [`Player::edit_transition`]
1098 /// builds it in -- but it clamps on commit instead of refusing, because the1083 /// builds it in -- but it clamps on commit instead of refusing, because the
@@ -1505,78 +1490,6 @@ fn the_sample_rate_list_marks_source_with_nothing_picked() {
1505 assert!(picked[2].3);1490 assert!(picked[2].3);
1506 }1491 }
1507 1492
1508-#[test]
1509-fn the_export_card_fits_the_smallest_window() {
1510- // Same 640x360 floor the keybindings card is measured against: the
1511- // capped row list, the two summary lines and the confirm button, under
1512- // a title and a status line.
1513- let title = 17.;
1514- let status = 28.;
1515- // The head is one line of 11 px at this width -- every field of it,
1516- // worst case, is 71 characters against the 76 that fit. The tail is
1517- // budgeted for two: the destination's name is the user's and a long one
1518- // wraps.
1519- let summary = 15. + 30.;
1520- // Six children in the column, so five gaps.
1521- let gaps = 5. * 2.;
1522- let padding = 24.;
1523- assert_eq!(
1524- (17. + 28. + 15. + 30. + CONTROL_H + 4. + 10. + 24.),
1525- title + status + summary + CONTROL_H + 4. + gaps + padding
1526- );
1527- assert!(
1528- (17. + 28. + 15. + 30. + CONTROL_H + 4. + 10. + 24.) + (8. * KEYS_ROW_H) <= 360.,
1529- "card too tall"
1530- );
1531- // The list grows with a window that has the room -- and never shrinks
1532- // below the cap that made the floor fit, whatever arithmetic the window
1533- // hands it.
1534- let cap = |h: f32| {
1535- (h - (17. + 28. + 15. + 30. + CONTROL_H + 4. + 10. + 24.) - 24.).max(8. * KEYS_ROW_H)
1536- };
1537- assert_eq!(cap(360.), (8. * KEYS_ROW_H));
1538- assert_eq!(cap(0.), (8. * KEYS_ROW_H));
1539- assert!(cap(720.) > (8. * KEYS_ROW_H));
1540- assert!((17. + 28. + 15. + 30. + CONTROL_H + 4. + 10. + 24.) + cap(720.) <= 720.);
1541- // ...and inside the 640 px floor with the scrim showing either side.
1542- assert!(EXPORT_W + 2. * 12. <= 640.);
1543- // The cap is only honest if enough of the list is on screen to read as
1544- // one -- and the whole format section is: its header and every codec
1545- // row, so nothing that is picked *first* is behind a scroll.
1546- let codecs = FORMATS.iter().filter(|(row, ..)| !row.is_empty()).count();
1547- assert!((8. * KEYS_ROW_H) / KEYS_ROW_H >= 1. + codecs as f32);
1548- // Clickable rows, so WCAG 2.5.8 binds them as it binds the panel's --
1549- // and the bitrate steppers are `HIT_MIN` squares sitting inside a row,
1550- // which only fits while the row is at least as tall as one.
1551- assert!(KEYS_ROW_H >= HIT_MIN);
1552- assert!(CONTROL_H >= HIT_MIN);
1553- // The dimmed text on the card -- every refusal, every detail, every key
1554- // in its column -- is body text on `BG_RAISED` and WCAG 1.4.3 binds it.
1555- // A dimmed row is drawn in this ink rather than at an opacity, which is
1556- // what a refusal used to be readable through.
1557- // Every palette, not the one in force: a family is picked at runtime
1558- // now (`ui::theme`), so a floor met by one of them and missed by the
1559- // other is a window somebody is looking at.
1560- for id in crate::ui::theme::PaletteId::ALL {
1561- let p = id.palette();
1562- assert!(
1563- contrast(p.FG_SECONDARY, p.BG_RAISED) >= 4.5,
1564- "{id:?}: refusal ink {:.2}",
1565- contrast(p.FG_SECONDARY, p.BG_RAISED)
1566- );
1567- // ...and on the picked row, where the highlight is the accent at
1568- // surface brightness. Both inks clear 4.5:1 on it now -- the row still
1569- // lifts its key and detail to `FG_PRIMARY`, as emphasis rather than as
1570- // the rescue it used to be.
1571- assert!(contrast(p.FG_PRIMARY, p.BG_SELECTED) >= 4.5, "{id:?}");
1572- assert!(
1573- contrast(p.FG_SECONDARY, p.BG_SELECTED) >= 4.5,
1574- "{id:?}: refusal ink on the picked row {:.2}",
1575- contrast(p.FG_SECONDARY, p.BG_SELECTED)
1576- );
1577- }
1578-}
1579-
1580 /// The progress line's two clocks, driven the way a repaint drives them:1493 /// The progress line's two clocks, driven the way a repaint drives them:
1581 /// steady work, a stall where hardware hands over to software, then steady1494 /// steady work, a stall where hardware hands over to software, then steady
1582 /// work again. The estimate may not whipsaw, may not vanish once it has1495 /// work again. The estimate may not whipsaw, may not vanish once it has
@@ -1682,85 +1595,6 @@ fn the_export_estimate_answers_a_bar_that_went_backwards_with_a_guess() {
1682 }1595 }
1683 }1596 }
1684 1597
1685-/// The primary pane's own round trip: every bundle's format-and-quality lands
1686-/// back on the preset that named it, so the row a person picked is the row
1687-/// the card shows picked. `Custom` is the one preset `bundle` names nothing
1688-/// for, and the one every pair outside the other four's must fall back to.
1689-#[test]
1690-fn every_preset_bundle_round_trips_through_from_state() {
1691- for preset in ExportPreset::ALL {
1692- match preset.bundle() {
1693- Some((format, quality)) => {
1694- assert_eq!(ExportPreset::from_state(format, quality), preset);
1695- }
1696- None => assert_eq!(preset, ExportPreset::Custom),
1697- }
1698- }
1699- // A pair no bundle names -- the launch default before this batch's fix --
1700- // reads as `Custom`, not as whichever preset happens to be first.
1701- assert_eq!(
1702- ExportPreset::from_state(Format::Mp4, Quality::Auto),
1703- ExportPreset::Custom
1704- );
1705- // Master's bundle is HEVC/High, not H.264: an intra-only master is the one
1706- // that keeps its own "for re-editing later" detail true.
1707- assert_eq!(
1708- ExportPreset::Master.bundle(),
1709- Some((Format::HevcMp4, Quality::High))
1710- );
1711-}
1712-
1713-/// The primary pane's own refusal: a bundle whose format this timeline cannot
1714-/// write reads exactly as a codec row does -- the reason in place of the
1715-/// detail, and no format-and-quality pair to land wrong once a click on a
1716-/// dimmed row is ignored.
1717-#[test]
1718-fn a_preset_over_a_picture_this_timeline_has_none_of_carries_the_codec_refusal() {
1719- let mut session = PlaybackSession::open(asset("test_tone.mp3")).expect("a song is a timeline");
1720- session.set_gain(0.0);
1721- let path = session.sources()[0].path.clone();
1722- session.seek(1.0);
1723- session
1724- .place_stream_at(1.0, &path, 0, Some(Lane::A1))
1725- .expect("its own file is on this timeline");
1726- assert!(session.lane_clips(Lane::V1).is_empty(), "still no picture");
1727-
1728- for preset in [ExportPreset::Web, ExportPreset::Small, ExportPreset::Master] {
1729- let (format, _) = preset.bundle().expect("a real bundle");
1730- assert!(
1731- format_refusal(&session, format).is_some(),
1732- "{preset:?}'s bundle is a picture format this audio-only timeline must refuse"
1733- );
1734- }
1735- // Audio only's bundle is FLAC, which has no picture to refuse.
1736- let (audio_format, _) = ExportPreset::AudioOnly.bundle().expect("a real bundle");
1737- assert_eq!(format_refusal(&session, audio_format), None);
1738-}
1739-
1740-/// Picking Exact must derive the container from the source's own codec
1741-/// rather than leave whatever format was already picked -- an HEVC or AV1
1742-/// source lands on its own copy-capable Matroska format, and a source Exact
1743-/// has no copy path for at all (h264) leaves `exact_format` with nothing to
1744-/// set, so the row's own [`exact_refusal`] is what a click on it would see.
1745-#[test]
1746-fn exact_derives_its_format_from_the_source_codec() {
1747- let hevc = PlaybackSession::open(asset("test_hevc.mkv")).expect("an hevc fixture");
1748- assert_eq!(crate::exact_format(&hevc), Some(Format::Hevc));
1749-
1750- let av1 = PlaybackSession::open(asset("test_av1.mkv")).expect("an av1 fixture");
1751- assert_eq!(crate::exact_format(&av1), Some(Format::Av1));
1752-
1753- let h264 = PlaybackSession::open(asset("test_h264.mkv")).expect("an h264 fixture");
1754- assert_eq!(h264.export_snapshot().1.codec, engine::demux::Codec::H264);
1755- assert_eq!(crate::exact_format(&h264), None);
1756- // No copy path for h264 at any format -- the row's own refusal is what a
1757- // click on Exact would still show, since `exact_format` sets nothing and
1758- // the format is left at whatever it already was (Mp4's own refusal, or
1759- // Hevc's if the pane was left there from an earlier pick).
1760- assert!(crate::exact_refusal(&h264, Format::Mp4, Quality::Exact).is_some());
1761- assert!(crate::exact_refusal(&h264, Format::Hevc, Quality::Exact).is_some());
1762-}
1763-
1764 /// The stacking-scrims bug: opening the speed card while the colour card was1598 /// The stacking-scrims bug: opening the speed card while the colour card was
1765 /// up left both up at once, because each `open_*` cleared a different1599 /// up left both up at once, because each `open_*` cleared a different
1766 /// hand-picked subset of the other flags rather than all of them. The fix is1600 /// hand-picked subset of the other flags rather than all of them. The fix is
crates/app/src/tests/media.rsmodified+31 -135
@@ -609,10 +609,6 @@ fn every_codec_row_is_offered_or_says_why_not() {
609 // Every box on one row is the same codec, so the quality rows609 // Every box on one row is the same codec, so the quality rows
610 // do not change meaning when the container does.610 // do not change meaning when the container does.
611 assert!(row.iter().all(|f| f.has_video() == first.has_video()));611 assert!(row.iter().all(|f| f.has_video() == first.has_video()));
612- assert!(
613- row.iter()
614- .all(|f| bitrate_refusal(*f) == bitrate_refusal(first))
615- );
616 }612 }
617 }613 }
618 // No two rows share a key, and none of them is a stroke the card already614 // No two rows share a key, and none of them is a stroke the card already
@@ -651,79 +647,11 @@ fn every_codec_row_is_offered_or_says_why_not() {
651 detail.contains("rusty_vorbis"),647 detail.contains("rusty_vorbis"),
652 "the row names the encoder like every other live one: {detail}"648 "the row names the encoder like every other live one: {detail}"
653 );649 );
654- // Both AV1 boxes say they carry sound: the file used to be picture only,
655- // and a line that still said so would be the lie a user plays the file
656- // to find out about. HEVC says intra-only before anyone waits on one --
657- // a file several times the size, which the disk would otherwise say.
658- for format in [Format::Av1, Format::Av1Mp4] {
659- assert!(format_line(format).starts_with("AV1 · "));
660- }
661- for format in [Format::Hevc, Format::HevcMp4] {
662- assert!(format_line(format).starts_with("HEVC intra · "));
663- }
664- // The head names the box every format goes in, which is what the
665- // destination is then named after.
666- for format in [
667- Format::Mp4,
668- Format::Av1,
669- Format::Av1Mp4,
670- Format::Hevc,
671- Format::HevcMp4,
672- ] {
673- assert!(
674- format_line(format).contains(&format.ext().to_uppercase()),
675- "{format:?}: {}",
676- format_line(format)
677- );
678- }
679- // ...and it stays inside the one line the card budgets for it: the
680- // longest of them, with every field after it, against the 76 characters
681- // that fit at `EXPORT_W`.
682- let longest = summary_head(
683- Format::Hevc,
684- Some(((1920, 1080), 23.976)),
685- "AAC · SW encode (rusty_aac)",
686- );
687- assert!(
688- longest.chars().count() <= 76,
689- "{longest} is {} long",
690- longest.chars().count()
691- );
692 assert!(650 assert!(
693 FORMATS651 FORMATS
694 .into_iter()652 .into_iter()
695 .any(|(row, _, _, detail)| row.contains(&Format::Hevc) && detail.contains("intra"))653 .any(|(row, _, _, detail)| row.contains(&Format::Hevc) && detail.contains("intra"))
696 );654 );
697- // Only a picture encoder is given a bitrate, and the quality rows dim
698- // with the reason for every format that is not one.
699- for format in [
700- Format::Mp4,
701- Format::Av1,
702- Format::Av1Mp4,
703- Format::Hevc,
704- Format::HevcMp4,
705- ] {
706- assert!(
707- format.has_video() && bitrate_refusal(format).is_none(),
708- "{format:?}"
709- );
710- }
711- for format in [Format::Wav, Format::Flac, Format::Mp3] {
712- assert!(!format.has_video());
713- assert!(
714- bitrate_refusal(format).is_some(),
715- "{format:?} dims silently"
716- );
717- }
718- assert!(bitrate_refusal(Format::Wav).unwrap().contains("lossless"));
719- // MP3 has a rate and it is the *Sound* row's: the quality rows are the
720- // picture's, and this refusal used to claim a fixed 256 kbps that the
721- // Sound row can now change under it.
722- assert!(bitrate_refusal(Format::Mp3).unwrap().contains("Sound row"));
723- assert!(
724- !format_line(Format::Mp3).contains("256"),
725- "the summary states a rate the Sound row can change under it"
726- );
727 // The destination follows the format and keeps the stem, mp4 included.655 // The destination follows the format and keeps the stem, mp4 included.
728 assert_eq!(656 assert_eq!(
729 retarget(std::path::Path::new("/a/take.export.mp4"), Format::Wav),657 retarget(std::path::Path::new("/a/take.export.mp4"), Format::Wav),
@@ -733,79 +661,47 @@ fn every_codec_row_is_offered_or_says_why_not() {
733 retarget(std::path::Path::new("/a/take.export.wav"), Format::Mp4),661 retarget(std::path::Path::new("/a/take.export.wav"), Format::Mp4),
734 std::path::Path::new("/a/take.export.mp4")662 std::path::Path::new("/a/take.export.mp4")
735 );663 );
736- assert!(format_line(Format::Flac).contains("lossless"));
737 }664 }
738 665
739-/// The one line the card is answerable for: what it says is on screen before666+/// What the budget row says about the file before it is written: the size a
740-/// the button is pressed, and every field of it is one `ffprobe` reads back667+/// rate makes over a span, in the unit the row states it in.
741-/// off the file that comes out.
742 #[test]668 #[test]
743-fn the_summary_states_the_file_before_it_is_written() {669+fn the_budget_row_states_the_size_before_it_is_written() {
744- let head = summary_head(Format::Mp4, Some(((1920, 1080), 30.)), "AAC copy");
745- for field in ["H.264", "MP4", "1920x1080", "30 fps", "AAC copy"] {
746- assert!(head.contains(field), "{field} missing from {head}");
747- }
748 // The rate as a person writes it, and the ratio one spelled out rather670 // The rate as a person writes it, and the ratio one spelled out rather
749 // than rounded to a rate nothing is written at.671 // than rounded to a rate nothing is written at.
750 assert_eq!(fps_label(30.), "30");672 assert_eq!(fps_label(30.), "30");
751 assert_eq!(fps_label(24000. / 1001.), "23.976");673 assert_eq!(fps_label(24000. / 1001.), "23.976");
752 assert_eq!(fps_label(29.97002997), "29.97");674 assert_eq!(fps_label(29.97002997), "29.97");
753- // A format with no picture states no size and no rate it does not write.675+ // 6 Mbps over a minute is 45 MB -- and the sound rides in the same
754- let audio = summary_head(Format::Wav, Some(((1920, 1080), 30.)), "PCM · SW (hound)");676+ // number, because it is in the same file.
755- assert!(677+ assert_eq!(estimated_bytes(6_000_000, 60.), 45_000_000);
756- !audio.contains("1920x1080") && !audio.contains("fps"),678+ assert_eq!(estimated_bytes(6_000_000 + 256_000, 60.), 46_920_000);
757- "{audio}"679+ assert_eq!(estimated_bytes(2_000_000, 90.), 22_500_000);
758- );680+ // Nothing to write is nothing to estimate, and never a negative span.
759- assert!(audio.contains("PCM · SW (hound)"));681+ assert_eq!(estimated_bytes(6_000_000, 0.), 0);
760- // ...and one with no sound on the timeline says that, rather than682+ assert_eq!(estimated_bytes(6_000_000, -3.), 0);
761- // leaving the field out and reading as a file with sound in it.683+ // Whole megabytes under a gigabyte, two decimals over it: the estimate
762- assert!(684+ // is an "≈" and a tenth of a megabyte is precision it does not have.
763- summary_head(Format::Mp4, Some(((640, 360), 25.)), "no sound to write")685+ assert_eq!(size_label(45_000_000), "45 MB");
764- .contains("no sound to write")686+ assert_eq!(size_label(999_999_999), "1000 MB");
765- );687+ assert_eq!(size_label(1_000_000_000), "1.00 GB");
766- // The tail: where it lands, about how big, and what will encode it --688+ assert_eq!(size_label(1_240_000_000), "1.24 GB");
767- // never a guessed seat, and no seat at all for a format with no picture.689+ // The lever's own readout, one decimal, in the unit it is moved in.
768- let tail = summary_tail(690+ assert_eq!(rate_label(6_000_000), "6.0");
769- Path::new("/a/take.export.mp4"),691+ assert_eq!(rate_label(6_500_000), "6.5");
770- Some(45_000_000),692+ assert_eq!(rate_label(BPS_MIN), "1.0");
771- Some("VA-API"),693+ // The faintest line: what resolved, never a control -- and it says the
772- true,694+ // marked span where there is one rather than "whole film".
773- );695+ let line = plan_line(Format::Mp4, "AAC 256 kbps", None, true);
774- assert!(tail.starts_with("take.export.mp4"), "{tail}");696+ assert_eq!(line, "H.264 · AAC 256 kbps · whole film · GPU");
775- assert!(697+ assert!(plan_line(Format::Mp4, "AAC", None, false).ends_with("SW"));
776- tail.contains("≈ 45 MB") && tail.contains("VA-API"),
777- "{tail}"
778- );
779- assert!(summary_tail(Path::new("/a/x.mp4"), None, None, true).contains("encoder …"));
780- assert!(!summary_tail(Path::new("/a/x.wav"), None, None, false).contains("encoder"));
781- assert!(!summary_tail(Path::new("/a/x.wav"), None, None, false).contains("MB"));
782- // 6 Mbps over a minute is 45 MB. `Auto` has no figure to estimate from
783- // and an empty timeline no length: neither invents one.
784- assert_eq!(estimated_bytes(Some(6_000_000), 60.), Some(45_000_000));
785- assert_eq!(estimated_bytes(Some(2_000_000), 90.), Some(22_500_000));
786- assert_eq!(estimated_bytes(None, 60.), None);
787- assert_eq!(estimated_bytes(Some(6_000_000), 0.), None);
788- assert_eq!(estimated_bytes(Some(0), 60.), None);
789- // ...and a short one is not nothing. Three seconds at the floor
790- // bitrate is 375 kB, which used to round to the "≈ 0 MB" this line
791- // exists to never say -- the shortest export a frame can make is
792- // still a real file with a real size.
793- let short = estimated_bytes(Some(1_000_000), 3.).expect("a rate and a length");
794- assert_eq!(size_label(short), "375 kB");
795- let frame = summary_tail(
796- Path::new("/a/x.mp4"),
797- estimated_bytes(Some(1_000_000), 1. / 60.),
798- None,
799- true,
800- );
801 assert!(698 assert!(
802- frame.contains("≈ 2 kB") && !frame.contains("0 MB") && !frame.contains("0 kB"),699+ plan_line(Format::Mp4, "AAC", Some("00:00:04:00–00:00:12:00"), true)
803- "{frame}"700+ .contains("marks 00:00:04:00–00:00:12:00")
804 );701 );
805- // The boundary reads in the unit that can state it, either side.702+ // A sound-only export names no picture codec and no seat to write it on.
806- assert_eq!(size_label(999_600), "1 MB");703+ let sound = plan_line(Format::Flac, "FLAC", None, true);
807- assert_eq!(size_label(499_000), "499 kB");704+ assert_eq!(sound, "FLAC · sound only");
808- assert_eq!(size_label(1), "1 kB");
809 }705 }
810 706
811 /// Which cue is on screen when: the whole of what the overlay decides, and707 /// Which cue is on screen when: the whole of what the overlay decides, and
crates/app/src/tests/mod.rsmodified+9 -9
@@ -13,24 +13,24 @@ use super::{
13 ACCENT_PRIMARY, AUDIO_KBPS, BG_RAISED, COLOR_BANDS, COLOR_BAR_W, COLOR_STEP, COLOR_W,13 ACCENT_PRIMARY, AUDIO_KBPS, BG_RAISED, COLOR_BANDS, COLOR_BAR_W, COLOR_STEP, COLOR_W,
14 CONTROL_H, Clip, Ctx, DEFAULT_AUDIO_KBPS, EQ_BANDS_MAX, EQ_CURVE_STEPS, EQ_FFT, EQ_FREQ_HIGH,14 CONTROL_H, Clip, Ctx, DEFAULT_AUDIO_KBPS, EQ_BANDS_MAX, EQ_CURVE_STEPS, EQ_FFT, EQ_FREQ_HIGH,
15 EQ_FREQ_LOW, EQ_FREQ_STEP, EQ_GAIN_LIMIT, EQ_GRAPH_H, EQ_HANDLE, EQ_Q_HIGH, EQ_Q_LOW,15 EQ_FREQ_LOW, EQ_FREQ_STEP, EQ_GAIN_LIMIT, EQ_GRAPH_H, EQ_HANDLE, EQ_Q_HIGH, EQ_Q_LOW,
16- EQ_Q_STEP, EQ_SPECTRUM_DB, EQ_TICKS, EQ_W_MAX, ESCAPE, EXPORT_DONE, EXPORT_W, Enable,16+ EQ_Q_STEP, EQ_SPECTRUM_DB, EQ_TICKS, EQ_W_MAX, ESCAPE, EXPORT_DONE, Enable,
17- EncoderSeat, ExportPreset, FORMATS, Format, HEADER_H, HIST_BINS, HIST_H, HIST_SAMPLES, HIT_MIN,17+ BPS_COARSE, BPS_FINE, BPS_MAX, BPS_MIN, EXPORT_MOMENT_H, EncoderSeat, FORMATS, Format, HEADER_H, HIST_BINS, HIST_H, HIST_SAMPLES, HIT_MIN,
18 KEYS_ROW_H, KEYS_W, KeyRow, LABEL_H, LANE_H, LANES_MAX, LATE_RESYNC, LIBRARY_MAX_W,18 KEYS_ROW_H, KEYS_W, KeyRow, LABEL_H, LANE_H, LANES_MAX, LATE_RESYNC, LIBRARY_MAX_W,
19- LIBRARY_MIN_W, Lane, MB_FLOOR, MBPS_DIGITS, MBPS_MAX, MBPS_MIN, MENU_ITEMS, MENU_PAD,19+ LIBRARY_MIN_W, Lane, MB_FLOOR, MENU_ITEMS, MENU_PAD,
20- MENU_ROW_H, MENU_W, NO_FILE, NOTICES_MAX, NumberEdit, OVERLAID, PANEL_H, Quality, RESYNC_GAP,20+ MENU_ROW_H, MENU_W, NO_FILE, NOTICES_MAX, NumberEdit, OVERLAID, PANEL_H, RESYNC_GAP,
21 ROW_ITEMS, RULER_HIT_H, RowCtx, RowItem, SCROLL_NOTCH_SHARE, SILENCE_ROWS, SOURCE_TINTS,21 ROW_ITEMS, RULER_HIT_H, RowCtx, RowItem, SCROLL_NOTCH_SHARE, SILENCE_ROWS, SOURCE_TINTS,
22 SPEED_PRESETS, SPEED_STEP, STATUS_ERROR, STATUS_SUCCESS, STATUS_WARNING, SUB_PLAN_CHARS,22 SPEED_PRESETS, SPEED_STEP, STATUS_ERROR, STATUS_SUCCESS, STATUS_WARNING, SUB_PLAN_CHARS,
23 Source, Speed, StreamInfo, TIMELINE_SHARE, Transport, VOLUME_W, Volume, WAVE_BPS, WAVE_COL,23 Source, Speed, StreamInfo, TIMELINE_SHARE, Transport, VOLUME_W, Volume, WAVE_BPS, WAVE_COL,
24- WAVE_COLS_MAX, Wave, ZOOM_MIN_FRAMES, active_lane, band_label, bitrate_detail, bitrate_refusal,24+ WAVE_COLS_MAX, Wave, ZOOM_MIN_FRAMES, active_lane, auto_bps, band_label, bitrate_detail,
25 clipboard_after_remove, color_snap, containers, enable, enable_lane, envelope, eq_card_w,25 clipboard_after_remove, color_snap, containers, enable, enable_lane, envelope, eq_card_w,
26 eq_freq, eq_freq_label, eq_graph_h, eq_spectrum, eq_x, eq_y, estimated_bytes, export_path,26 eq_freq, eq_freq_label, eq_graph_h, eq_spectrum, eq_x, eq_y, estimated_bytes, export_path,
27- export_settings, format_line, format_refusal, fps_choices, fps_label, frac_along, frac_down,27+ export_settings, format_refusal, fps_choices, fps_label, frac_along, frac_down,
28 frame_at, frame_rate_ladder, histogram, inserted_band, is_project, keymap, keys_rows, lanes_h,28 frame_at, frame_rate_ladder, histogram, inserted_band, is_project, keymap, keys_rows, lanes_h,
29 marked, menu_at, menu_items, menu_rows_h, next_container, normalise, nothing_to_play,29 marked, menu_at, menu_items, menu_rows_h, next_container, normalise, nothing_to_play,
30- notice_tone, panel_h, project_path, proxies_to_start, push_notice, px_below, retarget,30+ notice_tone, panel_h, parse_budget, plan_line, project_path, proxies_to_start, push_notice, px_below, retarget,
31 row_enable, row_items, scrub_due, secs_label, should_resync, silence_rate, size_label,31 row_enable, row_items, scrub_due, secs_label, should_resync, silence_rate, size_label,
32- snap_cue, snap_marks, snapped, source_tint, span_partner, speed_at, sub_pick_after_removal,32+ rate_label, snap_cue, snap_marks, snapped, source_tint, span_partner, speed_at, sub_pick_after_removal,
33- subtitle_plan, summary_head, summary_tail, timecode, timeline_fixed_h, tip_may_paint,33+ subtitle_plan, timecode, timeline_fixed_h, tip_may_paint,
34 transport, typed, unseen_paths, unseen_sources, whole_take, window_title,34 transport, typed, unseen_paths, unseen_sources, whole_take, window_title,
35 };35 };
36 36
crates/app/src/ui/cards.rsmodified+299 -819
@@ -259,23 +259,32 @@ fn dark_ghost_button(
259 })259 })
260 }260 }
261 261
262+/// Where an export lands, said the way the destination row says it: the
263+/// directory under `~` where it is one, so the row is a place a person
264+/// recognises rather than an absolute path that will not fit on the line.
265+fn dest_dir(path: &Path) -> String {
266+ let dir = path.parent().unwrap_or(path).to_string_lossy().to_string();
267+ match std::env::var("HOME") {
268+ Ok(home) if !home.is_empty() && dir.starts_with(&home) => {
269+ format!("~{}", &dir[home.len()..])
270+ }
271+ _ => dir,
272+ }
273+}
274+
262 impl Player {275 impl Player {
263- /// What an export is going to be, before there is one: the codec, the box276+ /// The export moment (DESIGN §4/§8/§10, the approved artboard): three
264- /// it goes into, the bitrate, where it lands -- and, above the button, the277+ /// lines, ~200px, no scroll, no sections and no prose. Where it lands
265- /// two lines that state the file all of that adds up to. The same scrim and278+ /// (`d` opens the save dialog), what it costs (one lever, read as a rate
266- /// row shape as the keybindings overlay (two cards of different builds over279+ /// and as a size), and what it resolved to on its own beside the one
267- /// one window read as two different programs) and the same plain divs, so280+ /// boxed chip.
268- /// the root keeps the keyboard and the custom row's field is typed into
269- /// through it ([`NumberEdit`]).
270 ///281 ///
271- /// Every row carries the key that picks it, so the card is drivable end to282+ /// Everything the old card asked apart -- codec, container, sound rate,
272- /// end without a pointer *and* without a legend to memorise -- and every283+ /// encoder seat, the presets, the Advanced pane -- keeps its state and
273- /// row is clickable, the bitrate's steppers included, so it is drivable end284+ /// its setters and is simply not on this surface: an export is one
274- /// to end without a keyboard as well.285+ /// decision, the budget, and the rest is a preference that belongs in
275- ///286+ /// Settings (user 2026-09-09: "too complicated plus I can only give mbps
276- /// Two shapes of it, behind `g` and `r`: sections against one flat list,287+ /// level bitrate").
277- /// and the codecs with no encoder collapsed into a footer against a dimmed
278- /// row each. Grouped and collapsed is what opens.
279 pub(crate) fn export_card(288 pub(crate) fn export_card(
280 &self,289 &self,
281 viewport: Size<Pixels>,290 viewport: Size<Pixels>,
@@ -284,673 +293,292 @@ impl Player {
284 if !self.export_open {293 if !self.export_open {
285 return None;294 return None;
286 }295 }
287- // The cap is what keeps the card inside the smallest window; a taller296+ let budget = self.budget_bps();
288- // one gets a taller list rather than a scroll past empty space, and the297+ let seconds = self.export_seconds();
289- // card is still only as tall as the rows it has.298+ // Both halves of the file, which is what a person means by "how big":
290- // DESIGN §4: plate surface, mono for what the film says, ghost rows,299+ // the picture's budget and the sound's own rate over the same span.
291- // one bordered chip for the commit action.300+ let bytes = estimated_bytes(budget + self.audio_bps(), seconds);
292- let ink_secondary = INK3();301+ let fill = ((budget.saturating_sub(BPS_MIN)) as f32 / (BPS_MAX - BPS_MIN) as f32).clamp(0., 1.);
293- let bg_hover = DARK_RAISED();302+ let name = file_name(&self.export_path);
294- let bg_selected = DARK_RAISED();303+ let (stem, ext) = match name.rfind('.') {
295- // Archivo for what the row *says as a verb* (its label), mono for304+ Some(at) => name.split_at(at),
296- // what the film says through it (its detail/key) -- DESIGN §3.305+ None => (name.as_str(), ""),
297- let label_style = Some(type_scale::label(
298- type_scale::LABEL_ROW_PX,
299- gpui::FontWeight::MEDIUM,
300- ));
301- let mono_style = Some(type_scale::mono(
302- type_scale::CHORD_METADATA_MAX_PX,
303- gpui::FontWeight::MEDIUM,
304- ));
305- let head_style = Some(type_scale::head());
306- let row = |id: (&'static str, usize)| {
307- div()
308- .id(id)
309- .flex()
310- // The floor, not the height: the destination's path wraps on a
311- // long name and must not paint over the row under it. Which it
312- // did: inside a capped, scrolling list a row shrinks to fit by
313- // default, so a wrapped detail was drawn over the row beneath
314- // it (the Sound row's "the source's own packets are copied…"
315- // over Subtitles). The list scrolls -- a row is as tall as what
316- // it has to say.
317- .flex_none()
318- .min_h(px(KEYS_ROW_H))
319- .items_center()
320- .justify_between()
321- .gap(px(12.))
322- .px(px(6.))
323- .rounded(px(3.))
324- };
325- // A row that cannot be picked is dimmed and takes no click, exactly as
326- // an inapplicable item in the clip menu is: it still says its piece.
327- let live = |d: Stateful<Div>, enabled: bool| {
328- d.when(!enabled, |d| {
329- d.cursor_not_allowed().text_color(rgb(ink_secondary))
330- })
331- .when(enabled, |d| {
332- d.cursor_pointer().hover(|s| s.bg(rgb(bg_hover)))
333- })
334 };306 };
335- // A row as this card writes them: the mark saying which one is picked,307+ // The picture's own seat, as the probe found it -- `SW` until it says
336- // the key that picks it, its name, and what the choice means. The mark308+ // otherwise is a promise; `GPU` is what `planned_seats` measured.
337- // is a glyph and not only a colour -- a background alone is gone the309+ let hardware = self
338- // moment a hover lands on the row, and invisible to anyone who cannot310+ .export_seat
339- // tell the two greys apart (WCAG 1.4.1).311+ .as_ref()
340- let entry = |id: (&'static str, usize),312+ .and_then(|(.., seats)| *seats)
341- key: &str,313+ .and_then(|(video, _)| video)
342- label: SharedString,314+ .is_some_and(|seat| seat.contains("VA-API") || seat.contains("GPU"));
343- detail: SharedString,315+ let audio = self
344- picked: bool,316+ .session
345- enabled: bool| {317+ .as_ref()
346- // The small print of a picked row sits on the highlight, where the318+ .map_or("", |s| s.planned_audio(self.format, self.range.is_some()));
347- // dim ink is only 3.3:1 -- the row it lands on lifts it (WCAG319+ let marks = self.range.map(|(start, end)| {
348- // 1.4.3, and the fit test pins both numbers).320+ format!(
349- // DESIGN §2's ink ladder, applied to a row rather than to a321+ "{}\u{2013}{}",
350- // whole card (user 2026-08-21: the export card's "colors are not322+ timecode(f64::from(start) / self.fps, self.fps),
351- // aligning a little so hard to read"). Two faults it fixes: the323+ timecode(f64::from(end) / self.fps, self.fps),
352- // detail of a picked row was drawn BRIGHTER than the label it324+ )
353- // belongs to -- the loudest thing on the row was its small print325+ });
354- // -- and the resting rows' detail sat at `ink3` on `panel`, the326+ let plan = plan_line(self.format, audio, marks.as_deref(), hardware);
355- // metadata step, for text that is the row's actual content and327+ // The refusal the button used to carry, said before it is pressed and
356- // has to be read at a glance. Label leads its row (`ink1`328+ // in the readout's own place: a few words and the chord that fixes it,
357- // picked, `ink2` resting), detail follows one step behind329+ // never the sentence the old card wrapped over three lines.
358- // (`ink2` picked, `ink2` resting -- never `ink3`, which stays330+ let blocked = self
359- // for the key column and the summary's small print).331+ .session
360- let ink = INK2();332+ .as_ref()
361- let label_ink = match picked {333+ .and_then(|s| format_refusal(s, self.format))
362- true => INK1(),334+ .map(|why| {
363- false => INK2(),335+ format!(
364- };336+ "{} — sound format in settings {}",
365- let key_ink = INK3();337+ why.split(" — ").next().unwrap_or("cannot export"),
366- live(row(id), enabled)338+ self.keymap.chord(ActionId::Settings)
367- .when(picked, |d| d.bg(rgb(bg_selected)))
368- .child(
369- div()
370- .flex()
371- .flex_none()
372- .items_center()
373- .gap(px(8.))
374- .child(div().w(px(10.)).child(match picked {
375- true => "✓",
376- false => " ",
377- }))
378- .child(
379- div()
380- .w(px(EXPORT_KEY_W))
381- .text_size(px(11.))
382- .text_color(rgb(key_ink))
383- .when_some(mono_style.clone(), |d, style| {
384- d.font(style.font).text_size(style.size)
385- })
386- .child(SharedString::from(key.to_string())),
387- )
388- .child(
389- // A fixed label column in the darkroom: the
390- // details are the long half and they wrap, so
391- // without one they start at a different x on
392- // every row and a wrapped line reads as if it
393- // began left of the label it belongs to.
394- div()
395- .map(|d| d.w(px(92.)).flex_none().text_color(rgb(label_ink)))
396- .when_some(label_style.clone(), |d, style| {
397- d.font(style.font).text_size(style.size)
398- })
399- .child(label),
400- ),
401- )
402- // Wraps rather than runs off the row: a refusal is the longest
403- // thing in this column and the half of it past the edge is the
404- // half that says what to do instead.
405- .child(
406- div()
407- .min_w(px(0.))
408- .flex_shrink()
409- .text_size(px(11.))
410- .text_color(rgb(ink))
411- .when_some(mono_style.clone(), |d, style| {
412- d.font(style.font).text_size(style.size)
413- })
414- .child(detail),
415 )339 )
416- };340+ });
417- let header = |text: &'static str| {341+ let chord = |key: &'static str| {
418 div()342 div()
419 .flex_none()343 .flex_none()
420- .px(px(6.))344+ .type_style(type_scale::mono(
421- .pt(px(4.))345+ type_scale::CHORD_METADATA_MIN_PX,
422- .text_size(px(10.))346+ gpui::FontWeight::MEDIUM,
423- .text_color(rgb(ink_secondary))347+ ))
424- .when_some(head_style.clone(), |d, style| {348+ .text_color(rgb(INK3()))
425- d.font(style.font).text_size(style.size)349+ .child(key)
426- })
427- .child(text)
428- .into_any_element()
429 };350 };
430- let mut list: Vec<AnyElement> = Vec::new();351+ // Row 1: the file. A readout -- `d` is the one way to change it, the
431- // The primary pane: destination first (the one thing every export352+ // desktop's own save dialog, exactly as the old row's `d` was.
432- // needs regardless of what it is), then the bundles most exports353+ let file_row = div()
433- // actually are, then the button to the rest. Everything under it is354+ .id("destination")
434- // exactly the codec, quality, sound and encoder rows the old flat355+ .flex_none()
435- // card opened on -- a bundle here only sets the same two fields the356+ .flex()
436- // Advanced pane's own Format and Quality rows set, so nothing here357+ .items_baseline()
437- // is a setting of its own to fall out of step with them.358+ .gap(px(16.))
438- let destination = entry(359+ .cursor_pointer()
439- ("destination", 0),360+ .on_click(cx.listener(|this, _: &ClickEvent, _, cx| this.pick_destination(cx)))
440- "d",361+ .child(
441- "Destination".into(),362+ div()
442- file_name(&self.export_path).into(),363+ .flex_1()
443- false,364+ .min_w(px(0.))
444- true,365+ .truncate()
445- )366+ .type_style(type_scale::mono(18., gpui::FontWeight::BOLD))
446- .on_click(cx.listener(|this, _: &ClickEvent, _, cx| this.pick_destination(cx)))367+ .text_color(rgb(INK1()))
447- .into_any_element();368+ .child(stem.to_string())
448- list.push(destination);369+ .child(
449- let current_preset = ExportPreset::from_state(self.format, self.quality);370+ div()
450- for (i, preset) in ExportPreset::ALL.into_iter().enumerate() {371+ .text_color(rgb(INK2()))
451- // A bundle whose format this timeline refuses (an audio-only edit372+ .child(ext.to_string()),
452- // against Web, Small or Master) is the same kind of row the codec373+ ),
453- // rows already carry: dimmed, unclickable, its reason in place of374+ )
454- // the detail -- not bright and pickable over a click that would375+ .child(
455- // only bounce off `set_format`'s own guard.376+ div()
456- let refusal = preset.bundle().and_then(|(format, _)| {377+ .flex_none()
457- self.session378+ .flex()
458- .as_ref()379+ .gap(px(10.))
459- .and_then(|s| format_refusal(s, format))380+ .type_style(type_scale::mono(
460- });381+ type_scale::CHORD_METADATA_MIN_PX,
461- let detail: SharedString = match &refusal {382+ gpui::FontWeight::MEDIUM,
462- Some(why) => why.clone().into(),383+ ))
463- None => preset.detail().into(),384+ .text_color(rgb(INK3()))
464- };385+ .child(dest_dir(&self.export_path))
465- let mut r = entry(386+ .child("d"),
466- ("preset", i),
467- preset.key(),
468- preset.label().into(),
469- detail,
470- preset == current_preset,
471- refusal.is_none(),
472 );387 );
473- if refusal.is_none() {388+ // Row 2: the budget. One lever, in bits per second, read as a rate and
474- r = r.on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {389+ // as a size -- the wheel moves it (shift by whole Mbps), `n` types one
475- this.pick_preset(preset);390+ // (`850k`, `6.5M`, `6.5`, `1.2G` of file), the track sets it by hand.
476- cx.notify();391+ let reading: Vec<AnyElement> = match &self.budget_edit {
477- }));392+ Some(text) => {
478- }393+ let parsed = parse_budget(text, seconds, self.audio_bps());
479- list.push(r.into_any_element());394+ vec![
480- }395+ div()
481- let advanced_detail = match self.export_advanced_open {396+ .type_style(type_scale::mono(18., gpui::FontWeight::BOLD))
482- true => "codec, container, quality, sound, encoder, subtitles — s collapses them"397+ .text_color(rgb(INK1()))
483- .to_string(),398+ .child(format!("{text}\u{258f}"))
484- false => {399+ .into_any_element(),
485- "codec, container, quality, sound, encoder, subtitles — s for the rows".to_string()400+ div()
401+ .type_style(type_scale::mono(15., gpui::FontWeight::MEDIUM))
402+ .text_color(rgb(INK2()))
403+ .child(match parsed {
404+ Some(bps) => format!(
405+ "{} Mbps ≈ {}",
406+ rate_label(bps),
407+ size_label(estimated_bytes(bps + self.audio_bps(), seconds))
408+ ),
409+ None => "↵ takes it · esc leaves it".to_string(),
410+ })
411+ .into_any_element(),
412+ ]
486 }413 }
414+ None => vec![
415+ div()
416+ .flex()
417+ .items_baseline()
418+ .type_style(type_scale::mono(18., gpui::FontWeight::BOLD))
419+ .text_color(rgb(INK1()))
420+ .child(rate_label(budget))
421+ .child(
422+ div()
423+ .type_style(type_scale::mono(
424+ type_scale::CHORD_METADATA_MIN_PX,
425+ gpui::FontWeight::MEDIUM,
426+ ))
427+ .text_color(rgb(INK2()))
428+ .child(" Mbps"),
429+ )
430+ .into_any_element(),
431+ div()
432+ .type_style(type_scale::mono(15., gpui::FontWeight::MEDIUM))
433+ .text_color(rgb(INK2()))
434+ .child(format!("≈ {}", size_label(bytes)))
435+ .into_any_element(),
436+ ],
487 };437 };
488- list.push(438+ let budget_row = div()
489- entry(439+ .id("budget")
490- ("export-advanced", 0),440+ .flex_none()
491- "s",441+ .flex()
492- "Advanced".into(),442+ .flex_col()
493- advanced_detail.into(),443+ .gap(px(10.))
494- self.export_advanced_open,444+ .on_scroll_wheel(cx.listener(|this, event: &ScrollWheelEvent, _, cx| {
495- true,445+ this.wheel_budget(event);
496- )446+ cx.stop_propagation();
497- .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
498- this.export_advanced_open = !this.export_advanced_open;
499 cx.notify();447 cx.notify();
500 }))448 }))
501- .into_any_element(),449+ .child(
502- );450+ div()
503- // Everything from here down is the Advanced pane: the codec, its451+ .flex()
504- // container, the quality rows, sound, encoder, subtitles, the two452+ .items_baseline()
505- // display switches and what this machine can encode with -- all of453+ .gap(px(16.))
506- // it built exactly as the flat card built it, only not pushed at all454+ .id("budget-read")
507- // while the pane is shut.455+ .cursor_pointer()
508- if self.export_advanced_open {
509- if self.export_grouped {
510- list.push(header("FORMAT"));
511- }
512- // The codecs first: which one is being written decides whether every
513- // row under it means anything. One a *this* timeline cannot be written
514- // as (an audio-only edit, for a picture codec) reads exactly like one
515- // there is no encoder for -- dimmed, unclickable, and carrying its own
516- // reason where its detail was, with nothing to click to find that out.
517- let mut refusals: Vec<String> = Vec::new();
518- for (i, (boxes, key, label, detail)) in FORMATS.into_iter().enumerate() {
519- let format = same_box(boxes, self.format);
520- let refused = format
521- .zip(self.session.as_ref())
522- .and_then(|(f, s)| format_refusal(s, f));
523- // A codec with no encoder here at all is the other kind of refusal,
524- // and the one the footer collects: it can never become pickable, so
525- // a row each is dead rows above the fold.
526- if format.is_none() {
527- refusals.push(format!("{label} — {detail}"));
528- if !self.export_refusals_inline {
529- continue;
530- }
531- }
532- let detail: SharedString = match &refused {
533- Some(why) => why.clone().into(),
534- None => detail.into(),
535- };
536- let format = format.filter(|_| refused.is_none());
537- let mut r = entry(
538- ("format", i),
539- key,
540- label.into(),
541- detail,
542- boxes.contains(&self.format),
543- format.is_some(),
544- );
545- if let Some(format) = format {
546- r = r.on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
547- this.set_format(format);
548- cx.notify();
549- }));
550- }
551- list.push(r.into_any_element());
552- }
553- if self.export_grouped {
554- list.push(header("DETAILS"));
555- }
556- // The container, and only where the picked codec has more than one box:
557- // a row offering a single choice reads as a choice.
558- let boxes = containers(self.format);
559- if boxes.len() > 1 {
560- let next = next_container(self.format);
561- list.push(
562- entry(
563- ("container", 0),
564- "c",
565- "Container".into(),
566- format!(
567- "{} — c for {}",
568- self.format.ext().to_uppercase(),
569- next.ext().to_uppercase()
570- )
571- .into(),
572- false,
573- true,
574- )
575 .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {456 .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
576- this.cycle_container();457+ this.edit_budget();
577 cx.notify();458 cx.notify();
578 }))459 }))
579- .into_any_element(),460+ .children(reading)
580- );461+ .child(div().flex_1())
581- }462+ .child(chord("n")),
582- match bitrate_refusal(self.format) {463+ )
583- // One dimmed row carrying the reason, rather than five rows of a464+ .child(
584- // figure that will not be written: the quality rows are the465+ // 1px to look at, a whole row to grab (WCAG 2.5.8) -- the
585- // *picture's* bitrate, and this file has no picture in it.466+ // ruler's own split between what is drawn and what is hit.
586- Some(why) => list.push(467+ div()
587- entry(468+ .id("budget-track")
588- ("quality", 0),469+ .relative()
589- "q",470+ .h(px(KEYS_ROW_H))
590- "Quality".into(),471+ .cursor_pointer()
591- why.into(),472+ .child(bounds_probe(self.budget_bar.clone()))
592- false,473+ .on_mouse_down(
593- false,474+ MouseButton::Left,
475+ cx.listener(|this, event: &MouseDownEvent, _, cx| {
476+ this.drag_budget(event.position.x);
477+ cx.stop_propagation();
478+ cx.notify();
479+ }),
594 )480 )
595- .into_any_element(),481+ .on_mouse_move(cx.listener(|this, event: &MouseMoveEvent, _, cx| {
596- ),482+ if event.pressed_button == Some(MouseButton::Left) {
597- None => {483+ this.drag_budget(event.position.x);
598- for (i, quality) in Quality::ALL.into_iter().enumerate() {484+ cx.notify();
599- // The custom row is a field: `n` opens it, a click in it
600- // opens it too, and while it is open the row shows what is
601- // being typed with a caret in it rather than the number in
602- // force. The other four are picked whole.
603- let field = self
604- .mbps_edit
605- .as_ref()
606- .filter(|_| quality == Quality::Custom);
607- // Exact's own row carries whatever [`exact_refusal`] says of
608- // the format currently picked, whether or not Exact is the
609- // row in force -- the same reason `start_export` would give,
610- // said here instead of only after the button is pressed.
611- let exact_why = (quality == Quality::Exact)
612- .then(|| self.session.as_ref())
613- .flatten()
614- .and_then(|s| exact_refusal(s, self.format, quality));
615- let mut r = entry(
616- ("quality", i),
617- match quality {
618- Quality::Custom => "n",
619- _ => "q",
620- },
621- quality.label().into(),
622- match (&exact_why, field) {
623- (Some(why), _) => why.clone().into(),
624- (None, Some(edit)) => edit.detail().into(),
625- (None, None) => quality.detail(self.custom_mbps).into(),
626- },
627- self.quality == quality,
628- true,
629- )
630- .on_click(cx.listener(
631- move |this, _: &ClickEvent, _, cx| {
632- match quality {
633- Quality::Custom => this.edit_mbps(),
634- _ => this.pick_quality(quality),
635- }
636- cx.notify();
637- },
638- ));
639- if quality == Quality::Custom {
640- // The wheel anywhere over the row moves the number, the
641- // buttons being one step each: the range is fifty wide
642- // now, and a number only a repeated press can walk to is
643- // a number nobody walks to. Swallowed, so the notch that
644- // moved the bitrate does not scroll the list under it as
645- // well -- one gesture, one thing changed.
646- r = r
647- .on_scroll_wheel(cx.listener(
648- |this, event: &ScrollWheelEvent, _, cx| {
649- this.wheel_mbps(event);
650- cx.stop_propagation();
651- cx.notify();
652- },
653- ))
654- .child(self.mbps_steppers(cx));
655 }485 }
656- list.push(r.into_any_element());
657- }
658- }
659- }
660- // The other half of the file, and the one this card used to write at a
661- // fixed rate without saying so: what the *sound* is coded at, for every
662- // format that codes it -- the AAC inside a video export as much as an
663- // MP3. Four rates, so the pointer gets the *list* of them
664- // ([`Pick::AudioRate`]) rather than a button clicked round -- the
665- // resolution row's rule, and the key still steps as `ctrl+r` still
666- // does. Dimmed with the reason where this timeline has no rate to pick,
667- // like the quality rows are.
668- let sound = self.audio_rate_refusal();
669- let mut r = entry(
670- ("sound", 0),
671- "b",
672- "Sound".into(),
673- match sound {
674- Some(why) => why.into(),
675- None => format!("{} kbps — b steps", self.audio_kbps).into(),
676- },
677- false,
678- sound.is_none(),
679- );
680- if sound.is_none() {
681- r = r.on_click(cx.listener(|this, event: &ClickEvent, _, cx| {
682- this.open_picker(Pick::AudioRate, event.position(), cx)
683- }));
684- }
685- list.push(r.into_any_element());
686- // Which encoder writes the picture, which was an env pin and therefore
687- // no choice at all. Three seats, so the pointer gets the *list* of them
688- // ([`Pick::Encoder`]) and never a button clicked round -- the Sound
689- // row's rule, one row above. Only where there is a picture to encode:
690- // a WAV has no seat to pick and the row would be a question about
691- // nothing.
692- if self.format.has_video() {
693- let seat = self.encoder_seat();
694- list.push(
695- entry(
696- ("encoder", 0),
697- "e",
698- "Encoder".into(),
699- format!("{} — e steps", encoder_label(seat)).into(),
700- false,
701- true,
702- )
703- .on_click(cx.listener(|this, event: &ClickEvent, _, cx| {
704- this.open_picker(Pick::Encoder, event.position(), cx)
705 }))486 }))
706- .into_any_element(),487+ .child(
707- );488+ div()
708- // ...and, under it, the one thing about that pick a person cannot489+ .absolute()
709- // know from the words in the list: this box's driver reset itself490+ .left_0()
710- // on the vendored AV1 encoder. A dimmed row and not a modal -- the491+ .right_0()
711- // pick is theirs, and the export runs.492+ .top(px(KEYS_ROW_H / 2.))
712- if let Some(warning) = av1_hw_warning(self.format, seat) {493+ .h(px(1.))
713- list.push(494+ .bg(rgb(DARK_HAIRLINE())),
714- entry(495+ )
715- ("encoder-av1", 0),496+ .child(
716- "",497+ div()
717- "".into(),498+ .absolute()
718- warning.into(),499+ .left_0()
719- false,500+ .top(px(KEYS_ROW_H / 2.))
720- false,501+ .h(px(1.))
721- )502+ .w(relative(fill))
722- .into_any_element(),503+ .bg(rgb(INK2())),
723- );504+ )
724- }505+ .child(
725- }506+ div()
726- // What happens to the subtitles on this timeline, in one line: how many507+ .absolute()
727- // are written into the file and under what names, or the reason each one508+ .left(relative(fill))
728- // is not. Which tracks travel is not a pick -- everything with a cue on509+ .top(px(KEYS_ROW_H / 2. - 4.))
729- // the timeline goes ([`Player::export_subs`]) -- so the row says rather510+ .w(px(2.))
730- // than offers, like the machine lines below.511+ .h(px(9.))
731- // ...and the ones that do not travel are named here too, which they were512+ .bg(rgb(INK1())),
732- // not: `export_subs` had already filtered a track with no cue on *this*513+ ),
733- // timeline out of the engine's sight, so the card said nothing about a
734- // row the list was still showing ([`subtitle_plan`]).
735- let plan = self.subtitle_line();
736- // The row used to end in "click for <fmt> in MKV" whenever the picture
737- // was going into an mp4, on the grounds that only Matroska carries a
738- // text track. An mp4 carries one now (`Mp4Muxer::write_subtitles` writes
739- // `tx3g`), so that was a refusal offering a way out of nothing: the
740- // container the card is already set to embeds them. The refusals left in
741- // `planned_subtitles` are the true ones -- a sound-only format has
742- // nowhere to put a track, and a PGS track is pictures whatever the box.
743- list.push(
744- entry(
745- ("subtitles", 0),
746- "",
747- "Subtitles".into(),
748- plan.into(),
749- false,
750- false,
751- )
752- .into_any_element(),
753- );
754- // The card's own two layout switches. They were `g` and `r` and nothing
755- // else, while the status line under the title advertised both of them:
756- // a hand on the mouse read what they do and had nothing to press.
757- list.push(
758- entry(
759- ("export-layout", 0),
760- "g",
761- "Layout".into(),
762- match self.export_grouped {
763- true => "sections — g for one flat list".into(),
764- false => "one flat list — g for sections".into(),
765- },
766- self.export_grouped,
767- true,
768- )
769- .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
770- this.export_grouped = !this.export_grouped;
771- cx.notify();
772- }))
773- .into_any_element(),
774- );
775- list.push(
776- entry(
777- ("export-refusals", 0),
778- "r",
779- "Codecs with no encoder".into(),
780- match self.export_refusals_inline {
781- true => "a dimmed row each — r collapses them".into(),
782- false => "one line at the foot — r shows a row each".into(),
783- },
784- self.export_refusals_inline,
785- true,
786- )
787- .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
788- this.export_refusals_inline = !this.export_refusals_inline;
789- cx.notify();
790- }))
791- .into_any_element(),
792 );514 );
793- if !self.export_refusals_inline && !refusals.is_empty() {515+ // Row 3: what auto resolved to, in the faintest ink -- or, where the
794- // Last, and one line: the reason travels with the name (a footer516+ // press would be refused, the refusal in its place -- and the one
795- // that only listed them would be the "why not?" the rows exist to517+ // boxed chip in the room (§4).
796- // answer), but nothing here can ever be picked, so it sits under518+ let commit_row = div()
797- // every row that can rather than above them.519+ .flex_none()
798- list.push(520+ .flex()
799- div()521+ .items_center()
800- .flex_none()522+ .gap(px(16.))
801- .px(px(6.))523+ .child(
802- .py(px(2.))524+ div()
803- .text_size(px(11.))525+ .flex_1()
804- .text_color(rgb(ink_secondary))526+ .min_w(px(0.))
805- .when_some(mono_style.clone(), |d, style| {527+ .truncate()
806- d.font(style.font).text_size(style.size)528+ .type_style(type_scale::mono(
807- })529+ type_scale::CHORD_METADATA_MIN_PX,
808- .child(format!("cannot write: {}", refusals.join(" · ")))530+ gpui::FontWeight::MEDIUM,
809- .into_any_element(),531+ ))
810- );532+ .text_color(rgb(match blocked.is_some() {
811- }533+ true => STATUS_WARNING(),
812- // What is doing the work, on this machine and in this build: the GPU534+ false => INK4(),
813- // half is asked of the driver through the plugin (a different answer on535+ }))
814- // every machine, and "none" where there is no plugin at all), the build536+ .child(blocked.clone().unwrap_or(plan)),
815- // half is the crates that were compiled in. Last in the list, because it537+ )
816- // is what a user checks rather than what they pick -- and a listing538+ .child(
817- // rather than rows, since none of it can be clicked.
818- if self.export_grouped {
819- list.push(header("THIS MACHINE"));
820- }
821- let note = |text: String| {
822 div()539 div()
540+ .id("export-confirm")
823 .flex_none()541 .flex_none()
824- .px(px(6.))542+ .flex()
825- .py(px(2.))543+ .items_center()
826- .text_size(px(11.))544+ .justify_center()
827- .text_color(rgb(ink_secondary))545+ .gap(px(10.))
828- .when_some(mono_style.clone(), |d, style| {546+ .h(px(32.))
829- d.font(style.font).text_size(style.size)547+ .px(px(22.))
548+ .rounded(px(3.))
549+ .border_1()
550+ .border_color(rgb(match blocked.is_some() {
551+ true => INK4(),
552+ false => INK3(),
553+ }))
554+ .when(blocked.is_none(), |d| {
555+ d.cursor_pointer().hover(|s| s.bg(rgb(DARK_RAISED())))
830 })556 })
831- .child(text)557+ .when(blocked.is_some(), |d| d.cursor_not_allowed())
832- .into_any_element()558+ .on_click(cx.listener(|this, _: &ClickEvent, _, cx| this.start_export(cx)))
833- };559+ .type_style(type_scale::label(
834- list.push(note(format!(560+ type_scale::LABEL_ROW_PX,
835- "GPU: {}",561+ gpui::FontWeight::MEDIUM,
836- self.hw_caps.clone().unwrap_or_else(|| "asking…".into())562+ ))
837- )));563+ .text_color(rgb(match blocked.is_some() {
838- list.push(note(format!("Built in: {}", engine::caps::software())));564+ true => INK4(),
839- } // self.export_advanced_open565+ false => INK1(),
840- // What the rows add up to, which is the one thing that has to be right:566+ }))
841- // codec, box, size, rate, sound, where it goes and about how big. Two567+ .child("Export")
842- // lines, outside the scrolling list, so it is on screen whatever the568+ .child(
843- // list is scrolled to and whatever is picked.569+ div()
844- let picture = self570+ .type_style(type_scale::mono(
845- .session571+ type_scale::CHORD_METADATA_MIN_PX,
846- .as_ref()572+ gpui::FontWeight::MEDIUM,
847- .map(|s| (s.resolution(), s.meta().frame_rate));573+ ))
848- // The probe's answer where it has one -- the export's own decision,574+ .text_color(rgb(INK3()))
849- // sound included ([`engine::export::planned_seats`]) -- and the pure575+ .child(self.keymap.chord(ActionId::Export)),
850- // prediction from the format alone until it lands, which is the same576+ ),
851- // line this card always showed.577+ );
852- let seats = self.export_seat.as_ref().and_then(|(.., seats)| *seats);
853- let audio = seats.map_or_else(
854- || {
855- self.session
856- .as_ref()
857- .map_or("", |s| s.planned_audio(self.format, self.range.is_some()))
858- },
859- |(_, audio)| audio,
860- );
861- let settings = export_settings(
862- self.quality,
863- self.custom_mbps,
864- self.format,
865- self.audio_kbps,
866- self.encoder_seat(),
867- );
868- let size = estimated_bytes(
869- settings.bitrate.filter(|_| self.format.has_video()),
870- self.session.as_ref().map_or(0., |s| match self.range {
871- Some((start, end)) => f64::from(end - start) / s.meta().frame_rate,
872- None => s.timeline_duration(),
873- }),
874- );
875- let head = summary_head(self.format, picture, audio);
876- let tail = summary_tail(
877- &self.export_path,
878- size,
879- seats.and_then(|(video, _)| video),
880- self.format.has_video(),
881- );
882- // The button says the refusal *before* it is pressed: the picked codec
883- // can go invalid one edit after it was picked (a cleared video lane),
884- // and a button that looks ready until it is pressed is the lie the
885- // dimmed rows above it are there to avoid.
886- let blocked = self
887- .session
888- .as_ref()
889- .and_then(|s| format_refusal(s, self.format));
890- let action: SharedString = match &blocked {
891- Some(why) => {
892- format!("Cannot export — {}", why.split(" — ").next().unwrap_or(why)).into()
893- }
894- None => "Export".into(),
895- };
896- let status_line = match (&self.mbps_edit, self.notices.front()) {
897- // A field being typed into says so here as well as in its row:
898- // this line is outside the scrolling list and on screen at every
899- // window size, and at 360 px the custom row itself can be below
900- // the fold -- a number typed where it cannot be seen is the
901- // blind capture this field replaced.
902- (Some(edit), _) => SharedString::from(format!("Custom bitrate {}", edit.detail())),
903- (None, Some(notice)) => notice.clone(),
904- // `g`/`r` only do anything once Advanced is open -- they moved
905- // off the front pane with the rows they reshape -- so a shut
906- // pane advertises `s` instead of a pair of keys with nothing on
907- // screen for them to touch.
908- // Short enough to read at a glance in the plate's own head row:
909- // the long four-clause sentence was 11px `ink3` mono across the
910- // whole sheet and read as noise above the rows it was meant to
911- // explain (user 2026-08-21: "hard to read").
912- (None, None) => match self.export_advanced_open {
913- true => "↵ exports · esc closes · g/r layout".into(),
914- false => "↵ exports · esc closes · s Advanced".into(),
915- },
916- };
917- // The darkroom's own language, not the corner-card sheet the legacy
918- // tree drew before it was removed --
919- // a plate (canvas-on-panel, §4), positioned over the bench+
920- // ledger footprint it can sit over rather than centred over the
921- // whole window (§11 check 6: the picture stays uncovered). The
922- // click-catcher behind it is `size_full` so a click anywhere
923- // still closes the card exactly as the legacy scrim's does, but
924- // paints nothing (`SCRIM()` is deliberately not applied here) --
925- // an invisible catcher changes zero picture pixels while a
926- // dimming one would still tint the screen it must never cover.
927- // The plate is the room's below-picture footprint, not a 340px
928- // corner card (user 2026-08-21: "export section is not aligning
929- // with our design"). Measured at 1280x720 the corner card's own
930- // max-height was ~9px taller than the footprint it had to fit
931- // in, so its scrolling row list collapsed to a single visible
932- // row: the presets, Advanced and every codec row under them were
933- // unreachable by pointer, and the long status sentence wrapped to
934- // three lines over the top of them. Two columns instead -- rows
935- // left, what-it-adds-up-to and the one bordered chip right --
936- // inside the same bench+ledger footprint every menu already
937- // hangs in, so the picture stays uncovered (§11 check 6) and the
938- // list gets the whole height rather than a fraction of it.
939 let floor = crate::ui::stance::below_picture_floor(578 let floor = crate::ui::stance::below_picture_floor(
940 f32::from(viewport.height),579 f32::from(viewport.height),
941 self.split_px(Split::Bench, viewport),580 self.split_px(Split::Bench, viewport),
942 );581 );
943- let summary = |text: SharedString, ink: u32| {
944- div()
945- .flex_none()
946- .px(px(6.))
947- .type_style(type_scale::mono(
948- type_scale::CHORD_METADATA_MAX_PX,
949- gpui::FontWeight::MEDIUM,
950- ))
951- .text_color(rgb(ink))
952- .child(text)
953- };
954 Some(582 Some(
955 div()583 div()
956 .id("export-click-catcher")584 .id("export-click-catcher")
@@ -960,11 +588,9 @@ impl Player {
960 .left_0()588 .left_0()
961 .right_0()589 .right_0()
962 .flex()590 .flex()
591+ .items_end()
963 // Below the time band, not merely below the picture: the592 // Below the time band, not merely below the picture: the
964- // transport and the Export chip that opened this card are593+ // chip that opened this moment is on that band.
965- // on that band, and a sheet drawn over them hides the
966- // control the editor just pressed. The bench and the
967- // ledger are what this plate is allowed to cover.
968 .pt(px(floor + crate::ui::stance::TIME_BAND_H + 6.))594 .pt(px(floor + crate::ui::stance::TIME_BAND_H + 6.))
969 .pb(px(6.))595 .pb(px(6.))
970 .px(px(6.))596 .px(px(6.))
@@ -981,140 +607,24 @@ impl Player {
981 .id("export-plate")607 .id("export-plate")
982 .flex_1()608 .flex_1()
983 .min_w(px(0.))609 .min_w(px(0.))
610+ // The artboard is 784 wide; wider windows give the
611+ // moment room, never a 2000px line of three words.
612+ .max_w(px(EXPORT_W * 2.))
613+ .h(px(EXPORT_MOMENT_H))
984 .on_mouse_down(MouseButton::Left, swallow)614 .on_mouse_down(MouseButton::Left, swallow)
985 .flex()615 .flex()
986 .flex_col()616 .flex_col()
987- .gap(px(4.))617+ .justify_between()
988- .p(px(10.))618+ .pt(px(22.))
619+ .pb(px(20.))
620+ .px(px(28.))
989 .rounded(px(4.))621 .rounded(px(4.))
990 .bg(rgb(DARK_PANEL()))622 .bg(rgb(DARK_PANEL()))
991 .border_1()623 .border_1()
992 .border_color(rgba(DARK_SEAM()))624 .border_color(rgba(DARK_SEAM()))
993- .child(625+ .child(file_row)
994- div()626+ .child(budget_row)
995- .flex_none()627+ .child(commit_row)
996- .flex()
997- .items_baseline()
998- .justify_between()
999- .gap(px(12.))
1000- .px(px(6.))
1001- .child(
1002- div()
1003- .type_style(type_scale::head())
1004- .text_color(rgb(INK3()))
1005- .child("EXPORT"),
1006- )
1007- .child(
1008- div()
1009- .min_w(px(0.))
1010- .truncate()
1011- .type_style(type_scale::mono(
1012- type_scale::CHORD_METADATA_MAX_PX,
1013- gpui::FontWeight::MEDIUM,
1014- ))
1015- .text_color(rgb(INK2()))
1016- .child(status_line),
1017- ),
1018- )
1019- .child(
1020- div()
1021- .flex_1()
1022- .min_h(px(0.))
1023- .flex()
1024- .gap(px(10.))
1025- .child(
1026- div()
1027- .id("export-rows")
1028- .flex_1()
1029- .min_w(px(0.))
1030- .h_full()
1031- .flex()
1032- .flex_col()
1033- .gap(px(2.))
1034- .overflow_y_scroll()
1035- .children(list),
1036- )
1037- .child(
1038- div()
1039- .flex_none()
1040- .w(px(300.))
1041- .h_full()
1042- .flex()
1043- .flex_col()
1044- .justify_end()
1045- .gap(px(4.))
1046- .border_l_1()
1047- .border_color(rgb(DARK_HAIRLINE()))
1048- .pl(px(8.))
1049- .child(summary(head.into(), INK2()))
1050- .children(self.range.map(|(start, end)| {
1051- summary(
1052- format!(
1053- "RANGE {}\u{2013}{} ({})",
1054- timecode(f64::from(start) / self.fps, self.fps),
1055- timecode(f64::from(end) / self.fps, self.fps),
1056- frames_timecode(end - start, self.fps),
1057- )
1058- .into(),
1059- INK3(),
1060- )
1061- }))
1062- .child(summary(tail.into(), INK3()))
1063- // §4: "the single bordered chip in
1064- // the whole room" -- ghosts
1065- // everywhere else in this card, one
1066- // border here, wearing its chord
1067- // live off the keymap so a rebind
1068- // cannot leave it stale.
1069- .child(
1070- div()
1071- .id("export-confirm")
1072- .mt(px(4.))
1073- .flex()
1074- .items_center()
1075- .justify_center()
1076- .gap(px(6.))
1077- .h(px(CONTROL_H))
1078- .px(px(10.))
1079- .rounded(px(3.))
1080- .border_1()
1081- .border_color(rgb(match blocked.is_some() {
1082- true => INK4(),
1083- false => INK2(),
1084- }))
1085- .when(blocked.is_none(), |d| d.cursor_pointer())
1086- .when(blocked.is_some(), |d| d.cursor_not_allowed())
1087- .hover(|s| s.bg(rgb(DARK_RAISED())))
1088- .on_click(cx.listener(
1089- |this, _: &ClickEvent, _, cx| {
1090- this.start_export(cx)
1091- },
1092- ))
1093- .type_style(type_scale::label(
1094- type_scale::LABEL_ROW_PX,
1095- gpui::FontWeight::MEDIUM,
1096- ))
1097- .text_color(rgb(match blocked.is_some() {
1098- true => INK4(),
1099- false => INK1(),
1100- }))
1101- .child(action)
1102- .when(blocked.is_none(), |d| {
1103- d.child(
1104- div()
1105- .type_style(type_scale::mono(
1106- type_scale::CHORD_METADATA_MIN_PX,
1107- gpui::FontWeight::MEDIUM,
1108- ))
1109- .text_color(rgb(INK3()))
1110- .child(
1111- self.keymap.chord(ActionId::Export),
1112- ),
1113- )
1114- }),
1115- ),
1116- ),
1117- )
1118 .into_any_element(),628 .into_any_element(),
1119 )629 )
1120 .into_any_element(),630 .into_any_element(),
@@ -1271,36 +781,6 @@ impl Player {
1271 )781 )
1272 }782 }
1273 783
1274- /// The custom bitrate's two pointer buttons. The typed digits were the last
1275- /// control in this card a mouse could not reach at all -- and a number that
1276- /// can only be typed is a number a hand on the pointer has to leave the
1277- /// card to change. `HIT_MIN` square, like every other target here.
1278- pub(crate) fn mbps_steppers(&self, cx: &mut Context<Self>) -> impl IntoElement {
1279- let step = |id: &'static str, label: &'static str, by: i32, cx: &mut Context<Self>| {
1280- div()
1281- .id(id)
1282- .flex()
1283- .w(px(HIT_MIN))
1284- .h(px(HIT_MIN))
1285- .items_center()
1286- .justify_center()
1287- .rounded(px(3.))
1288- .bg(rgb(BG_PANEL()))
1289- .cursor_pointer()
1290- .hover(|s| s.bg(rgb(BG_HOVER())))
1291- .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
1292- this.nudge_mbps(by);
1293- cx.notify();
1294- }))
1295- .child(label)
1296- };
1297- div()
1298- .flex()
1299- .gap(px(4.))
1300- .child(step("mbps-down", "−", -1, cx))
1301- .child(step("mbps-up", "+", 1, cx))
1302- }
1303-
1304 /// The equalizer of one audio clip: its frequency response drawn as a784 /// The equalizer of one audio clip: its frequency response drawn as a
1305 /// curve, a handle per band sitting on it, each band's own bell under the785 /// curve, a handle per band sitting on it, each band's own bell under the
1306 /// sum, and a row that reads and moves the picked band's three numbers. The786 /// sum, and a row that reads and moves the picked band's three numbers. The
crates/app/src/ui/widgets.rsmodified+2 -0
@@ -342,6 +342,7 @@ impl NumberEdit {
342 /// first press up is the row's minimum and not a jump to some remembered342 /// first press up is the row's minimum and not a jump to some remembered
343 /// value -- and stays inside the range, because a step is a walk through343 /// value -- and stays inside the range, because a step is a walk through
344 /// the legal numbers rather than a way out of them.344 /// the legal numbers rather than a way out of them.
345+ #[allow(dead_code)] // the budget field is free text; the transition row still types digits
345 pub(crate) fn step(&mut self, by: i32) {346 pub(crate) fn step(&mut self, by: i32) {
346 let at = self347 let at = self
347 .text348 .text
@@ -359,6 +360,7 @@ impl NumberEdit {
359 /// whose own stepper already clamps silently, use [`Self::commit_clamped`]360 /// whose own stepper already clamps silently, use [`Self::commit_clamped`]
360 /// instead -- refusing there would be a stricter rule than the mouse door361 /// instead -- refusing there would be a stricter rule than the mouse door
361 /// enforces.362 /// enforces.
363+ #[allow(dead_code)] // as above: `commit_clamped` is the transition row's door
362 pub(crate) fn commit(&mut self) -> Option<u32> {364 pub(crate) fn commit(&mut self) -> Option<u32> {
363 match self.text.parse::<u32>() {365 match self.text.parse::<u32>() {
364 Ok(v) if (self.min..=self.max).contains(&v) => {366 Ok(v) if (self.min..=self.max).contains(&v) => {