Merge branch 'worktree-agent-a40df354b258ccccc'
Browse files at this commit3 changed files +464 -5
- crates/app/src/player/cards.rs +53 -0
- crates/app/src/tests/layout.rs +139 -0
- crates/app/src/ui/settings_stance.rs +272 -5
crates/app/src/player/cards.rsmodified+53 -0
| @@ -866,6 +866,45 @@ impl Player { | |||
| 866 | /// Nothing here is a clip's or even the project's -- it never reaches the | 866 | /// Nothing here is a clip's or even the project's -- it never reaches the |
| 867 | /// export, which never burns a cue into the picture -- so like the mix | 867 | /// export, which never burns a cue into the picture -- so like the mix |
| 868 | /// card it opens with no timeline required and nothing to refuse. | 868 | /// card it opens with no timeline required and nothing to refuse. |
| 869 | + /// The settings page's Picture row: the next file this machine can write | ||
| 870 | + /// ([`ui::settings_stance::next_picture`] -- codec and container in one | ||
| 871 | + /// cycle now), through [`Self::set_format`] like every other pick, so the | ||
| 872 | + /// destination follows the format and a refusal is still said out loud. | ||
| 873 | + pub(crate) fn cycle_export_picture(&mut self) { | ||
| 874 | + let next = crate::ui::settings_stance::next_picture(self.format, |f| { | ||
| 875 | + self.session | ||
| 876 | + .as_ref() | ||
| 877 | + .and_then(|session| format_refusal(session, f)) | ||
| 878 | + .is_some() | ||
| 879 | + }); | ||
| 880 | + self.set_format(next); | ||
| 881 | + } | ||
| 882 | + | ||
| 883 | + /// The Sound row: the next rate in [`engine::export::AUDIO_KBPS`], and | ||
| 884 | + /// nothing at all where the picked format's codec carries no rate -- the | ||
| 885 | + /// row shows no chord there either. | ||
| 886 | + pub(crate) fn cycle_audio_kbps(&mut self) { | ||
| 887 | + if !crate::ui::settings_stance::sound_codec(self.format).1 { | ||
| 888 | + return; | ||
| 889 | + } | ||
| 890 | + let at = AUDIO_KBPS | ||
| 891 | + .iter() | ||
| 892 | + .position(|&kbps| kbps == self.audio_kbps) | ||
| 893 | + .unwrap_or_default(); | ||
| 894 | + self.audio_kbps = AUDIO_KBPS[(at + 1) % AUDIO_KBPS.len()]; | ||
| 895 | + } | ||
| 896 | + | ||
| 897 | + /// The Encoder row: the next seat, through [`Self::apply_encoder`] so the | ||
| 898 | + /// pick is said and saved with the project exactly as the card's own list | ||
| 899 | + /// row saves it. | ||
| 900 | + pub(crate) fn cycle_encoder(&mut self, cx: &mut Context<Self>) { | ||
| 901 | + let at = EncoderSeat::ALL | ||
| 902 | + .iter() | ||
| 903 | + .position(|&seat| seat == self.encoder_seat()) | ||
| 904 | + .unwrap_or_default(); | ||
| 905 | + self.apply_encoder(EncoderSeat::ALL[(at + 1) % EncoderSeat::ALL.len()], cx); | ||
| 906 | + } | ||
| 907 | + | ||
| 869 | /// Opens the settings page (PROJECT rows beside EDITOR rows, | 908 | /// Opens the settings page (PROJECT rows beside EDITOR rows, |
| 870 | /// `ui::settings_stance`): the one door for "edit project and editor | 909 | /// `ui::settings_stance`): the one door for "edit project and editor |
| 871 | /// settings" -- refused while an export is running, same as every other | 910 | /// settings" -- refused while an export is running, same as every other |
| @@ -1784,6 +1823,20 @@ impl Player { | |||
| 1784 | } | 1823 | } |
| 1785 | return true; | 1824 | return true; |
| 1786 | } | 1825 | } |
| 1826 | + // The settings page's EXPORT rows: `c` steps the file, `b` the rate | ||
| 1827 | + // its sound is coded at and `e` the encoder seat. Card-local like the | ||
| 1828 | + // colour and transform branches above -- and only these three, so | ||
| 1829 | + // escape still closes the page and every other key falls through to | ||
| 1830 | + // the room. | ||
| 1831 | + if self.settings_open { | ||
| 1832 | + match key { | ||
| 1833 | + "c" => self.cycle_export_picture(), | ||
| 1834 | + "b" => self.cycle_audio_kbps(), | ||
| 1835 | + "e" => self.cycle_encoder(cx), | ||
| 1836 | + _ => return false, | ||
| 1837 | + } | ||
| 1838 | + return true; | ||
| 1839 | + } | ||
| 1787 | // The export card's custom bitrate field: the mouse door is the | 1840 | // The export card's custom bitrate field: the mouse door is the |
| 1788 | // steppers and the row's own click (`Player::edit_mbps`), but the | 1841 | // steppers and the row's own click (`Player::edit_mbps`), but the |
| 1789 | // `0–9`/backspace/enter/esc chords `keymap::FIXED` already | 1842 | // `0–9`/backspace/enter/esc chords `keymap::FIXED` already |
crates/app/src/tests/layout.rsmodified+139 -0
| @@ -3308,3 +3308,142 @@ fn string_literals(text: &str) -> Vec<String> { | |||
| 3308 | } | 3308 | } |
| 3309 | out | 3309 | out |
| 3310 | } | 3310 | } |
| 3311 | + | ||
| 3312 | +/// The export moment holds the file and the budget; everything a project is | ||
| 3313 | +/// *delivered as* is a settings row now (user: the export card was "too | ||
| 3314 | +/// complicated"). Four rows, and a fifth would be the card growing back -- | ||
| 3315 | +/// this is a source scan for the same reason every guard on this page is. | ||
| 3316 | +#[test] | ||
| 3317 | +fn the_export_section_is_four_rows_and_no_fifth() { | ||
| 3318 | + let source = src_text("ui/settings_stance.rs"); | ||
| 3319 | + let start = source | ||
| 3320 | + .find("fn export_section(") | ||
| 3321 | + .expect("the export section"); | ||
| 3322 | + let body = &source[start..]; | ||
| 3323 | + let end = body.find("\n/// The page itself").expect("the page's render fn"); | ||
| 3324 | + let body = &body[..end]; | ||
| 3325 | + let rows = [ | ||
| 3326 | + "settings-export-picture", | ||
| 3327 | + "settings-export-sound", | ||
| 3328 | + "settings-export-encoder", | ||
| 3329 | + "settings-export-range", | ||
| 3330 | + ]; | ||
| 3331 | + for row in rows { | ||
| 3332 | + assert!(body.contains(row), "the EXPORT section has no {row} row"); | ||
| 3333 | + } | ||
| 3334 | + // The Sound row is written twice -- a rated codec's keyed row and an | ||
| 3335 | + // unrated one's readout, never both at once -- so the count is by label, | ||
| 3336 | + // not by id. | ||
| 3337 | + for label in ["\"Picture\"", "\"Sound\"", "\"Encoder\"", "\"Range\""] { | ||
| 3338 | + assert!(body.contains(label), "the EXPORT section has no {label} row"); | ||
| 3339 | + } | ||
| 3340 | + let ids = body.match_indices("\"settings-export-").count(); | ||
| 3341 | + assert_eq!(ids, 5, "the EXPORT section grew a row past the four (the two Sound rows are one row's two shapes)"); | ||
| 3342 | + assert!( | ||
| 3343 | + source.contains("what a delivery is written as"), | ||
| 3344 | + "the section lost its head" | ||
| 3345 | + ); | ||
| 3346 | + // Every row wears its chord (DESIGN §4): three keyed rows plus the | ||
| 3347 | + // range's own marks, which are keymap actions. | ||
| 3348 | + for chord in ["\"c\"", "\"b\"", "\"e\"", "ActionId::SetIn"] { | ||
| 3349 | + assert!(body.contains(chord), "an EXPORT row lost its chord {chord}"); | ||
| 3350 | + } | ||
| 3351 | +} | ||
| 3352 | + | ||
| 3353 | +/// `c` walks the nine files in one order -- a codec's two boxes side by side, | ||
| 3354 | +/// the sound-only formats last -- and never stops on a format this machine | ||
| 3355 | +/// cannot write, because [`Player::set_format`] would only refuse it back. | ||
| 3356 | +#[test] | ||
| 3357 | +fn the_picture_row_cycles_codec_and_container_together_and_skips_a_refusal() { | ||
| 3358 | + use crate::ui::settings_stance::{PICTURE_CYCLE, next_picture, picture_label}; | ||
| 3359 | + assert_eq!( | ||
| 3360 | + PICTURE_CYCLE, | ||
| 3361 | + [ | ||
| 3362 | + Format::Mp4, | ||
| 3363 | + Format::Av1Mp4, | ||
| 3364 | + Format::Av1, | ||
| 3365 | + Format::Hevc, | ||
| 3366 | + Format::HevcMp4, | ||
| 3367 | + Format::Wav, | ||
| 3368 | + Format::Flac, | ||
| 3369 | + Format::Mp3, | ||
| 3370 | + Format::Ogg, | ||
| 3371 | + ] | ||
| 3372 | + ); | ||
| 3373 | + // Nothing refused: the whole ring, wrapping back to the head. | ||
| 3374 | + let mut at = Format::Mp4; | ||
| 3375 | + let mut walked = vec![at]; | ||
| 3376 | + for _ in 1..PICTURE_CYCLE.len() { | ||
| 3377 | + at = next_picture(at, |_| false); | ||
| 3378 | + walked.push(at); | ||
| 3379 | + } | ||
| 3380 | + assert_eq!(walked, PICTURE_CYCLE.to_vec()); | ||
| 3381 | + assert_eq!(next_picture(at, |_| false), Format::Mp4); | ||
| 3382 | + | ||
| 3383 | + // HEVC unavailable (no plugin): `c` steps over both of its boxes rather | ||
| 3384 | + // than parking on a pick the setter refuses. | ||
| 3385 | + let no_hevc = |f: Format| matches!(f, Format::Hevc | Format::HevcMp4); | ||
| 3386 | + assert_eq!(next_picture(Format::Av1, no_hevc), Format::Wav); | ||
| 3387 | + // Everything refused: the row keeps what it has instead of cycling to | ||
| 3388 | + // nothing. | ||
| 3389 | + assert_eq!(next_picture(Format::Mp4, |_| true), Format::Mp4); | ||
| 3390 | + | ||
| 3391 | + assert_eq!(picture_label(Format::Mp4), "H.264 · MP4"); | ||
| 3392 | + assert_eq!(picture_label(Format::Av1), "AV1 · MKV"); | ||
| 3393 | + assert_eq!(picture_label(Format::Av1Mp4), "AV1 · MP4"); | ||
| 3394 | + assert_eq!(picture_label(Format::Wav), "WAV"); | ||
| 3395 | +} | ||
| 3396 | + | ||
| 3397 | +/// A refused codec is greyed with its reason, never hidden (DESIGN §8), and | ||
| 3398 | +/// the reason is short enough to sit beside a value: six words, the rest of | ||
| 3399 | +/// the sentence still said by the export moment's own banner. The sound row | ||
| 3400 | +/// wears a chord only where its codec has a rate to step. | ||
| 3401 | +#[test] | ||
| 3402 | +fn a_refusal_is_six_words_beside_the_value_and_soundless_codecs_wear_no_chord() { | ||
| 3403 | + use crate::ui::settings_stance::{encoder_word, short_reason, sound_codec}; | ||
| 3404 | + let long = "HEVC needs the VA-API plugin, which this machine has not built"; | ||
| 3405 | + assert_eq!(short_reason(long), "HEVC needs the VA-API plugin, which"); | ||
| 3406 | + assert!(short_reason(long).split_whitespace().count() <= 6); | ||
| 3407 | + assert_eq!(short_reason("no encoder here"), "no encoder here"); | ||
| 3408 | + | ||
| 3409 | + for (format, codec, rated) in [ | ||
| 3410 | + (Format::Mp4, "AAC", true), | ||
| 3411 | + (Format::Av1, "AAC", true), | ||
| 3412 | + (Format::Mp3, "MP3", true), | ||
| 3413 | + (Format::Wav, "PCM", false), | ||
| 3414 | + (Format::Flac, "FLAC", false), | ||
| 3415 | + (Format::Ogg, "Vorbis", false), | ||
| 3416 | + ] { | ||
| 3417 | + assert_eq!(sound_codec(format), (codec, rated), "{format:?}"); | ||
| 3418 | + } | ||
| 3419 | + | ||
| 3420 | + assert_eq!(encoder_word(EncoderSeat::Auto), "auto"); | ||
| 3421 | + assert_eq!(encoder_word(EncoderSeat::Hardware), "GPU"); | ||
| 3422 | + assert_eq!(encoder_word(EncoderSeat::Software), "software"); | ||
| 3423 | +} | ||
| 3424 | + | ||
| 3425 | +/// The one amber line on the page is the AV1-on-the-GPU seat, and it is the | ||
| 3426 | +/// only hue the EXPORT rows introduce -- every other value is an ink. | ||
| 3427 | +#[test] | ||
| 3428 | +fn the_only_hue_in_the_export_section_is_the_av1_gpu_notice() { | ||
| 3429 | + let source = src_text("ui/settings_stance.rs"); | ||
| 3430 | + let start = source | ||
| 3431 | + .find("fn export_section(") | ||
| 3432 | + .expect("the export section"); | ||
| 3433 | + let body = &source[start..]; | ||
| 3434 | + let body = &body[..body.find("\n/// The page itself").expect("the render fn")]; | ||
| 3435 | + assert!( | ||
| 3436 | + body.contains("NOTICE_LOOK()"), | ||
| 3437 | + "the AV1-on-the-GPU row lost its amber" | ||
| 3438 | + ); | ||
| 3439 | + assert_eq!( | ||
| 3440 | + crate::ui::settings_stance::AV1_GPU_NOTICE, | ||
| 3441 | + "ignores the budget \u{2014} constant quality" | ||
| 3442 | + ); | ||
| 3443 | + for hue in ["ACCENT_", "STATUS_", "NOTICE_TELL", "NOTICE_DECIDE"] { | ||
| 3444 | + assert!( | ||
| 3445 | + !body.contains(hue), | ||
| 3446 | + "the EXPORT rows reached for a second hue ({hue})" | ||
| 3447 | + ); | ||
| 3448 | + } | ||
| 3449 | +} | ||
crates/app/src/ui/settings_stance.rsmodified+272 -5
| @@ -89,6 +89,7 @@ fn row_keyed( | |||
| 89 | value, | 89 | value, |
| 90 | hint, | 90 | hint, |
| 91 | Some(player.keymap.chord(action).into()), | 91 | Some(player.keymap.chord(action).into()), |
| 92 | + None, | ||
| 92 | player, | 93 | player, |
| 93 | on_click, | 94 | on_click, |
| 94 | INK1(), | 95 | INK1(), |
| @@ -108,7 +109,7 @@ fn row_ink( | |||
| 108 | value_ink: u32, | 109 | value_ink: u32, |
| 109 | ) -> impl IntoElement { | 110 | ) -> impl IntoElement { |
| 110 | row_full( | 111 | row_full( |
| 111 | - id, label_text, value, hint, None, player, on_click, value_ink, | 112 | + id, label_text, value, hint, None, None, player, on_click, value_ink, |
| 112 | ) | 113 | ) |
| 113 | } | 114 | } |
| 114 | 115 | ||
| @@ -123,6 +124,7 @@ fn row_full( | |||
| 123 | value: impl Into<SharedString>, | 124 | value: impl Into<SharedString>, |
| 124 | hint: &'static str, | 125 | hint: &'static str, |
| 125 | chord: Option<SharedString>, | 126 | chord: Option<SharedString>, |
| 127 | + tail: Option<(SharedString, u32)>, | ||
| 126 | player: &Player, | 128 | player: &Player, |
| 127 | on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, | 129 | on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, |
| 128 | value_ink: u32, | 130 | value_ink: u32, |
| @@ -162,6 +164,17 @@ fn row_full( | |||
| 162 | .flex() | 164 | .flex() |
| 163 | .items_baseline() | 165 | .items_baseline() |
| 164 | .gap(px(8.)) | 166 | .gap(px(8.)) |
| 167 | + .children(tail.map(|(tail, ink)| { | ||
| 168 | + let tail_style = type_scale::mono( | ||
| 169 | + type_scale::CHORD_METADATA_MIN_PX, | ||
| 170 | + gpui::FontWeight::MEDIUM, | ||
| 171 | + ); | ||
| 172 | + div() | ||
| 173 | + .font(tail_style.font) | ||
| 174 | + .text_size(tail_style.size) | ||
| 175 | + .text_color(rgb(ink)) | ||
| 176 | + .child(tail) | ||
| 177 | + })) | ||
| 165 | .children(chord.map(|chord| { | 178 | .children(chord.map(|chord| { |
| 166 | let chord_style = type_scale::mono( | 179 | let chord_style = type_scale::mono( |
| 167 | type_scale::CHORD_METADATA_MIN_PX, | 180 | type_scale::CHORD_METADATA_MIN_PX, |
| @@ -195,6 +208,7 @@ fn row_static( | |||
| 195 | label_text: &'static str, | 208 | label_text: &'static str, |
| 196 | value: impl Into<SharedString>, | 209 | value: impl Into<SharedString>, |
| 197 | hint: &'static str, | 210 | hint: &'static str, |
| 211 | + chord: Option<SharedString>, | ||
| 198 | value_ink: u32, | 212 | value_ink: u32, |
| 199 | ) -> impl IntoElement { | 213 | ) -> impl IntoElement { |
| 200 | let value: SharedString = value.into(); | 214 | let value: SharedString = value.into(); |
| @@ -221,10 +235,27 @@ fn row_static( | |||
| 221 | .child( | 235 | .child( |
| 222 | div() | 236 | div() |
| 223 | .flex_none() | 237 | .flex_none() |
| 224 | - .font(value_style.font) | 238 | + .flex() |
| 225 | - .text_size(value_style.size) | 239 | + .items_baseline() |
| 226 | - .text_color(rgb(value_ink)) | 240 | + .gap(px(8.)) |
| 227 | - .child(value), | 241 | + .children(chord.map(|chord| { |
| 242 | + let chord_style = type_scale::mono( | ||
| 243 | + type_scale::CHORD_METADATA_MIN_PX, | ||
| 244 | + gpui::FontWeight::MEDIUM, | ||
| 245 | + ); | ||
| 246 | + div() | ||
| 247 | + .font(chord_style.font) | ||
| 248 | + .text_size(chord_style.size) | ||
| 249 | + .text_color(rgb(INK3())) | ||
| 250 | + .child(chord) | ||
| 251 | + })) | ||
| 252 | + .child( | ||
| 253 | + div() | ||
| 254 | + .font(value_style.font) | ||
| 255 | + .text_size(value_style.size) | ||
| 256 | + .text_color(rgb(value_ink)) | ||
| 257 | + .child(value), | ||
| 258 | + ), | ||
| 228 | ) | 259 | ) |
| 229 | } | 260 | } |
| 230 | 261 | ||
| @@ -331,6 +362,7 @@ fn project_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElemen | |||
| 331 | "HDR reference", | 362 | "HDR reference", |
| 332 | master_val, | 363 | master_val, |
| 333 | "the mastering display's own peak white, in cd/m^2, as the grade declared it -- what a 'Reference' tonemap targets before it ever looks at this film's own pixels", | 364 | "the mastering display's own peak white, in cd/m^2, as the grade declared it -- what a 'Reference' tonemap targets before it ever looks at this film's own pixels", |
| 365 | + None, | ||
| 334 | master_ink, | 366 | master_ink, |
| 335 | )) | 367 | )) |
| 336 | .child(row_static( | 368 | .child(row_static( |
| @@ -338,6 +370,7 @@ fn project_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElemen | |||
| 338 | "Content light", | 370 | "Content light", |
| 339 | content_val, | 371 | content_val, |
| 340 | "MaxCLL/MaxFALL: the brightest single pixel and the brightest frame average measured in the finished encode -- what a 'Reference' tonemap actually rolls off from when the file declares it, ahead of the mastering peak above", | 372 | "MaxCLL/MaxFALL: the brightest single pixel and the brightest frame average measured in the finished encode -- what a 'Reference' tonemap actually rolls off from when the file declares it, ahead of the mastering peak above", |
| 373 | + None, | ||
| 341 | content_ink, | 374 | content_ink, |
| 342 | )) | 375 | )) |
| 343 | .child(row( | 376 | .child(row( |
| @@ -408,6 +441,226 @@ fn editor_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElement | |||
| 408 | )) | 441 | )) |
| 409 | } | 442 | } |
| 410 | 443 | ||
| 444 | +/// [`row_keyed`] for a stroke that is the *card's* own rather than a binding: | ||
| 445 | +/// the export rows' `c`/`b`/`e` mean nothing outside this page and so are not | ||
| 446 | +/// in the keymap, exactly as the colour and transform cards' keys are not. | ||
| 447 | +/// The badge is drawn from the slot a bound row's is, so no reader can tell -- | ||
| 448 | +/// nor needs to -- which table a stroke came out of (DESIGN §4). | ||
| 449 | +fn row_chord( | ||
| 450 | + id: &'static str, | ||
| 451 | + label_text: &'static str, | ||
| 452 | + value: impl Into<SharedString>, | ||
| 453 | + hint: &'static str, | ||
| 454 | + chord: &'static str, | ||
| 455 | + tail: Option<(SharedString, u32)>, | ||
| 456 | + player: &Player, | ||
| 457 | + on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, | ||
| 458 | +) -> impl IntoElement { | ||
| 459 | + row_full( | ||
| 460 | + id, | ||
| 461 | + label_text, | ||
| 462 | + value, | ||
| 463 | + hint, | ||
| 464 | + Some(chord.into()), | ||
| 465 | + tail, | ||
| 466 | + player, | ||
| 467 | + on_click, | ||
| 468 | + INK1(), | ||
| 469 | + ) | ||
| 470 | +} | ||
| 471 | + | ||
| 472 | +/// The nine files this editor writes, in the order the Picture row cycles | ||
| 473 | +/// them: a codec's two boxes side by side (the container question the export | ||
| 474 | +/// card asked in a row of its own, folded into this one), and the sound-only | ||
| 475 | +/// formats after the pictures. | ||
| 476 | +pub(crate) const PICTURE_CYCLE: [Format; 9] = [ | ||
| 477 | + Format::Mp4, | ||
| 478 | + Format::Av1Mp4, | ||
| 479 | + Format::Av1, | ||
| 480 | + Format::Hevc, | ||
| 481 | + Format::HevcMp4, | ||
| 482 | + Format::Wav, | ||
| 483 | + Format::Flac, | ||
| 484 | + Format::Mp3, | ||
| 485 | + Format::Ogg, | ||
| 486 | +]; | ||
| 487 | + | ||
| 488 | +/// `H.264 · MP4`: the codec by the name it is picked under ([`format_label`]) | ||
| 489 | +/// and the box it lands in. An audio-only format names itself once -- `WAV · | ||
| 490 | +/// WAV` would be the one field on the line that says nothing. | ||
| 491 | +pub(crate) fn picture_label(format: Format) -> String { | ||
| 492 | + match format.has_video() { | ||
| 493 | + true => format!("{} · {}", format_label(format), format.ext().to_uppercase()), | ||
| 494 | + false => format_label(format).to_string(), | ||
| 495 | + } | ||
| 496 | +} | ||
| 497 | + | ||
| 498 | +/// The next file in [`PICTURE_CYCLE`] this machine can actually write. | ||
| 499 | +/// `refused` is the same door [`Player::set_format`] asks, so the stroke never | ||
| 500 | +/// stops on a codec the setter would only refuse back -- the refused ones are | ||
| 501 | +/// still *said*, on the row's own greyed tail (DESIGN §8: never hidden). | ||
| 502 | +/// `current` where every other stop is refused, so `c` cannot cycle to | ||
| 503 | +/// nothing. | ||
| 504 | +pub(crate) fn next_picture(current: Format, refused: impl Fn(Format) -> bool) -> Format { | ||
| 505 | + let n = PICTURE_CYCLE.len(); | ||
| 506 | + let at = PICTURE_CYCLE | ||
| 507 | + .iter() | ||
| 508 | + .position(|&f| f == current) | ||
| 509 | + .unwrap_or_default(); | ||
| 510 | + (1..=n) | ||
| 511 | + .map(|step| PICTURE_CYCLE[(at + step) % n]) | ||
| 512 | + .find(|&f| !refused(f)) | ||
| 513 | + .unwrap_or(current) | ||
| 514 | +} | ||
| 515 | + | ||
| 516 | +/// What the sound of a file in this format is, and whether that codec takes a | ||
| 517 | +/// rate: `AAC 256` steps with `b`, `PCM` has no rate to step and so wears no | ||
| 518 | +/// chord at all. | ||
| 519 | +pub(crate) fn sound_codec(format: Format) -> (&'static str, bool) { | ||
| 520 | + match format { | ||
| 521 | + Format::Wav => ("PCM", false), | ||
| 522 | + Format::Flac => ("FLAC", false), | ||
| 523 | + Format::Ogg => ("Vorbis", false), | ||
| 524 | + Format::Mp3 => ("MP3", true), | ||
| 525 | + _ => ("AAC", true), | ||
| 526 | + } | ||
| 527 | +} | ||
| 528 | + | ||
| 529 | +/// The seat in the words the artboard writes it in -- lowercase `auto` and | ||
| 530 | +/// `software` because they are what happens, `GPU` because that is the part | ||
| 531 | +/// of this machine a person picked. | ||
| 532 | +pub(crate) fn encoder_word(seat: EncoderSeat) -> &'static str { | ||
| 533 | + match seat { | ||
| 534 | + EncoderSeat::Auto => "auto", | ||
| 535 | + EncoderSeat::Hardware => "GPU", | ||
| 536 | + EncoderSeat::Software => "software", | ||
| 537 | + } | ||
| 538 | +} | ||
| 539 | + | ||
| 540 | +/// The one amber line on this page (`NOTICE_LOOK`, DESIGN §8's "worth a | ||
| 541 | +/// look"): the plugin's AV1 seat is constant-quality, so the budget the | ||
| 542 | +/// export moment now asks for is the one thing this pick does not honour. | ||
| 543 | +pub(crate) const AV1_GPU_NOTICE: &str = "ignores the budget \u{2014} constant quality"; | ||
| 544 | + | ||
| 545 | +/// A refusal in six words, which is what fits beside a value on one row -- | ||
| 546 | +/// the whole sentence is still said where the pick is actually refused | ||
| 547 | +/// ([`Player::set_format`]'s own banner). | ||
| 548 | +pub(crate) fn short_reason(why: &str) -> String { | ||
| 549 | + why.split_whitespace().take(6).collect::<Vec<_>>().join(" ") | ||
| 550 | +} | ||
| 551 | + | ||
| 552 | +/// EXPORT: the four choices a film is delivered by, off the export card (user: | ||
| 553 | +/// it was "too complicated") and into the room where a project's other | ||
| 554 | +/// once-a-project answers already live. The export moment keeps the file and | ||
| 555 | +/// the budget; the codec, the sound, the encoder and the range are here. | ||
| 556 | +fn export_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 557 | + let format = player.format; | ||
| 558 | + let refusals: Vec<String> = PICTURE_CYCLE | ||
| 559 | + .into_iter() | ||
| 560 | + .filter_map(|f| { | ||
| 561 | + player | ||
| 562 | + .session | ||
| 563 | + .as_ref() | ||
| 564 | + .and_then(|session| format_refusal(session, f)) | ||
| 565 | + .map(|why| format!("{} {}", format_label(f), short_reason(&why))) | ||
| 566 | + }) | ||
| 567 | + .collect(); | ||
| 568 | + // Never hidden (DESIGN §8): a codec this machine has no encoder for stays | ||
| 569 | + // on the row, greyed, with the reason beside it -- the export card's own | ||
| 570 | + // refusal rows, in the one place a codec is picked now. | ||
| 571 | + let refused_tail = (!refusals.is_empty()).then(|| (refusals.join(" \u{b7} ").into(), INK4())); | ||
| 572 | + let (codec, rated) = sound_codec(format); | ||
| 573 | + let seat = player.encoder_seat(); | ||
| 574 | + let av1_gpu = seat == EncoderSeat::Hardware && matches!(format, Format::Av1 | Format::Av1Mp4); | ||
| 575 | + let range = match player.range { | ||
| 576 | + Some((start, end)) => format!( | ||
| 577 | + "marks {}\u{2013}{}", | ||
| 578 | + timecode(f64::from(start) / player.fps, player.fps), | ||
| 579 | + timecode(f64::from(end) / player.fps, player.fps), | ||
| 580 | + ), | ||
| 581 | + None => "whole film".to_string(), | ||
| 582 | + }; | ||
| 583 | + div() | ||
| 584 | + .flex_none() | ||
| 585 | + .flex() | ||
| 586 | + .flex_col() | ||
| 587 | + .gap(px(2.)) | ||
| 588 | + .child(section_head("EXPORT \u{b7} what a delivery is written as")) | ||
| 589 | + .child(row_chord( | ||
| 590 | + "settings-export-picture", | ||
| 591 | + "Picture", | ||
| 592 | + picture_label(format), | ||
| 593 | + "the codec the picture is written with and the box it lands in; the export moment asks only for the file and the budget", | ||
| 594 | + "c", | ||
| 595 | + refused_tail, | ||
| 596 | + player, | ||
| 597 | + cx.listener(|this, _: &ClickEvent, _, cx| { | ||
| 598 | + this.cycle_export_picture(); | ||
| 599 | + cx.notify(); | ||
| 600 | + }), | ||
| 601 | + )) | ||
| 602 | + .children(rated.then(|| { | ||
| 603 | + row_chord( | ||
| 604 | + "settings-export-sound", | ||
| 605 | + "Sound", | ||
| 606 | + format!("{codec} {}", player.audio_kbps), | ||
| 607 | + "what the sound inside that file is coded at, in kbps", | ||
| 608 | + "b", | ||
| 609 | + None, | ||
| 610 | + player, | ||
| 611 | + cx.listener(|this, _: &ClickEvent, _, cx| { | ||
| 612 | + this.cycle_audio_kbps(); | ||
| 613 | + cx.notify(); | ||
| 614 | + }), | ||
| 615 | + ) | ||
| 616 | + .into_any_element() | ||
| 617 | + })) | ||
| 618 | + // A codec with no rate to pick is a readout, not a button that would | ||
| 619 | + // do nothing when pressed -- and it wears no chord, because there is | ||
| 620 | + // no step for one to take. | ||
| 621 | + .children((!rated).then(|| { | ||
| 622 | + row_static( | ||
| 623 | + "settings-export-sound", | ||
| 624 | + "Sound", | ||
| 625 | + codec, | ||
| 626 | + "this codec carries no rate to pick: it is written as the format itself says", | ||
| 627 | + None, | ||
| 628 | + INK1(), | ||
| 629 | + ) | ||
| 630 | + .into_any_element() | ||
| 631 | + })) | ||
| 632 | + .child(row_chord( | ||
| 633 | + "settings-export-encoder", | ||
| 634 | + "Encoder", | ||
| 635 | + encoder_word(seat), | ||
| 636 | + "which encoder writes the picture: the GPU where this machine has a seat, or the CPU", | ||
| 637 | + "e", | ||
| 638 | + av1_gpu.then(|| (AV1_GPU_NOTICE.into(), NOTICE_LOOK())), | ||
| 639 | + player, | ||
| 640 | + cx.listener(|this, _: &ClickEvent, _, cx| { | ||
| 641 | + this.cycle_encoder(cx); | ||
| 642 | + }), | ||
| 643 | + )) | ||
| 644 | + // Read-only: the range is set on the timeline with the marks | ||
| 645 | + // themselves ([`keymap::ActionId::SetIn`]/`SetOut`), which is where a | ||
| 646 | + // person can see what they are marking. | ||
| 647 | + .child(row_static( | ||
| 648 | + "settings-export-range", | ||
| 649 | + "Range", | ||
| 650 | + range, | ||
| 651 | + "the span an export writes: the whole timeline, or whatever the in/out marks hold", | ||
| 652 | + Some( | ||
| 653 | + format!( | ||
| 654 | + "{} {}", | ||
| 655 | + player.keymap.chord(ActionId::SetIn), | ||
| 656 | + player.keymap.chord(ActionId::SetOut) | ||
| 657 | + ) | ||
| 658 | + .into(), | ||
| 659 | + ), | ||
| 660 | + INK1(), | ||
| 661 | + )) | ||
| 662 | +} | ||
| 663 | + | ||
| 411 | /// The page itself: a plate in the room's own below-picture footprint, | 664 | /// The page itself: a plate in the room's own below-picture footprint, |
| 412 | /// closed by a click away or `esc` through [`Player::close_card`] like every | 665 | /// closed by a click away or `esc` through [`Player::close_card`] like every |
| 413 | /// other card here. | 666 | /// other card here. |
| @@ -513,6 +766,20 @@ pub(crate) fn render( | |||
| 513 | .border_color(rgb(DARK_HAIRLINE())) | 766 | .border_color(rgb(DARK_HAIRLINE())) |
| 514 | .pl(px(12.)) | 767 | .pl(px(12.)) |
| 515 | .child(editor_section(player, cx)), | 768 | .child(editor_section(player, cx)), |
| 769 | + ) | ||
| 770 | + // The third column: what a delivery is written as, the | ||
| 771 | + // rows the export card used to hold (user: it was "too | ||
| 772 | + // complicated"). Beside the other two rather than under | ||
| 773 | + // them -- a fold with no scrollbar is the defect this | ||
| 774 | + // page's own two columns exist to avoid. | ||
| 775 | + .child( | ||
| 776 | + div() | ||
| 777 | + .flex_1() | ||
| 778 | + .min_w(px(0.)) | ||
| 779 | + .border_l_1() | ||
| 780 | + .border_color(rgb(DARK_HAIRLINE())) | ||
| 781 | + .pl(px(12.)) | ||
| 782 | + .child(export_section(player, cx)), | ||
| 516 | ), | 783 | ), |
| 517 | ), | 784 | ), |
| 518 | ) | 785 | ) |