The export card opens on a preset, not fifteen rows
Browse files at this commit0d1aa327a57452bb4705f25483526ea191585b40Parent: 31449fc- refactor
- the export card opens on a preset, not fifteen rows
4 changed files +154 -16
- crates/app/src/export_ui.rs +71 -0
- crates/app/src/main.rs +9 -0
- crates/app/src/render.rs +4 -0
- crates/app/src/ui/cards.rs +70 -16
crates/app/src/export_ui.rsmodified+71 -0
| @@ -80,6 +80,77 @@ impl Quality { | ||
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | +/// The primary pane's one row: the format-and-quality bundles most exports | |
| 84 | +/// actually are, named the way a person asks for one rather than by codec and | |
| 85 | +/// megabits apart. Every bundle is still exactly a [`Format`] and a | |
| 86 | +/// [`Quality`] the Advanced pane's own rows already know how to set -- this | |
| 87 | +/// is a shortcut to the pair, not a third setting kept beside them, so a | |
| 88 | +/// bundle picked here and a codec picked below never disagree about what is | |
| 89 | +/// in force. `Custom` sets nothing; it only opens the Advanced pane, for a | |
| 90 | +/// combination none of the bundles name. | |
| 91 | +#[derive(Clone, Copy, PartialEq, Debug)] | |
| 92 | +pub(crate) enum ExportPreset { | |
| 93 | + Web, | |
| 94 | + Small, | |
| 95 | + Master, | |
| 96 | + AudioOnly, | |
| 97 | + Custom, | |
| 98 | +} | |
| 99 | + | |
| 100 | +impl ExportPreset { | |
| 101 | + pub(crate) const ALL: [ExportPreset; 5] = [ | |
| 102 | + ExportPreset::Web, | |
| 103 | + ExportPreset::Small, | |
| 104 | + ExportPreset::Master, | |
| 105 | + ExportPreset::AudioOnly, | |
| 106 | + ExportPreset::Custom, | |
| 107 | + ]; | |
| 108 | + | |
| 109 | + pub(crate) fn label(self) -> &'static str { | |
| 110 | + match self { | |
| 111 | + ExportPreset::Web => "Web", | |
| 112 | + ExportPreset::Small => "Small file", | |
| 113 | + ExportPreset::Master => "Master", | |
| 114 | + ExportPreset::AudioOnly => "Audio only", | |
| 115 | + ExportPreset::Custom => "Custom", | |
| 116 | + } | |
| 117 | + } | |
| 118 | + | |
| 119 | + pub(crate) fn detail(self) -> &'static str { | |
| 120 | + match self { | |
| 121 | + ExportPreset::Web => "H.264 · MP4 · medium quality — plays everywhere", | |
| 122 | + ExportPreset::Small => "AV1 · MP4 · low quality — smallest file", | |
| 123 | + ExportPreset::Master => "H.264 · MP4 · high quality — for re-editing later", | |
| 124 | + ExportPreset::AudioOnly => "FLAC — lossless sound, no picture", | |
| 125 | + ExportPreset::Custom => "pick a codec, quality and the rest below", | |
| 126 | + } | |
| 127 | + } | |
| 128 | + | |
| 129 | + /// The format and quality this bundle sets, or `None` for `Custom` -- | |
| 130 | + /// which changes nothing itself, it only opens the pane where the two are | |
| 131 | + /// set apart. | |
| 132 | + pub(crate) fn bundle(self) -> Option<(Format, Quality)> { | |
| 133 | + match self { | |
| 134 | + ExportPreset::Web => Some((Format::Mp4, Quality::Medium)), | |
| 135 | + ExportPreset::Small => Some((Format::Av1Mp4, Quality::Low)), | |
| 136 | + ExportPreset::Master => Some((Format::Mp4, Quality::High)), | |
| 137 | + ExportPreset::AudioOnly => Some((Format::Flac, Quality::Auto)), | |
| 138 | + ExportPreset::Custom => None, | |
| 139 | + } | |
| 140 | + } | |
| 141 | + | |
| 142 | + /// Which bundle the card's current format and quality already are, or | |
| 143 | + /// `Custom` where they match none of them -- so the primary pane always | |
| 144 | + /// says something true about what is actually going to be written rather | |
| 145 | + /// than defaulting to a bundle nobody picked. | |
| 146 | + pub(crate) fn from_state(format: Format, quality: Quality) -> ExportPreset { | |
| 147 | + ExportPreset::ALL | |
| 148 | + .into_iter() | |
| 149 | + .find(|p| p.bundle() == Some((format, quality))) | |
| 150 | + .unwrap_or(ExportPreset::Custom) | |
| 151 | + } | |
| 152 | +} | |
| 153 | + | |
| 83 | 154 | /// The export card's format rows: the key that picks one, its name, and what it |
| 84 | 155 | /// writes -- or, where this program cannot write it, the reason it cannot. A |
| 85 | 156 | /// format with no entry at all would read as an oversight, and a menu of three |
crates/app/src/main.rsmodified+9 -0
| @@ -409,6 +409,14 @@ struct Player { | ||
| 409 | 409 | /// Not persisted: this is a look, not a setting. |
| 410 | 410 | export_grouped: bool, |
| 411 | 411 | export_refusals_inline: bool, |
| 412 | + /// Whether the card's Advanced pane -- codec, container, quality, | |
| 413 | + /// sound, encoder, subtitles, this machine -- is open under the primary | |
| 414 | + /// pane's destination and preset rows. Closed by default: most exports | |
| 415 | + /// are one of the bundled presets, and the fifteen-odd rows under them | |
| 416 | + /// are what a person who is not one of those goes looking for, kept | |
| 417 | + /// behind one row rather than eaten by the fold. Not persisted, like the | |
| 418 | + /// two switches above it -- this is a look, not a setting. | |
| 419 | + export_advanced_open: bool, | |
| 412 | 420 | /// Which quality row the card has picked, and the megabits typed against |
| 413 | 421 | /// the custom one. Kept across closes, so a second export offers what the |
| 414 | 422 | /// first one chose. |
| @@ -727,6 +735,7 @@ fn main() { | ||
| 727 | 735 | export_open: false, |
| 728 | 736 | export_grouped: true, |
| 729 | 737 | export_refusals_inline: false, |
| 738 | + export_advanced_open: false, | |
| 730 | 739 | eq_open: None, |
| 731 | 740 | // Replaced by the clip's own curve the moment the card |
| 732 | 741 | // opens; nothing reads it before that. |
crates/app/src/render.rsmodified+4 -0
| @@ -259,6 +259,10 @@ impl Render for Player { | ||
| 259 | 259 | this.export_grouped = !this.export_grouped; |
| 260 | 260 | } else if key == "r" { |
| 261 | 261 | this.export_refusals_inline = !this.export_refusals_inline; |
| 262 | + } else if key == "s" { | |
| 263 | + // The Advanced pane, by keyboard: the primary pane's | |
| 264 | + // own row for it opens the same way a click does. | |
| 265 | + this.export_advanced_open = !this.export_advanced_open; | |
| 262 | 266 | } else if key == "n" { |
| 263 | 267 | // The custom row's field, by keyboard. The digits used |
| 264 | 268 | // to do this from anywhere in the card, which meant a |
crates/app/src/ui/cards.rsmodified+70 -16
| @@ -121,6 +121,75 @@ impl Player { | ||
| 121 | 121 | .into_any_element() |
| 122 | 122 | }; |
| 123 | 123 | let mut list: Vec<AnyElement> = Vec::new(); |
| 124 | + // The primary pane: destination first (the one thing every export | |
| 125 | + // needs regardless of what it is), then the bundles most exports | |
| 126 | + // actually are, then the button to the rest. Everything under it is | |
| 127 | + // exactly the codec, quality, sound and encoder rows the old flat | |
| 128 | + // card opened on -- a bundle here only sets the same two fields the | |
| 129 | + // Advanced pane's own Format and Quality rows set, so nothing here | |
| 130 | + // is a setting of its own to fall out of step with them. | |
| 131 | + let destination = entry( | |
| 132 | + ("destination", 0), | |
| 133 | + "d", | |
| 134 | + "Destination".into(), | |
| 135 | + file_name(&self.export_path).into(), | |
| 136 | + false, | |
| 137 | + true, | |
| 138 | + ) | |
| 139 | + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| this.pick_destination(cx))) | |
| 140 | + .into_any_element(); | |
| 141 | + list.push(destination); | |
| 142 | + let current_preset = ExportPreset::from_state(self.format, self.quality); | |
| 143 | + for (i, preset) in ExportPreset::ALL.into_iter().enumerate() { | |
| 144 | + let mut r = entry( | |
| 145 | + ("preset", i), | |
| 146 | + "", | |
| 147 | + preset.label().into(), | |
| 148 | + preset.detail().into(), | |
| 149 | + preset == current_preset, | |
| 150 | + true, | |
| 151 | + ); | |
| 152 | + r = r.on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | |
| 153 | + match preset.bundle() { | |
| 154 | + Some((format, quality)) => { | |
| 155 | + this.set_format(format); | |
| 156 | + this.quality = quality; | |
| 157 | + } | |
| 158 | + // Custom sets nothing -- it only opens the pane where the | |
| 159 | + // codec and the quality are picked apart. | |
| 160 | + None => this.export_advanced_open = true, | |
| 161 | + } | |
| 162 | + cx.notify(); | |
| 163 | + })); | |
| 164 | + list.push(r.into_any_element()); | |
| 165 | + } | |
| 166 | + let advanced_detail = match self.export_advanced_open { | |
| 167 | + true => "codec, container, quality, sound, encoder, subtitles — s collapses them" | |
| 168 | + .to_string(), | |
| 169 | + false => "codec, container, quality, sound, encoder, subtitles — s for the rows" | |
| 170 | + .to_string(), | |
| 171 | + }; | |
| 172 | + list.push( | |
| 173 | + entry( | |
| 174 | + ("export-advanced", 0), | |
| 175 | + "s", | |
| 176 | + "Advanced".into(), | |
| 177 | + advanced_detail.into(), | |
| 178 | + self.export_advanced_open, | |
| 179 | + true, | |
| 180 | + ) | |
| 181 | + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { | |
| 182 | + this.export_advanced_open = !this.export_advanced_open; | |
| 183 | + cx.notify(); | |
| 184 | + })) | |
| 185 | + .into_any_element(), | |
| 186 | + ); | |
| 187 | + // Everything from here down is the Advanced pane: the codec, its | |
| 188 | + // container, the quality rows, sound, encoder, subtitles, the two | |
| 189 | + // display switches and what this machine can encode with -- all of | |
| 190 | + // it built exactly as the flat card built it, only not pushed at all | |
| 191 | + // while the pane is shut. | |
| 192 | + if self.export_advanced_open { | |
| 124 | 193 | if self.export_grouped { |
| 125 | 194 | list.push(header("FORMAT")); |
| 126 | 195 | } |
| @@ -347,16 +416,6 @@ impl Player { | ||
| 347 | 416 | ) |
| 348 | 417 | .into_any_element(), |
| 349 | 418 | ); |
| 350 | - let destination = entry( | |
| 351 | - ("destination", 0), | |
| 352 | - "d", | |
| 353 | - "Destination".into(), | |
| 354 | - file_name(&self.export_path).into(), | |
| 355 | - false, | |
| 356 | - true, | |
| 357 | - ) | |
| 358 | - .on_click(cx.listener(|this, _: &ClickEvent, _, cx| this.pick_destination(cx))) | |
| 359 | - .into_any_element(); | |
| 360 | 419 | // The card's own two layout switches. They were `g` and `r` and nothing |
| 361 | 420 | // else, while the status line under the title advertised both of them: |
| 362 | 421 | // a hand on the mouse read what they do and had nothing to press. |
| @@ -396,12 +455,6 @@ impl Player { | ||
| 396 | 455 | })) |
| 397 | 456 | .into_any_element(), |
| 398 | 457 | ); |
| 399 | - match self.export_grouped { | |
| 400 | - true => list.push(destination), | |
| 401 | - // Flat: the same rows with no headers over them, and the | |
| 402 | - // destination back at the top where the card used to open with it. | |
| 403 | - false => list.insert(0, destination), | |
| 404 | - } | |
| 405 | 458 | if !self.export_refusals_inline && !refusals.is_empty() { |
| 406 | 459 | // Last, and one line: the reason travels with the name (a footer |
| 407 | 460 | // that only listed them would be the "why not?" the rows exist to |
| @@ -442,6 +495,7 @@ impl Player { | ||
| 442 | 495 | self.hw_caps.clone().unwrap_or_else(|| "asking…".into()) |
| 443 | 496 | ))); |
| 444 | 497 | list.push(note(format!("Built in: {}", engine::caps::software()))); |
| 498 | + } // self.export_advanced_open | |
| 445 | 499 | // What the rows add up to, which is the one thing that has to be right: |
| 446 | 500 | // codec, box, size, rate, sound, where it goes and about how big. Two |
| 447 | 501 | // lines, outside the scrolling list, so it is on screen whatever the |