From 62a0894ace763ef2394e8fe84bf42f973f8b4f93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 9 Sep 2026 17:51:57 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(app):=20the=20export's=20once-?= =?UTF-8?q?a-project=20choices=20move=20into=20the=20settings=20room?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Picture, Sound, Encoder and Range join PROJECT and EDITOR as a third column: the export moment keeps the file and the budget, and the codec, its container, the sound rate, the encoder seat and the marked range are answered once, where a project's other once-a-project answers already live. c/b/e step them, card-local like the colour card's own keys; the range is a readout wearing the marks' own chords. A codec this machine has no encoder for is greyed with its reason beside the value rather than hidden, and AV1 on the GPU wears the one amber line on the page. --- crates/app/src/player/cards.rs | 53 +++++ crates/app/src/tests/layout.rs | 139 ++++++++++++++ crates/app/src/ui/settings_stance.rs | 277 ++++++++++++++++++++++++++- 3 files changed, 464 insertions(+), 5 deletions(-) diff --git a/crates/app/src/player/cards.rs b/crates/app/src/player/cards.rs index c48163a..c2ec9e8 100644 --- a/crates/app/src/player/cards.rs +++ b/crates/app/src/player/cards.rs @@ -870,6 +870,45 @@ impl Player { /// Nothing here is a clip's or even the project's -- it never reaches the /// export, which never burns a cue into the picture -- so like the mix /// card it opens with no timeline required and nothing to refuse. + /// The settings page's Picture row: the next file this machine can write + /// ([`ui::settings_stance::next_picture`] -- codec and container in one + /// cycle now), through [`Self::set_format`] like every other pick, so the + /// destination follows the format and a refusal is still said out loud. + pub(crate) fn cycle_export_picture(&mut self) { + let next = crate::ui::settings_stance::next_picture(self.format, |f| { + self.session + .as_ref() + .and_then(|session| format_refusal(session, f)) + .is_some() + }); + self.set_format(next); + } + + /// The Sound row: the next rate in [`engine::export::AUDIO_KBPS`], and + /// nothing at all where the picked format's codec carries no rate -- the + /// row shows no chord there either. + pub(crate) fn cycle_audio_kbps(&mut self) { + if !crate::ui::settings_stance::sound_codec(self.format).1 { + return; + } + let at = AUDIO_KBPS + .iter() + .position(|&kbps| kbps == self.audio_kbps) + .unwrap_or_default(); + self.audio_kbps = AUDIO_KBPS[(at + 1) % AUDIO_KBPS.len()]; + } + + /// The Encoder row: the next seat, through [`Self::apply_encoder`] so the + /// pick is said and saved with the project exactly as the card's own list + /// row saves it. + pub(crate) fn cycle_encoder(&mut self, cx: &mut Context) { + let at = EncoderSeat::ALL + .iter() + .position(|&seat| seat == self.encoder_seat()) + .unwrap_or_default(); + self.apply_encoder(EncoderSeat::ALL[(at + 1) % EncoderSeat::ALL.len()], cx); + } + /// Opens the settings page (PROJECT rows beside EDITOR rows, /// `ui::settings_stance`): the one door for "edit project and editor /// settings" -- refused while an export is running, same as every other @@ -1788,6 +1827,20 @@ impl Player { } return true; } + // The settings page's EXPORT rows: `c` steps the file, `b` the rate + // its sound is coded at and `e` the encoder seat. Card-local like the + // colour and transform branches above -- and only these three, so + // escape still closes the page and every other key falls through to + // the room. + if self.settings_open { + match key { + "c" => self.cycle_export_picture(), + "b" => self.cycle_audio_kbps(), + "e" => self.cycle_encoder(cx), + _ => return false, + } + return true; + } // The export card's custom bitrate field: the mouse door is the // steppers and the row's own click (`Player::edit_mbps`), but the // `0–9`/backspace/enter/esc chords `keymap::FIXED` already diff --git a/crates/app/src/tests/layout.rs b/crates/app/src/tests/layout.rs index aaaa842..c8bae89 100644 --- a/crates/app/src/tests/layout.rs +++ b/crates/app/src/tests/layout.rs @@ -2814,3 +2814,142 @@ fn the_lane_bed_clips_its_clips_at_the_pinned_heads() { pinned lane heads: {bed}" ); } + +/// The export moment holds the file and the budget; everything a project is +/// *delivered as* is a settings row now (user: the export card was "too +/// complicated"). Four rows, and a fifth would be the card growing back -- +/// this is a source scan for the same reason every guard on this page is. +#[test] +fn the_export_section_is_four_rows_and_no_fifth() { + let source = src_text("ui/settings_stance.rs"); + let start = source + .find("fn export_section(") + .expect("the export section"); + let body = &source[start..]; + let end = body.find("\n/// The page itself").expect("the page's render fn"); + let body = &body[..end]; + let rows = [ + "settings-export-picture", + "settings-export-sound", + "settings-export-encoder", + "settings-export-range", + ]; + for row in rows { + assert!(body.contains(row), "the EXPORT section has no {row} row"); + } + // The Sound row is written twice -- a rated codec's keyed row and an + // unrated one's readout, never both at once -- so the count is by label, + // not by id. + for label in ["\"Picture\"", "\"Sound\"", "\"Encoder\"", "\"Range\""] { + assert!(body.contains(label), "the EXPORT section has no {label} row"); + } + let ids = body.match_indices("\"settings-export-").count(); + assert_eq!(ids, 5, "the EXPORT section grew a row past the four (the two Sound rows are one row's two shapes)"); + assert!( + source.contains("what a delivery is written as"), + "the section lost its head" + ); + // Every row wears its chord (DESIGN §4): three keyed rows plus the + // range's own marks, which are keymap actions. + for chord in ["\"c\"", "\"b\"", "\"e\"", "ActionId::SetIn"] { + assert!(body.contains(chord), "an EXPORT row lost its chord {chord}"); + } +} + +/// `c` walks the nine files in one order -- a codec's two boxes side by side, +/// the sound-only formats last -- and never stops on a format this machine +/// cannot write, because [`Player::set_format`] would only refuse it back. +#[test] +fn the_picture_row_cycles_codec_and_container_together_and_skips_a_refusal() { + use crate::ui::settings_stance::{PICTURE_CYCLE, next_picture, picture_label}; + assert_eq!( + PICTURE_CYCLE, + [ + Format::Mp4, + Format::Av1Mp4, + Format::Av1, + Format::Hevc, + Format::HevcMp4, + Format::Wav, + Format::Flac, + Format::Mp3, + Format::Ogg, + ] + ); + // Nothing refused: the whole ring, wrapping back to the head. + let mut at = Format::Mp4; + let mut walked = vec![at]; + for _ in 1..PICTURE_CYCLE.len() { + at = next_picture(at, |_| false); + walked.push(at); + } + assert_eq!(walked, PICTURE_CYCLE.to_vec()); + assert_eq!(next_picture(at, |_| false), Format::Mp4); + + // HEVC unavailable (no plugin): `c` steps over both of its boxes rather + // than parking on a pick the setter refuses. + let no_hevc = |f: Format| matches!(f, Format::Hevc | Format::HevcMp4); + assert_eq!(next_picture(Format::Av1, no_hevc), Format::Wav); + // Everything refused: the row keeps what it has instead of cycling to + // nothing. + assert_eq!(next_picture(Format::Mp4, |_| true), Format::Mp4); + + assert_eq!(picture_label(Format::Mp4), "H.264 · MP4"); + assert_eq!(picture_label(Format::Av1), "AV1 · MKV"); + assert_eq!(picture_label(Format::Av1Mp4), "AV1 · MP4"); + assert_eq!(picture_label(Format::Wav), "WAV"); +} + +/// A refused codec is greyed with its reason, never hidden (DESIGN §8), and +/// the reason is short enough to sit beside a value: six words, the rest of +/// the sentence still said by the export moment's own banner. The sound row +/// wears a chord only where its codec has a rate to step. +#[test] +fn a_refusal_is_six_words_beside_the_value_and_soundless_codecs_wear_no_chord() { + use crate::ui::settings_stance::{encoder_word, short_reason, sound_codec}; + let long = "HEVC needs the VA-API plugin, which this machine has not built"; + assert_eq!(short_reason(long), "HEVC needs the VA-API plugin, which"); + assert!(short_reason(long).split_whitespace().count() <= 6); + assert_eq!(short_reason("no encoder here"), "no encoder here"); + + for (format, codec, rated) in [ + (Format::Mp4, "AAC", true), + (Format::Av1, "AAC", true), + (Format::Mp3, "MP3", true), + (Format::Wav, "PCM", false), + (Format::Flac, "FLAC", false), + (Format::Ogg, "Vorbis", false), + ] { + assert_eq!(sound_codec(format), (codec, rated), "{format:?}"); + } + + assert_eq!(encoder_word(EncoderSeat::Auto), "auto"); + assert_eq!(encoder_word(EncoderSeat::Hardware), "GPU"); + assert_eq!(encoder_word(EncoderSeat::Software), "software"); +} + +/// The one amber line on the page is the AV1-on-the-GPU seat, and it is the +/// only hue the EXPORT rows introduce -- every other value is an ink. +#[test] +fn the_only_hue_in_the_export_section_is_the_av1_gpu_notice() { + let source = src_text("ui/settings_stance.rs"); + let start = source + .find("fn export_section(") + .expect("the export section"); + let body = &source[start..]; + let body = &body[..body.find("\n/// The page itself").expect("the render fn")]; + assert!( + body.contains("NOTICE_LOOK()"), + "the AV1-on-the-GPU row lost its amber" + ); + assert_eq!( + crate::ui::settings_stance::AV1_GPU_NOTICE, + "ignores the budget \u{2014} constant quality" + ); + for hue in ["ACCENT_", "STATUS_", "NOTICE_TELL", "NOTICE_DECIDE"] { + assert!( + !body.contains(hue), + "the EXPORT rows reached for a second hue ({hue})" + ); + } +} diff --git a/crates/app/src/ui/settings_stance.rs b/crates/app/src/ui/settings_stance.rs index fd39f33..3342b50 100644 --- a/crates/app/src/ui/settings_stance.rs +++ b/crates/app/src/ui/settings_stance.rs @@ -89,6 +89,7 @@ fn row_keyed( value, hint, Some(player.keymap.chord(action).into()), + None, player, on_click, INK1(), @@ -108,7 +109,7 @@ fn row_ink( value_ink: u32, ) -> impl IntoElement { row_full( - id, label_text, value, hint, None, player, on_click, value_ink, + id, label_text, value, hint, None, None, player, on_click, value_ink, ) } @@ -123,6 +124,7 @@ fn row_full( value: impl Into, hint: &'static str, chord: Option, + tail: Option<(SharedString, u32)>, player: &Player, on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, value_ink: u32, @@ -162,6 +164,17 @@ fn row_full( .flex() .items_baseline() .gap(px(8.)) + .children(tail.map(|(tail, ink)| { + let tail_style = type_scale::mono( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + ); + div() + .font(tail_style.font) + .text_size(tail_style.size) + .text_color(rgb(ink)) + .child(tail) + })) .children(chord.map(|chord| { let chord_style = type_scale::mono( type_scale::CHORD_METADATA_MIN_PX, @@ -195,6 +208,7 @@ fn row_static( label_text: &'static str, value: impl Into, hint: &'static str, + chord: Option, value_ink: u32, ) -> impl IntoElement { let value: SharedString = value.into(); @@ -221,10 +235,27 @@ fn row_static( .child( div() .flex_none() - .font(value_style.font) - .text_size(value_style.size) - .text_color(rgb(value_ink)) - .child(value), + .flex() + .items_baseline() + .gap(px(8.)) + .children(chord.map(|chord| { + let chord_style = type_scale::mono( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + ); + div() + .font(chord_style.font) + .text_size(chord_style.size) + .text_color(rgb(INK3())) + .child(chord) + })) + .child( + div() + .font(value_style.font) + .text_size(value_style.size) + .text_color(rgb(value_ink)) + .child(value), + ), ) } @@ -331,6 +362,7 @@ fn project_section(player: &Player, cx: &mut Context) -> impl IntoElemen "HDR reference", master_val, "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", + None, master_ink, )) .child(row_static( @@ -338,6 +370,7 @@ fn project_section(player: &Player, cx: &mut Context) -> impl IntoElemen "Content light", content_val, "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", + None, content_ink, )) .child(row( @@ -408,6 +441,226 @@ fn editor_section(player: &Player, cx: &mut Context) -> impl IntoElement )) } +/// [`row_keyed`] for a stroke that is the *card's* own rather than a binding: +/// the export rows' `c`/`b`/`e` mean nothing outside this page and so are not +/// in the keymap, exactly as the colour and transform cards' keys are not. +/// The badge is drawn from the slot a bound row's is, so no reader can tell -- +/// nor needs to -- which table a stroke came out of (DESIGN §4). +fn row_chord( + id: &'static str, + label_text: &'static str, + value: impl Into, + hint: &'static str, + chord: &'static str, + tail: Option<(SharedString, u32)>, + player: &Player, + on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, +) -> impl IntoElement { + row_full( + id, + label_text, + value, + hint, + Some(chord.into()), + tail, + player, + on_click, + INK1(), + ) +} + +/// The nine files this editor writes, in the order the Picture row cycles +/// them: a codec's two boxes side by side (the container question the export +/// card asked in a row of its own, folded into this one), and the sound-only +/// formats after the pictures. +pub(crate) const PICTURE_CYCLE: [Format; 9] = [ + Format::Mp4, + Format::Av1Mp4, + Format::Av1, + Format::Hevc, + Format::HevcMp4, + Format::Wav, + Format::Flac, + Format::Mp3, + Format::Ogg, +]; + +/// `H.264 · MP4`: the codec by the name it is picked under ([`format_label`]) +/// and the box it lands in. An audio-only format names itself once -- `WAV · +/// WAV` would be the one field on the line that says nothing. +pub(crate) fn picture_label(format: Format) -> String { + match format.has_video() { + true => format!("{} · {}", format_label(format), format.ext().to_uppercase()), + false => format_label(format).to_string(), + } +} + +/// The next file in [`PICTURE_CYCLE`] this machine can actually write. +/// `refused` is the same door [`Player::set_format`] asks, so the stroke never +/// stops on a codec the setter would only refuse back -- the refused ones are +/// still *said*, on the row's own greyed tail (DESIGN §8: never hidden). +/// `current` where every other stop is refused, so `c` cannot cycle to +/// nothing. +pub(crate) fn next_picture(current: Format, refused: impl Fn(Format) -> bool) -> Format { + let n = PICTURE_CYCLE.len(); + let at = PICTURE_CYCLE + .iter() + .position(|&f| f == current) + .unwrap_or_default(); + (1..=n) + .map(|step| PICTURE_CYCLE[(at + step) % n]) + .find(|&f| !refused(f)) + .unwrap_or(current) +} + +/// What the sound of a file in this format is, and whether that codec takes a +/// rate: `AAC 256` steps with `b`, `PCM` has no rate to step and so wears no +/// chord at all. +pub(crate) fn sound_codec(format: Format) -> (&'static str, bool) { + match format { + Format::Wav => ("PCM", false), + Format::Flac => ("FLAC", false), + Format::Ogg => ("Vorbis", false), + Format::Mp3 => ("MP3", true), + _ => ("AAC", true), + } +} + +/// The seat in the words the artboard writes it in -- lowercase `auto` and +/// `software` because they are what happens, `GPU` because that is the part +/// of this machine a person picked. +pub(crate) fn encoder_word(seat: EncoderSeat) -> &'static str { + match seat { + EncoderSeat::Auto => "auto", + EncoderSeat::Hardware => "GPU", + EncoderSeat::Software => "software", + } +} + +/// The one amber line on this page (`NOTICE_LOOK`, DESIGN §8's "worth a +/// look"): the plugin's AV1 seat is constant-quality, so the budget the +/// export moment now asks for is the one thing this pick does not honour. +pub(crate) const AV1_GPU_NOTICE: &str = "ignores the budget \u{2014} constant quality"; + +/// A refusal in six words, which is what fits beside a value on one row -- +/// the whole sentence is still said where the pick is actually refused +/// ([`Player::set_format`]'s own banner). +pub(crate) fn short_reason(why: &str) -> String { + why.split_whitespace().take(6).collect::>().join(" ") +} + +/// EXPORT: the four choices a film is delivered by, off the export card (user: +/// it was "too complicated") and into the room where a project's other +/// once-a-project answers already live. The export moment keeps the file and +/// the budget; the codec, the sound, the encoder and the range are here. +fn export_section(player: &Player, cx: &mut Context) -> impl IntoElement { + let format = player.format; + let refusals: Vec = PICTURE_CYCLE + .into_iter() + .filter_map(|f| { + player + .session + .as_ref() + .and_then(|session| format_refusal(session, f)) + .map(|why| format!("{} {}", format_label(f), short_reason(&why))) + }) + .collect(); + // Never hidden (DESIGN §8): a codec this machine has no encoder for stays + // on the row, greyed, with the reason beside it -- the export card's own + // refusal rows, in the one place a codec is picked now. + let refused_tail = (!refusals.is_empty()).then(|| (refusals.join(" \u{b7} ").into(), INK4())); + let (codec, rated) = sound_codec(format); + let seat = player.encoder_seat(); + let av1_gpu = seat == EncoderSeat::Hardware && matches!(format, Format::Av1 | Format::Av1Mp4); + let range = match player.range { + Some((start, end)) => format!( + "marks {}\u{2013}{}", + timecode(f64::from(start) / player.fps, player.fps), + timecode(f64::from(end) / player.fps, player.fps), + ), + None => "whole film".to_string(), + }; + div() + .flex_none() + .flex() + .flex_col() + .gap(px(2.)) + .child(section_head("EXPORT \u{b7} what a delivery is written as")) + .child(row_chord( + "settings-export-picture", + "Picture", + picture_label(format), + "the codec the picture is written with and the box it lands in; the export moment asks only for the file and the budget", + "c", + refused_tail, + player, + cx.listener(|this, _: &ClickEvent, _, cx| { + this.cycle_export_picture(); + cx.notify(); + }), + )) + .children(rated.then(|| { + row_chord( + "settings-export-sound", + "Sound", + format!("{codec} {}", player.audio_kbps), + "what the sound inside that file is coded at, in kbps", + "b", + None, + player, + cx.listener(|this, _: &ClickEvent, _, cx| { + this.cycle_audio_kbps(); + cx.notify(); + }), + ) + .into_any_element() + })) + // A codec with no rate to pick is a readout, not a button that would + // do nothing when pressed -- and it wears no chord, because there is + // no step for one to take. + .children((!rated).then(|| { + row_static( + "settings-export-sound", + "Sound", + codec, + "this codec carries no rate to pick: it is written as the format itself says", + None, + INK1(), + ) + .into_any_element() + })) + .child(row_chord( + "settings-export-encoder", + "Encoder", + encoder_word(seat), + "which encoder writes the picture: the GPU where this machine has a seat, or the CPU", + "e", + av1_gpu.then(|| (AV1_GPU_NOTICE.into(), NOTICE_LOOK())), + player, + cx.listener(|this, _: &ClickEvent, _, cx| { + this.cycle_encoder(cx); + }), + )) + // Read-only: the range is set on the timeline with the marks + // themselves ([`keymap::ActionId::SetIn`]/`SetOut`), which is where a + // person can see what they are marking. + .child(row_static( + "settings-export-range", + "Range", + range, + "the span an export writes: the whole timeline, or whatever the in/out marks hold", + Some( + format!( + "{} {}", + player.keymap.chord(ActionId::SetIn), + player.keymap.chord(ActionId::SetOut) + ) + .into(), + ), + INK1(), + )) +} + /// The page itself: a plate in the room's own below-picture footprint, /// closed by a click away or `esc` through [`Player::close_card`] like every /// other card here. @@ -513,6 +766,20 @@ pub(crate) fn render( .border_color(rgb(DARK_HAIRLINE())) .pl(px(12.)) .child(editor_section(player, cx)), + ) + // The third column: what a delivery is written as, the + // rows the export card used to hold (user: it was "too + // complicated"). Beside the other two rather than under + // them -- a fold with no scrollbar is the defect this + // page's own two columns exist to avoid. + .child( + div() + .flex_1() + .min_w(px(0.)) + .border_l_1() + .border_color(rgb(DARK_HAIRLINE())) + .pl(px(12.)) + .child(export_section(player, cx)), ), ), )