diff --git a/crates/app/src/export_ui.rs b/crates/app/src/export_ui.rs index f9bfbdb..dd2f508 100644 --- a/crates/app/src/export_ui.rs +++ b/crates/app/src/export_ui.rs @@ -80,6 +80,77 @@ impl Quality { } } +/// The primary pane's one row: the format-and-quality bundles most exports +/// actually are, named the way a person asks for one rather than by codec and +/// megabits apart. Every bundle is still exactly a [`Format`] and a +/// [`Quality`] the Advanced pane's own rows already know how to set -- this +/// is a shortcut to the pair, not a third setting kept beside them, so a +/// bundle picked here and a codec picked below never disagree about what is +/// in force. `Custom` sets nothing; it only opens the Advanced pane, for a +/// combination none of the bundles name. +#[derive(Clone, Copy, PartialEq, Debug)] +pub(crate) enum ExportPreset { + Web, + Small, + Master, + AudioOnly, + Custom, +} + +impl ExportPreset { + pub(crate) const ALL: [ExportPreset; 5] = [ + ExportPreset::Web, + ExportPreset::Small, + ExportPreset::Master, + ExportPreset::AudioOnly, + ExportPreset::Custom, + ]; + + pub(crate) fn label(self) -> &'static str { + match self { + ExportPreset::Web => "Web", + ExportPreset::Small => "Small file", + ExportPreset::Master => "Master", + ExportPreset::AudioOnly => "Audio only", + ExportPreset::Custom => "Custom", + } + } + + pub(crate) fn detail(self) -> &'static str { + match self { + ExportPreset::Web => "H.264 · MP4 · medium quality — plays everywhere", + ExportPreset::Small => "AV1 · MP4 · low quality — smallest file", + ExportPreset::Master => "H.264 · MP4 · high quality — for re-editing later", + ExportPreset::AudioOnly => "FLAC — lossless sound, no picture", + ExportPreset::Custom => "pick a codec, quality and the rest below", + } + } + + /// The format and quality this bundle sets, or `None` for `Custom` -- + /// which changes nothing itself, it only opens the pane where the two are + /// set apart. + pub(crate) fn bundle(self) -> Option<(Format, Quality)> { + match self { + ExportPreset::Web => Some((Format::Mp4, Quality::Medium)), + ExportPreset::Small => Some((Format::Av1Mp4, Quality::Low)), + ExportPreset::Master => Some((Format::Mp4, Quality::High)), + ExportPreset::AudioOnly => Some((Format::Flac, Quality::Auto)), + ExportPreset::Custom => None, + } + } + + /// Which bundle the card's current format and quality already are, or + /// `Custom` where they match none of them -- so the primary pane always + /// says something true about what is actually going to be written rather + /// than defaulting to a bundle nobody picked. + pub(crate) fn from_state(format: Format, quality: Quality) -> ExportPreset { + ExportPreset::ALL + .into_iter() + .find(|p| p.bundle() == Some((format, quality))) + .unwrap_or(ExportPreset::Custom) + } +} + /// The export card's format rows: the key that picks one, its name, and what it /// writes -- or, where this program cannot write it, the reason it cannot. A /// format with no entry at all would read as an oversight, and a menu of three diff --git a/crates/app/src/main.rs b/crates/app/src/main.rs index 111eeb6..2ccb721 100644 --- a/crates/app/src/main.rs +++ b/crates/app/src/main.rs @@ -409,6 +409,14 @@ struct Player { /// Not persisted: this is a look, not a setting. export_grouped: bool, export_refusals_inline: bool, + /// Whether the card's Advanced pane -- codec, container, quality, + /// sound, encoder, subtitles, this machine -- is open under the primary + /// pane's destination and preset rows. Closed by default: most exports + /// are one of the bundled presets, and the fifteen-odd rows under them + /// are what a person who is not one of those goes looking for, kept + /// behind one row rather than eaten by the fold. Not persisted, like the + /// two switches above it -- this is a look, not a setting. + export_advanced_open: bool, /// Which quality row the card has picked, and the megabits typed against /// the custom one. Kept across closes, so a second export offers what the /// first one chose. @@ -727,6 +735,7 @@ fn main() { export_open: false, export_grouped: true, export_refusals_inline: false, + export_advanced_open: false, eq_open: None, // Replaced by the clip's own curve the moment the card // opens; nothing reads it before that. diff --git a/crates/app/src/render.rs b/crates/app/src/render.rs index 1ac0ee0..66b87ae 100644 --- a/crates/app/src/render.rs +++ b/crates/app/src/render.rs @@ -259,6 +259,10 @@ impl Render for Player { this.export_grouped = !this.export_grouped; } else if key == "r" { this.export_refusals_inline = !this.export_refusals_inline; + } else if key == "s" { + // The Advanced pane, by keyboard: the primary pane's + // own row for it opens the same way a click does. + this.export_advanced_open = !this.export_advanced_open; } else if key == "n" { // The custom row's field, by keyboard. The digits used // to do this from anywhere in the card, which meant a diff --git a/crates/app/src/ui/cards.rs b/crates/app/src/ui/cards.rs index 6f72c9f..c1b2dc0 100644 --- a/crates/app/src/ui/cards.rs +++ b/crates/app/src/ui/cards.rs @@ -121,6 +121,75 @@ impl Player { .into_any_element() }; let mut list: Vec = Vec::new(); + // The primary pane: destination first (the one thing every export + // needs regardless of what it is), then the bundles most exports + // actually are, then the button to the rest. Everything under it is + // exactly the codec, quality, sound and encoder rows the old flat + // card opened on -- a bundle here only sets the same two fields the + // Advanced pane's own Format and Quality rows set, so nothing here + // is a setting of its own to fall out of step with them. + let destination = entry( + ("destination", 0), + "d", + "Destination".into(), + file_name(&self.export_path).into(), + false, + true, + ) + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| this.pick_destination(cx))) + .into_any_element(); + list.push(destination); + let current_preset = ExportPreset::from_state(self.format, self.quality); + for (i, preset) in ExportPreset::ALL.into_iter().enumerate() { + let mut r = entry( + ("preset", i), + "", + preset.label().into(), + preset.detail().into(), + preset == current_preset, + true, + ); + r = r.on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { + match preset.bundle() { + Some((format, quality)) => { + this.set_format(format); + this.quality = quality; + } + // Custom sets nothing -- it only opens the pane where the + // codec and the quality are picked apart. + None => this.export_advanced_open = true, + } + cx.notify(); + })); + list.push(r.into_any_element()); + } + let advanced_detail = match self.export_advanced_open { + true => "codec, container, quality, sound, encoder, subtitles — s collapses them" + .to_string(), + false => "codec, container, quality, sound, encoder, subtitles — s for the rows" + .to_string(), + }; + list.push( + entry( + ("export-advanced", 0), + "s", + "Advanced".into(), + advanced_detail.into(), + self.export_advanced_open, + true, + ) + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { + this.export_advanced_open = !this.export_advanced_open; + cx.notify(); + })) + .into_any_element(), + ); + // Everything from here down is the Advanced pane: the codec, its + // container, the quality rows, sound, encoder, subtitles, the two + // display switches and what this machine can encode with -- all of + // it built exactly as the flat card built it, only not pushed at all + // while the pane is shut. + if self.export_advanced_open { if self.export_grouped { list.push(header("FORMAT")); } @@ -347,16 +416,6 @@ impl Player { ) .into_any_element(), ); - let destination = entry( - ("destination", 0), - "d", - "Destination".into(), - file_name(&self.export_path).into(), - false, - true, - ) - .on_click(cx.listener(|this, _: &ClickEvent, _, cx| this.pick_destination(cx))) - .into_any_element(); // The card's own two layout switches. They were `g` and `r` and nothing // else, while the status line under the title advertised both of them: // a hand on the mouse read what they do and had nothing to press. @@ -396,12 +455,6 @@ impl Player { })) .into_any_element(), ); - match self.export_grouped { - true => list.push(destination), - // Flat: the same rows with no headers over them, and the - // destination back at the top where the card used to open with it. - false => list.insert(0, destination), - } if !self.export_refusals_inline && !refusals.is_empty() { // Last, and one line: the reason travels with the name (a footer // that only listed them would be the "why not?" the rows exist to @@ -442,6 +495,7 @@ impl Player { self.hw_caps.clone().unwrap_or_else(|| "asking…".into()) ))); list.push(note(format!("Built in: {}", engine::caps::software()))); + } // self.export_advanced_open // What the rows add up to, which is the one thing that has to be right: // codec, box, size, rate, sound, where it goes and about how big. Two // lines, outside the scrolling list, so it is on screen whatever the