merge feat-scale
Browse files at this commit11 changed files +1274 -674
- DESIGN.md +3 -3
- crates/app/src/audio_cards.rs +1 -1
- crates/app/src/layout.rs +19 -12
- crates/app/src/tests/cards.rs +108 -38
- crates/app/src/ui/bench_stance.rs +115 -74
- crates/app/src/ui/cards.rs +640 -399
- crates/app/src/ui/dock_stance.rs +86 -25
- crates/app/src/ui/spine_stance.rs +179 -31
- crates/app/src/ui/stance.rs +90 -59
- crates/app/src/ui/timeband_stance.rs +4 -7
- crates/app/src/ui/type_scale.rs +29 -25
DESIGN.mdmodified+3 -3
| @@ -76,9 +76,9 @@ Two faces, fixed roles (bundled, no runtime deps): | ||
| 76 | 76 | - **Spline Sans Mono** — everything the film says: timecode, chords, readouts, metadata, |
| 77 | 77 | cue text, the ledger. Mono = data; if a string is *about the footage or a key*, it is mono. |
| 78 | 78 | |
| 79 | -Scale: 15px hero timecode (700, colons in `ink3`) · 13px labels/rows (500) · 11–12px chords | |
| 80 | -and metadata (500) · 10px section heads (Archivo 700, uppercase, +0.14em letter-spacing, `ink3`). | |
| 81 | -Nothing below 9px. Every size is a whole pixel (no half-pixel sizes -- they put glyph baselines | |
| 79 | +Scale: 18px hero timecode (700, colons in `ink3`) · 15px labels/rows (500) · 13–14px chords | |
| 80 | +and metadata (500) · 12px section heads (Archivo 700, uppercase, +0.14em letter-spacing, `ink3`). | |
| 81 | +Nothing below 10px. Every size is a whole pixel (no half-pixel sizes -- they put glyph baselines | |
| 82 | 82 | off the pixel grid and blurred cosmic-text's AA). No italics. Tabular figures wherever digits |
| 83 | 83 | align. |
| 84 | 84 |
crates/app/src/audio_cards.rsmodified+1 -1
| @@ -235,7 +235,7 @@ mod eq_tick_end_w_tests { | ||
| 235 | 235 | use super::*; |
| 236 | 236 | |
| 237 | 237 | /// The defect measured live: a fixed 24 px box wrapped "20 Hz" (5 chars) |
| 238 | - /// at the dark theme's 11 px end-tick size. The derived width must clear | |
| 238 | + /// at the dark theme's 13 px end-tick size. The derived width must clear | |
| 239 | 239 | /// that box, and must grow, not shrink, if a future scale bump raises |
| 240 | 240 | /// the size fed in. |
| 241 | 241 | #[test] |
crates/app/src/layout.rsmodified+19 -12
| @@ -322,10 +322,11 @@ pub(crate) const TIMELINE_FIXED_H: f32 = 16. + 18. + 8. + RULER_HIT_H + 8. + 4.; | ||
| 322 | 322 | /// hand it to the lane column as a bonus at exactly the zoom where the hand is |
| 323 | 323 | /// least expecting the bed to move. |
| 324 | 324 | pub(crate) fn timeline_fixed_h(scroll: bool) -> f32 { |
| 325 | - TIMELINE_FIXED_H + match scroll { | |
| 326 | - true => 8. + SCROLL_HIT, | |
| 327 | - false => 0., | |
| 328 | - } | |
| 325 | + TIMELINE_FIXED_H | |
| 326 | + + match scroll { | |
| 327 | + true => 8. + SCROLL_HIT, | |
| 328 | + false => 0., | |
| 329 | + } | |
| 329 | 330 | } |
| 330 | 331 | |
| 331 | 332 | /// The most of a short window the timeline may take, sized so the seam's own |
| @@ -471,11 +472,9 @@ const LEDGER_SEAM_CLEARANCE: f32 = 1.; | ||
| 471 | 472 | /// lane, which has no next row to spill into and clipped straight into the |
| 472 | 473 | /// ledger instead. |
| 473 | 474 | /// |
| 474 | -/// A third driven pass at the next floor (`94.`, `BENCH_CHROME_H` still | |
| 475 | -/// undercounted at `20.`) clipped A1's dot again, by one row -- two 1px | |
| 476 | -/// causes stacked, not one 2px guess: `BENCH_CHROME_H`'s own undercount | |
| 477 | -/// (`20.` vs its real `21.`) and this term, `LEDGER_SEAM_CLEARANCE`, which | |
| 478 | -/// the formula never carried at all. `21 + 22 + 2 + 48 + 2 + 1` = `96.`. | |
| 475 | +/// With the 18/15/14-13/12/10px type scale, the same derivation uses a 24px | |
| 476 | +/// chrome block and two 27px lane floors: | |
| 477 | +/// `24 + 22 + 2 + 54 + 2 + 1` = `105.`. | |
| 479 | 478 | pub(crate) const BENCH_MIN_H: f32 = crate::ui::stance::BENCH_CHROME_H |
| 480 | 479 | + crate::ui::bench_stance::RULER_H |
| 481 | 480 | + crate::ui::bench_stance::ROW_GAP |
| @@ -539,8 +538,12 @@ pub(crate) fn load_stance_splits_from(path: &std::path::Path) -> Splits { | ||
| 539 | 538 | let mut splits = Splits::default(); |
| 540 | 539 | if let Ok(text) = std::fs::read_to_string(path) { |
| 541 | 540 | for line in text.lines() { |
| 542 | - let Some((key, value)) = line.split_once('=') else { continue }; | |
| 543 | - let Ok(px) = value.trim().parse::<f32>() else { continue }; | |
| 541 | + let Some((key, value)) = line.split_once('=') else { | |
| 542 | + continue; | |
| 543 | + }; | |
| 544 | + let Ok(px) = value.trim().parse::<f32>() else { | |
| 545 | + continue; | |
| 546 | + }; | |
| 544 | 547 | let Some(split) = Split::PERSISTED.into_iter().find(|s| s.key() == key) else { |
| 545 | 548 | continue; |
| 546 | 549 | }; |
| @@ -561,7 +564,11 @@ pub(crate) fn save_stance_splits(splits: &Splits) { | ||
| 561 | 564 | pub(crate) fn save_stance_splits_to(splits: &Splits, path: &std::path::Path) { |
| 562 | 565 | let text: String = Split::PERSISTED |
| 563 | 566 | .into_iter() |
| 564 | - .filter_map(|split| splits.get(split).map(|px| format!("{}={px}\n", split.key()))) | |
| 567 | + .filter_map(|split| { | |
| 568 | + splits | |
| 569 | + .get(split) | |
| 570 | + .map(|px| format!("{}={px}\n", split.key())) | |
| 571 | + }) | |
| 565 | 572 | .collect(); |
| 566 | 573 | if let Some(dir) = path.parent() { |
| 567 | 574 | let _ = std::fs::create_dir_all(dir); |
crates/app/src/tests/cards.rsmodified+108 -38
| @@ -16,7 +16,9 @@ use std::sync::atomic::Ordering; | ||
| 16 | 16 | #[test] |
| 17 | 17 | fn no_overlaid_state_in_the_stance_goes_modal_without_painting_something() { |
| 18 | 18 | let stance = src_text("ui/stance.rs"); |
| 19 | - let render_body = &stance[stance.find("pub(crate) fn render(").expect("the stance's entry point")..]; | |
| 19 | + let render_body = &stance[stance | |
| 20 | + .find("pub(crate) fn render(") | |
| 21 | + .expect("the stance's entry point")..]; | |
| 20 | 22 | for menu in ["context_card(", "library_card(", "picker_card("] { |
| 21 | 23 | assert!( |
| 22 | 24 | render_body.contains(menu), |
| @@ -28,7 +30,11 @@ fn no_overlaid_state_in_the_stance_goes_modal_without_painting_something() { | ||
| 28 | 30 | .find("if this.rebinding.is_some()\n || this.card_open()") |
| 29 | 31 | .expect("the stance's modal guard"); |
| 30 | 32 | let guard = &stance[guard_at..guard_at + 1600]; |
| 31 | - for field in ["this.context_menu = None", "this.library_menu = None", "this.picker = None"] { | |
| 33 | + for field in [ | |
| 34 | + "this.context_menu = None", | |
| 35 | + "this.library_menu = None", | |
| 36 | + "this.picker = None", | |
| 37 | + ] { | |
| 32 | 38 | assert!( |
| 33 | 39 | guard.contains(field), |
| 34 | 40 | "the overlaid()/rebinding branch no longer clears {field} on every key -- \ |
| @@ -61,7 +67,10 @@ fn every_modal_field_has_a_mounted_surface_somewhere_in_the_darkroom() { | ||
| 61 | 67 | fields.push(name); |
| 62 | 68 | } |
| 63 | 69 | } |
| 64 | - assert!(fields.len() >= 9, "modal()'s own field list looks too short to have been parsed: {fields:?}"); | |
| 70 | + assert!( | |
| 71 | + fields.len() >= 9, | |
| 72 | + "modal()'s own field list looks too short to have been parsed: {fields:?}" | |
| 73 | + ); | |
| 65 | 74 | // The mounted-surface function each field's own card draws, by the |
| 66 | 75 | // convention the param cards already follow (`x_open` -> `x_card(` -- |
| 67 | 76 | // `Player::eq_card`/`color_card`/... in `ui/cards.rs`). `keys_open` and |
| @@ -91,7 +100,11 @@ fn every_modal_field_has_a_mounted_surface_somewhere_in_the_darkroom() { | ||
| 91 | 100 | ), |
| 92 | 101 | } |
| 93 | 102 | }; |
| 94 | - let haystack = format!("{}\n{}", src_text("ui/stance.rs"), src_text("ui/dock_stance.rs")); | |
| 103 | + let haystack = format!( | |
| 104 | + "{}\n{}", | |
| 105 | + src_text("ui/stance.rs"), | |
| 106 | + src_text("ui/dock_stance.rs") | |
| 107 | + ); | |
| 95 | 108 | for field in &fields { |
| 96 | 109 | let mount = mount_for(field); |
| 97 | 110 | assert!( |
| @@ -249,7 +262,10 @@ fn every_action_is_on_the_actions_card() { | ||
| 249 | 262 | } |
| 250 | 263 | // The list scrolls inside a card the smallest window holds, so a |
| 251 | 264 | // thirty-fourth action costs no height at all. |
| 252 | - assert!(rows.len() as f32 * KEYS_ROW_H > KEYS_ROWS_H, "no cap needed?"); | |
| 265 | + assert!( | |
| 266 | + rows.len() as f32 * KEYS_ROW_H > KEYS_ROWS_H, | |
| 267 | + "no cap needed?" | |
| 268 | + ); | |
| 253 | 269 | // Both halves of a row are click targets, so WCAG 2.5.8 binds them. |
| 254 | 270 | assert!(KEYS_ROW_H >= HIT_MIN); |
| 255 | 271 | } |
| @@ -458,10 +474,19 @@ fn the_equalizer_graph_puts_a_band_where_a_drag_reads_it_and_fits_the_smallest_w | ||
| 458 | 474 | |
| 459 | 475 | // The card fits the smallest window and takes the room a bigger one has |
| 460 | 476 | // -- it is a graph, and the width *is* the frequency resolution. |
| 461 | - assert!(eq_card_w(640., false) <= 640. - 24., "card too wide for 640"); | |
| 462 | - assert!(eq_card_w(1280., false) > eq_card_w(640., false), "card ignores the window"); | |
| 477 | + assert!( | |
| 478 | + eq_card_w(640., false) <= 640. - 24., | |
| 479 | + "card too wide for 640" | |
| 480 | + ); | |
| 481 | + assert!( | |
| 482 | + eq_card_w(1280., false) > eq_card_w(640., false), | |
| 483 | + "card ignores the window" | |
| 484 | + ); | |
| 463 | 485 | assert_eq!(eq_card_w(1920., false), EQ_W_MAX, "card grows without end"); |
| 464 | - assert!(eq_card_w(320., false) >= KEYS_W, "card narrower than a row of text"); | |
| 486 | + assert!( | |
| 487 | + eq_card_w(320., false) >= KEYS_W, | |
| 488 | + "card narrower than a row of text" | |
| 489 | + ); | |
| 465 | 490 | // At the smallest window the graph is still a graph: three across for |
| 466 | 491 | // one down, so an octave is wide enough to put a handle in. |
| 467 | 492 | assert!( |
| @@ -905,7 +930,10 @@ fn the_clock_stops_where_the_timeline_does_and_the_end_still_restarts() { | ||
| 905 | 930 | let deadline = Instant::now() + Duration::from_secs(20); |
| 906 | 931 | let mut state = transport(session.is_playing(), session.is_eos()); |
| 907 | 932 | while state != Transport::Ended { |
| 908 | - assert!(Instant::now() < deadline, "never reached the end of a 5s file"); | |
| 933 | + assert!( | |
| 934 | + Instant::now() < deadline, | |
| 935 | + "never reached the end of a 5s file" | |
| 936 | + ); | |
| 909 | 937 | session.tick(); |
| 910 | 938 | while session.try_frame().is_some() {} |
| 911 | 939 | state = transport(session.is_playing(), session.is_eos()); |
| @@ -982,7 +1010,14 @@ fn a_quality_row_is_the_bitrate_it_promises() { | ||
| 982 | 1010 | Some(2_000_000) |
| 983 | 1011 | ); |
| 984 | 1012 | assert_eq!( |
| 985 | - export_settings(Quality::Medium, 0, mp4, DEFAULT_AUDIO_KBPS, EncoderSeat::Auto).bitrate, | |
| 1013 | + export_settings( | |
| 1014 | + Quality::Medium, | |
| 1015 | + 0, | |
| 1016 | + mp4, | |
| 1017 | + DEFAULT_AUDIO_KBPS, | |
| 1018 | + EncoderSeat::Auto | |
| 1019 | + ) | |
| 1020 | + .bitrate, | |
| 986 | 1021 | Some(6_000_000) |
| 987 | 1022 | ); |
| 988 | 1023 | assert_eq!( |
| @@ -991,7 +1026,14 @@ fn a_quality_row_is_the_bitrate_it_promises() { | ||
| 991 | 1026 | ); |
| 992 | 1027 | // Megabits as typed, and as the row says it back. |
| 993 | 1028 | assert_eq!( |
| 994 | - export_settings(Quality::Custom, 7, mp4, DEFAULT_AUDIO_KBPS, EncoderSeat::Auto).bitrate, | |
| 1029 | + export_settings( | |
| 1030 | + Quality::Custom, | |
| 1031 | + 7, | |
| 1032 | + mp4, | |
| 1033 | + DEFAULT_AUDIO_KBPS, | |
| 1034 | + EncoderSeat::Auto | |
| 1035 | + ) | |
| 1036 | + .bitrate, | |
| 995 | 1037 | Some(7_000_000) |
| 996 | 1038 | ); |
| 997 | 1039 | assert_eq!(Quality::Low.detail(0), "2 Mbps"); |
| @@ -999,7 +1041,14 @@ fn a_quality_row_is_the_bitrate_it_promises() { | ||
| 999 | 1041 | // choice the engine never hears about. |
| 1000 | 1042 | for format in [Format::Mp4, Format::Wav, Format::Flac] { |
| 1001 | 1043 | assert_eq!( |
| 1002 | - export_settings(Quality::Auto, 0, format, DEFAULT_AUDIO_KBPS, EncoderSeat::Auto).format, | |
| 1044 | + export_settings( | |
| 1045 | + Quality::Auto, | |
| 1046 | + 0, | |
| 1047 | + format, | |
| 1048 | + DEFAULT_AUDIO_KBPS, | |
| 1049 | + EncoderSeat::Auto | |
| 1050 | + ) | |
| 1051 | + .format, | |
| 1003 | 1052 | format |
| 1004 | 1053 | ); |
| 1005 | 1054 | } |
| @@ -1008,7 +1057,13 @@ fn a_quality_row_is_the_bitrate_it_promises() { | ||
| 1008 | 1057 | // silently changes -- the ceiling row included, which is the one a |
| 1009 | 1058 | // raised cap could have walked out past. |
| 1010 | 1059 | for quality in Quality::ALL { |
| 1011 | - let settings = export_settings(quality, MBPS_MAX, mp4, DEFAULT_AUDIO_KBPS, EncoderSeat::Auto); | |
| 1060 | + let settings = export_settings( | |
| 1061 | + quality, | |
| 1062 | + MBPS_MAX, | |
| 1063 | + mp4, | |
| 1064 | + DEFAULT_AUDIO_KBPS, | |
| 1065 | + EncoderSeat::Auto, | |
| 1066 | + ); | |
| 1012 | 1067 | if let Some(bitrate) = settings.bitrate { |
| 1013 | 1068 | assert!( |
| 1014 | 1069 | (u64::from(MBPS_MIN) * 1_000_000..=u64::from(MBPS_MAX) * 1_000_000) |
| @@ -1144,7 +1199,10 @@ fn a_typed_bitrate_is_a_field_and_not_a_key_capture() { | ||
| 1144 | 1199 | // The hint the field shows when there is nothing to refuse names both |
| 1145 | 1200 | // ways out of it. |
| 1146 | 1201 | let detail = NumberEdit::new(6).detail(); |
| 1147 | - assert!(detail.contains("enter") && detail.contains("esc"), "{detail}"); | |
| 1202 | + assert!( | |
| 1203 | + detail.contains("enter") && detail.contains("esc"), | |
| 1204 | + "{detail}" | |
| 1205 | + ); | |
| 1148 | 1206 | assert!(detail.starts_with("6▏"), "{detail}"); |
| 1149 | 1207 | } |
| 1150 | 1208 | |
| @@ -1198,10 +1256,7 @@ fn a_held_key_moves_a_value_and_nothing_else() { | ||
| 1198 | 1256 | held, |
| 1199 | 1257 | matches!( |
| 1200 | 1258 | action, |
| 1201 | - ActionId::VolumeUp | |
| 1202 | - | ActionId::VolumeDown | |
| 1203 | - | ActionId::ZoomIn | |
| 1204 | - | ActionId::ZoomOut | |
| 1259 | + ActionId::VolumeUp | ActionId::VolumeDown | ActionId::ZoomIn | ActionId::ZoomOut | |
| 1205 | 1260 | ), |
| 1206 | 1261 | "{action:?} on a hold" |
| 1207 | 1262 | ); |
| @@ -1292,10 +1347,7 @@ fn a_choice_list_offers_every_value_and_fits_the_smallest_window() { | ||
| 1292 | 1347 | // The media's own size says so: it is the one rung a person cannot read |
| 1293 | 1348 | // off a number they chose. |
| 1294 | 1349 | let (.., native_detail, _) = &rows[3]; |
| 1295 | - assert!( | |
| 1296 | - native_detail.contains("the media's own"), | |
| 1297 | - "{native_detail}" | |
| 1298 | - ); | |
| 1350 | + assert!(native_detail.contains("the media's own"), "{native_detail}"); | |
| 1299 | 1351 | // A project at a size nobody listed still gets the whole list, with |
| 1300 | 1352 | // nothing marked rather than a wrong row marked. |
| 1301 | 1353 | assert!( |
| @@ -1375,7 +1427,11 @@ fn a_choice_list_offers_every_value_and_fits_the_smallest_window() { | ||
| 1375 | 1427 | for format in [Format::Av1, Format::Av1Mp4] { |
| 1376 | 1428 | assert!(av1_hw_warning(format, EncoderSeat::Hardware).is_some()); |
| 1377 | 1429 | for seat in [EncoderSeat::Auto, EncoderSeat::Software] { |
| 1378 | - assert_eq!(av1_hw_warning(format, seat), None, "{seat:?} is the safe seat"); | |
| 1430 | + assert_eq!( | |
| 1431 | + av1_hw_warning(format, seat), | |
| 1432 | + None, | |
| 1433 | + "{seat:?} is the safe seat" | |
| 1434 | + ); | |
| 1379 | 1435 | } |
| 1380 | 1436 | } |
| 1381 | 1437 | for format in [Format::Mp4, Format::Hevc, Format::HevcMp4, Format::Wav] { |
| @@ -1411,7 +1467,10 @@ fn a_choice_list_offers_every_value_and_fits_the_smallest_window() { | ||
| 1411 | 1467 | fn the_resolution_and_rate_lists_work_before_any_file_is_open() { |
| 1412 | 1468 | let none = pending_resolution_choices(None); |
| 1413 | 1469 | assert_eq!(none.len(), RESOLUTIONS.len()); |
| 1414 | - assert!(none.iter().all(|(.., picked)| !picked), "nothing picked yet"); | |
| 1470 | + assert!( | |
| 1471 | + none.iter().all(|(.., picked)| !picked), | |
| 1472 | + "nothing picked yet" | |
| 1473 | + ); | |
| 1415 | 1474 | for ((choice, label, detail, _), size) in none.iter().zip(RESOLUTIONS) { |
| 1416 | 1475 | assert_eq!(*choice, Choice::Size(size.0, size.1)); |
| 1417 | 1476 | assert_eq!(label.as_ref(), format!("{}p", size.1)); |
| @@ -1510,10 +1569,10 @@ fn the_export_card_fits_the_smallest_window() { | ||
| 1510 | 1569 | "{id:?}: refusal ink {:.2}", |
| 1511 | 1570 | contrast(p.FG_SECONDARY, p.BG_RAISED) |
| 1512 | 1571 | ); |
| 1513 | - // ...and on the picked row, where the highlight is the accent at | |
| 1514 | - // surface brightness. Both inks clear 4.5:1 on it now -- the row still | |
| 1515 | - // lifts its key and detail to `FG_PRIMARY`, as emphasis rather than as | |
| 1516 | - // the rescue it used to be. | |
| 1572 | + // ...and on the picked row, where the highlight is the accent at | |
| 1573 | + // surface brightness. Both inks clear 4.5:1 on it now -- the row still | |
| 1574 | + // lifts its key and detail to `FG_PRIMARY`, as emphasis rather than as | |
| 1575 | + // the rescue it used to be. | |
| 1517 | 1576 | assert!(contrast(p.FG_PRIMARY, p.BG_SELECTED) >= 4.5, "{id:?}"); |
| 1518 | 1577 | assert!( |
| 1519 | 1578 | contrast(p.FG_SECONDARY, p.BG_SELECTED) >= 4.5, |
| @@ -1662,8 +1721,7 @@ fn every_preset_bundle_round_trips_through_from_state() { | ||
| 1662 | 1721 | /// dimmed row is ignored. |
| 1663 | 1722 | #[test] |
| 1664 | 1723 | fn a_preset_over_a_picture_this_timeline_has_none_of_carries_the_codec_refusal() { |
| 1665 | - let mut session = | |
| 1666 | - PlaybackSession::open(asset("test_tone.mp3")).expect("a song is a timeline"); | |
| 1724 | + let mut session = PlaybackSession::open(asset("test_tone.mp3")).expect("a song is a timeline"); | |
| 1667 | 1725 | session.set_gain(0.0); |
| 1668 | 1726 | let path = session.sources()[0].path.clone(); |
| 1669 | 1727 | session.seek(1.0); |
| @@ -1751,18 +1809,26 @@ fn a_cards_own_help_paints_while_the_card_is_open_but_the_ui_under_it_stays_quie | ||
| 1751 | 1809 | exemption must not weaken" |
| 1752 | 1810 | ); |
| 1753 | 1811 | OVERLAID.store(false, Ordering::Relaxed); |
| 1754 | - assert!(tip_may_paint(false), "with nothing overlaid, an ordinary tip paints too"); | |
| 1812 | + assert!( | |
| 1813 | + tip_may_paint(false), | |
| 1814 | + "with nothing overlaid, an ordinary tip paints too" | |
| 1815 | + ); | |
| 1755 | 1816 | |
| 1756 | 1817 | // Structural half: every card routes its head through `dark_card_head`, |
| 1757 | 1818 | // so checking its one help-tooltip call site covers all seven cards (and |
| 1758 | 1819 | // any future eighth) at once -- it must build an `OverlayTip`, not a |
| 1759 | 1820 | // plain `Tip`, or this whole fix is undone by construction. |
| 1760 | 1821 | let cards_src = src_text("ui/cards.rs"); |
| 1761 | - let head_fn_at = cards_src.find("fn dark_card_head(").expect("dark_card_head"); | |
| 1762 | - // 1200 was wide enough before this session's maximize glyph/tooltip | |
| 1763 | - // (`.when(maximize.is_some(), ...)` + its own `OverlayTip`) grew the | |
| 1764 | - // function ahead of the help tooltip this test is actually pinning. | |
| 1765 | - let head_fn = &cards_src[head_fn_at..head_fn_at + 2400]; | |
| 1822 | + let head_fn_at = cards_src | |
| 1823 | + .find("fn dark_card_head(") | |
| 1824 | + .expect("dark_card_head"); | |
| 1825 | + // Bound the inspected source by the next item, not a byte count: rustfmt | |
| 1826 | + // may legitimately reflow this function without moving its tooltip out of | |
| 1827 | + // scope. | |
| 1828 | + let head_fn_end = cards_src[head_fn_at..] | |
| 1829 | + .find("\n/// A ghost action row") | |
| 1830 | + .expect("dark_card_head's following item"); | |
| 1831 | + let head_fn = &cards_src[head_fn_at..head_fn_at + head_fn_end]; | |
| 1766 | 1832 | assert!( |
| 1767 | 1833 | head_fn.contains("OverlayTip(h.clone())"), |
| 1768 | 1834 | "dark_card_head's own `?` tooltip no longer builds an OverlayTip -- the \ |
| @@ -1831,8 +1897,8 @@ fn maximizing_a_card_grows_its_box_without_moving_where_a_value_sits_in_it() { | ||
| 1831 | 1897 | /// inside the dock, or hands it the dock's width again, fails this. |
| 1832 | 1898 | #[test] |
| 1833 | 1899 | fn a_maximized_cards_room_is_bigger_than_the_docked_rooms_not_smaller() { |
| 1834 | - use crate::layout::{Split, split_size}; | |
| 1835 | 1900 | use crate::SPLIT_W; |
| 1901 | + use crate::layout::{Split, split_size}; | |
| 1836 | 1902 | |
| 1837 | 1903 | // Mirrors `ui/stance.rs`'s private `SPINE_W` (56.) and `layout::SPLIT_W` |
| 1838 | 1904 | // (the one divider between `stance-centre` and the dock): recomputed |
| @@ -1934,7 +2000,11 @@ fn a_maximized_card_reopens_exactly_as_left_across_a_restart() { | ||
| 1934 | 2000 | |
| 1935 | 2001 | // A file from a future/corrupt version leaves the default in force |
| 1936 | 2002 | // rather than failing the room that opens over it. |
| 1937 | - std::fs::write(crate::ui::dock_stance::maximized_config_path(), "not a bool\n").unwrap(); | |
| 2003 | + std::fs::write( | |
| 2004 | + crate::ui::dock_stance::maximized_config_path(), | |
| 2005 | + "not a bool\n", | |
| 2006 | + ) | |
| 2007 | + .unwrap(); | |
| 1938 | 2008 | assert_eq!(crate::ui::dock_stance::load_maximized(), false); |
| 1939 | 2009 | |
| 1940 | 2010 | unsafe { std::env::remove_var("XDG_CONFIG_HOME") }; |
crates/app/src/ui/bench_stance.rsmodified+115 -74
| @@ -38,9 +38,9 @@ | ||
| 38 | 38 | //! `nudge_cut` and friends still act on `Player::selected` directly, with no |
| 39 | 39 | //! element under the pointer required, and stay untouched by any of this. |
| 40 | 40 | |
| 41 | -use crate::*; | |
| 42 | 41 | use crate::ui::type_scale::{self, Typeset}; |
| 43 | 42 | use crate::ui::widgets::*; |
| 43 | +use crate::*; | |
| 44 | 44 | |
| 45 | 45 | /// The pinned ruler's own height, above the lane stack -- tall enough for a |
| 46 | 46 | /// tick line plus a mono `MM:SS` label under it (DESIGN §5's "tick marks with |
| @@ -53,11 +53,15 @@ const TICK_STOPS: [f64; 13] = [ | ||
| 53 | 53 | 0.5, 1., 2., 5., 10., 15., 30., 60., 120., 300., 600., 1800., 3600., |
| 54 | 54 | ]; |
| 55 | 55 | /// The floor a tick's pixel spacing must clear before its label is legible |
| 56 | -/// mono text at 8px. | |
| 56 | +/// mono text at 10px. | |
| 57 | 57 | const TICK_MIN_PX: f64 = 64.; |
| 58 | -/// The playhead timecode plate's own width, wide enough for `HH:MM:SS:FF` | |
| 59 | -/// mono at 10px plus the plate's padding. | |
| 60 | -const PLATE_W: f32 = 74.; | |
| 58 | +/// The playhead timecode plate's own width: eleven mono characters at the | |
| 59 | +/// 14px readout role plus its horizontal padding and a 1px rounding guard, | |
| 60 | +/// derived from the shared list-character calibration so the plate grows with | |
| 61 | +/// its type scale. | |
| 62 | +const PLATE_W: f32 = 11. * crate::layout::LIST_CHAR_W / type_scale::CHORD_METADATA_MIN_PX | |
| 63 | + * type_scale::CHORD_METADATA_MAX_PX | |
| 64 | + + 9.; | |
| 61 | 65 | /// The pinned track-head column, DESIGN §5's "track heads" -- narrower than |
| 62 | 66 | /// the legacy timeline's `HEADER_W` since a darkroom lane carries no mix/eye |
| 63 | 67 | /// button yet (deferred with the rest of the header's verbs). |
| @@ -79,10 +83,8 @@ pub(crate) const LANE_DOT_D: f32 = 4.; | ||
| 79 | 83 | /// golden ratio (`gpui::phi()` == `relative(1.618034)`), and `lane_row` |
| 80 | 84 | /// never calls `.line_height()` on the head label to override it -- so this |
| 81 | 85 | /// is what the label really occupies, not its glyph height. |
| 82 | -/// round(12. * 1.618034) would be wrong here: the head uses | |
| 83 | -/// `CHORD_METADATA_MIN_PX` (11.), so round(11. * 1.618034) = round(17.798) | |
| 84 | -/// = 18. | |
| 85 | -const LANE_LABEL_LINE_H: f32 = 18.; | |
| 86 | +/// `round(13. * 1.618034) = 21`. | |
| 87 | +const LANE_LABEL_LINE_H: f32 = 21.; | |
| 86 | 88 | /// The least a lane row may be: what its own head actually draws, not a |
| 87 | 89 | /// number copied from nowhere. The old `18.` fit only the label's line box |
| 88 | 90 | /// and let every lane's status dot overflow into the row beneath it -- |
| @@ -200,7 +202,9 @@ fn clip_box( | ||
| 200 | 202 | let source = player.sources().get(clip.source); |
| 201 | 203 | let label = source.map(|s| file_name(&s.path)); |
| 202 | 204 | let audio = lane.kind == LaneKind::Audio; |
| 203 | - let wave = source.and_then(|s| player.waves.get(&(s.path.clone(), s.audio_stream))).cloned(); | |
| 205 | + let wave = source | |
| 206 | + .and_then(|s| player.waves.get(&(s.path.clone(), s.audio_stream))) | |
| 207 | + .cloned(); | |
| 204 | 208 | // hook: §12 step 5 -- per-source film ink attaches here, replacing |
| 205 | 209 | // `source_tint` (library_meta.rs's own placeholder wheel, index-keyed and |
| 206 | 210 | // already different per source) with the source's own quantized hue. |
| @@ -213,7 +217,10 @@ fn clip_box( | ||
| 213 | 217 | let has_spine = t != Tier::Sliver; |
| 214 | 218 | let has_label = matches!(t, Tier::Full | Tier::NoChip); |
| 215 | 219 | let has_chip = t == Tier::Full && !clip.speed.is_normal(); |
| 216 | - let (in_frame, out_frame) = (f64::from(clip.in_frame) / player.fps, f64::from(clip.out_frame) / player.fps); | |
| 220 | + let (in_frame, out_frame) = ( | |
| 221 | + f64::from(clip.in_frame) / player.fps, | |
| 222 | + f64::from(clip.out_frame) / player.fps, | |
| 223 | + ); | |
| 217 | 224 | let speed = clip.speed; |
| 218 | 225 | // Right-aligned readout: the trim delta off the source's full length when |
| 219 | 226 | // this clip is shorter than the file it was cut from, else the plain |
| @@ -222,7 +229,12 @@ fn clip_box( | ||
| 222 | 229 | // means (§12's cut object has no per-edge history at this layer) -- |
| 223 | 230 | // ceiling is wiring this to the same cut state once the time band exposes |
| 224 | 231 | // it, rather than a second reading of "trim" here. |
| 225 | - let full_frames = source.map(|s| player.session.as_ref().map_or(0, |sess| sess.file_frames(&s.path))); | |
| 232 | + let full_frames = source.map(|s| { | |
| 233 | + player | |
| 234 | + .session | |
| 235 | + .as_ref() | |
| 236 | + .map_or(0, |sess| sess.file_frames(&s.path)) | |
| 237 | + }); | |
| 226 | 238 | let readout = match full_frames { |
| 227 | 239 | Some(full) if full > clip.frames() => { |
| 228 | 240 | let delta = f64::from(full - clip.frames()) / player.fps; |
| @@ -234,7 +246,10 @@ fn clip_box( | ||
| 234 | 246 | // is consumed by the name plate below. |
| 235 | 247 | let ghost: SharedString = label.clone().unwrap_or_else(|| lane.label()).into(); |
| 236 | 248 | div() |
| 237 | - .id(("bench-clip", lane.ord * 1000 + lane.kind as usize * 100 + idx)) | |
| 249 | + .id(( | |
| 250 | + "bench-clip", | |
| 251 | + lane.ord * 1000 + lane.kind as usize * 100 + idx, | |
| 252 | + )) | |
| 238 | 253 | .absolute() |
| 239 | 254 | .top_0() |
| 240 | 255 | .h_full() |
| @@ -270,10 +285,17 @@ fn clip_box( | ||
| 270 | 285 | // Dragged, it moves: to the frame and the lane it is let go over |
| 271 | 286 | // (`Player::move_clip`, `ClipDrag`) -- the same payload and the same |
| 272 | 287 | // ghost tooltip `ui/timeline.rs`'s own clip box drags. |
| 273 | - .on_drag(ClipDrag { lane, idx, clip: placed }, { | |
| 274 | - let ghost = ghost.clone(); | |
| 275 | - move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())) | |
| 276 | - }) | |
| 288 | + .on_drag( | |
| 289 | + ClipDrag { | |
| 290 | + lane, | |
| 291 | + idx, | |
| 292 | + clip: placed, | |
| 293 | + }, | |
| 294 | + { | |
| 295 | + let ghost = ghost.clone(); | |
| 296 | + move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())) | |
| 297 | + }, | |
| 298 | + ) | |
| 277 | 299 | // The two edge strips a drag lengthens or shortens the clip by |
| 278 | 300 | // (`Player::start_trim`), gated on the same `trims(span)` floor the |
| 279 | 301 | // legacy strips use -- a clip too narrow to aim at keeps its whole |
| @@ -330,17 +352,19 @@ fn clip_box( | ||
| 330 | 352 | // (falling back to a flat placeholder body while it loads or if the |
| 331 | 353 | // file never yields one). |
| 332 | 354 | .when(has_trace && audio, |d| { |
| 333 | - d.children(wave.and_then(|w| match w { | |
| 334 | - Wave::Peaks(peaks) => Some( | |
| 335 | - div() | |
| 336 | - .absolute() | |
| 337 | - .left(px(3.)) | |
| 338 | - .right_0() | |
| 339 | - .top_0() | |
| 340 | - .bottom_0() | |
| 341 | - .child(waveform_ink(peaks, in_frame, out_frame, ink)), | |
| 342 | - ), | |
| 343 | - _ => None, | |
| 355 | + d.children(wave.and_then(|w| { | |
| 356 | + match w { | |
| 357 | + Wave::Peaks(peaks) => Some( | |
| 358 | + div() | |
| 359 | + .absolute() | |
| 360 | + .left(px(3.)) | |
| 361 | + .right_0() | |
| 362 | + .top_0() | |
| 363 | + .bottom_0() | |
| 364 | + .child(waveform_ink(peaks, in_frame, out_frame, ink)), | |
| 365 | + ), | |
| 366 | + _ => None, | |
| 367 | + } | |
| 344 | 368 | })) |
| 345 | 369 | }) |
| 346 | 370 | .when(has_trace && !audio, |d| { |
| @@ -361,7 +385,8 @@ fn clip_box( | ||
| 361 | 385 | }) |
| 362 | 386 | // Name plate + trim/duration readout: one strip, DESIGN §4's plate |
| 363 | 387 | // (canvas-on-panel), sat at the clip's top-left/top-right per the mock |
| 364 | - // rather than the name alone hanging below the box. | |
| 388 | + // rather than the name alone hanging below the box. Its 21px height is | |
| 389 | + // the metadata role's default phi() line box, not its 13px glyph size. | |
| 365 | 390 | .when(has_label, |d| { |
| 366 | 391 | d.child( |
| 367 | 392 | div() |
| @@ -369,7 +394,7 @@ fn clip_box( | ||
| 369 | 394 | .left(px(3.)) |
| 370 | 395 | .right_0() |
| 371 | 396 | .top_0() |
| 372 | - .h(px(13.)) | |
| 397 | + .h(px(LANE_LABEL_LINE_H)) | |
| 373 | 398 | .px(px(3.)) |
| 374 | 399 | .flex() |
| 375 | 400 | .items_center() |
| @@ -392,7 +417,10 @@ fn clip_box( | ||
| 392 | 417 | .child( |
| 393 | 418 | div() |
| 394 | 419 | .flex_none() |
| 395 | - .type_style(type_scale::mono(9., gpui::FontWeight::MEDIUM)) | |
| 420 | + .type_style(type_scale::mono( | |
| 421 | + type_scale::FLOOR_PX, | |
| 422 | + gpui::FontWeight::MEDIUM, | |
| 423 | + )) | |
| 396 | 424 | .text_color(rgb(INK3())) |
| 397 | 425 | .child(readout), |
| 398 | 426 | ), |
| @@ -408,7 +436,10 @@ fn clip_box( | ||
| 408 | 436 | .right_0() |
| 409 | 437 | .px(px(3.)) |
| 410 | 438 | .bg(rgb(DARK_RAISED())) |
| 411 | - .type_style(type_scale::mono(9., gpui::FontWeight::MEDIUM)) | |
| 439 | + .type_style(type_scale::mono( | |
| 440 | + type_scale::FLOOR_PX, | |
| 441 | + gpui::FontWeight::MEDIUM, | |
| 442 | + )) | |
| 412 | 443 | .text_color(rgb(INK2())) |
| 413 | 444 | .child(format!("{speed}")), |
| 414 | 445 | ) |
| @@ -458,7 +489,10 @@ fn sub_box( | ||
| 458 | 489 | // (`PlaybackSession::sub_lane_cues`, the same map the export and the |
| 459 | 490 | // picture's own plate go through). |
| 460 | 491 | let cues: Vec<(f32, f32)> = player.session.as_ref().map_or_else(Vec::new, |s| { |
| 461 | - s.sub_lane_cues(lane).iter().map(|cue| cue_box(scale, cue)).collect() | |
| 492 | + s.sub_lane_cues(lane) | |
| 493 | + .iter() | |
| 494 | + .map(|cue| cue_box(scale, cue)) | |
| 495 | + .collect() | |
| 462 | 496 | }); |
| 463 | 497 | let label = player |
| 464 | 498 | .session |
| @@ -490,10 +524,17 @@ fn sub_box( | ||
| 490 | 524 | this.open_menu(lane, idx, event.position, cx); |
| 491 | 525 | }), |
| 492 | 526 | ) |
| 493 | - .on_drag(SubDrag { lane, idx, sub: placed }, { | |
| 494 | - let ghost = ghost.clone(); | |
| 495 | - move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())) | |
| 496 | - }) | |
| 527 | + .on_drag( | |
| 528 | + SubDrag { | |
| 529 | + lane, | |
| 530 | + idx, | |
| 531 | + sub: placed, | |
| 532 | + }, | |
| 533 | + { | |
| 534 | + let ghost = ghost.clone(); | |
| 535 | + move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())) | |
| 536 | + }, | |
| 537 | + ) | |
| 497 | 538 | // The same edge-trim strips a clip gets, on the same [`trims`] floor. |
| 498 | 539 | .children( |
| 499 | 540 | [Edge::Start, Edge::End] |
| @@ -681,15 +722,15 @@ fn lane_row( | ||
| 681 | 722 | // pointer actually being inside this bed's own bounds, since |
| 682 | 723 | // `on_drag_move` fires on every painted element of the drag's |
| 683 | 724 | // type, not just the one under the pointer. |
| 684 | - .on_drag_move(cx.listener( | |
| 685 | - move |this, event: &DragMoveEvent<AssetDrag>, _, cx| { | |
| 725 | + .on_drag_move( | |
| 726 | + cx.listener(move |this, event: &DragMoveEvent<AssetDrag>, _, cx| { | |
| 686 | 727 | if !event.bounds.contains(&event.event.position) { |
| 687 | 728 | return; |
| 688 | 729 | } |
| 689 | 730 | let path = event.drag(cx).0.clone(); |
| 690 | 731 | this.preview_ghost_asset(&path, lane, event.event.position.x, cx); |
| 691 | - }, | |
| 692 | - )) | |
| 732 | + }), | |
| 733 | + ) | |
| 693 | 734 | .drag_over::<ClipDrag>(|d, _, _, _| d.bg(rgb(DARK_RAISED()))) |
| 694 | 735 | .on_drop(cx.listener(move |this, drag: &ClipDrag, window, cx| { |
| 695 | 736 | let Some(idx) = this.dragged(drag) else { |
| @@ -697,15 +738,15 @@ fn lane_row( | ||
| 697 | 738 | }; |
| 698 | 739 | this.move_clip(drag.lane, idx, lane, window.mouse_position().x, cx) |
| 699 | 740 | })) |
| 700 | - .on_drag_move(cx.listener( | |
| 701 | - move |this, event: &DragMoveEvent<ClipDrag>, _, cx| { | |
| 741 | + .on_drag_move( | |
| 742 | + cx.listener(move |this, event: &DragMoveEvent<ClipDrag>, _, cx| { | |
| 702 | 743 | if !event.bounds.contains(&event.event.position) { |
| 703 | 744 | return; |
| 704 | 745 | } |
| 705 | 746 | let drag = *event.drag(cx); |
| 706 | 747 | this.preview_ghost(&drag, lane, event.event.position.x, cx); |
| 707 | - }, | |
| 708 | - )) | |
| 748 | + }), | |
| 749 | + ) | |
| 709 | 750 | // A caption already on a lane moves along it, or onto another |
| 710 | 751 | // subtitle track, exactly as a clip does (`Player::move_sub`, |
| 711 | 752 | // the same call `ui/timeline.rs`'s own bed makes). |
| @@ -713,25 +754,25 @@ fn lane_row( | ||
| 713 | 754 | .on_drop(cx.listener(move |this, drag: &SubDrag, window, cx| { |
| 714 | 755 | this.move_sub(drag, lane, window.mouse_position().x, cx); |
| 715 | 756 | })) |
| 716 | - .on_drag_move(cx.listener( | |
| 717 | - move |this, event: &DragMoveEvent<SubDrag>, _, cx| { | |
| 757 | + .on_drag_move( | |
| 758 | + cx.listener(move |this, event: &DragMoveEvent<SubDrag>, _, cx| { | |
| 718 | 759 | if !event.bounds.contains(&event.event.position) { |
| 719 | 760 | return; |
| 720 | 761 | } |
| 721 | 762 | let drag = *event.drag(cx); |
| 722 | 763 | this.preview_ghost_sub(&drag, lane, event.event.position.x, cx); |
| 723 | - }, | |
| 724 | - )) | |
| 764 | + }), | |
| 765 | + ) | |
| 725 | 766 | .drag_over::<SubPick>(|d, _, _, _| d.bg(rgb(DARK_RAISED()))) |
| 726 | - .on_drag_move(cx.listener( | |
| 727 | - move |this, event: &DragMoveEvent<SubPick>, _, cx| { | |
| 767 | + .on_drag_move( | |
| 768 | + cx.listener(move |this, event: &DragMoveEvent<SubPick>, _, cx| { | |
| 728 | 769 | if !event.bounds.contains(&event.event.position) { |
| 729 | 770 | return; |
| 730 | 771 | } |
| 731 | 772 | let track = event.drag(cx).0; |
| 732 | 773 | this.preview_ghost_pick(track, lane, event.event.position.x, cx); |
| 733 | - }, | |
| 734 | - )) | |
| 774 | + }), | |
| 775 | + ) | |
| 735 | 776 | // The wheel, matched to the legacy timeline's own mapping: |
| 736 | 777 | // ctrl+wheel zooms about the pointer, a bare wheel scrolls |
| 737 | 778 | // the bed along the film (`Player::timeline_wheel`). Stopped |
| @@ -793,7 +834,11 @@ fn lane_row( | ||
| 793 | 834 | |
| 794 | 835 | /// The bench's content: pinned ruler, pinned heads, lane stack -- compressed |
| 795 | 836 | /// evenly to [`LANES_COMPRESS`] rows and then scrolling (DESIGN §7). |
| 796 | -pub(crate) fn render(player: &mut Player, box_h: f32, cx: &mut Context<Player>) -> impl IntoElement { | |
| 837 | +pub(crate) fn render( | |
| 838 | + player: &mut Player, | |
| 839 | + box_h: f32, | |
| 840 | + cx: &mut Context<Player>, | |
| 841 | +) -> impl IntoElement { | |
| 797 | 842 | let lanes = player |
| 798 | 843 | .session |
| 799 | 844 | .as_ref() |
| @@ -869,26 +914,22 @@ pub(crate) fn render(player: &mut Player, box_h: f32, cx: &mut Context<Player>) | ||
| 869 | 914 | this.timeline_wheel(event, cx); |
| 870 | 915 | })) |
| 871 | 916 | .children(ticks.into_iter().map(|(x, label)| { |
| 872 | - div() | |
| 873 | - .absolute() | |
| 874 | - .top_0() | |
| 875 | - .left(px(x)) | |
| 876 | - .child( | |
| 877 | - div() | |
| 878 | - .flex() | |
| 879 | - .flex_col() | |
| 880 | - .items_start() | |
| 881 | - .child(div().w(px(1.)).h(px(4.)).bg(rgb(INK3()))) | |
| 882 | - .child( | |
| 883 | - div() | |
| 884 | - .type_style(type_scale::mono( | |
| 885 | - type_scale::FLOOR_PX, | |
| 886 | - gpui::FontWeight::MEDIUM, | |
| 887 | - )) | |
| 888 | - .text_color(rgb(INK3())) | |
| 889 | - .child(label), | |
| 890 | - ), | |
| 891 | - ) | |
| 917 | + div().absolute().top_0().left(px(x)).child( | |
| 918 | + div() | |
| 919 | + .flex() | |
| 920 | + .flex_col() | |
| 921 | + .items_start() | |
| 922 | + .child(div().w(px(1.)).h(px(4.)).bg(rgb(INK3()))) | |
| 923 | + .child( | |
| 924 | + div() | |
| 925 | + .type_style(type_scale::mono( | |
| 926 | + type_scale::FLOOR_PX, | |
| 927 | + gpui::FontWeight::MEDIUM, | |
| 928 | + )) | |
| 929 | + .text_color(rgb(INK3())) | |
| 930 | + .child(label), | |
| 931 | + ), | |
| 932 | + ) | |
| 892 | 933 | })) |
| 893 | 934 | .child( |
| 894 | 935 | div() |
crates/app/src/ui/cards.rsmodified+640 -399
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | //! The property cards -- docked into the inspector, or floated when modal. |
| 2 | 2 | |
| 3 | -use crate::*; | |
| 4 | 3 | use crate::ui::type_scale::{self, Typeset}; |
| 5 | 4 | use crate::ui::widgets::*; |
| 5 | +use crate::*; | |
| 6 | 6 | |
| 7 | 7 | /// DESIGN §3/§4 atoms shared by every param/setting card below (colour, |
| 8 | 8 | /// transform, speed, EQ, silence, mix, subtitle style): what a row's label |
| @@ -11,11 +11,14 @@ use crate::ui::widgets::*; | ||
| 11 | 11 | /// times (`export_card`'s own `dark`-branch technique, one level up). |
| 12 | 12 | /// |
| 13 | 13 | /// A row label is what the room says about the control -- Archivo, §3's |
| 14 | -/// 10.5px row size, `ink2` at rest / `ink1` picked (no permanent pill: the | |
| 14 | +/// label-row size, `ink2` at rest / `ink1` picked (no permanent pill: the | |
| 15 | 15 | /// picked state is a 1px `ink1` rule, §4's focus ring, not a fill). |
| 16 | 16 | fn dark_row_label(text: impl Into<SharedString>, picked: bool) -> Div { |
| 17 | 17 | div() |
| 18 | - .type_style(type_scale::label(type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM)) | |
| 18 | + .type_style(type_scale::label( | |
| 19 | + type_scale::LABEL_ROW_PX, | |
| 20 | + gpui::FontWeight::MEDIUM, | |
| 21 | + )) | |
| 19 | 22 | .text_color(rgb(if picked { INK1() } else { INK2() })) |
| 20 | 23 | .child(text.into()) |
| 21 | 24 | } |
| @@ -38,7 +41,10 @@ fn transform_row_value(band: usize, value: f32) -> String { | ||
| 38 | 41 | /// A row's value -- what the film/the setting *says*, mono per §3. |
| 39 | 42 | fn dark_row_value(text: impl Into<SharedString>) -> Div { |
| 40 | 43 | div() |
| 41 | - .type_style(type_scale::mono(type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM)) | |
| 44 | + .type_style(type_scale::mono( | |
| 45 | + type_scale::LABEL_ROW_PX, | |
| 46 | + gpui::FontWeight::MEDIUM, | |
| 47 | + )) | |
| 42 | 48 | .text_color(rgb(INK1())) |
| 43 | 49 | .child(text.into()) |
| 44 | 50 | } |
| @@ -95,15 +101,24 @@ fn dark_card_head( | ||
| 95 | 101 | .id("card-head-maximize") |
| 96 | 102 | .flex_none() |
| 97 | 103 | .cursor_pointer() |
| 98 | - .type_style(type_scale::mono(type_scale::CHORD_METADATA_MAX_PX, gpui::FontWeight::MEDIUM)) | |
| 104 | + .type_style(type_scale::mono( | |
| 105 | + type_scale::CHORD_METADATA_MAX_PX, | |
| 106 | + gpui::FontWeight::MEDIUM, | |
| 107 | + )) | |
| 99 | 108 | .text_color(rgb(INK3())) |
| 100 | 109 | .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { |
| 101 | 110 | this.toggle_maximize(); |
| 102 | 111 | cx.notify(); |
| 103 | 112 | })) |
| 104 | 113 | .tooltip(move |_, cx| { |
| 105 | - cx.new(|_| OverlayTip(if max { "m -- back to the room".into() } else { "m -- fills the room".into() })) | |
| 106 | - .into() | |
| 114 | + cx.new(|_| { | |
| 115 | + OverlayTip(if max { | |
| 116 | + "m -- back to the room".into() | |
| 117 | + } else { | |
| 118 | + "m -- fills the room".into() | |
| 119 | + }) | |
| 120 | + }) | |
| 121 | + .into() | |
| 107 | 122 | }) |
| 108 | 123 | .child(if max { "▣ m" } else { "⤢ m" }) |
| 109 | 124 | })) |
| @@ -115,7 +130,10 @@ fn dark_card_head( | ||
| 115 | 130 | ) |
| 116 | 131 | .children(meta.map(|m| { |
| 117 | 132 | div() |
| 118 | - .type_style(type_scale::mono(type_scale::CHORD_METADATA_MAX_PX, gpui::FontWeight::MEDIUM)) | |
| 133 | + .type_style(type_scale::mono( | |
| 134 | + type_scale::CHORD_METADATA_MAX_PX, | |
| 135 | + gpui::FontWeight::MEDIUM, | |
| 136 | + )) | |
| 119 | 137 | .text_color(rgb(INK3())) |
| 120 | 138 | .child(m) |
| 121 | 139 | })) |
| @@ -123,7 +141,10 @@ fn dark_card_head( | ||
| 123 | 141 | div() |
| 124 | 142 | .id("card-head-help") |
| 125 | 143 | .flex_none() |
| 126 | - .type_style(type_scale::mono(type_scale::CHORD_METADATA_MAX_PX, gpui::FontWeight::MEDIUM)) | |
| 144 | + .type_style(type_scale::mono( | |
| 145 | + type_scale::CHORD_METADATA_MAX_PX, | |
| 146 | + gpui::FontWeight::MEDIUM, | |
| 147 | + )) | |
| 127 | 148 | .text_color(rgb(INK3())) |
| 128 | 149 | .tooltip(move |_, cx| cx.new(|_| OverlayTip(h.clone())).into()) |
| 129 | 150 | .child("?") |
| @@ -136,7 +157,10 @@ fn dark_help(text: impl Into<SharedString>) -> Div { | ||
| 136 | 157 | div() |
| 137 | 158 | .flex_none() |
| 138 | 159 | .px(px(6.)) |
| 139 | - .type_style(type_scale::mono(type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM)) | |
| 160 | + .type_style(type_scale::mono( | |
| 161 | + type_scale::LABEL_ROW_PX, | |
| 162 | + gpui::FontWeight::MEDIUM, | |
| 163 | + )) | |
| 140 | 164 | .text_color(rgb(INK3())) |
| 141 | 165 | .child(text.into()) |
| 142 | 166 | } |
| @@ -192,7 +216,10 @@ fn dark_ghost_button( | ||
| 192 | 216 | .on_click(on_click) |
| 193 | 217 | .child( |
| 194 | 218 | div() |
| 195 | - .type_style(type_scale::label(type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM)) | |
| 219 | + .type_style(type_scale::label( | |
| 220 | + type_scale::LABEL_ROW_PX, | |
| 221 | + gpui::FontWeight::MEDIUM, | |
| 222 | + )) | |
| 196 | 223 | .text_color(rgb(if active { INK1() } else { INK2() })) |
| 197 | 224 | .child(text.into()), |
| 198 | 225 | ) |
| @@ -260,8 +287,11 @@ impl Player { | ||
| 260 | 287 | let bg_selected = if dark { DARK_RAISED() } else { BG_SELECTED() }; |
| 261 | 288 | // Archivo for what the row *says as a verb* (its label), mono for |
| 262 | 289 | // what the film says through it (its detail/key) -- DESIGN §3. |
| 263 | - let font_label = dark.then(|| type_scale::label(11., gpui::FontWeight::MEDIUM).font); | |
| 264 | - let font_mono = dark.then(|| type_scale::mono(11., gpui::FontWeight::MEDIUM).font); | |
| 290 | + let label_style = | |
| 291 | + dark.then(|| type_scale::label(type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM)); | |
| 292 | + let mono_style = dark | |
| 293 | + .then(|| type_scale::mono(type_scale::CHORD_METADATA_MAX_PX, gpui::FontWeight::MEDIUM)); | |
| 294 | + let head_style = dark.then(type_scale::head); | |
| 265 | 295 | let row = |id: (&'static str, usize)| { |
| 266 | 296 | div() |
| 267 | 297 | .id(id) |
| @@ -287,7 +317,9 @@ impl Player { | ||
| 287 | 317 | d.when(!enabled, |d| { |
| 288 | 318 | d.cursor_not_allowed().text_color(rgb(ink_secondary)) |
| 289 | 319 | }) |
| 290 | - .when(enabled, |d| d.cursor_pointer().hover(|s| s.bg(rgb(bg_hover)))) | |
| 320 | + .when(enabled, |d| { | |
| 321 | + d.cursor_pointer().hover(|s| s.bg(rgb(bg_hover))) | |
| 322 | + }) | |
| 291 | 323 | }; |
| 292 | 324 | // A row as this card writes them: the mark saying which one is picked, |
| 293 | 325 | // the key that picks it, its name, and what the choice means. The mark |
| @@ -324,12 +356,16 @@ impl Player { | ||
| 324 | 356 | .w(px(EXPORT_KEY_W)) |
| 325 | 357 | .text_size(px(11.)) |
| 326 | 358 | .text_color(rgb(ink)) |
| 327 | - .when_some(font_mono.clone(), |d, f| d.font(f)) | |
| 359 | + .when_some(mono_style.clone(), |d, style| { | |
| 360 | + d.font(style.font).text_size(style.size) | |
| 361 | + }) | |
| 328 | 362 | .child(SharedString::from(key.to_string())), |
| 329 | 363 | ) |
| 330 | 364 | .child( |
| 331 | 365 | div() |
| 332 | - .when_some(font_label.clone(), |d, f| d.font(f)) | |
| 366 | + .when_some(label_style.clone(), |d, style| { | |
| 367 | + d.font(style.font).text_size(style.size) | |
| 368 | + }) | |
| 333 | 369 | .child(label), |
| 334 | 370 | ), |
| 335 | 371 | ) |
| @@ -342,7 +378,9 @@ impl Player { | ||
| 342 | 378 | .flex_shrink() |
| 343 | 379 | .text_size(px(11.)) |
| 344 | 380 | .text_color(rgb(ink)) |
| 345 | - .when_some(font_mono.clone(), |d, f| d.font(f)) | |
| 381 | + .when_some(mono_style.clone(), |d, style| { | |
| 382 | + d.font(style.font).text_size(style.size) | |
| 383 | + }) | |
| 346 | 384 | .child(detail), |
| 347 | 385 | ) |
| 348 | 386 | }; |
| @@ -353,7 +391,9 @@ impl Player { | ||
| 353 | 391 | .pt(px(4.)) |
| 354 | 392 | .text_size(px(10.)) |
| 355 | 393 | .text_color(rgb(ink_secondary)) |
| 356 | - .when_some(font_label.clone(), |d, f| d.font(f)) | |
| 394 | + .when_some(head_style.clone(), |d, style| { | |
| 395 | + d.font(style.font).text_size(style.size) | |
| 396 | + }) | |
| 357 | 397 | .child(text) |
| 358 | 398 | .into_any_element() |
| 359 | 399 | }; |
| @@ -383,9 +423,11 @@ impl Player { | ||
| 383 | 423 | // rows already carry: dimmed, unclickable, its reason in place of |
| 384 | 424 | // the detail -- not bright and pickable over a click that would |
| 385 | 425 | // only bounce off `set_format`'s own guard. |
| 386 | - let refusal = preset | |
| 387 | - .bundle() | |
| 388 | - .and_then(|(format, _)| self.session.as_ref().and_then(|s| format_refusal(s, format))); | |
| 426 | + let refusal = preset.bundle().and_then(|(format, _)| { | |
| 427 | + self.session | |
| 428 | + .as_ref() | |
| 429 | + .and_then(|s| format_refusal(s, format)) | |
| 430 | + }); | |
| 389 | 431 | let detail: SharedString = match &refusal { |
| 390 | 432 | Some(why) => why.clone().into(), |
| 391 | 433 | None => preset.detail().into(), |
| @@ -409,8 +451,9 @@ impl Player { | ||
| 409 | 451 | let advanced_detail = match self.export_advanced_open { |
| 410 | 452 | true => "codec, container, quality, sound, encoder, subtitles — s collapses them" |
| 411 | 453 | .to_string(), |
| 412 | - false => "codec, container, quality, sound, encoder, subtitles — s for the rows" | |
| 413 | - .to_string(), | |
| 454 | + false => { | |
| 455 | + "codec, container, quality, sound, encoder, subtitles — s for the rows".to_string() | |
| 456 | + } | |
| 414 | 457 | }; |
| 415 | 458 | list.push( |
| 416 | 459 | entry( |
| @@ -433,313 +476,327 @@ impl Player { | ||
| 433 | 476 | // it built exactly as the flat card built it, only not pushed at all |
| 434 | 477 | // while the pane is shut. |
| 435 | 478 | if self.export_advanced_open { |
| 436 | - if self.export_grouped { | |
| 437 | - list.push(header("FORMAT")); | |
| 438 | - } | |
| 439 | - // The codecs first: which one is being written decides whether every | |
| 440 | - // row under it means anything. One a *this* timeline cannot be written | |
| 441 | - // as (an audio-only edit, for a picture codec) reads exactly like one | |
| 442 | - // there is no encoder for -- dimmed, unclickable, and carrying its own | |
| 443 | - // reason where its detail was, with nothing to click to find that out. | |
| 444 | - let mut refusals: Vec<String> = Vec::new(); | |
| 445 | - for (i, (boxes, key, label, detail)) in FORMATS.into_iter().enumerate() { | |
| 446 | - let format = same_box(boxes, self.format); | |
| 447 | - let refused = format | |
| 448 | - .zip(self.session.as_ref()) | |
| 449 | - .and_then(|(f, s)| format_refusal(s, f)); | |
| 450 | - // A codec with no encoder here at all is the other kind of refusal, | |
| 451 | - // and the one the footer collects: it can never become pickable, so | |
| 452 | - // a row each is dead rows above the fold. | |
| 453 | - if format.is_none() { | |
| 454 | - refusals.push(format!("{label} — {detail}")); | |
| 455 | - if !self.export_refusals_inline { | |
| 456 | - continue; | |
| 479 | + if self.export_grouped { | |
| 480 | + list.push(header("FORMAT")); | |
| 481 | + } | |
| 482 | + // The codecs first: which one is being written decides whether every | |
| 483 | + // row under it means anything. One a *this* timeline cannot be written | |
| 484 | + // as (an audio-only edit, for a picture codec) reads exactly like one | |
| 485 | + // there is no encoder for -- dimmed, unclickable, and carrying its own | |
| 486 | + // reason where its detail was, with nothing to click to find that out. | |
| 487 | + let mut refusals: Vec<String> = Vec::new(); | |
| 488 | + for (i, (boxes, key, label, detail)) in FORMATS.into_iter().enumerate() { | |
| 489 | + let format = same_box(boxes, self.format); | |
| 490 | + let refused = format | |
| 491 | + .zip(self.session.as_ref()) | |
| 492 | + .and_then(|(f, s)| format_refusal(s, f)); | |
| 493 | + // A codec with no encoder here at all is the other kind of refusal, | |
| 494 | + // and the one the footer collects: it can never become pickable, so | |
| 495 | + // a row each is dead rows above the fold. | |
| 496 | + if format.is_none() { | |
| 497 | + refusals.push(format!("{label} — {detail}")); | |
| 498 | + if !self.export_refusals_inline { | |
| 499 | + continue; | |
| 500 | + } | |
| 501 | + } | |
| 502 | + let detail: SharedString = match &refused { | |
| 503 | + Some(why) => why.clone().into(), | |
| 504 | + None => detail.into(), | |
| 505 | + }; | |
| 506 | + let format = format.filter(|_| refused.is_none()); | |
| 507 | + let mut r = entry( | |
| 508 | + ("format", i), | |
| 509 | + key, | |
| 510 | + label.into(), | |
| 511 | + detail, | |
| 512 | + boxes.contains(&self.format), | |
| 513 | + format.is_some(), | |
| 514 | + ); | |
| 515 | + if let Some(format) = format { | |
| 516 | + r = r.on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | |
| 517 | + this.set_format(format); | |
| 518 | + cx.notify(); | |
| 519 | + })); | |
| 457 | 520 | } |
| 521 | + list.push(r.into_any_element()); | |
| 458 | 522 | } |
| 459 | - let detail: SharedString = match &refused { | |
| 460 | - Some(why) => why.clone().into(), | |
| 461 | - None => detail.into(), | |
| 462 | - }; | |
| 463 | - let format = format.filter(|_| refused.is_none()); | |
| 523 | + if self.export_grouped { | |
| 524 | + list.push(header("DETAILS")); | |
| 525 | + } | |
| 526 | + // The container, and only where the picked codec has more than one box: | |
| 527 | + // a row offering a single choice reads as a choice. | |
| 528 | + let boxes = containers(self.format); | |
| 529 | + if boxes.len() > 1 { | |
| 530 | + let next = next_container(self.format); | |
| 531 | + list.push( | |
| 532 | + entry( | |
| 533 | + ("container", 0), | |
| 534 | + "c", | |
| 535 | + "Container".into(), | |
| 536 | + format!( | |
| 537 | + "{} — c for {}", | |
| 538 | + self.format.ext().to_uppercase(), | |
| 539 | + next.ext().to_uppercase() | |
| 540 | + ) | |
| 541 | + .into(), | |
| 542 | + false, | |
| 543 | + true, | |
| 544 | + ) | |
| 545 | + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { | |
| 546 | + this.cycle_container(); | |
| 547 | + cx.notify(); | |
| 548 | + })) | |
| 549 | + .into_any_element(), | |
| 550 | + ); | |
| 551 | + } | |
| 552 | + match bitrate_refusal(self.format) { | |
| 553 | + // One dimmed row carrying the reason, rather than five rows of a | |
| 554 | + // figure that will not be written: the quality rows are the | |
| 555 | + // *picture's* bitrate, and this file has no picture in it. | |
| 556 | + Some(why) => list.push( | |
| 557 | + entry( | |
| 558 | + ("quality", 0), | |
| 559 | + "q", | |
| 560 | + "Quality".into(), | |
| 561 | + why.into(), | |
| 562 | + false, | |
| 563 | + false, | |
| 564 | + ) | |
| 565 | + .into_any_element(), | |
| 566 | + ), | |
| 567 | + None => { | |
| 568 | + for (i, quality) in Quality::ALL.into_iter().enumerate() { | |
| 569 | + // The custom row is a field: `n` opens it, a click in it | |
| 570 | + // opens it too, and while it is open the row shows what is | |
| 571 | + // being typed with a caret in it rather than the number in | |
| 572 | + // force. The other four are picked whole. | |
| 573 | + let field = self | |
| 574 | + .mbps_edit | |
| 575 | + .as_ref() | |
| 576 | + .filter(|_| quality == Quality::Custom); | |
| 577 | + let mut r = entry( | |
| 578 | + ("quality", i), | |
| 579 | + match quality { | |
| 580 | + Quality::Custom => "n", | |
| 581 | + _ => "q", | |
| 582 | + }, | |
| 583 | + quality.label().into(), | |
| 584 | + match field { | |
| 585 | + Some(edit) => edit.detail().into(), | |
| 586 | + None => quality.detail(self.custom_mbps).into(), | |
| 587 | + }, | |
| 588 | + self.quality == quality, | |
| 589 | + true, | |
| 590 | + ) | |
| 591 | + .on_click(cx.listener( | |
| 592 | + move |this, _: &ClickEvent, _, cx| { | |
| 593 | + match quality { | |
| 594 | + Quality::Custom => this.edit_mbps(), | |
| 595 | + _ => this.quality = quality, | |
| 596 | + } | |
| 597 | + cx.notify(); | |
| 598 | + }, | |
| 599 | + )); | |
| 600 | + if quality == Quality::Custom { | |
| 601 | + // The wheel anywhere over the row moves the number, the | |
| 602 | + // buttons being one step each: the range is fifty wide | |
| 603 | + // now, and a number only a repeated press can walk to is | |
| 604 | + // a number nobody walks to. Swallowed, so the notch that | |
| 605 | + // moved the bitrate does not scroll the list under it as | |
| 606 | + // well -- one gesture, one thing changed. | |
| 607 | + r = r | |
| 608 | + .on_scroll_wheel(cx.listener( | |
| 609 | + |this, event: &ScrollWheelEvent, _, cx| { | |
| 610 | + this.wheel_mbps(event); | |
| 611 | + cx.stop_propagation(); | |
| 612 | + cx.notify(); | |
| 613 | + }, | |
| 614 | + )) | |
| 615 | + .child(self.mbps_steppers(cx)); | |
| 616 | + } | |
| 617 | + list.push(r.into_any_element()); | |
| 618 | + } | |
| 619 | + } | |
| 620 | + } | |
| 621 | + // The other half of the file, and the one this card used to write at a | |
| 622 | + // fixed rate without saying so: what the *sound* is coded at, for every | |
| 623 | + // format that codes it -- the AAC inside a video export as much as an | |
| 624 | + // MP3. Four rates, so the pointer gets the *list* of them | |
| 625 | + // ([`Pick::AudioRate`]) rather than a button clicked round -- the | |
| 626 | + // resolution row's rule, and the key still steps as `ctrl+r` still | |
| 627 | + // does. Dimmed with the reason where this timeline has no rate to pick, | |
| 628 | + // like the quality rows are. | |
| 629 | + let sound = self.audio_rate_refusal(); | |
| 464 | 630 | let mut r = entry( |
| 465 | - ("format", i), | |
| 466 | - key, | |
| 467 | - label.into(), | |
| 468 | - detail, | |
| 469 | - boxes.contains(&self.format), | |
| 470 | - format.is_some(), | |
| 631 | + ("sound", 0), | |
| 632 | + "b", | |
| 633 | + "Sound".into(), | |
| 634 | + match sound { | |
| 635 | + Some(why) => why.into(), | |
| 636 | + None => format!("{} kbps — b steps", self.audio_kbps).into(), | |
| 637 | + }, | |
| 638 | + false, | |
| 639 | + sound.is_none(), | |
| 471 | 640 | ); |
| 472 | - if let Some(format) = format { | |
| 473 | - r = r.on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | |
| 474 | - this.set_format(format); | |
| 475 | - cx.notify(); | |
| 641 | + if sound.is_none() { | |
| 642 | + r = r.on_click(cx.listener(|this, event: &ClickEvent, _, cx| { | |
| 643 | + this.open_picker(Pick::AudioRate, event.position(), cx) | |
| 476 | 644 | })); |
| 477 | 645 | } |
| 478 | 646 | list.push(r.into_any_element()); |
| 479 | - } | |
| 480 | - if self.export_grouped { | |
| 481 | - list.push(header("DETAILS")); | |
| 482 | - } | |
| 483 | - // The container, and only where the picked codec has more than one box: | |
| 484 | - // a row offering a single choice reads as a choice. | |
| 485 | - let boxes = containers(self.format); | |
| 486 | - if boxes.len() > 1 { | |
| 487 | - let next = next_container(self.format); | |
| 647 | + // Which encoder writes the picture, which was an env pin and therefore | |
| 648 | + // no choice at all. Three seats, so the pointer gets the *list* of them | |
| 649 | + // ([`Pick::Encoder`]) and never a button clicked round -- the Sound | |
| 650 | + // row's rule, one row above. Only where there is a picture to encode: | |
| 651 | + // a WAV has no seat to pick and the row would be a question about | |
| 652 | + // nothing. | |
| 653 | + if self.format.has_video() { | |
| 654 | + let seat = self.encoder_seat(); | |
| 655 | + list.push( | |
| 656 | + entry( | |
| 657 | + ("encoder", 0), | |
| 658 | + "e", | |
| 659 | + "Encoder".into(), | |
| 660 | + format!("{} — e steps", encoder_label(seat)).into(), | |
| 661 | + false, | |
| 662 | + true, | |
| 663 | + ) | |
| 664 | + .on_click(cx.listener(|this, event: &ClickEvent, _, cx| { | |
| 665 | + this.open_picker(Pick::Encoder, event.position(), cx) | |
| 666 | + })) | |
| 667 | + .into_any_element(), | |
| 668 | + ); | |
| 669 | + // ...and, under it, the one thing about that pick a person cannot | |
| 670 | + // know from the words in the list: this box's driver reset itself | |
| 671 | + // on the vendored AV1 encoder. A dimmed row and not a modal -- the | |
| 672 | + // pick is theirs, and the export runs. | |
| 673 | + if let Some(warning) = av1_hw_warning(self.format, seat) { | |
| 674 | + list.push( | |
| 675 | + entry( | |
| 676 | + ("encoder-av1", 0), | |
| 677 | + "", | |
| 678 | + "".into(), | |
| 679 | + warning.into(), | |
| 680 | + false, | |
| 681 | + false, | |
| 682 | + ) | |
| 683 | + .into_any_element(), | |
| 684 | + ); | |
| 685 | + } | |
| 686 | + } | |
| 687 | + // What happens to the subtitles on this timeline, in one line: how many | |
| 688 | + // are written into the file and under what names, or the reason each one | |
| 689 | + // is not. Which tracks travel is not a pick -- everything with a cue on | |
| 690 | + // the timeline goes ([`Player::export_subs`]) -- so the row says rather | |
| 691 | + // than offers, like the machine lines below. | |
| 692 | + // ...and the ones that do not travel are named here too, which they were | |
| 693 | + // not: `export_subs` had already filtered a track with no cue on *this* | |
| 694 | + // timeline out of the engine's sight, so the card said nothing about a | |
| 695 | + // row the list was still showing ([`subtitle_plan`]). | |
| 696 | + let plan = self.subtitle_line(); | |
| 697 | + // The row used to end in "click for <fmt> in MKV" whenever the picture | |
| 698 | + // was going into an mp4, on the grounds that only Matroska carries a | |
| 699 | + // text track. An mp4 carries one now (`Mp4Muxer::write_subtitles` writes | |
| 700 | + // `tx3g`), so that was a refusal offering a way out of nothing: the | |
| 701 | + // container the card is already set to embeds them. The refusals left in | |
| 702 | + // `planned_subtitles` are the true ones -- a sound-only format has | |
| 703 | + // nowhere to put a track, and a PGS track is pictures whatever the box. | |
| 488 | 704 | list.push( |
| 489 | 705 | entry( |
| 490 | - ("container", 0), | |
| 491 | - "c", | |
| 492 | - "Container".into(), | |
| 493 | - format!( | |
| 494 | - "{} — c for {}", | |
| 495 | - self.format.ext().to_uppercase(), | |
| 496 | - next.ext().to_uppercase() | |
| 497 | - ) | |
| 498 | - .into(), | |
| 706 | + ("subtitles", 0), | |
| 707 | + "", | |
| 708 | + "Subtitles".into(), | |
| 709 | + plan.into(), | |
| 710 | + false, | |
| 499 | 711 | false, |
| 712 | + ) | |
| 713 | + .into_any_element(), | |
| 714 | + ); | |
| 715 | + // The card's own two layout switches. They were `g` and `r` and nothing | |
| 716 | + // else, while the status line under the title advertised both of them: | |
| 717 | + // a hand on the mouse read what they do and had nothing to press. | |
| 718 | + list.push( | |
| 719 | + entry( | |
| 720 | + ("export-layout", 0), | |
| 721 | + "g", | |
| 722 | + "Layout".into(), | |
| 723 | + match self.export_grouped { | |
| 724 | + true => "sections — g for one flat list".into(), | |
| 725 | + false => "one flat list — g for sections".into(), | |
| 726 | + }, | |
| 727 | + self.export_grouped, | |
| 500 | 728 | true, |
| 501 | 729 | ) |
| 502 | 730 | .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { |
| 503 | - this.cycle_container(); | |
| 731 | + this.export_grouped = !this.export_grouped; | |
| 504 | 732 | cx.notify(); |
| 505 | 733 | })) |
| 506 | 734 | .into_any_element(), |
| 507 | 735 | ); |
| 508 | - } | |
| 509 | - match bitrate_refusal(self.format) { | |
| 510 | - // One dimmed row carrying the reason, rather than five rows of a | |
| 511 | - // figure that will not be written: the quality rows are the | |
| 512 | - // *picture's* bitrate, and this file has no picture in it. | |
| 513 | - Some(why) => list.push( | |
| 514 | - entry( | |
| 515 | - ("quality", 0), | |
| 516 | - "q", | |
| 517 | - "Quality".into(), | |
| 518 | - why.into(), | |
| 519 | - false, | |
| 520 | - false, | |
| 521 | - ) | |
| 522 | - .into_any_element(), | |
| 523 | - ), | |
| 524 | - None => { | |
| 525 | - for (i, quality) in Quality::ALL.into_iter().enumerate() { | |
| 526 | - // The custom row is a field: `n` opens it, a click in it | |
| 527 | - // opens it too, and while it is open the row shows what is | |
| 528 | - // being typed with a caret in it rather than the number in | |
| 529 | - // force. The other four are picked whole. | |
| 530 | - let field = self.mbps_edit.as_ref().filter(|_| quality == Quality::Custom); | |
| 531 | - let mut r = entry( | |
| 532 | - ("quality", i), | |
| 533 | - match quality { | |
| 534 | - Quality::Custom => "n", | |
| 535 | - _ => "q", | |
| 536 | - }, | |
| 537 | - quality.label().into(), | |
| 538 | - match field { | |
| 539 | - Some(edit) => edit.detail().into(), | |
| 540 | - None => quality.detail(self.custom_mbps).into(), | |
| 541 | - }, | |
| 542 | - self.quality == quality, | |
| 543 | - true, | |
| 544 | - ) | |
| 545 | - .on_click(cx.listener( | |
| 546 | - move |this, _: &ClickEvent, _, cx| { | |
| 547 | - match quality { | |
| 548 | - Quality::Custom => this.edit_mbps(), | |
| 549 | - _ => this.quality = quality, | |
| 550 | - } | |
| 551 | - cx.notify(); | |
| 552 | - }, | |
| 553 | - )); | |
| 554 | - if quality == Quality::Custom { | |
| 555 | - // The wheel anywhere over the row moves the number, the | |
| 556 | - // buttons being one step each: the range is fifty wide | |
| 557 | - // now, and a number only a repeated press can walk to is | |
| 558 | - // a number nobody walks to. Swallowed, so the notch that | |
| 559 | - // moved the bitrate does not scroll the list under it as | |
| 560 | - // well -- one gesture, one thing changed. | |
| 561 | - r = r | |
| 562 | - .on_scroll_wheel(cx.listener( | |
| 563 | - |this, event: &ScrollWheelEvent, _, cx| { | |
| 564 | - this.wheel_mbps(event); | |
| 565 | - cx.stop_propagation(); | |
| 566 | - cx.notify(); | |
| 567 | - }, | |
| 568 | - )) | |
| 569 | - .child(self.mbps_steppers(cx)); | |
| 570 | - } | |
| 571 | - list.push(r.into_any_element()); | |
| 572 | - } | |
| 573 | - } | |
| 574 | - } | |
| 575 | - // The other half of the file, and the one this card used to write at a | |
| 576 | - // fixed rate without saying so: what the *sound* is coded at, for every | |
| 577 | - // format that codes it -- the AAC inside a video export as much as an | |
| 578 | - // MP3. Four rates, so the pointer gets the *list* of them | |
| 579 | - // ([`Pick::AudioRate`]) rather than a button clicked round -- the | |
| 580 | - // resolution row's rule, and the key still steps as `ctrl+r` still | |
| 581 | - // does. Dimmed with the reason where this timeline has no rate to pick, | |
| 582 | - // like the quality rows are. | |
| 583 | - let sound = self.audio_rate_refusal(); | |
| 584 | - let mut r = entry( | |
| 585 | - ("sound", 0), | |
| 586 | - "b", | |
| 587 | - "Sound".into(), | |
| 588 | - match sound { | |
| 589 | - Some(why) => why.into(), | |
| 590 | - None => format!("{} kbps — b steps", self.audio_kbps).into(), | |
| 591 | - }, | |
| 592 | - false, | |
| 593 | - sound.is_none(), | |
| 594 | - ); | |
| 595 | - if sound.is_none() { | |
| 596 | - r = r.on_click(cx.listener(|this, event: &ClickEvent, _, cx| { | |
| 597 | - this.open_picker(Pick::AudioRate, event.position(), cx) | |
| 598 | - })); | |
| 599 | - } | |
| 600 | - list.push(r.into_any_element()); | |
| 601 | - // Which encoder writes the picture, which was an env pin and therefore | |
| 602 | - // no choice at all. Three seats, so the pointer gets the *list* of them | |
| 603 | - // ([`Pick::Encoder`]) and never a button clicked round -- the Sound | |
| 604 | - // row's rule, one row above. Only where there is a picture to encode: | |
| 605 | - // a WAV has no seat to pick and the row would be a question about | |
| 606 | - // nothing. | |
| 607 | - if self.format.has_video() { | |
| 608 | - let seat = self.encoder_seat(); | |
| 609 | 736 | list.push( |
| 610 | 737 | entry( |
| 611 | - ("encoder", 0), | |
| 612 | - "e", | |
| 613 | - "Encoder".into(), | |
| 614 | - format!("{} — e steps", encoder_label(seat)).into(), | |
| 615 | - false, | |
| 738 | + ("export-refusals", 0), | |
| 739 | + "r", | |
| 740 | + "Codecs with no encoder".into(), | |
| 741 | + match self.export_refusals_inline { | |
| 742 | + true => "a dimmed row each — r collapses them".into(), | |
| 743 | + false => "one line at the foot — r shows a row each".into(), | |
| 744 | + }, | |
| 745 | + self.export_refusals_inline, | |
| 616 | 746 | true, |
| 617 | 747 | ) |
| 618 | - .on_click(cx.listener(|this, event: &ClickEvent, _, cx| { | |
| 619 | - this.open_picker(Pick::Encoder, event.position(), cx) | |
| 748 | + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { | |
| 749 | + this.export_refusals_inline = !this.export_refusals_inline; | |
| 750 | + cx.notify(); | |
| 620 | 751 | })) |
| 621 | 752 | .into_any_element(), |
| 622 | 753 | ); |
| 623 | - // ...and, under it, the one thing about that pick a person cannot | |
| 624 | - // know from the words in the list: this box's driver reset itself | |
| 625 | - // on the vendored AV1 encoder. A dimmed row and not a modal -- the | |
| 626 | - // pick is theirs, and the export runs. | |
| 627 | - if let Some(warning) = av1_hw_warning(self.format, seat) { | |
| 754 | + if !self.export_refusals_inline && !refusals.is_empty() { | |
| 755 | + // Last, and one line: the reason travels with the name (a footer | |
| 756 | + // that only listed them would be the "why not?" the rows exist to | |
| 757 | + // answer), but nothing here can ever be picked, so it sits under | |
| 758 | + // every row that can rather than above them. | |
| 628 | 759 | list.push( |
| 629 | - entry(("encoder-av1", 0), "", "".into(), warning.into(), false, false) | |
| 760 | + div() | |
| 761 | + .flex_none() | |
| 762 | + .px(px(6.)) | |
| 763 | + .py(px(2.)) | |
| 764 | + .text_size(px(11.)) | |
| 765 | + .text_color(rgb(ink_secondary)) | |
| 766 | + .when_some(mono_style.clone(), |d, style| { | |
| 767 | + d.font(style.font).text_size(style.size) | |
| 768 | + }) | |
| 769 | + .child(format!("cannot write: {}", refusals.join(" · "))) | |
| 630 | 770 | .into_any_element(), |
| 631 | 771 | ); |
| 632 | 772 | } |
| 633 | - } | |
| 634 | - // What happens to the subtitles on this timeline, in one line: how many | |
| 635 | - // are written into the file and under what names, or the reason each one | |
| 636 | - // is not. Which tracks travel is not a pick -- everything with a cue on | |
| 637 | - // the timeline goes ([`Player::export_subs`]) -- so the row says rather | |
| 638 | - // than offers, like the machine lines below. | |
| 639 | - // ...and the ones that do not travel are named here too, which they were | |
| 640 | - // not: `export_subs` had already filtered a track with no cue on *this* | |
| 641 | - // timeline out of the engine's sight, so the card said nothing about a | |
| 642 | - // row the list was still showing ([`subtitle_plan`]). | |
| 643 | - let plan = self.subtitle_line(); | |
| 644 | - // The row used to end in "click for <fmt> in MKV" whenever the picture | |
| 645 | - // was going into an mp4, on the grounds that only Matroska carries a | |
| 646 | - // text track. An mp4 carries one now (`Mp4Muxer::write_subtitles` writes | |
| 647 | - // `tx3g`), so that was a refusal offering a way out of nothing: the | |
| 648 | - // container the card is already set to embeds them. The refusals left in | |
| 649 | - // `planned_subtitles` are the true ones -- a sound-only format has | |
| 650 | - // nowhere to put a track, and a PGS track is pictures whatever the box. | |
| 651 | - list.push( | |
| 652 | - entry( | |
| 653 | - ("subtitles", 0), | |
| 654 | - "", | |
| 655 | - "Subtitles".into(), | |
| 656 | - plan.into(), | |
| 657 | - false, | |
| 658 | - false, | |
| 659 | - ) | |
| 660 | - .into_any_element(), | |
| 661 | - ); | |
| 662 | - // The card's own two layout switches. They were `g` and `r` and nothing | |
| 663 | - // else, while the status line under the title advertised both of them: | |
| 664 | - // a hand on the mouse read what they do and had nothing to press. | |
| 665 | - list.push( | |
| 666 | - entry( | |
| 667 | - ("export-layout", 0), | |
| 668 | - "g", | |
| 669 | - "Layout".into(), | |
| 670 | - match self.export_grouped { | |
| 671 | - true => "sections — g for one flat list".into(), | |
| 672 | - false => "one flat list — g for sections".into(), | |
| 673 | - }, | |
| 674 | - self.export_grouped, | |
| 675 | - true, | |
| 676 | - ) | |
| 677 | - .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { | |
| 678 | - this.export_grouped = !this.export_grouped; | |
| 679 | - cx.notify(); | |
| 680 | - })) | |
| 681 | - .into_any_element(), | |
| 682 | - ); | |
| 683 | - list.push( | |
| 684 | - entry( | |
| 685 | - ("export-refusals", 0), | |
| 686 | - "r", | |
| 687 | - "Codecs with no encoder".into(), | |
| 688 | - match self.export_refusals_inline { | |
| 689 | - true => "a dimmed row each — r collapses them".into(), | |
| 690 | - false => "one line at the foot — r shows a row each".into(), | |
| 691 | - }, | |
| 692 | - self.export_refusals_inline, | |
| 693 | - true, | |
| 694 | - ) | |
| 695 | - .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { | |
| 696 | - this.export_refusals_inline = !this.export_refusals_inline; | |
| 697 | - cx.notify(); | |
| 698 | - })) | |
| 699 | - .into_any_element(), | |
| 700 | - ); | |
| 701 | - if !self.export_refusals_inline && !refusals.is_empty() { | |
| 702 | - // Last, and one line: the reason travels with the name (a footer | |
| 703 | - // that only listed them would be the "why not?" the rows exist to | |
| 704 | - // answer), but nothing here can ever be picked, so it sits under | |
| 705 | - // every row that can rather than above them. | |
| 706 | - list.push( | |
| 773 | + // What is doing the work, on this machine and in this build: the GPU | |
| 774 | + // half is asked of the driver through the plugin (a different answer on | |
| 775 | + // every machine, and "none" where there is no plugin at all), the build | |
| 776 | + // half is the crates that were compiled in. Last in the list, because it | |
| 777 | + // is what a user checks rather than what they pick -- and a listing | |
| 778 | + // rather than rows, since none of it can be clicked. | |
| 779 | + if self.export_grouped { | |
| 780 | + list.push(header("THIS MACHINE")); | |
| 781 | + } | |
| 782 | + let note = |text: String| { | |
| 707 | 783 | div() |
| 708 | 784 | .flex_none() |
| 709 | 785 | .px(px(6.)) |
| 710 | 786 | .py(px(2.)) |
| 711 | 787 | .text_size(px(11.)) |
| 712 | 788 | .text_color(rgb(ink_secondary)) |
| 713 | - .when_some(font_mono.clone(), |d, f| d.font(f)) | |
| 714 | - .child(format!("cannot write: {}", refusals.join(" · "))) | |
| 715 | - .into_any_element(), | |
| 716 | - ); | |
| 717 | - } | |
| 718 | - // What is doing the work, on this machine and in this build: the GPU | |
| 719 | - // half is asked of the driver through the plugin (a different answer on | |
| 720 | - // every machine, and "none" where there is no plugin at all), the build | |
| 721 | - // half is the crates that were compiled in. Last in the list, because it | |
| 722 | - // is what a user checks rather than what they pick -- and a listing | |
| 723 | - // rather than rows, since none of it can be clicked. | |
| 724 | - if self.export_grouped { | |
| 725 | - list.push(header("THIS MACHINE")); | |
| 726 | - } | |
| 727 | - let note = |text: String| { | |
| 728 | - div() | |
| 729 | - .flex_none() | |
| 730 | - .px(px(6.)) | |
| 731 | - .py(px(2.)) | |
| 732 | - .text_size(px(11.)) | |
| 733 | - .text_color(rgb(ink_secondary)) | |
| 734 | - .when_some(font_mono.clone(), |d, f| d.font(f)) | |
| 735 | - .child(text) | |
| 736 | - .into_any_element() | |
| 737 | - }; | |
| 738 | - list.push(note(format!( | |
| 739 | - "GPU: {}", | |
| 740 | - self.hw_caps.clone().unwrap_or_else(|| "asking…".into()) | |
| 741 | - ))); | |
| 742 | - list.push(note(format!("Built in: {}", engine::caps::software()))); | |
| 789 | + .when_some(mono_style.clone(), |d, style| { | |
| 790 | + d.font(style.font).text_size(style.size) | |
| 791 | + }) | |
| 792 | + .child(text) | |
| 793 | + .into_any_element() | |
| 794 | + }; | |
| 795 | + list.push(note(format!( | |
| 796 | + "GPU: {}", | |
| 797 | + self.hw_caps.clone().unwrap_or_else(|| "asking…".into()) | |
| 798 | + ))); | |
| 799 | + list.push(note(format!("Built in: {}", engine::caps::software()))); | |
| 743 | 800 | } // self.export_advanced_open |
| 744 | 801 | // What the rows add up to, which is the one thing that has to be right: |
| 745 | 802 | // codec, box, size, rate, sound, where it goes and about how big. Two |
| @@ -762,8 +819,7 @@ impl Player { | ||
| 762 | 819 | }, |
| 763 | 820 | |(_, audio)| audio, |
| 764 | 821 | ); |
| 765 | - let settings = | |
| 766 | - export_settings( | |
| 822 | + let settings = export_settings( | |
| 767 | 823 | self.quality, |
| 768 | 824 | self.custom_mbps, |
| 769 | 825 | self.format, |
| @@ -875,9 +931,11 @@ impl Player { | ||
| 875 | 931 | div() |
| 876 | 932 | .flex_none() |
| 877 | 933 | .px(px(6.)) |
| 878 | - .text_size(px(10.5)) | |
| 879 | 934 | .text_color(rgb(INK3())) |
| 880 | - .type_style(type_scale::mono(10.5, gpui::FontWeight::MEDIUM)) | |
| 935 | + .type_style(type_scale::mono( | |
| 936 | + type_scale::CHORD_METADATA_MAX_PX, | |
| 937 | + gpui::FontWeight::MEDIUM, | |
| 938 | + )) | |
| 881 | 939 | .child(status_line), |
| 882 | 940 | ) |
| 883 | 941 | .child( |
| @@ -894,8 +952,10 @@ impl Player { | ||
| 894 | 952 | div() |
| 895 | 953 | .flex_none() |
| 896 | 954 | .px(px(6.)) |
| 897 | - .text_size(px(11.)) | |
| 898 | - .type_style(type_scale::mono(10.5, gpui::FontWeight::MEDIUM)) | |
| 955 | + .type_style(type_scale::mono( | |
| 956 | + type_scale::CHORD_METADATA_MAX_PX, | |
| 957 | + gpui::FontWeight::MEDIUM, | |
| 958 | + )) | |
| 899 | 959 | .text_color(rgb(INK2())) |
| 900 | 960 | .child(head), |
| 901 | 961 | ) |
| @@ -903,7 +963,10 @@ impl Player { | ||
| 903 | 963 | div() |
| 904 | 964 | .flex_none() |
| 905 | 965 | .px(px(6.)) |
| 906 | - .type_style(type_scale::mono(10.5, gpui::FontWeight::MEDIUM)) | |
| 966 | + .type_style(type_scale::mono( | |
| 967 | + type_scale::CHORD_METADATA_MAX_PX, | |
| 968 | + gpui::FontWeight::MEDIUM, | |
| 969 | + )) | |
| 907 | 970 | .text_color(rgb(INK3())) |
| 908 | 971 | .child(format!( |
| 909 | 972 | "RANGE {}\u{2013}{} ({})", |
| @@ -916,7 +979,10 @@ impl Player { | ||
| 916 | 979 | div() |
| 917 | 980 | .flex_none() |
| 918 | 981 | .px(px(6.)) |
| 919 | - .type_style(type_scale::mono(10.5, gpui::FontWeight::MEDIUM)) | |
| 982 | + .type_style(type_scale::mono( | |
| 983 | + type_scale::CHORD_METADATA_MAX_PX, | |
| 984 | + gpui::FontWeight::MEDIUM, | |
| 985 | + )) | |
| 920 | 986 | .text_color(rgb(INK3())) |
| 921 | 987 | .child(tail), |
| 922 | 988 | ) |
| @@ -946,7 +1012,10 @@ impl Player { | ||
| 946 | 1012 | .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { |
| 947 | 1013 | this.start_export(cx) |
| 948 | 1014 | })) |
| 949 | - .type_style(type_scale::label(11., gpui::FontWeight::MEDIUM)) | |
| 1015 | + .type_style(type_scale::label( | |
| 1016 | + type_scale::LABEL_ROW_PX, | |
| 1017 | + gpui::FontWeight::MEDIUM, | |
| 1018 | + )) | |
| 950 | 1019 | .text_color(rgb(match blocked.is_some() { |
| 951 | 1020 | true => INK4(), |
| 952 | 1021 | false => INK1(), |
| @@ -956,7 +1025,7 @@ impl Player { | ||
| 956 | 1025 | d.child( |
| 957 | 1026 | div() |
| 958 | 1027 | .type_style(type_scale::mono( |
| 959 | - 9.5, | |
| 1028 | + type_scale::CHORD_METADATA_MIN_PX, | |
| 960 | 1029 | gpui::FontWeight::MEDIUM, |
| 961 | 1030 | )) |
| 962 | 1031 | .text_color(rgb(INK3())) |
| @@ -1143,8 +1212,12 @@ impl Player { | ||
| 1143 | 1212 | .rounded(px(6.)) |
| 1144 | 1213 | .bg(rgb(if dark { DARK_PANEL() } else { BG_RAISED() })) |
| 1145 | 1214 | .when(dark, |d| d.border_1().border_color(rgba(DARK_SEAM()))) |
| 1146 | - .when(dark, |d| d.child(dark_card_head("Exporting", None, None, None, cx))) | |
| 1147 | - .when(!dark, |d| d.child(div().flex_none().px(px(6.)).child("Exporting"))) | |
| 1215 | + .when(dark, |d| { | |
| 1216 | + d.child(dark_card_head("Exporting", None, None, None, cx)) | |
| 1217 | + }) | |
| 1218 | + .when(!dark, |d| { | |
| 1219 | + d.child(div().flex_none().px(px(6.)).child("Exporting")) | |
| 1220 | + }) | |
| 1148 | 1221 | // The bar itself: the same number as the percentage |
| 1149 | 1222 | // below it, and it only ever moves forward -- the |
| 1150 | 1223 | // worker's progress is a monotone `fetch_max`. |
| @@ -1191,8 +1264,9 @@ impl Player { | ||
| 1191 | 1264 | )) |
| 1192 | 1265 | .child(note( |
| 1193 | 1266 | match armed { |
| 1194 | - true => "cancelling deletes what has been written so far" | |
| 1195 | - .to_string(), | |
| 1267 | + true => { | |
| 1268 | + "cancelling deletes what has been written so far".to_string() | |
| 1269 | + } | |
| 1196 | 1270 | false => format!( |
| 1197 | 1271 | "{} cancels · esc alone does nothing while this runs · the \ |
| 1198 | 1272 | timeline is read-only until it finishes", |
| @@ -1262,8 +1336,10 @@ impl Player { | ||
| 1262 | 1336 | match armed { |
| 1263 | 1337 | true => "stops the worker and deletes the part file" |
| 1264 | 1338 | .to_string(), |
| 1265 | - false => "asks first -- one press only offers the choice" | |
| 1266 | - .to_string(), | |
| 1339 | + false => { | |
| 1340 | + "asks first -- one press only offers the choice" | |
| 1341 | + .to_string() | |
| 1342 | + } | |
| 1267 | 1343 | }, |
| 1268 | 1344 | true, |
| 1269 | 1345 | cx.listener(move |this, _: &ClickEvent, _, cx| { |
| @@ -1393,10 +1469,16 @@ impl Player { | ||
| 1393 | 1469 | // tracked from. |
| 1394 | 1470 | .id("eq-graph") |
| 1395 | 1471 | .relative() |
| 1396 | - .when(graph_maximized, |d| d.flex_1().min_h(px(EQ_GRAPH_H)).max_h(px(EQ_GRAPH_MAX_H))) | |
| 1472 | + .when(graph_maximized, |d| { | |
| 1473 | + d.flex_1().min_h(px(EQ_GRAPH_H)).max_h(px(EQ_GRAPH_MAX_H)) | |
| 1474 | + }) | |
| 1397 | 1475 | .when(!graph_maximized, |d| d.flex_none().h(px(eq_graph_h(false)))) |
| 1398 | 1476 | .rounded(px(3.)) |
| 1399 | - .bg(rgb(if dark { DARK_HAIRLINE() } else { BG_HOVER_DIM() })) | |
| 1477 | + .bg(rgb(if dark { | |
| 1478 | + DARK_HAIRLINE() | |
| 1479 | + } else { | |
| 1480 | + BG_HOVER_DIM() | |
| 1481 | + })) | |
| 1400 | 1482 | .cursor_pointer() |
| 1401 | 1483 | // The press picks the band under it *and* is already the first |
| 1402 | 1484 | // sample of the drag, so a plain click sets a value. A second click |
| @@ -1488,25 +1570,37 @@ impl Player { | ||
| 1488 | 1570 | // a box narrower than the text. `.whitespace_nowrap()` is |
| 1489 | 1571 | // the platform's own backstop, so a mis-measured box clips |
| 1490 | 1572 | // or overhangs instead of silently wrapping again. |
| 1491 | - let end_px = if dark { type_scale::CHORD_METADATA_MIN_PX } else { 9. }; | |
| 1573 | + let end_px = if dark { | |
| 1574 | + type_scale::CHORD_METADATA_MIN_PX | |
| 1575 | + } else { | |
| 1576 | + 9. | |
| 1577 | + }; | |
| 1492 | 1578 | let div = div().absolute().bottom(px(1.)).whitespace_nowrap(); |
| 1493 | 1579 | let div = if i == 0 { |
| 1494 | - div.w(px(eq_tick_end_w(label, end_px))).left(px(0.)).text_align(TextAlign::Left) | |
| 1580 | + div.w(px(eq_tick_end_w(label, end_px))) | |
| 1581 | + .left(px(0.)) | |
| 1582 | + .text_align(TextAlign::Left) | |
| 1495 | 1583 | } else if i == EQ_TICKS.len() - 1 { |
| 1496 | - div.w(px(eq_tick_end_w(label, end_px))).right(px(0.)).text_align(TextAlign::Right) | |
| 1584 | + div.w(px(eq_tick_end_w(label, end_px))) | |
| 1585 | + .right(px(0.)) | |
| 1586 | + .text_align(TextAlign::Right) | |
| 1497 | 1587 | } else { |
| 1498 | - div.w(px(24.)).left(relative(eq_x(*freq))).ml(px(-12.)).text_align(TextAlign::Center) | |
| 1588 | + div.w(px(24.)) | |
| 1589 | + .left(relative(eq_x(*freq))) | |
| 1590 | + .ml(px(-12.)) | |
| 1591 | + .text_align(TextAlign::Center) | |
| 1499 | 1592 | }; |
| 1500 | - div | |
| 1501 | - .when(dark, |d| { | |
| 1502 | - d.type_style(type_scale::mono( | |
| 1503 | - type_scale::CHORD_METADATA_MIN_PX, | |
| 1504 | - gpui::FontWeight::MEDIUM, | |
| 1505 | - )) | |
| 1506 | - .text_color(rgb(INK3())) | |
| 1507 | - }) | |
| 1508 | - .when(!dark, |d| d.text_size(px(9.)).text_color(rgb(FG_SECONDARY()))) | |
| 1509 | - .child(*label) | |
| 1593 | + div.when(dark, |d| { | |
| 1594 | + d.type_style(type_scale::mono( | |
| 1595 | + type_scale::CHORD_METADATA_MIN_PX, | |
| 1596 | + gpui::FontWeight::MEDIUM, | |
| 1597 | + )) | |
| 1598 | + .text_color(rgb(INK3())) | |
| 1599 | + }) | |
| 1600 | + .when(!dark, |d| { | |
| 1601 | + d.text_size(px(9.)).text_color(rgb(FG_SECONDARY())) | |
| 1602 | + }) | |
| 1603 | + .child(*label) | |
| 1510 | 1604 | })) |
| 1511 | 1605 | .child( |
| 1512 | 1606 | div() |
| @@ -1520,7 +1614,9 @@ impl Player { | ||
| 1520 | 1614 | )) |
| 1521 | 1615 | .text_color(rgb(INK3())) |
| 1522 | 1616 | }) |
| 1523 | - .when(!dark, |d| d.text_size(px(9.)).text_color(rgb(FG_SECONDARY()))) | |
| 1617 | + .when(!dark, |d| { | |
| 1618 | + d.text_size(px(9.)).text_color(rgb(FG_SECONDARY())) | |
| 1619 | + }) | |
| 1524 | 1620 | .child(format!("+{EQ_GAIN_LIMIT:.0} dB")), |
| 1525 | 1621 | ); |
| 1526 | 1622 | // The bottom of the axis is not named: -12 dB would land in the same |
| @@ -1835,7 +1931,11 @@ impl Player { | ||
| 1835 | 1931 | /// arrows do the same three things, but a value only a key can change is a |
| 1836 | 1932 | /// value a hand on the pointer cannot reach at all, which is the same reason |
| 1837 | 1933 | /// [`Player::mbps_steppers`] exists. |
| 1838 | - pub(crate) fn eq_numbers(&self, picked: Option<&Band>, cx: &mut Context<Self>) -> impl IntoElement { | |
| 1934 | + pub(crate) fn eq_numbers( | |
| 1935 | + &self, | |
| 1936 | + picked: Option<&Band>, | |
| 1937 | + cx: &mut Context<Self>, | |
| 1938 | + ) -> impl IntoElement { | |
| 1839 | 1939 | let dark = self.darkroom; |
| 1840 | 1940 | let row = div() |
| 1841 | 1941 | .flex_none() |
| @@ -1858,9 +1958,8 @@ impl Player { | ||
| 1858 | 1958 | label: &'static str, |
| 1859 | 1959 | change: fn(&mut Band), |
| 1860 | 1960 | cx: &mut Context<Self>| { |
| 1861 | - let on_click = cx.listener(move |this, _: &ClickEvent, _, cx| { | |
| 1862 | - this.nudge_band(change, cx) | |
| 1863 | - }); | |
| 1961 | + let on_click = | |
| 1962 | + cx.listener(move |this, _: &ClickEvent, _, cx| this.nudge_band(change, cx)); | |
| 1864 | 1963 | match dark { |
| 1865 | 1964 | true => dark_step_glyph(id, label == "+", on_click).into_any_element(), |
| 1866 | 1965 | false => div() |
| @@ -1901,16 +2000,17 @@ impl Player { | ||
| 1901 | 2000 | self.eq_params.bands.len() |
| 1902 | 2001 | )) |
| 1903 | 2002 | .into_any_element(), |
| 1904 | - false => format!("Band {} of {}", self.eq_band + 1, self.eq_params.bands.len()) | |
| 1905 | - .into_any_element(), | |
| 2003 | + false => format!( | |
| 2004 | + "Band {} of {}", | |
| 2005 | + self.eq_band + 1, | |
| 2006 | + self.eq_params.bands.len() | |
| 2007 | + ) | |
| 2008 | + .into_any_element(), | |
| 1906 | 2009 | }) |
| 1907 | 2010 | .child(number( |
| 1908 | 2011 | band_label(&band), |
| 1909 | 2012 | ("eq-freq-down", "eq-freq-up"), |
| 1910 | - ( | |
| 1911 | - |b| b.freq_hz /= EQ_FREQ_STEP, | |
| 1912 | - |b| b.freq_hz *= EQ_FREQ_STEP, | |
| 1913 | - ), | |
| 2013 | + (|b| b.freq_hz /= EQ_FREQ_STEP, |b| b.freq_hz *= EQ_FREQ_STEP), | |
| 1914 | 2014 | cx, |
| 1915 | 2015 | )) |
| 1916 | 2016 | .child(number( |
| @@ -1939,11 +2039,9 @@ impl Player { | ||
| 1939 | 2039 | .bg(rgb(BG_PANEL())) |
| 1940 | 2040 | .cursor_pointer() |
| 1941 | 2041 | .hover(|s| s.bg(rgb(BG_HOVER()))) |
| 1942 | - .on_click( | |
| 1943 | - cx.listener(|this, _: &ClickEvent, _, cx| { | |
| 1944 | - this.nudge_band(|b| b.gain_db = 0., cx) | |
| 1945 | - }), | |
| 1946 | - ) | |
| 2042 | + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { | |
| 2043 | + this.nudge_band(|b| b.gain_db = 0., cx) | |
| 2044 | + })) | |
| 1947 | 2045 | .child("Flatten this"), |
| 1948 | 2046 | ) |
| 1949 | 2047 | } |
| @@ -1959,7 +2057,11 @@ impl Player { | ||
| 1959 | 2057 | /// the decoder is grading with, never a copy that could drift from it. The |
| 1960 | 2058 | /// graph above them is counted off the frame that came *back* through that |
| 1961 | 2059 | /// grade ([`histogram`]), so pulling exposure tilts it while the hand moves. |
| 1962 | - pub(crate) fn color_card(&self, viewport: Size<Pixels>, cx: &mut Context<Self>) -> Option<impl IntoElement> { | |
| 2060 | + pub(crate) fn color_card( | |
| 2061 | + &self, | |
| 2062 | + viewport: Size<Pixels>, | |
| 2063 | + cx: &mut Context<Self>, | |
| 2064 | + ) -> Option<impl IntoElement> { | |
| 1963 | 2065 | let (lane, idx) = self.color_open?; |
| 1964 | 2066 | let params = self.color_params(); |
| 1965 | 2067 | let dark = self.darkroom; |
| @@ -2040,7 +2142,9 @@ impl Player { | ||
| 2040 | 2142 | .child( |
| 2041 | 2143 | div() |
| 2042 | 2144 | .w(px(44.)) |
| 2043 | - .when(dark, |d| d.child(dark_row_value(format!("{:.0}%", value * 100.)))) | |
| 2145 | + .when(dark, |d| { | |
| 2146 | + d.child(dark_row_value(format!("{:.0}%", value * 100.))) | |
| 2147 | + }) | |
| 2044 | 2148 | .when(!dark, |d| { |
| 2045 | 2149 | d.text_size(px(11.)) |
| 2046 | 2150 | .text_color(rgb(FG_SECONDARY())) |
| @@ -2058,7 +2162,12 @@ impl Player { | ||
| 2058 | 2162 | .justify_center() |
| 2059 | 2163 | .items_center() |
| 2060 | 2164 | .bg(rgba(SCRIM())) |
| 2061 | - .when(self.card_maximized, |d| d.top(px(crate::ui::stance::maximized_card_top(f32::from(viewport.height), self.split_px(Split::Bench, viewport))))) | |
| 2165 | + .when(self.card_maximized, |d| { | |
| 2166 | + d.top(px(crate::ui::stance::maximized_card_top( | |
| 2167 | + f32::from(viewport.height), | |
| 2168 | + self.split_px(Split::Bench, viewport), | |
| 2169 | + ))) | |
| 2170 | + }) | |
| 2062 | 2171 | // Click away closes it, as on every card here. |
| 2063 | 2172 | .on_mouse_down( |
| 2064 | 2173 | MouseButton::Left, |
| @@ -2071,7 +2180,11 @@ impl Player { | ||
| 2071 | 2180 | .child( |
| 2072 | 2181 | div() |
| 2073 | 2182 | .w_full() |
| 2074 | - .max_w(px(card_max_w(COLOR_W, self.card_maximized, f32::from(viewport.width)))) | |
| 2183 | + .max_w(px(card_max_w( | |
| 2184 | + COLOR_W, | |
| 2185 | + self.card_maximized, | |
| 2186 | + f32::from(viewport.width), | |
| 2187 | + ))) | |
| 2075 | 2188 | .on_mouse_down(MouseButton::Left, swallow) |
| 2076 | 2189 | .flex() |
| 2077 | 2190 | .flex_col() |
| @@ -2081,7 +2194,13 @@ impl Player { | ||
| 2081 | 2194 | .bg(rgb(if dark { DARK_PANEL() } else { BG_RAISED() })) |
| 2082 | 2195 | .when(dark, |d| d.border_1().border_color(rgba(DARK_SEAM()))) |
| 2083 | 2196 | .when(dark, |d| { |
| 2084 | - d.child(dark_card_head("Colour", Some(head_meta.clone()), Some(help_text.into()), Some(self.card_maximized), cx)) | |
| 2197 | + d.child(dark_card_head( | |
| 2198 | + "Colour", | |
| 2199 | + Some(head_meta.clone()), | |
| 2200 | + Some(help_text.into()), | |
| 2201 | + Some(self.card_maximized), | |
| 2202 | + cx, | |
| 2203 | + )) | |
| 2085 | 2204 | }) |
| 2086 | 2205 | .when(!dark, |d| { |
| 2087 | 2206 | d.child(div().flex_none().px(px(6.)).child(format!( |
| @@ -2109,7 +2228,11 @@ impl Player { | ||
| 2109 | 2228 | .flex_none() |
| 2110 | 2229 | .h(px(HIST_H)) |
| 2111 | 2230 | .rounded(px(3.)) |
| 2112 | - .bg(rgb(if dark { DARK_HAIRLINE() } else { BG_HOVER_DIM() })) | |
| 2231 | + .bg(rgb(if dark { | |
| 2232 | + DARK_HAIRLINE() | |
| 2233 | + } else { | |
| 2234 | + BG_HOVER_DIM() | |
| 2235 | + })) | |
| 2113 | 2236 | .relative() |
| 2114 | 2237 | .child(hist_curves(self.histogram)), |
| 2115 | 2238 | ) |
| @@ -2151,7 +2274,11 @@ impl Player { | ||
| 2151 | 2274 | /// The transform card: [`color_card`](Self::color_card)'s own shape, one |
| 2152 | 2275 | /// row per [`TRANSFORM_BANDS`] entry instead of four, and no histogram -- |
| 2153 | 2276 | /// there is nothing here a graded frame would tilt. |
| 2154 | - pub(crate) fn transform_card(&self, viewport: Size<Pixels>, cx: &mut Context<Self>) -> Option<impl IntoElement> { | |
| 2277 | + pub(crate) fn transform_card( | |
| 2278 | + &self, | |
| 2279 | + viewport: Size<Pixels>, | |
| 2280 | + cx: &mut Context<Self>, | |
| 2281 | + ) -> Option<impl IntoElement> { | |
| 2155 | 2282 | let (lane, idx) = self.transform_open?; |
| 2156 | 2283 | let params = self.transform_params(); |
| 2157 | 2284 | let dark = self.darkroom; |
| @@ -2222,13 +2349,16 @@ impl Player { | ||
| 2222 | 2349 | ), |
| 2223 | 2350 | ) |
| 2224 | 2351 | .child( |
| 2225 | - div().w(px(44.)).when(dark, |d| { | |
| 2226 | - d.child(dark_row_value(transform_row_value(i, value))) | |
| 2227 | - }).when(!dark, |d| { | |
| 2228 | - d.text_size(px(11.)) | |
| 2229 | - .text_color(rgb(FG_SECONDARY())) | |
| 2230 | - .child(transform_row_value(i, value)) | |
| 2231 | - }), | |
| 2352 | + div() | |
| 2353 | + .w(px(44.)) | |
| 2354 | + .when(dark, |d| { | |
| 2355 | + d.child(dark_row_value(transform_row_value(i, value))) | |
| 2356 | + }) | |
| 2357 | + .when(!dark, |d| { | |
| 2358 | + d.text_size(px(11.)) | |
| 2359 | + .text_color(rgb(FG_SECONDARY())) | |
| 2360 | + .child(transform_row_value(i, value)) | |
| 2361 | + }), | |
| 2232 | 2362 | ) |
| 2233 | 2363 | }) |
| 2234 | 2364 | .collect(); |
| @@ -2241,7 +2371,12 @@ impl Player { | ||
| 2241 | 2371 | .justify_center() |
| 2242 | 2372 | .items_center() |
| 2243 | 2373 | .bg(rgba(SCRIM())) |
| 2244 | - .when(self.card_maximized, |d| d.top(px(crate::ui::stance::maximized_card_top(f32::from(viewport.height), self.split_px(Split::Bench, viewport))))) | |
| 2374 | + .when(self.card_maximized, |d| { | |
| 2375 | + d.top(px(crate::ui::stance::maximized_card_top( | |
| 2376 | + f32::from(viewport.height), | |
| 2377 | + self.split_px(Split::Bench, viewport), | |
| 2378 | + ))) | |
| 2379 | + }) | |
| 2245 | 2380 | .on_mouse_down( |
| 2246 | 2381 | MouseButton::Left, |
| 2247 | 2382 | cx.listener(|this, _: &MouseDownEvent, _, cx| { |
| @@ -2253,7 +2388,11 @@ impl Player { | ||
| 2253 | 2388 | .child( |
| 2254 | 2389 | div() |
| 2255 | 2390 | .w_full() |
| 2256 | - .max_w(px(card_max_w(TRANSFORM_W, self.card_maximized, f32::from(viewport.width)))) | |
| 2391 | + .max_w(px(card_max_w( | |
| 2392 | + TRANSFORM_W, | |
| 2393 | + self.card_maximized, | |
| 2394 | + f32::from(viewport.width), | |
| 2395 | + ))) | |
| 2257 | 2396 | .on_mouse_down(MouseButton::Left, swallow) |
| 2258 | 2397 | .flex() |
| 2259 | 2398 | .flex_col() |
| @@ -2263,7 +2402,13 @@ impl Player { | ||
| 2263 | 2402 | .bg(rgb(if dark { DARK_PANEL() } else { BG_RAISED() })) |
| 2264 | 2403 | .when(dark, |d| d.border_1().border_color(rgba(DARK_SEAM()))) |
| 2265 | 2404 | .when(dark, |d| { |
| 2266 | - d.child(dark_card_head("Transform", Some(head_meta.clone()), Some(help_text.into()), Some(self.card_maximized), cx)) | |
| 2405 | + d.child(dark_card_head( | |
| 2406 | + "Transform", | |
| 2407 | + Some(head_meta.clone()), | |
| 2408 | + Some(help_text.into()), | |
| 2409 | + Some(self.card_maximized), | |
| 2410 | + cx, | |
| 2411 | + )) | |
| 2267 | 2412 | }) |
| 2268 | 2413 | .when(!dark, |d| { |
| 2269 | 2414 | d.child(div().flex_none().px(px(6.)).child(format!( |
| @@ -2326,7 +2471,11 @@ impl Player { | ||
| 2326 | 2471 | /// |
| 2327 | 2472 | /// Honest about what it does: the sound is *resampled*, so the pitch goes up |
| 2328 | 2473 | /// with the rate, which is what the tape in the title means. |
| 2329 | - pub(crate) fn speed_card(&self, viewport: Size<Pixels>, cx: &mut Context<Self>) -> Option<impl IntoElement> { | |
| 2474 | + pub(crate) fn speed_card( | |
| 2475 | + &self, | |
| 2476 | + viewport: Size<Pixels>, | |
| 2477 | + cx: &mut Context<Self>, | |
| 2478 | + ) -> Option<impl IntoElement> { | |
| 2330 | 2479 | let (lane, idx) = self.speed_open?; |
| 2331 | 2480 | let speed = self.card_speed(); |
| 2332 | 2481 | let session = self.session.as_ref()?; |
| @@ -2365,8 +2514,7 @@ impl Player { | ||
| 2365 | 2514 | }) |
| 2366 | 2515 | .collect(); |
| 2367 | 2516 | let head_meta: SharedString = format!("{} clip {}", lane.label(), idx + 1).into(); |
| 2368 | - let help_text = | |
| 2369 | - "drag the bar or ←→ moves it, r is 1.00x — the pitch moves with the rate; a click away or esc closes"; | |
| 2517 | + let help_text = "drag the bar or ←→ moves it, r is 1.00x — the pitch moves with the rate; a click away or esc closes"; | |
| 2370 | 2518 | let tail_text: SharedString = format!( |
| 2371 | 2519 | "{speed} — {} source frames over {} on the timeline ({})", |
| 2372 | 2520 | clip.len(), |
| @@ -2380,7 +2528,12 @@ impl Player { | ||
| 2380 | 2528 | .justify_center() |
| 2381 | 2529 | .items_center() |
| 2382 | 2530 | .bg(rgba(SCRIM())) |
| 2383 | - .when(self.card_maximized, |d| d.top(px(crate::ui::stance::maximized_card_top(f32::from(viewport.height), self.split_px(Split::Bench, viewport))))) | |
| 2531 | + .when(self.card_maximized, |d| { | |
| 2532 | + d.top(px(crate::ui::stance::maximized_card_top( | |
| 2533 | + f32::from(viewport.height), | |
| 2534 | + self.split_px(Split::Bench, viewport), | |
| 2535 | + ))) | |
| 2536 | + }) | |
| 2384 | 2537 | // Click away closes it, as on every card here. |
| 2385 | 2538 | .on_mouse_down( |
| 2386 | 2539 | MouseButton::Left, |
| @@ -2393,7 +2546,11 @@ impl Player { | ||
| 2393 | 2546 | .child( |
| 2394 | 2547 | div() |
| 2395 | 2548 | .w_full() |
| 2396 | - .max_w(px(card_max_w(COLOR_W, self.card_maximized, f32::from(viewport.width)))) | |
| 2549 | + .max_w(px(card_max_w( | |
| 2550 | + COLOR_W, | |
| 2551 | + self.card_maximized, | |
| 2552 | + f32::from(viewport.width), | |
| 2553 | + ))) | |
| 2397 | 2554 | .on_mouse_down(MouseButton::Left, swallow) |
| 2398 | 2555 | .flex() |
| 2399 | 2556 | .flex_col() |
| @@ -2403,7 +2560,13 @@ impl Player { | ||
| 2403 | 2560 | .bg(rgb(if dark { DARK_PANEL() } else { BG_RAISED() })) |
| 2404 | 2561 | .when(dark, |d| d.border_1().border_color(rgba(DARK_SEAM()))) |
| 2405 | 2562 | .when(dark, |d| { |
| 2406 | - d.child(dark_card_head("Speed (tape)", Some(head_meta.clone()), Some(help_text.into()), Some(self.card_maximized), cx)) | |
| 2563 | + d.child(dark_card_head( | |
| 2564 | + "Speed (tape)", | |
| 2565 | + Some(head_meta.clone()), | |
| 2566 | + Some(help_text.into()), | |
| 2567 | + Some(self.card_maximized), | |
| 2568 | + cx, | |
| 2569 | + )) | |
| 2407 | 2570 | }) |
| 2408 | 2571 | .when(!dark, |d| { |
| 2409 | 2572 | d.child(div().flex_none().px(px(6.)).child(format!( |
| @@ -2492,7 +2655,11 @@ impl Player { | ||
| 2492 | 2655 | /// move it too. The rows scroll rather than the card growing past the |
| 2493 | 2656 | /// window -- a timeline may hold more tracks than a 360 px window has room |
| 2494 | 2657 | /// for faders. |
| 2495 | - pub(crate) fn mix_card(&self, viewport: Size<Pixels>, cx: &mut Context<Self>) -> Option<impl IntoElement> { | |
| 2658 | + pub(crate) fn mix_card( | |
| 2659 | + &self, | |
| 2660 | + viewport: Size<Pixels>, | |
| 2661 | + cx: &mut Context<Self>, | |
| 2662 | + ) -> Option<impl IntoElement> { | |
| 2496 | 2663 | if !self.mix_open { |
| 2497 | 2664 | return None; |
| 2498 | 2665 | } |
| @@ -2583,13 +2750,15 @@ impl Player { | ||
| 2583 | 2750 | .bg(rgb(BG_PANEL())) |
| 2584 | 2751 | .cursor_pointer() |
| 2585 | 2752 | .hover(|s| s.bg(rgb(BG_HOVER()))) |
| 2586 | - .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | |
| 2587 | - // Picked as well as moved, the silence | |
| 2588 | - // card's rule: the row a press lands on | |
| 2589 | - // is the row the arrows carry on from. | |
| 2590 | - this.mix_field = n; | |
| 2591 | - this.nudge_mix(steps, cx); | |
| 2592 | - })) | |
| 2753 | + .on_click(cx.listener( | |
| 2754 | + move |this, _: &ClickEvent, _, cx| { | |
| 2755 | + // Picked as well as moved, the silence | |
| 2756 | + // card's rule: the row a press lands on | |
| 2757 | + // is the row the arrows carry on from. | |
| 2758 | + this.mix_field = n; | |
| 2759 | + this.nudge_mix(steps, cx); | |
| 2760 | + }, | |
| 2761 | + )) | |
| 2593 | 2762 | .child(match steps > 0 { |
| 2594 | 2763 | true => "+", |
| 2595 | 2764 | false => "−", |
| @@ -2614,7 +2783,12 @@ impl Player { | ||
| 2614 | 2783 | .justify_center() |
| 2615 | 2784 | .items_center() |
| 2616 | 2785 | .bg(rgba(SCRIM())) |
| 2617 | - .when(self.card_maximized, |d| d.top(px(crate::ui::stance::maximized_card_top(f32::from(viewport.height), self.split_px(Split::Bench, viewport))))) | |
| 2786 | + .when(self.card_maximized, |d| { | |
| 2787 | + d.top(px(crate::ui::stance::maximized_card_top( | |
| 2788 | + f32::from(viewport.height), | |
| 2789 | + self.split_px(Split::Bench, viewport), | |
| 2790 | + ))) | |
| 2791 | + }) | |
| 2618 | 2792 | // Click away closes it, as on every card here. |
| 2619 | 2793 | .on_mouse_down( |
| 2620 | 2794 | MouseButton::Left, |
| @@ -2627,7 +2801,11 @@ impl Player { | ||
| 2627 | 2801 | .child( |
| 2628 | 2802 | div() |
| 2629 | 2803 | .w_full() |
| 2630 | - .max_w(px(card_max_w(COLOR_W, self.card_maximized, f32::from(viewport.width)))) | |
| 2804 | + .max_w(px(card_max_w( | |
| 2805 | + COLOR_W, | |
| 2806 | + self.card_maximized, | |
| 2807 | + f32::from(viewport.width), | |
| 2808 | + ))) | |
| 2631 | 2809 | .on_mouse_down(MouseButton::Left, swallow) |
| 2632 | 2810 | .max_h(px(360. - 24.)) |
| 2633 | 2811 | .flex() |
| @@ -2637,7 +2815,15 @@ impl Player { | ||
| 2637 | 2815 | .rounded(px(6.)) |
| 2638 | 2816 | .bg(rgb(if dark { DARK_PANEL() } else { BG_RAISED() })) |
| 2639 | 2817 | .when(dark, |d| d.border_1().border_color(rgba(DARK_SEAM()))) |
| 2640 | - .when(dark, |d| d.child(dark_card_head("Mix", None, Some(help_text.into()), Some(self.card_maximized), cx))) | |
| 2818 | + .when(dark, |d| { | |
| 2819 | + d.child(dark_card_head( | |
| 2820 | + "Mix", | |
| 2821 | + None, | |
| 2822 | + Some(help_text.into()), | |
| 2823 | + Some(self.card_maximized), | |
| 2824 | + cx, | |
| 2825 | + )) | |
| 2826 | + }) | |
| 2641 | 2827 | .when(!dark, |d| { |
| 2642 | 2828 | d.child( |
| 2643 | 2829 | div() |
| @@ -2690,13 +2876,25 @@ impl Player { | ||
| 2690 | 2876 | /// card's shape for the same reason: app-global, kept in a file beside |
| 2691 | 2877 | /// the theme, and drawn straight off `self.sub_text` / `self.sub_family` |
| 2692 | 2878 | /// so a change is on the cue underneath before the card is closed. |
| 2693 | - pub(crate) fn subtitle_style_card(&self, viewport: Size<Pixels>, cx: &mut Context<Self>) -> Option<impl IntoElement> { | |
| 2879 | + pub(crate) fn subtitle_style_card( | |
| 2880 | + &self, | |
| 2881 | + viewport: Size<Pixels>, | |
| 2882 | + cx: &mut Context<Self>, | |
| 2883 | + ) -> Option<impl IntoElement> { | |
| 2694 | 2884 | if !self.subtitle_style_open { |
| 2695 | 2885 | return None; |
| 2696 | 2886 | } |
| 2697 | 2887 | let dark = self.darkroom; |
| 2698 | 2888 | let help_text = "− and + move the size, or ↑↓ picks a row and ←→ moves it (held or pressed); a family row picks it outright — a click away or esc closes"; |
| 2699 | - let head = dark.then(|| dark_card_head("Subtitle style", None, Some(help_text.into()), Some(self.card_maximized), cx)); | |
| 2889 | + let head = dark.then(|| { | |
| 2890 | + dark_card_head( | |
| 2891 | + "Subtitle style", | |
| 2892 | + None, | |
| 2893 | + Some(help_text.into()), | |
| 2894 | + Some(self.card_maximized), | |
| 2895 | + cx, | |
| 2896 | + ) | |
| 2897 | + }); | |
| 2700 | 2898 | let size_picked = self.subtitle_style_field == 0; |
| 2701 | 2899 | let size_row = div() |
| 2702 | 2900 | .id("subtitle-size-row") |
| @@ -2707,7 +2905,9 @@ impl Player { | ||
| 2707 | 2905 | .justify_between() |
| 2708 | 2906 | .px(px(6.)) |
| 2709 | 2907 | .rounded(px(3.)) |
| 2710 | - .when(dark && size_picked, |d| d.border_l_2().border_color(rgb(INK1()))) | |
| 2908 | + .when(dark && size_picked, |d| { | |
| 2909 | + d.border_l_2().border_color(rgb(INK1())) | |
| 2910 | + }) | |
| 2711 | 2911 | .when(!dark, |d| { |
| 2712 | 2912 | d.bg(rgb(match size_picked { |
| 2713 | 2913 | true => BG_SELECTED(), |
| @@ -2724,7 +2924,9 @@ impl Player { | ||
| 2724 | 2924 | .flex() |
| 2725 | 2925 | .items_center() |
| 2726 | 2926 | .gap(px(4.)) |
| 2727 | - .when(dark, |d| d.child(dark_row_value(format!("{:.0}px", self.sub_text)))) | |
| 2927 | + .when(dark, |d| { | |
| 2928 | + d.child(dark_row_value(format!("{:.0}px", self.sub_text))) | |
| 2929 | + }) | |
| 2728 | 2930 | .when(!dark, |d| d.child(format!("{:.0}px", self.sub_text))) |
| 2729 | 2931 | .children([-1, 1].map(|steps: i32| { |
| 2730 | 2932 | let id = ("subtitle-size-step", usize::from(steps > 0)); |
| @@ -2771,7 +2973,9 @@ impl Player { | ||
| 2771 | 2973 | .items_center() |
| 2772 | 2974 | .px(px(6.)) |
| 2773 | 2975 | .rounded(px(3.)) |
| 2774 | - .when(dark && default_picked, |d| d.border_l_2().border_color(rgb(INK1()))) | |
| 2976 | + .when(dark && default_picked, |d| { | |
| 2977 | + d.border_l_2().border_color(rgb(INK1())) | |
| 2978 | + }) | |
| 2775 | 2979 | .when(!dark, |d| { |
| 2776 | 2980 | d.bg(rgb(match default_picked { |
| 2777 | 2981 | true => BG_SELECTED(), |
| @@ -2783,7 +2987,9 @@ impl Player { | ||
| 2783 | 2987 | .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { |
| 2784 | 2988 | this.set_sub_family(None, cx); |
| 2785 | 2989 | })) |
| 2786 | - .when(dark, |d| d.child(dark_row_label("System default", default_picked))) | |
| 2990 | + .when(dark, |d| { | |
| 2991 | + d.child(dark_row_label("System default", default_picked)) | |
| 2992 | + }) | |
| 2787 | 2993 | .when(!dark, |d| d.child("System default")); |
| 2788 | 2994 | let family_rows = self.subtitle_fonts.iter().enumerate().map(|(n, name)| { |
| 2789 | 2995 | let picked = self.subtitle_style_field == n + 2 |
| @@ -2820,7 +3026,12 @@ impl Player { | ||
| 2820 | 3026 | .justify_center() |
| 2821 | 3027 | .items_center() |
| 2822 | 3028 | .bg(rgba(SCRIM())) |
| 2823 | - .when(self.card_maximized, |d| d.top(px(crate::ui::stance::maximized_card_top(f32::from(viewport.height), self.split_px(Split::Bench, viewport))))) | |
| 3029 | + .when(self.card_maximized, |d| { | |
| 3030 | + d.top(px(crate::ui::stance::maximized_card_top( | |
| 3031 | + f32::from(viewport.height), | |
| 3032 | + self.split_px(Split::Bench, viewport), | |
| 3033 | + ))) | |
| 3034 | + }) | |
| 2824 | 3035 | .on_mouse_down( |
| 2825 | 3036 | MouseButton::Left, |
| 2826 | 3037 | cx.listener(|this, _: &MouseDownEvent, _, cx| { |
| @@ -2832,7 +3043,11 @@ impl Player { | ||
| 2832 | 3043 | .child( |
| 2833 | 3044 | div() |
| 2834 | 3045 | .w_full() |
| 2835 | - .max_w(px(card_max_w(COLOR_W, self.card_maximized, f32::from(viewport.width)))) | |
| 3046 | + .max_w(px(card_max_w( | |
| 3047 | + COLOR_W, | |
| 3048 | + self.card_maximized, | |
| 3049 | + f32::from(viewport.width), | |
| 3050 | + ))) | |
| 2836 | 3051 | .on_mouse_down(MouseButton::Left, swallow) |
| 2837 | 3052 | .max_h(px(360. - 24.)) |
| 2838 | 3053 | .flex() |
| @@ -2883,12 +3098,24 @@ impl Player { | ||
| 2883 | 3098 | /// *about* the timeline -- the marks under it are the whole preview -- so |
| 2884 | 3099 | /// the bed stays readable and the card sits up in the picture area rather |
| 2885 | 3100 | /// than over the lanes. |
| 2886 | - pub(crate) fn silence_card(&self, viewport: Size<Pixels>, cx: &mut Context<Self>) -> Option<impl IntoElement> { | |
| 3101 | + pub(crate) fn silence_card( | |
| 3102 | + &self, | |
| 3103 | + viewport: Size<Pixels>, | |
| 3104 | + cx: &mut Context<Self>, | |
| 3105 | + ) -> Option<impl IntoElement> { | |
| 2887 | 3106 | let (lane, idx) = self.silence_open?; |
| 2888 | 3107 | let dark = self.darkroom; |
| 2889 | 3108 | let head_meta: SharedString = format!("{} clip {}", lane.label(), idx + 1).into(); |
| 2890 | 3109 | let help_text = "− and + move a setting, or ↑↓ picks one and ←→ moves it (hold to run it) — the marks on the lane are what would go; a click away or esc closes"; |
| 2891 | - let head = dark.then(|| dark_card_head("Silences", Some(head_meta.clone()), Some(help_text.into()), Some(self.card_maximized), cx)); | |
| 3110 | + let head = dark.then(|| { | |
| 3111 | + dark_card_head( | |
| 3112 | + "Silences", | |
| 3113 | + Some(head_meta.clone()), | |
| 3114 | + Some(help_text.into()), | |
| 3115 | + Some(self.card_maximized), | |
| 3116 | + cx, | |
| 3117 | + ) | |
| 3118 | + }); | |
| 2892 | 3119 | let cfg = self.silence; |
| 2893 | 3120 | // The unit is a label, never a conversion: the threshold is a level |
| 2894 | 3121 | // below full scale whichever of the two the row says (`silence_dbfs`). |
| @@ -2926,7 +3153,10 @@ impl Player { | ||
| 2926 | 3153 | let status = match &self.silence_scan { |
| 2927 | 3154 | Some(scan) => silence_line( |
| 2928 | 3155 | scan.seen as f32 / 10., |
| 2929 | - scan.progress.total.load(std::sync::atomic::Ordering::Relaxed) as f32 / 10., | |
| 3156 | + scan.progress | |
| 3157 | + .total | |
| 3158 | + .load(std::sync::atomic::Ordering::Relaxed) as f32 | |
| 3159 | + / 10., | |
| 2930 | 3160 | scan.started.elapsed().as_secs_f32(), |
| 2931 | 3161 | scan.since.elapsed().as_secs_f32(), |
| 2932 | 3162 | ), |
| @@ -3005,14 +3235,16 @@ impl Player { | ||
| 3005 | 3235 | .bg(rgb(BG_PANEL())) |
| 3006 | 3236 | .cursor_pointer() |
| 3007 | 3237 | .hover(|s| s.bg(rgb(BG_HOVER()))) |
| 3008 | - .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | |
| 3009 | - // Picked as well as moved: the row a | |
| 3010 | - // press lands on is the row the arrows | |
| 3011 | - // carry on from. | |
| 3012 | - this.silence_field = n; | |
| 3013 | - this.nudge_silence(steps); | |
| 3014 | - cx.notify(); | |
| 3015 | - })) | |
| 3238 | + .on_click(cx.listener( | |
| 3239 | + move |this, _: &ClickEvent, _, cx| { | |
| 3240 | + // Picked as well as moved: the row a | |
| 3241 | + // press lands on is the row the arrows | |
| 3242 | + // carry on from. | |
| 3243 | + this.silence_field = n; | |
| 3244 | + this.nudge_silence(steps); | |
| 3245 | + cx.notify(); | |
| 3246 | + }, | |
| 3247 | + )) | |
| 3016 | 3248 | .child(match steps > 0 { |
| 3017 | 3249 | true => "+", |
| 3018 | 3250 | false => "−", |
| @@ -3064,7 +3296,12 @@ impl Player { | ||
| 3064 | 3296 | // Light enough to read the lanes and the marks on them through: |
| 3065 | 3297 | // the preview is the point of this card. |
| 3066 | 3298 | .bg(rgba(SCRIM_LIGHT())) |
| 3067 | - .when(self.card_maximized, |d| d.top(px(crate::ui::stance::maximized_card_top(f32::from(viewport.height), self.split_px(Split::Bench, viewport))))) | |
| 3299 | + .when(self.card_maximized, |d| { | |
| 3300 | + d.top(px(crate::ui::stance::maximized_card_top( | |
| 3301 | + f32::from(viewport.height), | |
| 3302 | + self.split_px(Split::Bench, viewport), | |
| 3303 | + ))) | |
| 3304 | + }) | |
| 3068 | 3305 | // Click away closes it, as on every card here -- and the marks |
| 3069 | 3306 | // go with it, which is what makes this one a call and not a flag. |
| 3070 | 3307 | .on_mouse_down( |
| @@ -3078,7 +3315,11 @@ impl Player { | ||
| 3078 | 3315 | .child( |
| 3079 | 3316 | div() |
| 3080 | 3317 | .w_full() |
| 3081 | - .max_w(px(card_max_w(COLOR_W, self.card_maximized, f32::from(viewport.width)))) | |
| 3318 | + .max_w(px(card_max_w( | |
| 3319 | + COLOR_W, | |
| 3320 | + self.card_maximized, | |
| 3321 | + f32::from(viewport.width), | |
| 3322 | + ))) | |
| 3082 | 3323 | .on_mouse_down(MouseButton::Left, swallow) |
| 3083 | 3324 | .flex() |
| 3084 | 3325 | .flex_col() |
crates/app/src/ui/dock_stance.rsmodified+86 -25
| @@ -11,8 +11,8 @@ | ||
| 11 | 11 | //! still supply the row facts ([`library_rows`], [`source_tint`], |
| 12 | 12 | //! [`clip_middle`]...), only the anatomy around them is new. |
| 13 | 13 | |
| 14 | -use crate::*; | |
| 15 | 14 | use crate::ui::type_scale::{self, head, label, mono}; |
| 15 | +use crate::*; | |
| 16 | 16 | use gpui::FontWeight; |
| 17 | 17 | |
| 18 | 18 | /// Where the dock tab pick lives: one word beside the theme and the |
| @@ -79,7 +79,12 @@ pub(crate) enum DockSort { | ||
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | impl DockSort { |
| 82 | - const ALL: [DockSort; 4] = [DockSort::Recent, DockSort::Name, DockSort::Usage, DockSort::Unused]; | |
| 82 | + const ALL: [DockSort; 4] = [ | |
| 83 | + DockSort::Recent, | |
| 84 | + DockSort::Name, | |
| 85 | + DockSort::Usage, | |
| 86 | + DockSort::Unused, | |
| 87 | + ]; | |
| 83 | 88 | fn label(self) -> &'static str { |
| 84 | 89 | match self { |
| 85 | 90 | DockSort::Recent => "Recent", |
| @@ -156,7 +161,12 @@ fn ghost_verb( | ||
| 156 | 161 | /// DESIGN §11's frequency check puts a lift and a mark far ahead of a tab |
| 157 | 162 | /// switch -- wearing a chord this room does not answer to would be exactly |
| 158 | 163 | /// the lie DESIGN §4 forbids, so the letters go instead. |
| 159 | -fn dock_tab(id: &'static str, label_text: &'static str, active: bool, cx: &mut Context<Player>) -> impl IntoElement { | |
| 164 | +fn dock_tab( | |
| 165 | + id: &'static str, | |
| 166 | + label_text: &'static str, | |
| 167 | + active: bool, | |
| 168 | + cx: &mut Context<Player>, | |
| 169 | +) -> impl IntoElement { | |
| 160 | 170 | let style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM); |
| 161 | 171 | div() |
| 162 | 172 | .id(id) |
| @@ -183,7 +193,7 @@ fn dock_tab(id: &'static str, label_text: &'static str, active: bool, cx: &mut C | ||
| 183 | 193 | ) |
| 184 | 194 | } |
| 185 | 195 | |
| 186 | -/// A 9px uppercase Archivo section head, `ink3` (DESIGN §3). | |
| 196 | +/// A 12px uppercase Archivo section head, `ink3` (DESIGN §3). | |
| 187 | 197 | fn section_head(text: impl Into<SharedString>) -> impl IntoElement { |
| 188 | 198 | let style = head(); |
| 189 | 199 | div() |
| @@ -206,11 +216,20 @@ fn usage_line(player: &Player, source_idx: usize, placed: usize) -> String { | ||
| 206 | 216 | session |
| 207 | 217 | .lanes() |
| 208 | 218 | .into_iter() |
| 209 | - .filter(|lane| session.lane_clips(*lane).iter().any(|c| c.source == source_idx)) | |
| 219 | + .filter(|lane| { | |
| 220 | + session | |
| 221 | + .lane_clips(*lane) | |
| 222 | + .iter() | |
| 223 | + .any(|c| c.source == source_idx) | |
| 224 | + }) | |
| 210 | 225 | .map(Lane::label) |
| 211 | 226 | .collect() |
| 212 | 227 | }); |
| 213 | - format!("{} · {placed} use{}", lanes.join(" "), if placed == 1 { "" } else { "s" }) | |
| 228 | + format!( | |
| 229 | + "{} · {placed} use{}", | |
| 230 | + lanes.join(" "), | |
| 231 | + if placed == 1 { "" } else { "s" } | |
| 232 | + ) | |
| 214 | 233 | } |
| 215 | 234 | |
| 216 | 235 | /// One source row, two lines (MOCK-SPEC "Dock" §4): an ink dot, the name in |
| @@ -220,12 +239,22 @@ fn usage_line(player: &Player, source_idx: usize, placed: usize) -> String { | ||
| 220 | 239 | /// 2, wired in `render.rs`'s key handler since a row takes no keyboard focus |
| 221 | 240 | /// of its own), double-click (gesture 3) and right-click the dot (gesture 4) |
| 222 | 241 | /// all live here. |
| 223 | -fn source_row(player: &Player, i: usize, row: &Row, placed: usize, picked: bool, cx: &mut Context<Player>) -> impl IntoElement { | |
| 242 | +fn source_row( | |
| 243 | + player: &Player, | |
| 244 | + i: usize, | |
| 245 | + row: &Row, | |
| 246 | + placed: usize, | |
| 247 | + picked: bool, | |
| 248 | + cx: &mut Context<Player>, | |
| 249 | +) -> impl IntoElement { | |
| 224 | 250 | let usable = row.unusable.is_none(); |
| 225 | 251 | let name: SharedString = row.name.clone().into(); |
| 226 | 252 | let under: String = match &row.unusable { |
| 227 | 253 | Some(why) => why.clone(), |
| 228 | - None => join_detail(&row.detail, &timecode(f64::from(row.frames) / player.fps, player.fps)), | |
| 254 | + None => join_detail( | |
| 255 | + &row.detail, | |
| 256 | + &timecode(f64::from(row.frames) / player.fps, player.fps), | |
| 257 | + ), | |
| 229 | 258 | }; |
| 230 | 259 | let usage = usage_line(player, row.tint, placed); |
| 231 | 260 | let (path, stream) = (row.path.clone(), row.stream); |
| @@ -354,11 +383,23 @@ fn source_row(player: &Player, i: usize, row: &Row, placed: usize, picked: bool, | ||
| 354 | 383 | /// Media/Audio/Text panel `library.rs` draws. That panel's row facts |
| 355 | 384 | /// ([`library_rows`]) are still what every row here is built from. |
| 356 | 385 | fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { |
| 357 | - let sources = player.session.as_ref().map_or(&[][..], PlaybackSession::sources); | |
| 386 | + let sources = player | |
| 387 | + .session | |
| 388 | + .as_ref() | |
| 389 | + .map_or(&[][..], PlaybackSession::sources); | |
| 358 | 390 | let meta = player.session.as_ref().map(PlaybackSession::meta); |
| 359 | - let all_rows: Vec<Row> = library_rows(sources, &player.streams, &player.decoders, player.timeline_audio(), |path| { | |
| 360 | - player.session.as_ref().map_or(0, |session| session.file_frames(path)) | |
| 361 | - }); | |
| 391 | + let all_rows: Vec<Row> = library_rows( | |
| 392 | + sources, | |
| 393 | + &player.streams, | |
| 394 | + &player.decoders, | |
| 395 | + player.timeline_audio(), | |
| 396 | + |path| { | |
| 397 | + player | |
| 398 | + .session | |
| 399 | + .as_ref() | |
| 400 | + .map_or(0, |session| session.file_frames(path)) | |
| 401 | + }, | |
| 402 | + ); | |
| 362 | 403 | let _ = meta; |
| 363 | 404 | let unused_count = all_rows |
| 364 | 405 | .iter() |
| @@ -380,7 +421,9 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 380 | 421 | .collect(); |
| 381 | 422 | match player.dock_sort { |
| 382 | 423 | DockSort::Recent => {} |
| 383 | - DockSort::Name => rows.sort_by(|(a, _), (b, _)| a.name.to_lowercase().cmp(&b.name.to_lowercase())), | |
| 424 | + DockSort::Name => { | |
| 425 | + rows.sort_by(|(a, _), (b, _)| a.name.to_lowercase().cmp(&b.name.to_lowercase())) | |
| 426 | + } | |
| 384 | 427 | DockSort::Usage => rows.sort_by(|(_, a), (_, b)| b.cmp(a)), |
| 385 | 428 | DockSort::Unused => rows.sort_by_key(|(_, placed)| *placed > 0), |
| 386 | 429 | } |
| @@ -395,7 +438,9 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 395 | 438 | .gap(px(6.)) |
| 396 | 439 | .p(px(8.)) |
| 397 | 440 | .overflow_y_scroll() |
| 398 | - .child(section_head(format!("SOURCES · {total} · {unused_count} UNUSED"))) | |
| 441 | + .child(section_head(format!( | |
| 442 | + "SOURCES · {total} · {unused_count} UNUSED" | |
| 443 | + ))) | |
| 399 | 444 | .child({ |
| 400 | 445 | let style = mono(type_scale::CHORD_METADATA_MAX_PX, FontWeight::MEDIUM); |
| 401 | 446 | div() |
| @@ -404,7 +449,11 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 404 | 449 | .cursor_text() |
| 405 | 450 | .font(style.font) |
| 406 | 451 | .text_size(style.size) |
| 407 | - .text_color(rgb(if player.dock_filter_edit { INK1() } else { INK3() })) | |
| 452 | + .text_color(rgb(if player.dock_filter_edit { | |
| 453 | + INK1() | |
| 454 | + } else { | |
| 455 | + INK3() | |
| 456 | + })) | |
| 408 | 457 | .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { |
| 409 | 458 | this.dock_filter_edit = true; |
| 410 | 459 | cx.notify(); |
| @@ -421,7 +470,7 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 421 | 470 | .gap(px(4.)) |
| 422 | 471 | .children(DockSort::ALL.map(|sort| { |
| 423 | 472 | let on = sort == player.dock_sort; |
| 424 | - let style = label(9.5, FontWeight::MEDIUM); | |
| 473 | + let style = label(type_scale::FLOOR_PX, FontWeight::MEDIUM); | |
| 425 | 474 | div() |
| 426 | 475 | .id(("dock-sort", sort as usize)) |
| 427 | 476 | .flex_none() |
| @@ -458,7 +507,8 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 458 | 507 | .text_size(style.size) |
| 459 | 508 | .text_color(rgb(INK3())) |
| 460 | 509 | .child(match player.dock_filter.is_empty() { |
| 461 | - true => "No sources yet — Add files, or drop one on the window".to_string(), | |
| 510 | + true => "No sources yet — Add files, or drop one on the window" | |
| 511 | + .to_string(), | |
| 462 | 512 | false => "nothing matches the filter".to_string(), |
| 463 | 513 | }), |
| 464 | 514 | ) |
| @@ -468,7 +518,10 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 468 | 518 | .iter() |
| 469 | 519 | .enumerate() |
| 470 | 520 | .map(|(i, (row, placed))| { |
| 471 | - let picked = player.selected_asset.as_ref().is_some_and(|p| *p == (row.path.clone(), row.stream)); | |
| 521 | + let picked = player | |
| 522 | + .selected_asset | |
| 523 | + .as_ref() | |
| 524 | + .is_some_and(|p| *p == (row.path.clone(), row.stream)); | |
| 472 | 525 | source_row(player, i, row, *placed, picked, cx).into_any_element() |
| 473 | 526 | }) |
| 474 | 527 | .collect(); |
| @@ -501,11 +554,9 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 501 | 554 | )), |
| 502 | 555 | ) |
| 503 | 556 | .child({ |
| 504 | - // FAULT 2: metadata, not a row -- DESIGN §3's 9.5-10px band via | |
| 505 | - // the named constant (a bespoke 9px literal was neither the | |
| 506 | - // metadata size nor any other named role), and the quietest text | |
| 507 | - // in the dock: ink3, tight leading so it never competes with the | |
| 508 | - // 10.5px source rows above it. | |
| 557 | + // Metadata, not a row: DESIGN §3's metadata role, and the quietest | |
| 558 | + // text in the dock: ink3, tight leading so it never competes with | |
| 559 | + // the source rows above it. | |
| 509 | 560 | let style = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM); |
| 510 | 561 | div() |
| 511 | 562 | .flex_none() |
| @@ -524,7 +575,12 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 524 | 575 | /// these onto. Drag-while-playing and every other gesture on a row is |
| 525 | 576 | /// whatever that card already does; nothing about the gesture is reimplemented |
| 526 | 577 | /// here. |
| 527 | -fn clip_tab(player: &Player, width: f32, window_size: Size<Pixels>, cx: &mut Context<Player>) -> impl IntoElement { | |
| 578 | +fn clip_tab( | |
| 579 | + player: &Player, | |
| 580 | + width: f32, | |
| 581 | + window_size: Size<Pixels>, | |
| 582 | + cx: &mut Context<Player>, | |
| 583 | +) -> impl IntoElement { | |
| 528 | 584 | // The room actually given here, not the window's: `eq_card_w`/ |
| 529 | 585 | // `card_max_w` are asked "how wide may I draw" and answered with the |
| 530 | 586 | // *whole viewport's* width when handed `window_size` verbatim -- but this |
| @@ -699,7 +755,12 @@ fn clip_tab(player: &Player, width: f32, window_size: Size<Pixels>, cx: &mut Con | ||
| 699 | 755 | /// pair). What degrades *inside* fixed width is the two tabs' own content: |
| 700 | 756 | /// Sources scrolls its own row list; Clip's param rows are whatever their |
| 701 | 757 | /// card already draws at this width. |
| 702 | -pub(crate) fn render(player: &Player, width: f32, window_size: Size<Pixels>, cx: &mut Context<Player>) -> impl IntoElement { | |
| 758 | +pub(crate) fn render( | |
| 759 | + player: &Player, | |
| 760 | + width: f32, | |
| 761 | + window_size: Size<Pixels>, | |
| 762 | + cx: &mut Context<Player>, | |
| 763 | +) -> impl IntoElement { | |
| 703 | 764 | let src_active = player.dock_src_active; |
| 704 | 765 | div() |
| 705 | 766 | .id("stance-dock-body") |
crates/app/src/ui/spine_stance.rsmodified+179 -31
| @@ -4,17 +4,13 @@ | ||
| 4 | 4 | //! drew. `stance.rs::spine()` keeps the panel frame (width, surface, |
| 5 | 5 | //! border); this module owns the rows inside it. |
| 6 | 6 | |
| 7 | -use crate::*; | |
| 8 | 7 | use crate::ui::type_scale::{self, Typeset}; |
| 8 | +use crate::*; | |
| 9 | 9 | |
| 10 | -/// The glyph icon itself: DESIGN §3 names no separate role for it, so this | |
| 11 | -/// keeps the size the module has always drawn it at (13px, the same number | |
| 12 | -/// as the hero timecode by coincidence, not by role) and routes only the | |
| 13 | -/// font family through [`type_scale`] (Archivo -- the glyph is a verb, the | |
| 14 | -/// room's voice, not something the film says). | |
| 15 | -const GLYPH_SIZE: f32 = 13.; | |
| 10 | +/// The glyph icon is a room verb, so it uses the label role rather than a | |
| 11 | +/// bespoke size: Archivo at `LABEL_ROW_PX`. | |
| 16 | 12 | |
| 17 | -/// A group head: 9px uppercase Archivo 700 in `ink3`, +0.14em tracking | |
| 13 | +/// A group head: uppercase Archivo 700 in `ink3`, +0.14em tracking | |
| 18 | 14 | /// (DESIGN §3) -- reused as its own small fn rather than `stance::section_head` |
| 19 | 15 | /// because that one is private to its module and carries a different |
| 20 | 16 | /// vertical rhythm (a region label, not a spine group head). |
| @@ -79,16 +75,21 @@ fn glyph( | ||
| 79 | 75 | .when(on, |d| { |
| 80 | 76 | d.cursor_pointer() |
| 81 | 77 | .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) |
| 82 | - .on_click(cx.listener(move |this, _: &ClickEvent, window, cx| { | |
| 83 | - this.act(action, window, cx) | |
| 84 | - })) | |
| 78 | + .on_click( | |
| 79 | + cx.listener(move |this, _: &ClickEvent, window, cx| { | |
| 80 | + this.act(action, window, cx) | |
| 81 | + }), | |
| 82 | + ) | |
| 85 | 83 | }) |
| 86 | 84 | .child( |
| 87 | 85 | div() |
| 88 | 86 | .line_height(relative(1.05)) |
| 89 | 87 | // FAULT 1: the glyph is the loudest thing in its row -- BOLD, |
| 90 | 88 | // not the MEDIUM weight the chord beneath it also wears. |
| 91 | - .type_style(type_scale::label(GLYPH_SIZE, gpui::FontWeight::BOLD)) | |
| 89 | + .type_style(type_scale::label( | |
| 90 | + type_scale::LABEL_ROW_PX, | |
| 91 | + gpui::FontWeight::BOLD, | |
| 92 | + )) | |
| 92 | 93 | .text_color(rgb(if active { |
| 93 | 94 | INK1() |
| 94 | 95 | } else if quiet { |
| @@ -143,7 +144,10 @@ fn trim_control(active: bool, player: &Player, cx: &mut Context<Player>) -> impl | ||
| 143 | 144 | .child( |
| 144 | 145 | div() |
| 145 | 146 | .line_height(relative(1.05)) |
| 146 | - .type_style(type_scale::label(GLYPH_SIZE, gpui::FontWeight::BOLD)) | |
| 147 | + .type_style(type_scale::label( | |
| 148 | + type_scale::LABEL_ROW_PX, | |
| 149 | + gpui::FontWeight::BOLD, | |
| 150 | + )) | |
| 147 | 151 | .text_color(rgb(if active { INK1() } else { INK2() })) |
| 148 | 152 | .child(txt), |
| 149 | 153 | ) |
| @@ -222,8 +226,24 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem | ||
| 222 | 226 | .gap(px(1.)) |
| 223 | 227 | .overflow_y_scroll() |
| 224 | 228 | .child(group_head("edit")) |
| 225 | - .child(glyph("spine-split", "||", ActionId::Cut, false, false, player, cx)) | |
| 226 | - .child(glyph("spine-delete", "⊂⊃", ActionId::Delete, false, false, player, cx)) | |
| 229 | + .child(glyph( | |
| 230 | + "spine-split", | |
| 231 | + "||", | |
| 232 | + ActionId::Cut, | |
| 233 | + false, | |
| 234 | + false, | |
| 235 | + player, | |
| 236 | + cx, | |
| 237 | + )) | |
| 238 | + .child(glyph( | |
| 239 | + "spine-delete", | |
| 240 | + "⊂⊃", | |
| 241 | + ActionId::Delete, | |
| 242 | + false, | |
| 243 | + false, | |
| 244 | + player, | |
| 245 | + cx, | |
| 246 | + )) | |
| 227 | 247 | .child(pair( |
| 228 | 248 | glyph("spine-undo", "↺", ActionId::Undo, false, false, player, cx), |
| 229 | 249 | // Redo had a legacy toolbar button (`toolbar.rs:347`) but no |
| @@ -234,8 +254,24 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem | ||
| 234 | 254 | )) |
| 235 | 255 | .child(group_head("cut")) |
| 236 | 256 | .child(pair( |
| 237 | - glyph("spine-cut-prev", "‹", ActionId::WalkCutPrev, false, false, player, cx), | |
| 238 | - glyph("spine-cut-next", "›", ActionId::WalkCutNext, false, false, player, cx), | |
| 257 | + glyph( | |
| 258 | + "spine-cut-prev", | |
| 259 | + "‹", | |
| 260 | + ActionId::WalkCutPrev, | |
| 261 | + false, | |
| 262 | + false, | |
| 263 | + player, | |
| 264 | + cx, | |
| 265 | + ), | |
| 266 | + glyph( | |
| 267 | + "spine-cut-next", | |
| 268 | + "›", | |
| 269 | + ActionId::WalkCutNext, | |
| 270 | + false, | |
| 271 | + false, | |
| 272 | + player, | |
| 273 | + cx, | |
| 274 | + ), | |
| 239 | 275 | )) |
| 240 | 276 | .child(trim_control(player.loop_trim.is_some(), player, cx)) |
| 241 | 277 | .child(glyph( |
| @@ -271,13 +307,53 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem | ||
| 271 | 307 | // less than walking/trimming cuts above it. |
| 272 | 308 | .child(group_head("view")) |
| 273 | 309 | .child(pair( |
| 274 | - glyph("spine-zoom-out", "−", ActionId::ZoomOut, false, false, player, cx), | |
| 275 | - glyph("spine-zoom-in", "+", ActionId::ZoomIn, false, false, player, cx), | |
| 310 | + glyph( | |
| 311 | + "spine-zoom-out", | |
| 312 | + "−", | |
| 313 | + ActionId::ZoomOut, | |
| 314 | + false, | |
| 315 | + false, | |
| 316 | + player, | |
| 317 | + cx, | |
| 318 | + ), | |
| 319 | + glyph( | |
| 320 | + "spine-zoom-in", | |
| 321 | + "+", | |
| 322 | + ActionId::ZoomIn, | |
| 323 | + false, | |
| 324 | + false, | |
| 325 | + player, | |
| 326 | + cx, | |
| 327 | + ), | |
| 328 | + )) | |
| 329 | + .child(glyph( | |
| 330 | + "spine-zoom-fit", | |
| 331 | + "⊡", | |
| 332 | + ActionId::ZoomFit, | |
| 333 | + false, | |
| 334 | + false, | |
| 335 | + player, | |
| 336 | + cx, | |
| 276 | 337 | )) |
| 277 | - .child(glyph("spine-zoom-fit", "⊡", ActionId::ZoomFit, false, false, player, cx)) | |
| 278 | 338 | .child(group_head("track")) |
| 279 | - .child(glyph("spine-add-video", "+V", ActionId::AddVideoLane, false, false, player, cx)) | |
| 280 | - .child(glyph("spine-add-audio", "+A", ActionId::AddAudioLane, false, false, player, cx)) | |
| 339 | + .child(glyph( | |
| 340 | + "spine-add-video", | |
| 341 | + "+V", | |
| 342 | + ActionId::AddVideoLane, | |
| 343 | + false, | |
| 344 | + false, | |
| 345 | + player, | |
| 346 | + cx, | |
| 347 | + )) | |
| 348 | + .child(glyph( | |
| 349 | + "spine-add-audio", | |
| 350 | + "+A", | |
| 351 | + ActionId::AddAudioLane, | |
| 352 | + false, | |
| 353 | + false, | |
| 354 | + player, | |
| 355 | + cx, | |
| 356 | + )) | |
| 281 | 357 | // The subtitle trio (homeless per this task's audit): AddSubtitleLane |
| 282 | 358 | // joins +V/+A on the same "+letter" grammar per this task's own |
| 283 | 359 | // instruction ("+S joins +V/+A in TRACK"); remove/import are "the |
| @@ -291,12 +367,44 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem | ||
| 291 | 367 | // ROOM cluster below: cue visibility is judged shot to shot, closer |
| 292 | 368 | // in frequency to a view toggle used often than to a once-a-session |
| 293 | 369 | // preference. |
| 294 | - .child(glyph("spine-add-subtitle", "+S", ActionId::AddSubtitleLane, false, false, player, cx)) | |
| 370 | + .child(glyph( | |
| 371 | + "spine-add-subtitle", | |
| 372 | + "+S", | |
| 373 | + ActionId::AddSubtitleLane, | |
| 374 | + false, | |
| 375 | + false, | |
| 376 | + player, | |
| 377 | + cx, | |
| 378 | + )) | |
| 295 | 379 | .child(pair( |
| 296 | - glyph("spine-remove-subtitle", "−S", ActionId::RemoveSubtitleLane, false, false, player, cx), | |
| 297 | - glyph("spine-import-subtitles", "↓S", ActionId::ImportSubtitles, false, false, player, cx), | |
| 380 | + glyph( | |
| 381 | + "spine-remove-subtitle", | |
| 382 | + "−S", | |
| 383 | + ActionId::RemoveSubtitleLane, | |
| 384 | + false, | |
| 385 | + false, | |
| 386 | + player, | |
| 387 | + cx, | |
| 388 | + ), | |
| 389 | + glyph( | |
| 390 | + "spine-import-subtitles", | |
| 391 | + "↓S", | |
| 392 | + ActionId::ImportSubtitles, | |
| 393 | + false, | |
| 394 | + false, | |
| 395 | + player, | |
| 396 | + cx, | |
| 397 | + ), | |
| 398 | + )) | |
| 399 | + .child(glyph( | |
| 400 | + "spine-toggle-subtitles", | |
| 401 | + "CC", | |
| 402 | + ActionId::ToggleSubtitles, | |
| 403 | + player.subs_on, | |
| 404 | + false, | |
| 405 | + player, | |
| 406 | + cx, | |
| 298 | 407 | )) |
| 299 | - .child(glyph("spine-toggle-subtitles", "CC", ActionId::ToggleSubtitles, player.subs_on, false, player, cx)) | |
| 300 | 408 | // ROOM: the once-a-session/once-a-project acts this task's charter |
| 301 | 409 | // names explicitly (theme, proxies, screenshot, fullscreen) -- ink- |
| 302 | 410 | // demoted (`quiet: true`) and paired two-to-a-row to keep the group |
| @@ -312,18 +420,58 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem | ||
| 312 | 420 | .child(group_head("room")) |
| 313 | 421 | .child(pair( |
| 314 | 422 | glyph("spine-theme", "H", ActionId::Theme, false, true, player, cx), |
| 315 | - glyph("spine-proxies", "P", ActionId::ToggleProxies, player.proxies_on, true, player, cx), | |
| 423 | + glyph( | |
| 424 | + "spine-proxies", | |
| 425 | + "P", | |
| 426 | + ActionId::ToggleProxies, | |
| 427 | + player.proxies_on, | |
| 428 | + true, | |
| 429 | + player, | |
| 430 | + cx, | |
| 431 | + ), | |
| 316 | 432 | )) |
| 317 | 433 | .child(pair( |
| 318 | - glyph("spine-auto-proxies", "AP", ActionId::ToggleAutoProxies, player.auto_proxies_on, true, player, cx), | |
| 319 | - glyph("spine-fullscreen", "FS", ActionId::Fullscreen, false, true, player, cx), | |
| 434 | + glyph( | |
| 435 | + "spine-auto-proxies", | |
| 436 | + "AP", | |
| 437 | + ActionId::ToggleAutoProxies, | |
| 438 | + player.auto_proxies_on, | |
| 439 | + true, | |
| 440 | + player, | |
| 441 | + cx, | |
| 442 | + ), | |
| 443 | + glyph( | |
| 444 | + "spine-fullscreen", | |
| 445 | + "FS", | |
| 446 | + ActionId::Fullscreen, | |
| 447 | + false, | |
| 448 | + true, | |
| 449 | + player, | |
| 450 | + cx, | |
| 451 | + ), | |
| 452 | + )) | |
| 453 | + .child(glyph( | |
| 454 | + "spine-screenshot", | |
| 455 | + "Sh", | |
| 456 | + ActionId::Screenshot, | |
| 457 | + false, | |
| 458 | + true, | |
| 459 | + player, | |
| 460 | + cx, | |
| 320 | 461 | )) |
| 321 | - .child(glyph("spine-screenshot", "Sh", ActionId::Screenshot, false, true, player, cx)) | |
| 322 | 462 | // The settings page's own visible door (user complaint: "some |
| 323 | 463 | // options are only reachable via keyboard shortcut") -- a chord |
| 324 | 464 | // alone is a defect class this room has hit repeatedly, so this |
| 325 | 465 | // glyph sits beside the other once-a-session ROOM acts even though |
| 326 | 466 | // its chord (`^,`) is a preference, not a mnemonic. |
| 327 | - .child(glyph("spine-settings", "St", ActionId::Settings, player.settings_open, true, player, cx)) | |
| 467 | + .child(glyph( | |
| 468 | + "spine-settings", | |
| 469 | + "St", | |
| 470 | + ActionId::Settings, | |
| 471 | + player.settings_open, | |
| 472 | + true, | |
| 473 | + player, | |
| 474 | + cx, | |
| 475 | + )) | |
| 328 | 476 | .child(div().flex_1()) |
| 329 | 477 | } |
crates/app/src/ui/stance.rsmodified+90 -59
| @@ -8,13 +8,13 @@ | ||
| 8 | 8 | //! interaction, no cut machinery -- `// hook:` comments below mark where the |
| 9 | 9 | //! later steps in DESIGN §12's package attach. |
| 10 | 10 | |
| 11 | -use crate::*; | |
| 12 | 11 | use crate::ui::bench_stance; |
| 13 | 12 | use crate::ui::dock_stance; |
| 14 | 13 | use crate::ui::settings_stance; |
| 15 | -use crate::ui::timeband_stance; | |
| 16 | 14 | use crate::ui::spine_stance; |
| 15 | +use crate::ui::timeband_stance; | |
| 17 | 16 | use crate::ui::type_scale::{self, Typeset}; |
| 17 | +use crate::*; | |
| 18 | 18 | |
| 19 | 19 | /// Left rail, full height (DESIGN §5). |
| 20 | 20 | const SPINE_W: f32 = 56.; |
| @@ -39,16 +39,13 @@ pub(crate) const DOCK_W: f32 = 280.; | ||
| 39 | 39 | /// What [`bench`] spends above `bench_stance::render`'s own content: the |
| 40 | 40 | /// `bench` div's own `.border_t_1()` (1px) + its `py(4.)` top padding + |
| 41 | 41 | /// the section head's real line box -- `type_scale::head()` sizes text at |
| 42 | -/// `SECTION_HEAD_PX` (10) but never calls `.line_height()`, so gpui's | |
| 42 | +/// `SECTION_HEAD_PX` (12) but never calls `.line_height()`, so gpui's | |
| 43 | 43 | /// default `TextStyle::line_height` (the golden ratio, `gpui::phi()` == |
| 44 | 44 | /// `1.618034`, not 1x the font size) is what it actually draws: |
| 45 | -/// `round(10. * 1.618034)` = `round(16.18034)` = `16`. A driven pass found | |
| 46 | -/// this constant undercounting that line box as a bare `10`, one of the two | |
| 47 | -/// causes of `layout::BENCH_MIN_H`'s third clip (see its own doc comment for | |
| 48 | -/// the other). `1 + 4 + 16` = `21`. Named and `pub(crate)` rather than the | |
| 49 | -/// `- 20.` it used to be inlined as, so `layout::BENCH_MIN_H` can add it | |
| 50 | -/// into its own derivation instead of guessing it back out. | |
| 51 | -pub(crate) const BENCH_CHROME_H: f32 = 21.; | |
| 45 | +/// `round(12. * 1.618034)` = `round(19.416408)` = `19`. | |
| 46 | +/// `1 + 4 + 19` = `24`. Named and `pub(crate)` rather than an inline | |
| 47 | +/// subtraction, so `layout::BENCH_MIN_H` can derive from the real chrome. | |
| 48 | +pub(crate) const BENCH_CHROME_H: f32 = 24.; | |
| 52 | 49 | |
| 53 | 50 | /// The lowest a menu's top edge may sit and still land inside the |
| 54 | 51 | /// bench/ledger/dock footprint below the screen (DESIGN §5, §9, §11 check 6): |
| @@ -136,7 +133,10 @@ mod menu_floor_tests { | ||
| 136 | 133 | let list_h = (396f32).min(f32::from(room.height)); |
| 137 | 134 | assert!(list_h <= f32::from(room.height)); |
| 138 | 135 | let (_, y) = crate::oracle::menu_at(at, viewport, list_h); |
| 139 | - assert_eq!(y, floor, "the top edge must not be walked back above the floor"); | |
| 136 | + assert_eq!( | |
| 137 | + y, floor, | |
| 138 | + "the top edge must not be walked back above the floor" | |
| 139 | + ); | |
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
| @@ -196,7 +196,11 @@ thread_local! { | ||
| 196 | 196 | /// reimplemented here. Split out from `picture_scale` so this arithmetic has |
| 197 | 197 | /// a runnable check with no `Player`/window to stand up. |
| 198 | 198 | fn fit_scale(bounds: Bounds<Pixels>, native: gpui::Size<gpui::DevicePixels>) -> Option<f32> { |
| 199 | - if bounds.size.width <= px(0.) || bounds.size.height <= px(0.) || native.width.0 <= 0 || native.height.0 <= 0 { | |
| 199 | + if bounds.size.width <= px(0.) | |
| 200 | + || bounds.size.height <= px(0.) | |
| 201 | + || native.width.0 <= 0 | |
| 202 | + || native.height.0 <= 0 | |
| 203 | + { | |
| 200 | 204 | return None; |
| 201 | 205 | } |
| 202 | 206 | let fitted = gpui::ObjectFit::Contain.get_bounds(bounds, native); |
| @@ -269,7 +273,7 @@ fn scale_plate(player: &Player) -> impl IntoElement { | ||
| 269 | 273 | .child(div().text_color(rgb(INK1())).child(value)) |
| 270 | 274 | } |
| 271 | 275 | |
| 272 | -/// A section head: 9px, uppercase, `ink3` -- DESIGN §3's scale for the label | |
| 276 | +/// A section head, uppercase, `ink3` -- DESIGN §3's scale for the label | |
| 273 | 277 | /// that names a region before anything else lives in it. |
| 274 | 278 | fn section_head(label: &str) -> impl IntoElement { |
| 275 | 279 | div() |
| @@ -291,7 +295,10 @@ fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement { | ||
| 291 | 295 | .gap(px(2.)) |
| 292 | 296 | .py(px(6.)) |
| 293 | 297 | .rounded(px(3.)) |
| 294 | - .type_style(type_scale::label(13., gpui::FontWeight::MEDIUM)) | |
| 298 | + .type_style(type_scale::label( | |
| 299 | + type_scale::LABEL_ROW_PX, | |
| 300 | + gpui::FontWeight::MEDIUM, | |
| 301 | + )) | |
| 295 | 302 | .text_color(rgb(INK2())) |
| 296 | 303 | .child(glyph.to_string()) |
| 297 | 304 | .child( |
| @@ -352,43 +359,16 @@ fn keys_overlay(player: &Player) -> impl IntoElement { | ||
| 352 | 359 | .flex_col() |
| 353 | 360 | .gap(px(3.)) |
| 354 | 361 | .child(section_head("all commands · hold ? · release to close")) |
| 355 | - .children(keys_rows().into_iter().map(|row| match row { | |
| 356 | - KeyRow::Head(category) => div() | |
| 357 | - .flex_none() | |
| 358 | - .pt(px(4.)) | |
| 359 | - .type_style(type_scale::head()) | |
| 360 | - .text_color(rgb(INK3())) | |
| 361 | - .child(category.label().to_uppercase()) | |
| 362 | - .into_any_element(), | |
| 363 | - KeyRow::Act(action) => div() | |
| 364 | - .flex() | |
| 365 | - .justify_between() | |
| 366 | - .gap(px(12.)) | |
| 367 | - .child( | |
| 368 | - div() | |
| 369 | - .type_style(type_scale::label( | |
| 370 | - type_scale::CHORD_METADATA_MIN_PX, | |
| 371 | - gpui::FontWeight::MEDIUM, | |
| 372 | - )) | |
| 373 | - .text_color(rgb(INK2())) | |
| 374 | - .child(action.label()), | |
| 375 | - ) | |
| 376 | - .child( | |
| 377 | - div() | |
| 378 | - .type_style(type_scale::mono( | |
| 379 | - type_scale::CHORD_METADATA_MIN_PX, | |
| 380 | - gpui::FontWeight::MEDIUM, | |
| 381 | - )) | |
| 382 | - .text_color(rgb(INK3())) | |
| 383 | - // The keys overlay is the full-truth surface | |
| 384 | - // (FAULT 1): every chord an action answers to, | |
| 385 | - // not the badge's primary-only compact form. | |
| 386 | - .child(player.keymap.display(action)), | |
| 387 | - ) | |
| 388 | - .into_any_element(), | |
| 389 | - KeyRow::Fixed(i) => { | |
| 390 | - let f = &keymap::FIXED[i]; | |
| 391 | - div() | |
| 362 | + .children(keys_rows().into_iter().map(|row| { | |
| 363 | + match row { | |
| 364 | + KeyRow::Head(category) => div() | |
| 365 | + .flex_none() | |
| 366 | + .pt(px(4.)) | |
| 367 | + .type_style(type_scale::head()) | |
| 368 | + .text_color(rgb(INK3())) | |
| 369 | + .child(category.label().to_uppercase()) | |
| 370 | + .into_any_element(), | |
| 371 | + KeyRow::Act(action) => div() | |
| 392 | 372 | .flex() |
| 393 | 373 | .justify_between() |
| 394 | 374 | .gap(px(12.)) |
| @@ -399,7 +379,7 @@ fn keys_overlay(player: &Player) -> impl IntoElement { | ||
| 399 | 379 | gpui::FontWeight::MEDIUM, |
| 400 | 380 | )) |
| 401 | 381 | .text_color(rgb(INK2())) |
| 402 | - .child(f.label), | |
| 382 | + .child(action.label()), | |
| 403 | 383 | ) |
| 404 | 384 | .child( |
| 405 | 385 | div() |
| @@ -408,9 +388,38 @@ fn keys_overlay(player: &Player) -> impl IntoElement { | ||
| 408 | 388 | gpui::FontWeight::MEDIUM, |
| 409 | 389 | )) |
| 410 | 390 | .text_color(rgb(INK3())) |
| 411 | - .child(f.chord.clone()), | |
| 391 | + // The keys overlay is the full-truth surface | |
| 392 | + // (FAULT 1): every chord an action answers to, | |
| 393 | + // not the badge's primary-only compact form. | |
| 394 | + .child(player.keymap.display(action)), | |
| 412 | 395 | ) |
| 413 | - .into_any_element() | |
| 396 | + .into_any_element(), | |
| 397 | + KeyRow::Fixed(i) => { | |
| 398 | + let f = &keymap::FIXED[i]; | |
| 399 | + div() | |
| 400 | + .flex() | |
| 401 | + .justify_between() | |
| 402 | + .gap(px(12.)) | |
| 403 | + .child( | |
| 404 | + div() | |
| 405 | + .type_style(type_scale::label( | |
| 406 | + type_scale::CHORD_METADATA_MIN_PX, | |
| 407 | + gpui::FontWeight::MEDIUM, | |
| 408 | + )) | |
| 409 | + .text_color(rgb(INK2())) | |
| 410 | + .child(f.label), | |
| 411 | + ) | |
| 412 | + .child( | |
| 413 | + div() | |
| 414 | + .type_style(type_scale::mono( | |
| 415 | + type_scale::CHORD_METADATA_MIN_PX, | |
| 416 | + gpui::FontWeight::MEDIUM, | |
| 417 | + )) | |
| 418 | + .text_color(rgb(INK3())) | |
| 419 | + .child(f.chord.clone()), | |
| 420 | + ) | |
| 421 | + .into_any_element() | |
| 422 | + } | |
| 414 | 423 | } |
| 415 | 424 | })), |
| 416 | 425 | ) |
| @@ -447,7 +456,12 @@ fn spine(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 447 | 456 | /// the two-up OUT|IN judging *below* it as a flex sibling (DESIGN §6) rather |
| 448 | 457 | /// than layering plates over it: the picture's own `flex_1` shrinks to make |
| 449 | 458 | /// room, so every picture pixel that is drawn stays visible. |
| 450 | -fn screen(player: &mut Player, position: f64, window: &mut Window, cx: &mut Context<Player>) -> impl IntoElement { | |
| 459 | +fn screen( | |
| 460 | + player: &mut Player, | |
| 461 | + position: f64, | |
| 462 | + window: &mut Window, | |
| 463 | + cx: &mut Context<Player>, | |
| 464 | +) -> impl IntoElement { | |
| 451 | 465 | let two_up = player.two_up().map(IntoElement::into_any_element); |
| 452 | 466 | div() |
| 453 | 467 | .id("stance-screen") |
| @@ -615,7 +629,10 @@ fn notice_plate(message: SharedString, bench_h: f32) -> impl IntoElement { | ||
| 615 | 629 | // shape as the legacy notice bar's own tone stripe (`notice_bar`). |
| 616 | 630 | .border_l(px(3.)) |
| 617 | 631 | .border_color(rgb(notice_severity(&message))) |
| 618 | - .type_style(type_scale::label(10., gpui::FontWeight::MEDIUM)) | |
| 632 | + .type_style(type_scale::label( | |
| 633 | + type_scale::LABEL_ROW_PX, | |
| 634 | + gpui::FontWeight::MEDIUM, | |
| 635 | + )) | |
| 619 | 636 | .text_color(rgb(INK1())) |
| 620 | 637 | .child(message) |
| 621 | 638 | } |
| @@ -627,7 +644,14 @@ fn ledger(player: &Player, position: f64) -> impl IntoElement { | ||
| 627 | 644 | true => "untitled".to_string(), |
| 628 | 645 | false => file_name(&player.project_path), |
| 629 | 646 | }; |
| 630 | - let identity = format!("{name} · {}", if player.autosave_dirty { "unsaved" } else { "saved" }); | |
| 647 | + let identity = format!( | |
| 648 | + "{name} · {}", | |
| 649 | + if player.autosave_dirty { | |
| 650 | + "unsaved" | |
| 651 | + } else { | |
| 652 | + "saved" | |
| 653 | + } | |
| 654 | + ); | |
| 631 | 655 | let last_action = player.notices.back().cloned().unwrap_or_else(|| "—".into()); |
| 632 | 656 | let export = player |
| 633 | 657 | .exporting() |
| @@ -698,7 +722,12 @@ fn ledger(player: &Player, position: f64) -> impl IntoElement { | ||
| 698 | 722 | /// "ui fields are not stretchable" for the dock. `window_size` is threaded |
| 699 | 723 | /// through so the maximize-in-place cards inside the dock (`dock_stance.rs`) |
| 700 | 724 | /// see the real viewport rather than a fabricated `size(px(DOCK_W), h)`. |
| 701 | -fn dock(player: &Player, dock_w: f32, window_size: Size<Pixels>, cx: &mut Context<Player>) -> impl IntoElement { | |
| 725 | +fn dock( | |
| 726 | + player: &Player, | |
| 727 | + dock_w: f32, | |
| 728 | + window_size: Size<Pixels>, | |
| 729 | + cx: &mut Context<Player>, | |
| 730 | +) -> impl IntoElement { | |
| 702 | 731 | div() |
| 703 | 732 | .id("stance-dock") |
| 704 | 733 | .flex_none() |
| @@ -945,7 +974,9 @@ pub(crate) fn render( | ||
| 945 | 974 | el.child(notice_plate(n, bench_h)) |
| 946 | 975 | }) |
| 947 | 976 | .when(player.keys_open, |el| el.child(keys_overlay(player))) |
| 948 | - .when(player.settings_open, |el| el.child(settings_stance::render(player, cx))) | |
| 977 | + .when(player.settings_open, |el| { | |
| 978 | + el.child(settings_stance::render(player, cx)) | |
| 979 | + }) | |
| 949 | 980 | // The two menus (DESIGN §9: "verbs of the thing under the |
| 950 | 981 | // cursor", plate styling, the same scrim-and-row component |
| 951 | 982 | // the legacy tree already uses -- `library.rs`'s own doc |
crates/app/src/ui/timeband_stance.rsmodified+4 -7
| @@ -4,12 +4,9 @@ | ||
| 4 | 4 | //! the strip; this module owns what fills it, the same split |
| 5 | 5 | //! `dock_stance.rs`/`bench_stance.rs` already make for their regions. |
| 6 | 6 | //! |
| 7 | -//! Type note: DESIGN.md §3 says the hero timecode is 13px; the approved mock | |
| 8 | -//! (MOCK-SPEC.md) reads closer to ~20px. Kept at 13px here -- the binding | |
| 9 | -//! contract's own number, already what `stance.rs::time_band()` shipped -- | |
| 10 | -//! rather than silently picking the mock's, and named here per this task's | |
| 11 | -//! own instruction to say so when the two disagree. Every size in this | |
| 12 | -//! module now comes from `ui::type_scale` (role, not a bare `px()` literal). | |
| 7 | +//! Type note: DESIGN.md §3's approved scale gives the hero timecode 18px, | |
| 8 | +//! close to the mock's ~20px reading. Every size in this module comes from | |
| 9 | +//! `ui::type_scale` (role, not a bare `px()` literal). | |
| 13 | 10 | |
| 14 | 11 | use crate::*; |
| 15 | 12 | use crate::ui::type_scale::{self, label, mono}; |
| @@ -28,7 +25,7 @@ thread_local! { | ||
| 28 | 25 | } |
| 29 | 26 | |
| 30 | 27 | /// A stacked ghost command (DESIGN §4, MOCK-SPEC "Ghost transport"/"spine"): |
| 31 | -/// glyph ~13px `ink2` over its chord ~9.5px `ink3`, read live off the keymap | |
| 28 | +/// glyph 18px `ink2` over its chord 13px `ink3`, read live off the keymap | |
| 32 | 29 | /// so a rebind can never leave the band showing a stroke that no longer |
| 33 | 30 | /// fires it -- the same shape `stance::ghost` draws for the spine, kept local |
| 34 | 31 | /// here so this module owns its own region end to end. |
crates/app/src/ui/type_scale.rsmodified+29 -25
| @@ -37,20 +37,15 @@ pub const SPLINE_SANS_MONO: &str = "Spline Sans Mono"; | ||
| 37 | 37 | |
| 38 | 38 | /// DESIGN §3's scale, named so a call site reads the role, not a number. |
| 39 | 39 | /// |
| 40 | -/// Landed at a conservative +2px bump over the original half-pixel scale | |
| 41 | -/// (13/10.5/10-9.5/9/8 -> 15/13/12-11/10/9), chosen over a fuller | |
| 42 | -/// "readable at arm's length" candidate (18/15/14-13/12/10) to keep the | |
| 43 | -/// fixed-width dock/bench card labels clear of the truncation ladder | |
| 44 | -/// (DESIGN §7). To try the fuller scale, swap these six values for | |
| 45 | -/// 18./15./14./13./12./10. and update `the_scale_matches_design_3` (and | |
| 46 | -/// DESIGN.md §3) to match. | |
| 47 | -pub const HERO_TIMECODE_PX: f32 = 15.; | |
| 48 | -pub const LABEL_ROW_PX: f32 = 13.; | |
| 49 | -pub const CHORD_METADATA_MAX_PX: f32 = 12.; | |
| 50 | -pub const CHORD_METADATA_MIN_PX: f32 = 11.; | |
| 51 | -pub const SECTION_HEAD_PX: f32 = 10.; | |
| 40 | +/// The approved readable-at-arm's-length scale. Each role is a whole pixel: | |
| 41 | +/// fractional baselines blur cosmic-text's greyscale AA. | |
| 42 | +pub const HERO_TIMECODE_PX: f32 = 18.; | |
| 43 | +pub const LABEL_ROW_PX: f32 = 15.; | |
| 44 | +pub const CHORD_METADATA_MAX_PX: f32 = 14.; | |
| 45 | +pub const CHORD_METADATA_MIN_PX: f32 = 13.; | |
| 46 | +pub const SECTION_HEAD_PX: f32 = 12.; | |
| 52 | 47 | /// The floor DESIGN §3 sets: nothing in the room reads smaller than this. |
| 53 | -pub const FLOOR_PX: f32 = 9.; | |
| 48 | +pub const FLOOR_PX: f32 = 10.; | |
| 54 | 49 | |
| 55 | 50 | /// A family, weight and size together -- what a call site needs to paint |
| 56 | 51 | /// text with `.font(style.font).text_size(style.size)`, and nothing it has |
| @@ -90,7 +85,10 @@ impl WithWeight for Font { | ||
| 90 | 85 | /// Archivo, at the given size and weight -- labels, verbs, section heads. |
| 91 | 86 | /// No italics anywhere in the room (DESIGN §3), so this never offers one. |
| 92 | 87 | pub fn label(size_px: f32, weight: FontWeight) -> TypeStyle { |
| 93 | - debug_assert!(size_px >= FLOOR_PX, "below DESIGN §3's 8px floor: {size_px}"); | |
| 88 | + debug_assert!( | |
| 89 | + size_px >= FLOOR_PX, | |
| 90 | + "below DESIGN §3's 10px floor: {size_px}" | |
| 91 | + ); | |
| 94 | 92 | TypeStyle { |
| 95 | 93 | font: family_font(ARCHIVO, weight, false), |
| 96 | 94 | size: px(size_px), |
| @@ -100,14 +98,17 @@ pub fn label(size_px: f32, weight: FontWeight) -> TypeStyle { | ||
| 100 | 98 | /// Spline Sans Mono, at the given size and weight, tabular figures on -- |
| 101 | 99 | /// everything the film says. |
| 102 | 100 | pub fn mono(size_px: f32, weight: FontWeight) -> TypeStyle { |
| 103 | - debug_assert!(size_px >= FLOOR_PX, "below DESIGN §3's 8px floor: {size_px}"); | |
| 101 | + debug_assert!( | |
| 102 | + size_px >= FLOOR_PX, | |
| 103 | + "below DESIGN §3's 10px floor: {size_px}" | |
| 104 | + ); | |
| 104 | 105 | TypeStyle { |
| 105 | 106 | font: family_font(SPLINE_SANS_MONO, weight, true), |
| 106 | 107 | size: px(size_px), |
| 107 | 108 | } |
| 108 | 109 | } |
| 109 | 110 | |
| 110 | -/// A 9px Archivo 700 section head, `ink3`. The caller still has to uppercase | |
| 111 | +/// A 12px Archivo 700 section head, `ink3`. The caller still has to uppercase | |
| 111 | 112 | /// its own text (`.to_uppercase()`) and paint `ink3` -- this module only |
| 112 | 113 | /// owns type, not colour, and stays out of `ui::theme`'s door. |
| 113 | 114 | /// |
| @@ -122,7 +123,7 @@ pub fn head() -> TypeStyle { | ||
| 122 | 123 | } |
| 123 | 124 | |
| 124 | 125 | /// Applies a [`TypeStyle`] to any styled element in one call -- |
| 125 | -/// `div().type_style(mono(9.5, FontWeight::MEDIUM))` instead of the | |
| 126 | +/// `div().type_style(mono(CHORD_METADATA_MIN_PX, FontWeight::MEDIUM))` instead of the | |
| 126 | 127 | /// `.font(style.font).text_size(style.size)` pair spelled out at every call |
| 127 | 128 | /// site. Blanket-implemented over `Styled` so every element in the room gets |
| 128 | 129 | /// it for free. |
| @@ -168,8 +169,10 @@ const EMBEDDED: &[(&[u8], &str)] = &[ | ||
| 168 | 169 | /// runtime one -- these bytes are fixed at compile time -- so it panics |
| 169 | 170 | /// rather than falling silently back to a system face DESIGN §3 forbids. |
| 170 | 171 | pub fn register(cx: &App) { |
| 171 | - let fonts: Vec<Cow<'static, [u8]>> = | |
| 172 | - EMBEDDED.iter().map(|(bytes, _)| Cow::Borrowed(*bytes)).collect(); | |
| 172 | + let fonts: Vec<Cow<'static, [u8]>> = EMBEDDED | |
| 173 | + .iter() | |
| 174 | + .map(|(bytes, _)| Cow::Borrowed(*bytes)) | |
| 175 | + .collect(); | |
| 173 | 176 | cx.text_system() |
| 174 | 177 | .add_fonts(fonts) |
| 175 | 178 | .expect("bundled Archivo / Spline Sans Mono TTFs failed to register"); |
| @@ -181,7 +184,7 @@ mod tests { | ||
| 181 | 184 | use gpui::FontStyle; |
| 182 | 185 | |
| 183 | 186 | /// The scale never drifts below DESIGN §3's floor, and role sizes match |
| 184 | - /// the numbers §3 names -- a call site changing `15.` to `14.` for the | |
| 187 | + /// the numbers §3 names -- a call site changing `18.` to `17.` for the | |
| 185 | 188 | /// hero timecode is the design contract silently moving. |
| 186 | 189 | /// |
| 187 | 190 | /// Sizes are all whole pixels (raised from the original 13/10.5/9.5-10/9/8 |
| @@ -192,11 +195,12 @@ mod tests { | ||
| 192 | 195 | /// back into this scale. |
| 193 | 196 | #[test] |
| 194 | 197 | fn the_scale_matches_design_3() { |
| 195 | - assert_eq!(HERO_TIMECODE_PX, 15.); | |
| 196 | - assert_eq!(LABEL_ROW_PX, 13.); | |
| 197 | - assert!((11. ..=12.).contains(&CHORD_METADATA_MIN_PX)); | |
| 198 | - assert_eq!(SECTION_HEAD_PX, 10.); | |
| 199 | - assert_eq!(FLOOR_PX, 9.); | |
| 198 | + assert_eq!(HERO_TIMECODE_PX, 18.); | |
| 199 | + assert_eq!(LABEL_ROW_PX, 15.); | |
| 200 | + assert_eq!(CHORD_METADATA_MAX_PX, 14.); | |
| 201 | + assert_eq!(CHORD_METADATA_MIN_PX, 13.); | |
| 202 | + assert_eq!(SECTION_HEAD_PX, 12.); | |
| 203 | + assert_eq!(FLOOR_PX, 10.); | |
| 200 | 204 | for size in [ |
| 201 | 205 | HERO_TIMECODE_PX, |
| 202 | 206 | LABEL_ROW_PX, |