The export card leads with presets
Browse files at this commit- feat
- the export card leads with presets
8 changed files +313 -27
- crates/app/src/export_ui.rs +91 -0
- crates/app/src/keymap.rs +25 -1
- crates/app/src/main.rs +15 -3
- crates/app/src/player/export.rs +23 -3
- crates/app/src/render.rs +13 -0
- crates/app/src/tests/cards.rs +56 -0
- crates/app/src/tests/mod.rs +1 -1
- crates/app/src/ui/cards.rs +89 -19
crates/app/src/export_ui.rsmodified+91 -0
| @@ -80,6 +80,97 @@ 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 | + /// The key that picks this row, none of the sixteen the card's other rows | ||
| 120 | + /// already own (`n`, the digits, the codec row's `m/a/h/w/f/p/o`, and | ||
| 121 | + /// `c/q/b/e/d/g/r/s`): a letter out of the name itself where its initial is | ||
| 122 | + /// one of those (`smaLl`, `masTer`, `aUdio`), and a free one where every | ||
| 123 | + /// letter in the name already belongs to another row (`Web`'s w, e and b | ||
| 124 | + /// all are). `Custom` shares Advanced's own `s` -- the row does exactly what | ||
| 125 | + /// that key already does, not a second name for a third thing. | ||
| 126 | + pub(crate) fn key(self) -> &'static str { | ||
| 127 | + match self { | ||
| 128 | + ExportPreset::Web => "v", | ||
| 129 | + ExportPreset::Small => "l", | ||
| 130 | + ExportPreset::Master => "t", | ||
| 131 | + ExportPreset::AudioOnly => "u", | ||
| 132 | + ExportPreset::Custom => "s", | ||
| 133 | + } | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + pub(crate) fn detail(self) -> &'static str { | ||
| 137 | + match self { | ||
| 138 | + ExportPreset::Web => "H.264 · MP4 · medium quality — plays everywhere", | ||
| 139 | + ExportPreset::Small => "AV1 · MP4 · low quality — smallest file", | ||
| 140 | + ExportPreset::Master => "HEVC · MP4 · high quality — intra-only, for re-editing later", | ||
| 141 | + ExportPreset::AudioOnly => "FLAC — lossless sound, no picture", | ||
| 142 | + ExportPreset::Custom => "pick a codec, quality and the rest below", | ||
| 143 | + } | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + /// The format and quality this bundle sets, or `None` for `Custom` -- | ||
| 147 | + /// which changes nothing itself, it only opens the pane where the two are | ||
| 148 | + /// set apart. | ||
| 149 | + pub(crate) fn bundle(self) -> Option<(Format, Quality)> { | ||
| 150 | + match self { | ||
| 151 | + ExportPreset::Web => Some((Format::Mp4, Quality::Medium)), | ||
| 152 | + ExportPreset::Small => Some((Format::Av1Mp4, Quality::Low)), | ||
| 153 | + // HEVC, not H.264: a master is for cutting again later, and HEVC's | ||
| 154 | + // intra-only rows say why that is the one that keeps its promise -- | ||
| 155 | + // every frame already a cut point, where H.264's are not. | ||
| 156 | + ExportPreset::Master => Some((Format::HevcMp4, Quality::High)), | ||
| 157 | + ExportPreset::AudioOnly => Some((Format::Flac, Quality::Auto)), | ||
| 158 | + ExportPreset::Custom => None, | ||
| 159 | + } | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + /// Which bundle the card's current format and quality already are, or | ||
| 163 | + /// `Custom` where they match none of them -- so the primary pane always | ||
| 164 | + /// says something true about what is actually going to be written rather | ||
| 165 | + /// than defaulting to a bundle nobody picked. | ||
| 166 | + pub(crate) fn from_state(format: Format, quality: Quality) -> ExportPreset { | ||
| 167 | + ExportPreset::ALL | ||
| 168 | + .into_iter() | ||
| 169 | + .find(|p| p.bundle() == Some((format, quality))) | ||
| 170 | + .unwrap_or(ExportPreset::Custom) | ||
| 171 | + } | ||
| 172 | +} | ||
| 173 | + | ||
| 83 | /// The export card's format rows: the key that picks one, its name, and what it | 174 | /// The export card's format rows: the key that picks one, its name, and what it |
| 84 | /// writes -- or, where this program cannot write it, the reason it cannot. A | 175 | /// writes -- or, where this program cannot write it, the reason it cannot. A |
| 85 | /// format with no entry at all would read as an oversight, and a menu of three | 176 | /// format with no entry at all would read as an oversight, and a menu of three |
crates/app/src/keymap.rsmodified+25 -1
| @@ -438,7 +438,19 @@ fn codec_chord() -> String { | |||
| 438 | .join(" / ") | 438 | .join(" / ") |
| 439 | } | 439 | } |
| 440 | 440 | ||
| 441 | -pub static FIXED: std::sync::LazyLock<[Fixed; 30]> = std::sync::LazyLock::new(|| { | 441 | +/// The preset row's keys, from [`crate::ExportPreset::key`] -- `Custom` |
| 442 | +/// excepted, which shares Advanced's own `s` and so is that row's line, not a | ||
| 443 | +/// second one here. | ||
| 444 | +fn preset_chord() -> String { | ||
| 445 | + crate::ExportPreset::ALL | ||
| 446 | + .into_iter() | ||
| 447 | + .filter(|p| *p != crate::ExportPreset::Custom) | ||
| 448 | + .map(|p| p.key()) | ||
| 449 | + .collect::<Vec<_>>() | ||
| 450 | + .join(" / ") | ||
| 451 | +} | ||
| 452 | + | ||
| 453 | +pub static FIXED: std::sync::LazyLock<[Fixed; 32]> = std::sync::LazyLock::new(|| { | ||
| 442 | [ | 454 | [ |
| 443 | // Not a chord at all but a way of pressing one, and the only place the | 455 | // Not a chord at all but a way of pressing one, and the only place the |
| 444 | // editor can say so: holding a key that moves a *value* runs it, and | 456 | // editor can say so: holding a key that moves a *value* runs it, and |
| @@ -517,6 +529,18 @@ pub static FIXED: std::sync::LazyLock<[Fixed; 30]> = std::sync::LazyLock::new(|| | |||
| 517 | category: Category::File, | 529 | category: Category::File, |
| 518 | reach: Reach::Click("destination"), | 530 | reach: Reach::Click("destination"), |
| 519 | }, | 531 | }, |
| 532 | + Fixed { | ||
| 533 | + chord: preset_chord(), | ||
| 534 | + label: "Pick an export bundle: Web, Small file, Master or Audio only", | ||
| 535 | + category: Category::File, | ||
| 536 | + reach: Reach::Click("preset"), | ||
| 537 | + }, | ||
| 538 | + Fixed { | ||
| 539 | + chord: "s".into(), | ||
| 540 | + label: "Export card: open or close the Advanced pane", | ||
| 541 | + category: Category::File, | ||
| 542 | + reach: Reach::Click("export-advanced"), | ||
| 543 | + }, | ||
| 520 | Fixed { | 544 | Fixed { |
| 521 | chord: "g".into(), | 545 | chord: "g".into(), |
| 522 | label: "Export card: sections or one flat list", | 546 | label: "Export card: sections or one flat list", |
crates/app/src/main.rsmodified+15 -3
| @@ -416,6 +416,14 @@ struct Player { | |||
| 416 | /// Not persisted: this is a look, not a setting. | 416 | /// Not persisted: this is a look, not a setting. |
| 417 | export_grouped: bool, | 417 | export_grouped: bool, |
| 418 | export_refusals_inline: bool, | 418 | export_refusals_inline: bool, |
| 419 | + /// Whether the card's Advanced pane -- codec, container, quality, | ||
| 420 | + /// sound, encoder, subtitles, this machine -- is open under the primary | ||
| 421 | + /// pane's destination and preset rows. Closed by default: most exports | ||
| 422 | + /// are one of the bundled presets, and the fifteen-odd rows under them | ||
| 423 | + /// are what a person who is not one of those goes looking for, kept | ||
| 424 | + /// behind one row rather than eaten by the fold. Not persisted, like the | ||
| 425 | + /// two switches above it -- this is a look, not a setting. | ||
| 426 | + export_advanced_open: bool, | ||
| 419 | /// Which quality row the card has picked, and the megabits typed against | 427 | /// Which quality row the card has picked, and the megabits typed against |
| 420 | /// the custom one. Kept across closes, so a second export offers what the | 428 | /// the custom one. Kept across closes, so a second export offers what the |
| 421 | /// first one chose. | 429 | /// first one chose. |
| @@ -742,6 +750,7 @@ fn main() { | |||
| 742 | export_open: false, | 750 | export_open: false, |
| 743 | export_grouped: true, | 751 | export_grouped: true, |
| 744 | export_refusals_inline: false, | 752 | export_refusals_inline: false, |
| 753 | + export_advanced_open: false, | ||
| 745 | eq_open: None, | 754 | eq_open: None, |
| 746 | // Replaced by the clip's own curve the moment the card | 755 | // Replaced by the clip's own curve the moment the card |
| 747 | // opens; nothing reads it before that. | 756 | // opens; nothing reads it before that. |
| @@ -780,9 +789,12 @@ fn main() { | |||
| 780 | // Empty until the first frame is pumped, which draws as a | 789 | // Empty until the first frame is pumped, which draws as a |
| 781 | // flat line rather than as a shape nothing measured. | 790 | // flat line rather than as a shape nothing measured. |
| 782 | histogram: [[0; HIST_BINS]; 3], | 791 | histogram: [[0; HIST_BINS]; 3], |
| 783 | - // What an export is until someone says otherwise: the | 792 | + // What an export is until someone says otherwise: the Web |
| 784 | - // bitrate the picture asks for. | 793 | + // bundle, so `ExportPreset::from_state` opens on a real |
| 785 | - quality: Quality::Auto, | 794 | + // preset rather than a `Custom` nobody picked -- `Auto` |
| 795 | + // paired with `Format::default()`'s MP4 matched no bundle | ||
| 796 | + // at all. | ||
| 797 | + quality: Quality::Medium, | ||
| 786 | custom_mbps: 0, | 798 | custom_mbps: 0, |
| 787 | mbps_edit: None, | 799 | mbps_edit: None, |
| 788 | // ...and the rate the sound has always been written at. | 800 | // ...and the rate the sound has always been written at. |
crates/app/src/player/export.rsmodified+23 -3
| @@ -376,8 +376,10 @@ impl Player { | |||
| 376 | 376 | ||
| 377 | /// A format row was clicked. The destination follows it at once -- a WAV | 377 | /// A format row was clicked. The destination follows it at once -- a WAV |
| 378 | /// written to a path ending in `.mp4` is a file every player will lie | 378 | /// written to a path ending in `.mp4` is a file every player will lie |
| 379 | - /// about -- keeping whatever stem the save dialog last left there. | 379 | + /// about -- keeping whatever stem the save dialog last left there. `false` |
| 380 | - pub(crate) fn set_format(&mut self, format: Format) { | 380 | + /// on a refusal, so a caller that has more than the format to write (a |
| 381 | + /// preset's own quality) knows not to write the rest of it either. | ||
| 382 | + pub(crate) fn set_format(&mut self, format: Format) -> bool { | ||
| 381 | // The one door both the row and its initial go through, so a format the | 383 | // The one door both the row and its initial go through, so a format the |
| 382 | // card greys out cannot be picked by keyboard either. | 384 | // card greys out cannot be picked by keyboard either. |
| 383 | if let Some(why) = self | 385 | if let Some(why) = self |
| @@ -386,10 +388,28 @@ impl Player { | |||
| 386 | .and_then(|session| format_refusal(session, format)) | 388 | .and_then(|session| format_refusal(session, format)) |
| 387 | { | 389 | { |
| 388 | self.notify_user(format!("NOT {} — {why}", format_label(format)).into()); | 390 | self.notify_user(format!("NOT {} — {why}", format_label(format)).into()); |
| 389 | - return; | 391 | + return false; |
| 390 | } | 392 | } |
| 391 | self.format = format; | 393 | self.format = format; |
| 392 | self.export_path = retarget(&self.export_path, format); | 394 | self.export_path = retarget(&self.export_path, format); |
| 395 | + true | ||
| 396 | + } | ||
| 397 | + | ||
| 398 | + /// A preset row, by click or by its own key. `Custom` opens the pane where | ||
| 399 | + /// the codec and the quality are picked apart and changes nothing itself; | ||
| 400 | + /// the rest are exactly the bundle they name -- and nothing at all on a | ||
| 401 | + /// refusal, because [`set_format`](Self::set_format) already fired the | ||
| 402 | + /// banner and a quality written after it declined would be a row that | ||
| 403 | + /// looks picked over a format that was not. | ||
| 404 | + pub(crate) fn pick_preset(&mut self, preset: ExportPreset) { | ||
| 405 | + match preset.bundle() { | ||
| 406 | + Some((format, quality)) => { | ||
| 407 | + if self.set_format(format) { | ||
| 408 | + self.quality = quality; | ||
| 409 | + } | ||
| 410 | + } | ||
| 411 | + None => self.export_advanced_open = true, | ||
| 412 | + } | ||
| 393 | } | 413 | } |
| 394 | 414 | ||
| 395 | /// The container row: the same codec in the other box, which retargets the | 415 | /// The container row: the same codec in the other box, which retargets the |
crates/app/src/render.rsmodified+13 -0
| @@ -255,10 +255,23 @@ impl Render for Player { | |||
| 255 | // The save dialog, which was the one row here a | 255 | // The save dialog, which was the one row here a |
| 256 | // keyboard could not open. | 256 | // keyboard could not open. |
| 257 | this.pick_destination(cx); | 257 | this.pick_destination(cx); |
| 258 | + } else if let Some(preset) = ExportPreset::ALL | ||
| 259 | + .into_iter() | ||
| 260 | + .find(|p| p.key() == key) | ||
| 261 | + // `Custom` shares `s` with Advanced below, which already | ||
| 262 | + // handles that key -- reaching it here too would only | ||
| 263 | + // race the same assignment against itself. | ||
| 264 | + .filter(|p| *p != ExportPreset::Custom) | ||
| 265 | + { | ||
| 266 | + this.pick_preset(preset); | ||
| 258 | } else if key == "g" { | 267 | } else if key == "g" { |
| 259 | this.export_grouped = !this.export_grouped; | 268 | this.export_grouped = !this.export_grouped; |
| 260 | } else if key == "r" { | 269 | } else if key == "r" { |
| 261 | this.export_refusals_inline = !this.export_refusals_inline; | 270 | this.export_refusals_inline = !this.export_refusals_inline; |
| 271 | + } else if key == "s" { | ||
| 272 | + // The Advanced pane, by keyboard: the primary pane's | ||
| 273 | + // own row for it opens the same way a click does. | ||
| 274 | + this.export_advanced_open = !this.export_advanced_open; | ||
| 262 | } else if key == "n" { | 275 | } else if key == "n" { |
| 263 | // The custom row's field, by keyboard. The digits used | 276 | // The custom row's field, by keyboard. The digits used |
| 264 | // to do this from anywhere in the card, which meant a | 277 | // to do this from anywhere in the card, which meant a |
crates/app/src/tests/cards.rsmodified+56 -0
| @@ -1421,3 +1421,59 @@ fn the_export_estimate_answers_a_bar_that_went_backwards_with_a_guess() { | |||
| 1421 | ); | 1421 | ); |
| 1422 | } | 1422 | } |
| 1423 | } | 1423 | } |
| 1424 | + | ||
| 1425 | +/// The primary pane's own round trip: every bundle's format-and-quality lands | ||
| 1426 | +/// back on the preset that named it, so the row a person picked is the row | ||
| 1427 | +/// the card shows picked. `Custom` is the one preset `bundle` names nothing | ||
| 1428 | +/// for, and the one every pair outside the other four's must fall back to. | ||
| 1429 | +#[test] | ||
| 1430 | +fn every_preset_bundle_round_trips_through_from_state() { | ||
| 1431 | + for preset in ExportPreset::ALL { | ||
| 1432 | + match preset.bundle() { | ||
| 1433 | + Some((format, quality)) => { | ||
| 1434 | + assert_eq!(ExportPreset::from_state(format, quality), preset); | ||
| 1435 | + } | ||
| 1436 | + None => assert_eq!(preset, ExportPreset::Custom), | ||
| 1437 | + } | ||
| 1438 | + } | ||
| 1439 | + // A pair no bundle names -- the launch default before this batch's fix -- | ||
| 1440 | + // reads as `Custom`, not as whichever preset happens to be first. | ||
| 1441 | + assert_eq!( | ||
| 1442 | + ExportPreset::from_state(Format::Mp4, Quality::Auto), | ||
| 1443 | + ExportPreset::Custom | ||
| 1444 | + ); | ||
| 1445 | + // Master's bundle is HEVC/High, not H.264: an intra-only master is the one | ||
| 1446 | + // that keeps its own "for re-editing later" detail true. | ||
| 1447 | + assert_eq!( | ||
| 1448 | + ExportPreset::Master.bundle(), | ||
| 1449 | + Some((Format::HevcMp4, Quality::High)) | ||
| 1450 | + ); | ||
| 1451 | +} | ||
| 1452 | + | ||
| 1453 | +/// The primary pane's own refusal: a bundle whose format this timeline cannot | ||
| 1454 | +/// write reads exactly as a codec row does -- the reason in place of the | ||
| 1455 | +/// detail, and no format-and-quality pair to land wrong once a click on a | ||
| 1456 | +/// dimmed row is ignored. | ||
| 1457 | +#[test] | ||
| 1458 | +fn a_preset_over_a_picture_this_timeline_has_none_of_carries_the_codec_refusal() { | ||
| 1459 | + let mut session = | ||
| 1460 | + PlaybackSession::open(asset("test_tone.mp3")).expect("a song is a timeline"); | ||
| 1461 | + session.set_gain(0.0); | ||
| 1462 | + let path = session.sources()[0].path.clone(); | ||
| 1463 | + session.seek(1.0); | ||
| 1464 | + session | ||
| 1465 | + .place_stream_at(1.0, &path, 0, Some(Lane::A1)) | ||
| 1466 | + .expect("its own file is on this timeline"); | ||
| 1467 | + assert!(session.lane_clips(Lane::V1).is_empty(), "still no picture"); | ||
| 1468 | + | ||
| 1469 | + for preset in [ExportPreset::Web, ExportPreset::Small, ExportPreset::Master] { | ||
| 1470 | + let (format, _) = preset.bundle().expect("a real bundle"); | ||
| 1471 | + assert!( | ||
| 1472 | + format_refusal(&session, format).is_some(), | ||
| 1473 | + "{preset:?}'s bundle is a picture format this audio-only timeline must refuse" | ||
| 1474 | + ); | ||
| 1475 | + } | ||
| 1476 | + // Audio only's bundle is FLAC, which has no picture to refuse. | ||
| 1477 | + let (audio_format, _) = ExportPreset::AudioOnly.bundle().expect("a real bundle"); | ||
| 1478 | + assert_eq!(format_refusal(&session, audio_format), None); | ||
| 1479 | +} | ||
crates/app/src/tests/mod.rsmodified+1 -1
| @@ -13,7 +13,7 @@ use super::{ | |||
| 13 | ACCENT_PRIMARY, AUDIO_KBPS, COLOR_BANDS, COLOR_BAR_W, COLOR_STEP, COLOR_W, CONTROL_H, Clip, Ctx, DEFAULT_AUDIO_KBPS, EQ_BANDS_MAX, | 13 | ACCENT_PRIMARY, AUDIO_KBPS, COLOR_BANDS, COLOR_BAR_W, COLOR_STEP, COLOR_W, CONTROL_H, Clip, Ctx, DEFAULT_AUDIO_KBPS, EQ_BANDS_MAX, |
| 14 | EQ_CURVE_STEPS, EQ_FFT, EQ_FREQ_HIGH, EQ_FREQ_LOW, EQ_FREQ_STEP, EQ_GAIN_LIMIT, EQ_GRAPH_H, | 14 | EQ_CURVE_STEPS, EQ_FFT, EQ_FREQ_HIGH, EQ_FREQ_LOW, EQ_FREQ_STEP, EQ_GAIN_LIMIT, EQ_GRAPH_H, |
| 15 | EQ_HANDLE, EQ_Q_HIGH, EQ_Q_LOW, EQ_Q_STEP, EQ_SPECTRUM_DB, EQ_TICKS, EQ_W_MAX, ESCAPE, | 15 | EQ_HANDLE, EQ_Q_HIGH, EQ_Q_LOW, EQ_Q_STEP, EQ_SPECTRUM_DB, EQ_TICKS, EQ_W_MAX, ESCAPE, |
| 16 | - EXPORT_FIXED_H, EXPORT_ROWS_H, EXPORT_W, Enable, EncoderSeat, FORMATS, | 16 | + EXPORT_FIXED_H, EXPORT_ROWS_H, EXPORT_W, Enable, EncoderSeat, ExportPreset, FORMATS, |
| 17 | Format, HEADER_GAP, HEADER_H, HEADER_W, HIST_BINS, HIST_H, HIST_SAMPLES, HIT_MIN, | 17 | Format, HEADER_GAP, HEADER_H, HEADER_W, HIST_BINS, HIST_H, HIST_SAMPLES, HIT_MIN, |
| 18 | KEYS_ROW_H, KEYS_ROWS_H, KEYS_W, KeyRow, LABEL_H, LABEL_MIN_W, LANE_H, LANES_MAX, | 18 | KEYS_ROW_H, KEYS_ROWS_H, KEYS_W, KeyRow, LABEL_H, LABEL_MIN_W, LANE_H, LANES_MAX, |
| 19 | LIBRARY_MAX_W, LIBRARY_MIN_W, Lane, MENU_ITEMS, MENU_PAD, MENU_ROW_H, | 19 | LIBRARY_MAX_W, LIBRARY_MIN_W, Lane, MENU_ITEMS, MENU_PAD, MENU_ROW_H, |
crates/app/src/ui/cards.rsmodified+89 -19
| @@ -121,6 +121,81 @@ impl Player { | |||
| 121 | .into_any_element() | 121 | .into_any_element() |
| 122 | }; | 122 | }; |
| 123 | let mut list: Vec<AnyElement> = Vec::new(); | 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 | + // A bundle whose format this timeline refuses (an audio-only edit | ||
| 145 | + // against Web, Small or Master) is the same kind of row the codec | ||
| 146 | + // rows already carry: dimmed, unclickable, its reason in place of | ||
| 147 | + // the detail -- not bright and pickable over a click that would | ||
| 148 | + // only bounce off `set_format`'s own guard. | ||
| 149 | + let refusal = preset | ||
| 150 | + .bundle() | ||
| 151 | + .and_then(|(format, _)| self.session.as_ref().and_then(|s| format_refusal(s, format))); | ||
| 152 | + let detail: SharedString = match &refusal { | ||
| 153 | + Some(why) => why.clone().into(), | ||
| 154 | + None => preset.detail().into(), | ||
| 155 | + }; | ||
| 156 | + let mut r = entry( | ||
| 157 | + ("preset", i), | ||
| 158 | + preset.key(), | ||
| 159 | + preset.label().into(), | ||
| 160 | + detail, | ||
| 161 | + preset == current_preset, | ||
| 162 | + refusal.is_none(), | ||
| 163 | + ); | ||
| 164 | + if refusal.is_none() { | ||
| 165 | + r = r.on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | ||
| 166 | + this.pick_preset(preset); | ||
| 167 | + cx.notify(); | ||
| 168 | + })); | ||
| 169 | + } | ||
| 170 | + list.push(r.into_any_element()); | ||
| 171 | + } | ||
| 172 | + let advanced_detail = match self.export_advanced_open { | ||
| 173 | + true => "codec, container, quality, sound, encoder, subtitles — s collapses them" | ||
| 174 | + .to_string(), | ||
| 175 | + false => "codec, container, quality, sound, encoder, subtitles — s for the rows" | ||
| 176 | + .to_string(), | ||
| 177 | + }; | ||
| 178 | + list.push( | ||
| 179 | + entry( | ||
| 180 | + ("export-advanced", 0), | ||
| 181 | + "s", | ||
| 182 | + "Advanced".into(), | ||
| 183 | + advanced_detail.into(), | ||
| 184 | + self.export_advanced_open, | ||
| 185 | + true, | ||
| 186 | + ) | ||
| 187 | + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { | ||
| 188 | + this.export_advanced_open = !this.export_advanced_open; | ||
| 189 | + cx.notify(); | ||
| 190 | + })) | ||
| 191 | + .into_any_element(), | ||
| 192 | + ); | ||
| 193 | + // Everything from here down is the Advanced pane: the codec, its | ||
| 194 | + // container, the quality rows, sound, encoder, subtitles, the two | ||
| 195 | + // display switches and what this machine can encode with -- all of | ||
| 196 | + // it built exactly as the flat card built it, only not pushed at all | ||
| 197 | + // while the pane is shut. | ||
| 198 | + if self.export_advanced_open { | ||
| 124 | if self.export_grouped { | 199 | if self.export_grouped { |
| 125 | list.push(header("FORMAT")); | 200 | list.push(header("FORMAT")); |
| 126 | } | 201 | } |
| @@ -347,16 +422,6 @@ impl Player { | |||
| 347 | ) | 422 | ) |
| 348 | .into_any_element(), | 423 | .into_any_element(), |
| 349 | ); | 424 | ); |
| 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 | // The card's own two layout switches. They were `g` and `r` and nothing | 425 | // The card's own two layout switches. They were `g` and `r` and nothing |
| 361 | // else, while the status line under the title advertised both of them: | 426 | // else, while the status line under the title advertised both of them: |
| 362 | // a hand on the mouse read what they do and had nothing to press. | 427 | // a hand on the mouse read what they do and had nothing to press. |
| @@ -396,12 +461,6 @@ impl Player { | |||
| 396 | })) | 461 | })) |
| 397 | .into_any_element(), | 462 | .into_any_element(), |
| 398 | ); | 463 | ); |
| 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 | if !self.export_refusals_inline && !refusals.is_empty() { | 464 | if !self.export_refusals_inline && !refusals.is_empty() { |
| 406 | // Last, and one line: the reason travels with the name (a footer | 465 | // Last, and one line: the reason travels with the name (a footer |
| 407 | // that only listed them would be the "why not?" the rows exist to | 466 | // that only listed them would be the "why not?" the rows exist to |
| @@ -442,6 +501,7 @@ impl Player { | |||
| 442 | self.hw_caps.clone().unwrap_or_else(|| "asking…".into()) | 501 | self.hw_caps.clone().unwrap_or_else(|| "asking…".into()) |
| 443 | ))); | 502 | ))); |
| 444 | list.push(note(format!("Built in: {}", engine::caps::software()))); | 503 | list.push(note(format!("Built in: {}", engine::caps::software()))); |
| 504 | + } // self.export_advanced_open | ||
| 445 | // What the rows add up to, which is the one thing that has to be right: | 505 | // What the rows add up to, which is the one thing that has to be right: |
| 446 | // codec, box, size, rate, sound, where it goes and about how big. Two | 506 | // codec, box, size, rate, sound, where it goes and about how big. Two |
| 447 | // lines, outside the scrolling list, so it is on screen whatever the | 507 | // lines, outside the scrolling list, so it is on screen whatever the |
| @@ -547,9 +607,19 @@ impl Player { | |||
| 547 | SharedString::from(format!("Custom bitrate {}", edit.detail())) | 607 | SharedString::from(format!("Custom bitrate {}", edit.detail())) |
| 548 | } | 608 | } |
| 549 | (None, Some(notice)) => notice.clone(), | 609 | (None, Some(notice)) => notice.clone(), |
| 550 | - (None, None) => "the keys are on the rows · enter exports · \ | 610 | + // `g`/`r` only do anything once Advanced is |
| 551 | - a click away or esc closes · g/r change the layout" | 611 | + // open -- they moved off the front pane with |
| 552 | - .into(), | 612 | + // the rows they reshape -- so a shut pane |
| 613 | + // advertises `s` instead of a pair of keys | ||
| 614 | + // with nothing on screen for them to touch. | ||
| 615 | + (None, None) => match self.export_advanced_open { | ||
| 616 | + true => "the keys are on the rows · enter exports · \ | ||
| 617 | + a click away or esc closes · g/r change the layout" | ||
| 618 | + .into(), | ||
| 619 | + false => "the keys are on the rows · enter exports · \ | ||
| 620 | + a click away or esc closes · s for Advanced" | ||
| 621 | + .into(), | ||
| 622 | + }, | ||
| 553 | }), | 623 | }), |
| 554 | ) | 624 | ) |
| 555 | // Capped and scrolling like the keybindings list: the | 625 | // Capped and scrolling like the keybindings list: the |