From 73fc6461d08d640b6d44081f40c00d233ad9f474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 21 Aug 2026 13:06:16 +0300 Subject: [PATCH] feat(ui): adopt larger darkroom type scale --- DESIGN.md | 6 +- crates/app/src/audio_cards.rs | 2 +- crates/app/src/layout.rs | 31 +- crates/app/src/tests/cards.rs | 146 +++- crates/app/src/ui/bench_stance.rs | 189 +++-- crates/app/src/ui/cards.rs | 1039 ++++++++++++++++---------- crates/app/src/ui/dock_stance.rs | 111 ++- crates/app/src/ui/spine_stance.rs | 210 +++++- crates/app/src/ui/stance.rs | 149 ++-- crates/app/src/ui/timeband_stance.rs | 11 +- crates/app/src/ui/type_scale.rs | 54 +- 11 files changed, 1274 insertions(+), 674 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index fb52cbd..e9fe617 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -76,9 +76,9 @@ Two faces, fixed roles (bundled, no runtime deps): - **Spline Sans Mono** — everything the film says: timecode, chords, readouts, metadata, cue text, the ledger. Mono = data; if a string is *about the footage or a key*, it is mono. -Scale: 15px hero timecode (700, colons in `ink3`) · 13px labels/rows (500) · 11–12px chords -and metadata (500) · 10px section heads (Archivo 700, uppercase, +0.14em letter-spacing, `ink3`). -Nothing below 9px. Every size is a whole pixel (no half-pixel sizes -- they put glyph baselines +Scale: 18px hero timecode (700, colons in `ink3`) · 15px labels/rows (500) · 13–14px chords +and metadata (500) · 12px section heads (Archivo 700, uppercase, +0.14em letter-spacing, `ink3`). +Nothing below 10px. Every size is a whole pixel (no half-pixel sizes -- they put glyph baselines off the pixel grid and blurred cosmic-text's AA). No italics. Tabular figures wherever digits align. diff --git a/crates/app/src/audio_cards.rs b/crates/app/src/audio_cards.rs index daf7f66..a006656 100644 --- a/crates/app/src/audio_cards.rs +++ b/crates/app/src/audio_cards.rs @@ -235,7 +235,7 @@ mod eq_tick_end_w_tests { use super::*; /// The defect measured live: a fixed 24 px box wrapped "20 Hz" (5 chars) - /// at the dark theme's 11 px end-tick size. The derived width must clear + /// at the dark theme's 13 px end-tick size. The derived width must clear /// that box, and must grow, not shrink, if a future scale bump raises /// the size fed in. #[test] diff --git a/crates/app/src/layout.rs b/crates/app/src/layout.rs index 86be643..c414781 100644 --- a/crates/app/src/layout.rs +++ b/crates/app/src/layout.rs @@ -322,10 +322,11 @@ pub(crate) const TIMELINE_FIXED_H: f32 = 16. + 18. + 8. + RULER_HIT_H + 8. + 4.; /// hand it to the lane column as a bonus at exactly the zoom where the hand is /// least expecting the bed to move. pub(crate) fn timeline_fixed_h(scroll: bool) -> f32 { - TIMELINE_FIXED_H + match scroll { - true => 8. + SCROLL_HIT, - false => 0., - } + TIMELINE_FIXED_H + + match scroll { + true => 8. + SCROLL_HIT, + false => 0., + } } /// 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.; /// lane, which has no next row to spill into and clipped straight into the /// ledger instead. /// -/// A third driven pass at the next floor (`94.`, `BENCH_CHROME_H` still -/// undercounted at `20.`) clipped A1's dot again, by one row -- two 1px -/// causes stacked, not one 2px guess: `BENCH_CHROME_H`'s own undercount -/// (`20.` vs its real `21.`) and this term, `LEDGER_SEAM_CLEARANCE`, which -/// the formula never carried at all. `21 + 22 + 2 + 48 + 2 + 1` = `96.`. +/// With the 18/15/14-13/12/10px type scale, the same derivation uses a 24px +/// chrome block and two 27px lane floors: +/// `24 + 22 + 2 + 54 + 2 + 1` = `105.`. pub(crate) const BENCH_MIN_H: f32 = crate::ui::stance::BENCH_CHROME_H + crate::ui::bench_stance::RULER_H + crate::ui::bench_stance::ROW_GAP @@ -539,8 +538,12 @@ pub(crate) fn load_stance_splits_from(path: &std::path::Path) -> Splits { let mut splits = Splits::default(); if let Ok(text) = std::fs::read_to_string(path) { for line in text.lines() { - let Some((key, value)) = line.split_once('=') else { continue }; - let Ok(px) = value.trim().parse::() else { continue }; + let Some((key, value)) = line.split_once('=') else { + continue; + }; + let Ok(px) = value.trim().parse::() else { + continue; + }; let Some(split) = Split::PERSISTED.into_iter().find(|s| s.key() == key) else { continue; }; @@ -561,7 +564,11 @@ pub(crate) fn save_stance_splits(splits: &Splits) { pub(crate) fn save_stance_splits_to(splits: &Splits, path: &std::path::Path) { let text: String = Split::PERSISTED .into_iter() - .filter_map(|split| splits.get(split).map(|px| format!("{}={px}\n", split.key()))) + .filter_map(|split| { + splits + .get(split) + .map(|px| format!("{}={px}\n", split.key())) + }) .collect(); if let Some(dir) = path.parent() { let _ = std::fs::create_dir_all(dir); diff --git a/crates/app/src/tests/cards.rs b/crates/app/src/tests/cards.rs index d0461aa..592c837 100644 --- a/crates/app/src/tests/cards.rs +++ b/crates/app/src/tests/cards.rs @@ -16,7 +16,9 @@ use std::sync::atomic::Ordering; #[test] fn no_overlaid_state_in_the_stance_goes_modal_without_painting_something() { let stance = src_text("ui/stance.rs"); - let render_body = &stance[stance.find("pub(crate) fn render(").expect("the stance's entry point")..]; + let render_body = &stance[stance + .find("pub(crate) fn render(") + .expect("the stance's entry point")..]; for menu in ["context_card(", "library_card(", "picker_card("] { assert!( render_body.contains(menu), @@ -28,7 +30,11 @@ fn no_overlaid_state_in_the_stance_goes_modal_without_painting_something() { .find("if this.rebinding.is_some()\n || this.card_open()") .expect("the stance's modal guard"); let guard = &stance[guard_at..guard_at + 1600]; - for field in ["this.context_menu = None", "this.library_menu = None", "this.picker = None"] { + for field in [ + "this.context_menu = None", + "this.library_menu = None", + "this.picker = None", + ] { assert!( guard.contains(field), "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() { fields.push(name); } } - assert!(fields.len() >= 9, "modal()'s own field list looks too short to have been parsed: {fields:?}"); + assert!( + fields.len() >= 9, + "modal()'s own field list looks too short to have been parsed: {fields:?}" + ); // The mounted-surface function each field's own card draws, by the // convention the param cards already follow (`x_open` -> `x_card(` -- // `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() { ), } }; - let haystack = format!("{}\n{}", src_text("ui/stance.rs"), src_text("ui/dock_stance.rs")); + let haystack = format!( + "{}\n{}", + src_text("ui/stance.rs"), + src_text("ui/dock_stance.rs") + ); for field in &fields { let mount = mount_for(field); assert!( @@ -249,7 +262,10 @@ fn every_action_is_on_the_actions_card() { } // The list scrolls inside a card the smallest window holds, so a // thirty-fourth action costs no height at all. - assert!(rows.len() as f32 * KEYS_ROW_H > KEYS_ROWS_H, "no cap needed?"); + assert!( + rows.len() as f32 * KEYS_ROW_H > KEYS_ROWS_H, + "no cap needed?" + ); // Both halves of a row are click targets, so WCAG 2.5.8 binds them. assert!(KEYS_ROW_H >= HIT_MIN); } @@ -458,10 +474,19 @@ fn the_equalizer_graph_puts_a_band_where_a_drag_reads_it_and_fits_the_smallest_w // The card fits the smallest window and takes the room a bigger one has // -- it is a graph, and the width *is* the frequency resolution. - assert!(eq_card_w(640., false) <= 640. - 24., "card too wide for 640"); - assert!(eq_card_w(1280., false) > eq_card_w(640., false), "card ignores the window"); + assert!( + eq_card_w(640., false) <= 640. - 24., + "card too wide for 640" + ); + assert!( + eq_card_w(1280., false) > eq_card_w(640., false), + "card ignores the window" + ); assert_eq!(eq_card_w(1920., false), EQ_W_MAX, "card grows without end"); - assert!(eq_card_w(320., false) >= KEYS_W, "card narrower than a row of text"); + assert!( + eq_card_w(320., false) >= KEYS_W, + "card narrower than a row of text" + ); // At the smallest window the graph is still a graph: three across for // one down, so an octave is wide enough to put a handle in. assert!( @@ -905,7 +930,10 @@ fn the_clock_stops_where_the_timeline_does_and_the_end_still_restarts() { let deadline = Instant::now() + Duration::from_secs(20); let mut state = transport(session.is_playing(), session.is_eos()); while state != Transport::Ended { - assert!(Instant::now() < deadline, "never reached the end of a 5s file"); + assert!( + Instant::now() < deadline, + "never reached the end of a 5s file" + ); session.tick(); while session.try_frame().is_some() {} state = transport(session.is_playing(), session.is_eos()); @@ -982,7 +1010,14 @@ fn a_quality_row_is_the_bitrate_it_promises() { Some(2_000_000) ); assert_eq!( - export_settings(Quality::Medium, 0, mp4, DEFAULT_AUDIO_KBPS, EncoderSeat::Auto).bitrate, + export_settings( + Quality::Medium, + 0, + mp4, + DEFAULT_AUDIO_KBPS, + EncoderSeat::Auto + ) + .bitrate, Some(6_000_000) ); assert_eq!( @@ -991,7 +1026,14 @@ fn a_quality_row_is_the_bitrate_it_promises() { ); // Megabits as typed, and as the row says it back. assert_eq!( - export_settings(Quality::Custom, 7, mp4, DEFAULT_AUDIO_KBPS, EncoderSeat::Auto).bitrate, + export_settings( + Quality::Custom, + 7, + mp4, + DEFAULT_AUDIO_KBPS, + EncoderSeat::Auto + ) + .bitrate, Some(7_000_000) ); assert_eq!(Quality::Low.detail(0), "2 Mbps"); @@ -999,7 +1041,14 @@ fn a_quality_row_is_the_bitrate_it_promises() { // choice the engine never hears about. for format in [Format::Mp4, Format::Wav, Format::Flac] { assert_eq!( - export_settings(Quality::Auto, 0, format, DEFAULT_AUDIO_KBPS, EncoderSeat::Auto).format, + export_settings( + Quality::Auto, + 0, + format, + DEFAULT_AUDIO_KBPS, + EncoderSeat::Auto + ) + .format, format ); } @@ -1008,7 +1057,13 @@ fn a_quality_row_is_the_bitrate_it_promises() { // silently changes -- the ceiling row included, which is the one a // raised cap could have walked out past. for quality in Quality::ALL { - let settings = export_settings(quality, MBPS_MAX, mp4, DEFAULT_AUDIO_KBPS, EncoderSeat::Auto); + let settings = export_settings( + quality, + MBPS_MAX, + mp4, + DEFAULT_AUDIO_KBPS, + EncoderSeat::Auto, + ); if let Some(bitrate) = settings.bitrate { assert!( (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() { // The hint the field shows when there is nothing to refuse names both // ways out of it. let detail = NumberEdit::new(6).detail(); - assert!(detail.contains("enter") && detail.contains("esc"), "{detail}"); + assert!( + detail.contains("enter") && detail.contains("esc"), + "{detail}" + ); assert!(detail.starts_with("6▏"), "{detail}"); } @@ -1198,10 +1256,7 @@ fn a_held_key_moves_a_value_and_nothing_else() { held, matches!( action, - ActionId::VolumeUp - | ActionId::VolumeDown - | ActionId::ZoomIn - | ActionId::ZoomOut + ActionId::VolumeUp | ActionId::VolumeDown | ActionId::ZoomIn | ActionId::ZoomOut ), "{action:?} on a hold" ); @@ -1292,10 +1347,7 @@ fn a_choice_list_offers_every_value_and_fits_the_smallest_window() { // The media's own size says so: it is the one rung a person cannot read // off a number they chose. let (.., native_detail, _) = &rows[3]; - assert!( - native_detail.contains("the media's own"), - "{native_detail}" - ); + assert!(native_detail.contains("the media's own"), "{native_detail}"); // A project at a size nobody listed still gets the whole list, with // nothing marked rather than a wrong row marked. assert!( @@ -1375,7 +1427,11 @@ fn a_choice_list_offers_every_value_and_fits_the_smallest_window() { for format in [Format::Av1, Format::Av1Mp4] { assert!(av1_hw_warning(format, EncoderSeat::Hardware).is_some()); for seat in [EncoderSeat::Auto, EncoderSeat::Software] { - assert_eq!(av1_hw_warning(format, seat), None, "{seat:?} is the safe seat"); + assert_eq!( + av1_hw_warning(format, seat), + None, + "{seat:?} is the safe seat" + ); } } 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() { fn the_resolution_and_rate_lists_work_before_any_file_is_open() { let none = pending_resolution_choices(None); assert_eq!(none.len(), RESOLUTIONS.len()); - assert!(none.iter().all(|(.., picked)| !picked), "nothing picked yet"); + assert!( + none.iter().all(|(.., picked)| !picked), + "nothing picked yet" + ); for ((choice, label, detail, _), size) in none.iter().zip(RESOLUTIONS) { assert_eq!(*choice, Choice::Size(size.0, size.1)); assert_eq!(label.as_ref(), format!("{}p", size.1)); @@ -1510,10 +1569,10 @@ fn the_export_card_fits_the_smallest_window() { "{id:?}: refusal ink {:.2}", contrast(p.FG_SECONDARY, p.BG_RAISED) ); - // ...and on the picked row, where the highlight is the accent at - // surface brightness. Both inks clear 4.5:1 on it now -- the row still - // lifts its key and detail to `FG_PRIMARY`, as emphasis rather than as - // the rescue it used to be. + // ...and on the picked row, where the highlight is the accent at + // surface brightness. Both inks clear 4.5:1 on it now -- the row still + // lifts its key and detail to `FG_PRIMARY`, as emphasis rather than as + // the rescue it used to be. assert!(contrast(p.FG_PRIMARY, p.BG_SELECTED) >= 4.5, "{id:?}"); assert!( contrast(p.FG_SECONDARY, p.BG_SELECTED) >= 4.5, @@ -1662,8 +1721,7 @@ fn every_preset_bundle_round_trips_through_from_state() { /// dimmed row is ignored. #[test] fn a_preset_over_a_picture_this_timeline_has_none_of_carries_the_codec_refusal() { - let mut session = - PlaybackSession::open(asset("test_tone.mp3")).expect("a song is a timeline"); + let mut session = PlaybackSession::open(asset("test_tone.mp3")).expect("a song is a timeline"); session.set_gain(0.0); let path = session.sources()[0].path.clone(); 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 exemption must not weaken" ); OVERLAID.store(false, Ordering::Relaxed); - assert!(tip_may_paint(false), "with nothing overlaid, an ordinary tip paints too"); + assert!( + tip_may_paint(false), + "with nothing overlaid, an ordinary tip paints too" + ); // Structural half: every card routes its head through `dark_card_head`, // so checking its one help-tooltip call site covers all seven cards (and // any future eighth) at once -- it must build an `OverlayTip`, not a // plain `Tip`, or this whole fix is undone by construction. let cards_src = src_text("ui/cards.rs"); - let head_fn_at = cards_src.find("fn dark_card_head(").expect("dark_card_head"); - // 1200 was wide enough before this session's maximize glyph/tooltip - // (`.when(maximize.is_some(), ...)` + its own `OverlayTip`) grew the - // function ahead of the help tooltip this test is actually pinning. - let head_fn = &cards_src[head_fn_at..head_fn_at + 2400]; + let head_fn_at = cards_src + .find("fn dark_card_head(") + .expect("dark_card_head"); + // Bound the inspected source by the next item, not a byte count: rustfmt + // may legitimately reflow this function without moving its tooltip out of + // scope. + let head_fn_end = cards_src[head_fn_at..] + .find("\n/// A ghost action row") + .expect("dark_card_head's following item"); + let head_fn = &cards_src[head_fn_at..head_fn_at + head_fn_end]; assert!( head_fn.contains("OverlayTip(h.clone())"), "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() { /// inside the dock, or hands it the dock's width again, fails this. #[test] fn a_maximized_cards_room_is_bigger_than_the_docked_rooms_not_smaller() { - use crate::layout::{Split, split_size}; use crate::SPLIT_W; + use crate::layout::{Split, split_size}; // Mirrors `ui/stance.rs`'s private `SPINE_W` (56.) and `layout::SPLIT_W` // (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() { // A file from a future/corrupt version leaves the default in force // rather than failing the room that opens over it. - std::fs::write(crate::ui::dock_stance::maximized_config_path(), "not a bool\n").unwrap(); + std::fs::write( + crate::ui::dock_stance::maximized_config_path(), + "not a bool\n", + ) + .unwrap(); assert_eq!(crate::ui::dock_stance::load_maximized(), false); unsafe { std::env::remove_var("XDG_CONFIG_HOME") }; diff --git a/crates/app/src/ui/bench_stance.rs b/crates/app/src/ui/bench_stance.rs index 67df429..a5d39ce 100644 --- a/crates/app/src/ui/bench_stance.rs +++ b/crates/app/src/ui/bench_stance.rs @@ -38,9 +38,9 @@ //! `nudge_cut` and friends still act on `Player::selected` directly, with no //! element under the pointer required, and stay untouched by any of this. -use crate::*; use crate::ui::type_scale::{self, Typeset}; use crate::ui::widgets::*; +use crate::*; /// The pinned ruler's own height, above the lane stack -- tall enough for a /// 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] = [ 0.5, 1., 2., 5., 10., 15., 30., 60., 120., 300., 600., 1800., 3600., ]; /// The floor a tick's pixel spacing must clear before its label is legible -/// mono text at 8px. +/// mono text at 10px. const TICK_MIN_PX: f64 = 64.; -/// The playhead timecode plate's own width, wide enough for `HH:MM:SS:FF` -/// mono at 10px plus the plate's padding. -const PLATE_W: f32 = 74.; +/// The playhead timecode plate's own width: eleven mono characters at the +/// 14px readout role plus its horizontal padding and a 1px rounding guard, +/// derived from the shared list-character calibration so the plate grows with +/// its type scale. +const PLATE_W: f32 = 11. * crate::layout::LIST_CHAR_W / type_scale::CHORD_METADATA_MIN_PX + * type_scale::CHORD_METADATA_MAX_PX + + 9.; /// The pinned track-head column, DESIGN §5's "track heads" -- narrower than /// the legacy timeline's `HEADER_W` since a darkroom lane carries no mix/eye /// button yet (deferred with the rest of the header's verbs). @@ -79,10 +83,8 @@ pub(crate) const LANE_DOT_D: f32 = 4.; /// golden ratio (`gpui::phi()` == `relative(1.618034)`), and `lane_row` /// never calls `.line_height()` on the head label to override it -- so this /// is what the label really occupies, not its glyph height. -/// round(12. * 1.618034) would be wrong here: the head uses -/// `CHORD_METADATA_MIN_PX` (11.), so round(11. * 1.618034) = round(17.798) -/// = 18. -const LANE_LABEL_LINE_H: f32 = 18.; +/// `round(13. * 1.618034) = 21`. +const LANE_LABEL_LINE_H: f32 = 21.; /// The least a lane row may be: what its own head actually draws, not a /// number copied from nowhere. The old `18.` fit only the label's line box /// and let every lane's status dot overflow into the row beneath it -- @@ -200,7 +202,9 @@ fn clip_box( let source = player.sources().get(clip.source); let label = source.map(|s| file_name(&s.path)); let audio = lane.kind == LaneKind::Audio; - let wave = source.and_then(|s| player.waves.get(&(s.path.clone(), s.audio_stream))).cloned(); + let wave = source + .and_then(|s| player.waves.get(&(s.path.clone(), s.audio_stream))) + .cloned(); // hook: §12 step 5 -- per-source film ink attaches here, replacing // `source_tint` (library_meta.rs's own placeholder wheel, index-keyed and // already different per source) with the source's own quantized hue. @@ -213,7 +217,10 @@ fn clip_box( let has_spine = t != Tier::Sliver; let has_label = matches!(t, Tier::Full | Tier::NoChip); let has_chip = t == Tier::Full && !clip.speed.is_normal(); - let (in_frame, out_frame) = (f64::from(clip.in_frame) / player.fps, f64::from(clip.out_frame) / player.fps); + let (in_frame, out_frame) = ( + f64::from(clip.in_frame) / player.fps, + f64::from(clip.out_frame) / player.fps, + ); let speed = clip.speed; // Right-aligned readout: the trim delta off the source's full length when // this clip is shorter than the file it was cut from, else the plain @@ -222,7 +229,12 @@ fn clip_box( // means (§12's cut object has no per-edge history at this layer) -- // ceiling is wiring this to the same cut state once the time band exposes // it, rather than a second reading of "trim" here. - let full_frames = source.map(|s| player.session.as_ref().map_or(0, |sess| sess.file_frames(&s.path))); + let full_frames = source.map(|s| { + player + .session + .as_ref() + .map_or(0, |sess| sess.file_frames(&s.path)) + }); let readout = match full_frames { Some(full) if full > clip.frames() => { let delta = f64::from(full - clip.frames()) / player.fps; @@ -234,7 +246,10 @@ fn clip_box( // is consumed by the name plate below. let ghost: SharedString = label.clone().unwrap_or_else(|| lane.label()).into(); div() - .id(("bench-clip", lane.ord * 1000 + lane.kind as usize * 100 + idx)) + .id(( + "bench-clip", + lane.ord * 1000 + lane.kind as usize * 100 + idx, + )) .absolute() .top_0() .h_full() @@ -270,10 +285,17 @@ fn clip_box( // Dragged, it moves: to the frame and the lane it is let go over // (`Player::move_clip`, `ClipDrag`) -- the same payload and the same // ghost tooltip `ui/timeline.rs`'s own clip box drags. - .on_drag(ClipDrag { lane, idx, clip: placed }, { - let ghost = ghost.clone(); - move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())) - }) + .on_drag( + ClipDrag { + lane, + idx, + clip: placed, + }, + { + let ghost = ghost.clone(); + move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())) + }, + ) // The two edge strips a drag lengthens or shortens the clip by // (`Player::start_trim`), gated on the same `trims(span)` floor the // legacy strips use -- a clip too narrow to aim at keeps its whole @@ -330,17 +352,19 @@ fn clip_box( // (falling back to a flat placeholder body while it loads or if the // file never yields one). .when(has_trace && audio, |d| { - d.children(wave.and_then(|w| match w { - Wave::Peaks(peaks) => Some( - div() - .absolute() - .left(px(3.)) - .right_0() - .top_0() - .bottom_0() - .child(waveform_ink(peaks, in_frame, out_frame, ink)), - ), - _ => None, + d.children(wave.and_then(|w| { + match w { + Wave::Peaks(peaks) => Some( + div() + .absolute() + .left(px(3.)) + .right_0() + .top_0() + .bottom_0() + .child(waveform_ink(peaks, in_frame, out_frame, ink)), + ), + _ => None, + } })) }) .when(has_trace && !audio, |d| { @@ -361,7 +385,8 @@ fn clip_box( }) // Name plate + trim/duration readout: one strip, DESIGN §4's plate // (canvas-on-panel), sat at the clip's top-left/top-right per the mock - // rather than the name alone hanging below the box. + // rather than the name alone hanging below the box. Its 21px height is + // the metadata role's default phi() line box, not its 13px glyph size. .when(has_label, |d| { d.child( div() @@ -369,7 +394,7 @@ fn clip_box( .left(px(3.)) .right_0() .top_0() - .h(px(13.)) + .h(px(LANE_LABEL_LINE_H)) .px(px(3.)) .flex() .items_center() @@ -392,7 +417,10 @@ fn clip_box( .child( div() .flex_none() - .type_style(type_scale::mono(9., gpui::FontWeight::MEDIUM)) + .type_style(type_scale::mono( + type_scale::FLOOR_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(INK3())) .child(readout), ), @@ -408,7 +436,10 @@ fn clip_box( .right_0() .px(px(3.)) .bg(rgb(DARK_RAISED())) - .type_style(type_scale::mono(9., gpui::FontWeight::MEDIUM)) + .type_style(type_scale::mono( + type_scale::FLOOR_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(INK2())) .child(format!("{speed}")), ) @@ -458,7 +489,10 @@ fn sub_box( // (`PlaybackSession::sub_lane_cues`, the same map the export and the // picture's own plate go through). let cues: Vec<(f32, f32)> = player.session.as_ref().map_or_else(Vec::new, |s| { - s.sub_lane_cues(lane).iter().map(|cue| cue_box(scale, cue)).collect() + s.sub_lane_cues(lane) + .iter() + .map(|cue| cue_box(scale, cue)) + .collect() }); let label = player .session @@ -490,10 +524,17 @@ fn sub_box( this.open_menu(lane, idx, event.position, cx); }), ) - .on_drag(SubDrag { lane, idx, sub: placed }, { - let ghost = ghost.clone(); - move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())) - }) + .on_drag( + SubDrag { + lane, + idx, + sub: placed, + }, + { + let ghost = ghost.clone(); + move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())) + }, + ) // The same edge-trim strips a clip gets, on the same [`trims`] floor. .children( [Edge::Start, Edge::End] @@ -681,15 +722,15 @@ fn lane_row( // pointer actually being inside this bed's own bounds, since // `on_drag_move` fires on every painted element of the drag's // type, not just the one under the pointer. - .on_drag_move(cx.listener( - move |this, event: &DragMoveEvent, _, cx| { + .on_drag_move( + cx.listener(move |this, event: &DragMoveEvent, _, cx| { if !event.bounds.contains(&event.event.position) { return; } let path = event.drag(cx).0.clone(); this.preview_ghost_asset(&path, lane, event.event.position.x, cx); - }, - )) + }), + ) .drag_over::(|d, _, _, _| d.bg(rgb(DARK_RAISED()))) .on_drop(cx.listener(move |this, drag: &ClipDrag, window, cx| { let Some(idx) = this.dragged(drag) else { @@ -697,15 +738,15 @@ fn lane_row( }; this.move_clip(drag.lane, idx, lane, window.mouse_position().x, cx) })) - .on_drag_move(cx.listener( - move |this, event: &DragMoveEvent, _, cx| { + .on_drag_move( + cx.listener(move |this, event: &DragMoveEvent, _, cx| { if !event.bounds.contains(&event.event.position) { return; } let drag = *event.drag(cx); this.preview_ghost(&drag, lane, event.event.position.x, cx); - }, - )) + }), + ) // A caption already on a lane moves along it, or onto another // subtitle track, exactly as a clip does (`Player::move_sub`, // the same call `ui/timeline.rs`'s own bed makes). @@ -713,25 +754,25 @@ fn lane_row( .on_drop(cx.listener(move |this, drag: &SubDrag, window, cx| { this.move_sub(drag, lane, window.mouse_position().x, cx); })) - .on_drag_move(cx.listener( - move |this, event: &DragMoveEvent, _, cx| { + .on_drag_move( + cx.listener(move |this, event: &DragMoveEvent, _, cx| { if !event.bounds.contains(&event.event.position) { return; } let drag = *event.drag(cx); this.preview_ghost_sub(&drag, lane, event.event.position.x, cx); - }, - )) + }), + ) .drag_over::(|d, _, _, _| d.bg(rgb(DARK_RAISED()))) - .on_drag_move(cx.listener( - move |this, event: &DragMoveEvent, _, cx| { + .on_drag_move( + cx.listener(move |this, event: &DragMoveEvent, _, cx| { if !event.bounds.contains(&event.event.position) { return; } let track = event.drag(cx).0; this.preview_ghost_pick(track, lane, event.event.position.x, cx); - }, - )) + }), + ) // The wheel, matched to the legacy timeline's own mapping: // ctrl+wheel zooms about the pointer, a bare wheel scrolls // the bed along the film (`Player::timeline_wheel`). Stopped @@ -793,7 +834,11 @@ fn lane_row( /// The bench's content: pinned ruler, pinned heads, lane stack -- compressed /// evenly to [`LANES_COMPRESS`] rows and then scrolling (DESIGN §7). -pub(crate) fn render(player: &mut Player, box_h: f32, cx: &mut Context) -> impl IntoElement { +pub(crate) fn render( + player: &mut Player, + box_h: f32, + cx: &mut Context, +) -> impl IntoElement { let lanes = player .session .as_ref() @@ -869,26 +914,22 @@ pub(crate) fn render(player: &mut Player, box_h: f32, cx: &mut Context) this.timeline_wheel(event, cx); })) .children(ticks.into_iter().map(|(x, label)| { - div() - .absolute() - .top_0() - .left(px(x)) - .child( - div() - .flex() - .flex_col() - .items_start() - .child(div().w(px(1.)).h(px(4.)).bg(rgb(INK3()))) - .child( - div() - .type_style(type_scale::mono( - type_scale::FLOOR_PX, - gpui::FontWeight::MEDIUM, - )) - .text_color(rgb(INK3())) - .child(label), - ), - ) + div().absolute().top_0().left(px(x)).child( + div() + .flex() + .flex_col() + .items_start() + .child(div().w(px(1.)).h(px(4.)).bg(rgb(INK3()))) + .child( + div() + .type_style(type_scale::mono( + type_scale::FLOOR_PX, + gpui::FontWeight::MEDIUM, + )) + .text_color(rgb(INK3())) + .child(label), + ), + ) })) .child( div() diff --git a/crates/app/src/ui/cards.rs b/crates/app/src/ui/cards.rs index 2c66462..ae65429 100644 --- a/crates/app/src/ui/cards.rs +++ b/crates/app/src/ui/cards.rs @@ -1,8 +1,8 @@ //! The property cards -- docked into the inspector, or floated when modal. -use crate::*; use crate::ui::type_scale::{self, Typeset}; use crate::ui::widgets::*; +use crate::*; /// DESIGN §3/§4 atoms shared by every param/setting card below (colour, /// transform, speed, EQ, silence, mix, subtitle style): what a row's label @@ -11,11 +11,14 @@ use crate::ui::widgets::*; /// times (`export_card`'s own `dark`-branch technique, one level up). /// /// A row label is what the room says about the control -- Archivo, §3's -/// 10.5px row size, `ink2` at rest / `ink1` picked (no permanent pill: the +/// label-row size, `ink2` at rest / `ink1` picked (no permanent pill: the /// picked state is a 1px `ink1` rule, §4's focus ring, not a fill). fn dark_row_label(text: impl Into, picked: bool) -> Div { div() - .type_style(type_scale::label(type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM)) + .type_style(type_scale::label( + type_scale::LABEL_ROW_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(if picked { INK1() } else { INK2() })) .child(text.into()) } @@ -38,7 +41,10 @@ fn transform_row_value(band: usize, value: f32) -> String { /// A row's value -- what the film/the setting *says*, mono per §3. fn dark_row_value(text: impl Into) -> Div { div() - .type_style(type_scale::mono(type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM)) + .type_style(type_scale::mono( + type_scale::LABEL_ROW_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(INK1())) .child(text.into()) } @@ -95,15 +101,24 @@ fn dark_card_head( .id("card-head-maximize") .flex_none() .cursor_pointer() - .type_style(type_scale::mono(type_scale::CHORD_METADATA_MAX_PX, gpui::FontWeight::MEDIUM)) + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MAX_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(INK3())) .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { this.toggle_maximize(); cx.notify(); })) .tooltip(move |_, cx| { - cx.new(|_| OverlayTip(if max { "m -- back to the room".into() } else { "m -- fills the room".into() })) - .into() + cx.new(|_| { + OverlayTip(if max { + "m -- back to the room".into() + } else { + "m -- fills the room".into() + }) + }) + .into() }) .child(if max { "▣ m" } else { "⤢ m" }) })) @@ -115,7 +130,10 @@ fn dark_card_head( ) .children(meta.map(|m| { div() - .type_style(type_scale::mono(type_scale::CHORD_METADATA_MAX_PX, gpui::FontWeight::MEDIUM)) + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MAX_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(INK3())) .child(m) })) @@ -123,7 +141,10 @@ fn dark_card_head( div() .id("card-head-help") .flex_none() - .type_style(type_scale::mono(type_scale::CHORD_METADATA_MAX_PX, gpui::FontWeight::MEDIUM)) + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MAX_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(INK3())) .tooltip(move |_, cx| cx.new(|_| OverlayTip(h.clone())).into()) .child("?") @@ -136,7 +157,10 @@ fn dark_help(text: impl Into) -> Div { div() .flex_none() .px(px(6.)) - .type_style(type_scale::mono(type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM)) + .type_style(type_scale::mono( + type_scale::LABEL_ROW_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(INK3())) .child(text.into()) } @@ -192,7 +216,10 @@ fn dark_ghost_button( .on_click(on_click) .child( div() - .type_style(type_scale::label(type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM)) + .type_style(type_scale::label( + type_scale::LABEL_ROW_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(if active { INK1() } else { INK2() })) .child(text.into()), ) @@ -260,8 +287,11 @@ impl Player { let bg_selected = if dark { DARK_RAISED() } else { BG_SELECTED() }; // Archivo for what the row *says as a verb* (its label), mono for // what the film says through it (its detail/key) -- DESIGN §3. - let font_label = dark.then(|| type_scale::label(11., gpui::FontWeight::MEDIUM).font); - let font_mono = dark.then(|| type_scale::mono(11., gpui::FontWeight::MEDIUM).font); + let label_style = + dark.then(|| type_scale::label(type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM)); + let mono_style = dark + .then(|| type_scale::mono(type_scale::CHORD_METADATA_MAX_PX, gpui::FontWeight::MEDIUM)); + let head_style = dark.then(type_scale::head); let row = |id: (&'static str, usize)| { div() .id(id) @@ -287,7 +317,9 @@ impl Player { d.when(!enabled, |d| { d.cursor_not_allowed().text_color(rgb(ink_secondary)) }) - .when(enabled, |d| d.cursor_pointer().hover(|s| s.bg(rgb(bg_hover)))) + .when(enabled, |d| { + d.cursor_pointer().hover(|s| s.bg(rgb(bg_hover))) + }) }; // A row as this card writes them: the mark saying which one is picked, // the key that picks it, its name, and what the choice means. The mark @@ -324,12 +356,16 @@ impl Player { .w(px(EXPORT_KEY_W)) .text_size(px(11.)) .text_color(rgb(ink)) - .when_some(font_mono.clone(), |d, f| d.font(f)) + .when_some(mono_style.clone(), |d, style| { + d.font(style.font).text_size(style.size) + }) .child(SharedString::from(key.to_string())), ) .child( div() - .when_some(font_label.clone(), |d, f| d.font(f)) + .when_some(label_style.clone(), |d, style| { + d.font(style.font).text_size(style.size) + }) .child(label), ), ) @@ -342,7 +378,9 @@ impl Player { .flex_shrink() .text_size(px(11.)) .text_color(rgb(ink)) - .when_some(font_mono.clone(), |d, f| d.font(f)) + .when_some(mono_style.clone(), |d, style| { + d.font(style.font).text_size(style.size) + }) .child(detail), ) }; @@ -353,7 +391,9 @@ impl Player { .pt(px(4.)) .text_size(px(10.)) .text_color(rgb(ink_secondary)) - .when_some(font_label.clone(), |d, f| d.font(f)) + .when_some(head_style.clone(), |d, style| { + d.font(style.font).text_size(style.size) + }) .child(text) .into_any_element() }; @@ -383,9 +423,11 @@ impl Player { // rows already carry: dimmed, unclickable, its reason in place of // the detail -- not bright and pickable over a click that would // only bounce off `set_format`'s own guard. - let refusal = preset - .bundle() - .and_then(|(format, _)| self.session.as_ref().and_then(|s| format_refusal(s, format))); + let refusal = preset.bundle().and_then(|(format, _)| { + self.session + .as_ref() + .and_then(|s| format_refusal(s, format)) + }); let detail: SharedString = match &refusal { Some(why) => why.clone().into(), None => preset.detail().into(), @@ -409,8 +451,9 @@ impl Player { let advanced_detail = match self.export_advanced_open { true => "codec, container, quality, sound, encoder, subtitles — s collapses them" .to_string(), - false => "codec, container, quality, sound, encoder, subtitles — s for the rows" - .to_string(), + false => { + "codec, container, quality, sound, encoder, subtitles — s for the rows".to_string() + } }; list.push( entry( @@ -433,313 +476,327 @@ impl Player { // it built exactly as the flat card built it, only not pushed at all // while the pane is shut. if self.export_advanced_open { - if self.export_grouped { - list.push(header("FORMAT")); - } - // The codecs first: which one is being written decides whether every - // row under it means anything. One a *this* timeline cannot be written - // as (an audio-only edit, for a picture codec) reads exactly like one - // there is no encoder for -- dimmed, unclickable, and carrying its own - // reason where its detail was, with nothing to click to find that out. - let mut refusals: Vec = Vec::new(); - for (i, (boxes, key, label, detail)) in FORMATS.into_iter().enumerate() { - let format = same_box(boxes, self.format); - let refused = format - .zip(self.session.as_ref()) - .and_then(|(f, s)| format_refusal(s, f)); - // A codec with no encoder here at all is the other kind of refusal, - // and the one the footer collects: it can never become pickable, so - // a row each is dead rows above the fold. - if format.is_none() { - refusals.push(format!("{label} — {detail}")); - if !self.export_refusals_inline { - continue; + if self.export_grouped { + list.push(header("FORMAT")); + } + // The codecs first: which one is being written decides whether every + // row under it means anything. One a *this* timeline cannot be written + // as (an audio-only edit, for a picture codec) reads exactly like one + // there is no encoder for -- dimmed, unclickable, and carrying its own + // reason where its detail was, with nothing to click to find that out. + let mut refusals: Vec = Vec::new(); + for (i, (boxes, key, label, detail)) in FORMATS.into_iter().enumerate() { + let format = same_box(boxes, self.format); + let refused = format + .zip(self.session.as_ref()) + .and_then(|(f, s)| format_refusal(s, f)); + // A codec with no encoder here at all is the other kind of refusal, + // and the one the footer collects: it can never become pickable, so + // a row each is dead rows above the fold. + if format.is_none() { + refusals.push(format!("{label} — {detail}")); + if !self.export_refusals_inline { + continue; + } + } + let detail: SharedString = match &refused { + Some(why) => why.clone().into(), + None => detail.into(), + }; + let format = format.filter(|_| refused.is_none()); + let mut r = entry( + ("format", i), + key, + label.into(), + detail, + boxes.contains(&self.format), + format.is_some(), + ); + if let Some(format) = format { + r = r.on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { + this.set_format(format); + cx.notify(); + })); } + list.push(r.into_any_element()); } - let detail: SharedString = match &refused { - Some(why) => why.clone().into(), - None => detail.into(), - }; - let format = format.filter(|_| refused.is_none()); + if self.export_grouped { + list.push(header("DETAILS")); + } + // The container, and only where the picked codec has more than one box: + // a row offering a single choice reads as a choice. + let boxes = containers(self.format); + if boxes.len() > 1 { + let next = next_container(self.format); + list.push( + entry( + ("container", 0), + "c", + "Container".into(), + format!( + "{} — c for {}", + self.format.ext().to_uppercase(), + next.ext().to_uppercase() + ) + .into(), + false, + true, + ) + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { + this.cycle_container(); + cx.notify(); + })) + .into_any_element(), + ); + } + match bitrate_refusal(self.format) { + // One dimmed row carrying the reason, rather than five rows of a + // figure that will not be written: the quality rows are the + // *picture's* bitrate, and this file has no picture in it. + Some(why) => list.push( + entry( + ("quality", 0), + "q", + "Quality".into(), + why.into(), + false, + false, + ) + .into_any_element(), + ), + None => { + for (i, quality) in Quality::ALL.into_iter().enumerate() { + // The custom row is a field: `n` opens it, a click in it + // opens it too, and while it is open the row shows what is + // being typed with a caret in it rather than the number in + // force. The other four are picked whole. + let field = self + .mbps_edit + .as_ref() + .filter(|_| quality == Quality::Custom); + let mut r = entry( + ("quality", i), + match quality { + Quality::Custom => "n", + _ => "q", + }, + quality.label().into(), + match field { + Some(edit) => edit.detail().into(), + None => quality.detail(self.custom_mbps).into(), + }, + self.quality == quality, + true, + ) + .on_click(cx.listener( + move |this, _: &ClickEvent, _, cx| { + match quality { + Quality::Custom => this.edit_mbps(), + _ => this.quality = quality, + } + cx.notify(); + }, + )); + if quality == Quality::Custom { + // The wheel anywhere over the row moves the number, the + // buttons being one step each: the range is fifty wide + // now, and a number only a repeated press can walk to is + // a number nobody walks to. Swallowed, so the notch that + // moved the bitrate does not scroll the list under it as + // well -- one gesture, one thing changed. + r = r + .on_scroll_wheel(cx.listener( + |this, event: &ScrollWheelEvent, _, cx| { + this.wheel_mbps(event); + cx.stop_propagation(); + cx.notify(); + }, + )) + .child(self.mbps_steppers(cx)); + } + list.push(r.into_any_element()); + } + } + } + // The other half of the file, and the one this card used to write at a + // fixed rate without saying so: what the *sound* is coded at, for every + // format that codes it -- the AAC inside a video export as much as an + // MP3. Four rates, so the pointer gets the *list* of them + // ([`Pick::AudioRate`]) rather than a button clicked round -- the + // resolution row's rule, and the key still steps as `ctrl+r` still + // does. Dimmed with the reason where this timeline has no rate to pick, + // like the quality rows are. + let sound = self.audio_rate_refusal(); let mut r = entry( - ("format", i), - key, - label.into(), - detail, - boxes.contains(&self.format), - format.is_some(), + ("sound", 0), + "b", + "Sound".into(), + match sound { + Some(why) => why.into(), + None => format!("{} kbps — b steps", self.audio_kbps).into(), + }, + false, + sound.is_none(), ); - if let Some(format) = format { - r = r.on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { - this.set_format(format); - cx.notify(); + if sound.is_none() { + r = r.on_click(cx.listener(|this, event: &ClickEvent, _, cx| { + this.open_picker(Pick::AudioRate, event.position(), cx) })); } list.push(r.into_any_element()); - } - if self.export_grouped { - list.push(header("DETAILS")); - } - // The container, and only where the picked codec has more than one box: - // a row offering a single choice reads as a choice. - let boxes = containers(self.format); - if boxes.len() > 1 { - let next = next_container(self.format); + // Which encoder writes the picture, which was an env pin and therefore + // no choice at all. Three seats, so the pointer gets the *list* of them + // ([`Pick::Encoder`]) and never a button clicked round -- the Sound + // row's rule, one row above. Only where there is a picture to encode: + // a WAV has no seat to pick and the row would be a question about + // nothing. + if self.format.has_video() { + let seat = self.encoder_seat(); + list.push( + entry( + ("encoder", 0), + "e", + "Encoder".into(), + format!("{} — e steps", encoder_label(seat)).into(), + false, + true, + ) + .on_click(cx.listener(|this, event: &ClickEvent, _, cx| { + this.open_picker(Pick::Encoder, event.position(), cx) + })) + .into_any_element(), + ); + // ...and, under it, the one thing about that pick a person cannot + // know from the words in the list: this box's driver reset itself + // on the vendored AV1 encoder. A dimmed row and not a modal -- the + // pick is theirs, and the export runs. + if let Some(warning) = av1_hw_warning(self.format, seat) { + list.push( + entry( + ("encoder-av1", 0), + "", + "".into(), + warning.into(), + false, + false, + ) + .into_any_element(), + ); + } + } + // What happens to the subtitles on this timeline, in one line: how many + // are written into the file and under what names, or the reason each one + // is not. Which tracks travel is not a pick -- everything with a cue on + // the timeline goes ([`Player::export_subs`]) -- so the row says rather + // than offers, like the machine lines below. + // ...and the ones that do not travel are named here too, which they were + // not: `export_subs` had already filtered a track with no cue on *this* + // timeline out of the engine's sight, so the card said nothing about a + // row the list was still showing ([`subtitle_plan`]). + let plan = self.subtitle_line(); + // The row used to end in "click for in MKV" whenever the picture + // was going into an mp4, on the grounds that only Matroska carries a + // text track. An mp4 carries one now (`Mp4Muxer::write_subtitles` writes + // `tx3g`), so that was a refusal offering a way out of nothing: the + // container the card is already set to embeds them. The refusals left in + // `planned_subtitles` are the true ones -- a sound-only format has + // nowhere to put a track, and a PGS track is pictures whatever the box. list.push( entry( - ("container", 0), - "c", - "Container".into(), - format!( - "{} — c for {}", - self.format.ext().to_uppercase(), - next.ext().to_uppercase() - ) - .into(), + ("subtitles", 0), + "", + "Subtitles".into(), + plan.into(), + false, false, + ) + .into_any_element(), + ); + // The card's own two layout switches. They were `g` and `r` and nothing + // else, while the status line under the title advertised both of them: + // a hand on the mouse read what they do and had nothing to press. + list.push( + entry( + ("export-layout", 0), + "g", + "Layout".into(), + match self.export_grouped { + true => "sections — g for one flat list".into(), + false => "one flat list — g for sections".into(), + }, + self.export_grouped, true, ) .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { - this.cycle_container(); + this.export_grouped = !this.export_grouped; cx.notify(); })) .into_any_element(), ); - } - match bitrate_refusal(self.format) { - // One dimmed row carrying the reason, rather than five rows of a - // figure that will not be written: the quality rows are the - // *picture's* bitrate, and this file has no picture in it. - Some(why) => list.push( - entry( - ("quality", 0), - "q", - "Quality".into(), - why.into(), - false, - false, - ) - .into_any_element(), - ), - None => { - for (i, quality) in Quality::ALL.into_iter().enumerate() { - // The custom row is a field: `n` opens it, a click in it - // opens it too, and while it is open the row shows what is - // being typed with a caret in it rather than the number in - // force. The other four are picked whole. - let field = self.mbps_edit.as_ref().filter(|_| quality == Quality::Custom); - let mut r = entry( - ("quality", i), - match quality { - Quality::Custom => "n", - _ => "q", - }, - quality.label().into(), - match field { - Some(edit) => edit.detail().into(), - None => quality.detail(self.custom_mbps).into(), - }, - self.quality == quality, - true, - ) - .on_click(cx.listener( - move |this, _: &ClickEvent, _, cx| { - match quality { - Quality::Custom => this.edit_mbps(), - _ => this.quality = quality, - } - cx.notify(); - }, - )); - if quality == Quality::Custom { - // The wheel anywhere over the row moves the number, the - // buttons being one step each: the range is fifty wide - // now, and a number only a repeated press can walk to is - // a number nobody walks to. Swallowed, so the notch that - // moved the bitrate does not scroll the list under it as - // well -- one gesture, one thing changed. - r = r - .on_scroll_wheel(cx.listener( - |this, event: &ScrollWheelEvent, _, cx| { - this.wheel_mbps(event); - cx.stop_propagation(); - cx.notify(); - }, - )) - .child(self.mbps_steppers(cx)); - } - list.push(r.into_any_element()); - } - } - } - // The other half of the file, and the one this card used to write at a - // fixed rate without saying so: what the *sound* is coded at, for every - // format that codes it -- the AAC inside a video export as much as an - // MP3. Four rates, so the pointer gets the *list* of them - // ([`Pick::AudioRate`]) rather than a button clicked round -- the - // resolution row's rule, and the key still steps as `ctrl+r` still - // does. Dimmed with the reason where this timeline has no rate to pick, - // like the quality rows are. - let sound = self.audio_rate_refusal(); - let mut r = entry( - ("sound", 0), - "b", - "Sound".into(), - match sound { - Some(why) => why.into(), - None => format!("{} kbps — b steps", self.audio_kbps).into(), - }, - false, - sound.is_none(), - ); - if sound.is_none() { - r = r.on_click(cx.listener(|this, event: &ClickEvent, _, cx| { - this.open_picker(Pick::AudioRate, event.position(), cx) - })); - } - list.push(r.into_any_element()); - // Which encoder writes the picture, which was an env pin and therefore - // no choice at all. Three seats, so the pointer gets the *list* of them - // ([`Pick::Encoder`]) and never a button clicked round -- the Sound - // row's rule, one row above. Only where there is a picture to encode: - // a WAV has no seat to pick and the row would be a question about - // nothing. - if self.format.has_video() { - let seat = self.encoder_seat(); list.push( entry( - ("encoder", 0), - "e", - "Encoder".into(), - format!("{} — e steps", encoder_label(seat)).into(), - false, + ("export-refusals", 0), + "r", + "Codecs with no encoder".into(), + match self.export_refusals_inline { + true => "a dimmed row each — r collapses them".into(), + false => "one line at the foot — r shows a row each".into(), + }, + self.export_refusals_inline, true, ) - .on_click(cx.listener(|this, event: &ClickEvent, _, cx| { - this.open_picker(Pick::Encoder, event.position(), cx) + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { + this.export_refusals_inline = !this.export_refusals_inline; + cx.notify(); })) .into_any_element(), ); - // ...and, under it, the one thing about that pick a person cannot - // know from the words in the list: this box's driver reset itself - // on the vendored AV1 encoder. A dimmed row and not a modal -- the - // pick is theirs, and the export runs. - if let Some(warning) = av1_hw_warning(self.format, seat) { + if !self.export_refusals_inline && !refusals.is_empty() { + // Last, and one line: the reason travels with the name (a footer + // that only listed them would be the "why not?" the rows exist to + // answer), but nothing here can ever be picked, so it sits under + // every row that can rather than above them. list.push( - entry(("encoder-av1", 0), "", "".into(), warning.into(), false, false) + div() + .flex_none() + .px(px(6.)) + .py(px(2.)) + .text_size(px(11.)) + .text_color(rgb(ink_secondary)) + .when_some(mono_style.clone(), |d, style| { + d.font(style.font).text_size(style.size) + }) + .child(format!("cannot write: {}", refusals.join(" · "))) .into_any_element(), ); } - } - // What happens to the subtitles on this timeline, in one line: how many - // are written into the file and under what names, or the reason each one - // is not. Which tracks travel is not a pick -- everything with a cue on - // the timeline goes ([`Player::export_subs`]) -- so the row says rather - // than offers, like the machine lines below. - // ...and the ones that do not travel are named here too, which they were - // not: `export_subs` had already filtered a track with no cue on *this* - // timeline out of the engine's sight, so the card said nothing about a - // row the list was still showing ([`subtitle_plan`]). - let plan = self.subtitle_line(); - // The row used to end in "click for in MKV" whenever the picture - // was going into an mp4, on the grounds that only Matroska carries a - // text track. An mp4 carries one now (`Mp4Muxer::write_subtitles` writes - // `tx3g`), so that was a refusal offering a way out of nothing: the - // container the card is already set to embeds them. The refusals left in - // `planned_subtitles` are the true ones -- a sound-only format has - // nowhere to put a track, and a PGS track is pictures whatever the box. - list.push( - entry( - ("subtitles", 0), - "", - "Subtitles".into(), - plan.into(), - false, - false, - ) - .into_any_element(), - ); - // The card's own two layout switches. They were `g` and `r` and nothing - // else, while the status line under the title advertised both of them: - // a hand on the mouse read what they do and had nothing to press. - list.push( - entry( - ("export-layout", 0), - "g", - "Layout".into(), - match self.export_grouped { - true => "sections — g for one flat list".into(), - false => "one flat list — g for sections".into(), - }, - self.export_grouped, - true, - ) - .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { - this.export_grouped = !this.export_grouped; - cx.notify(); - })) - .into_any_element(), - ); - list.push( - entry( - ("export-refusals", 0), - "r", - "Codecs with no encoder".into(), - match self.export_refusals_inline { - true => "a dimmed row each — r collapses them".into(), - false => "one line at the foot — r shows a row each".into(), - }, - self.export_refusals_inline, - true, - ) - .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { - this.export_refusals_inline = !this.export_refusals_inline; - cx.notify(); - })) - .into_any_element(), - ); - if !self.export_refusals_inline && !refusals.is_empty() { - // Last, and one line: the reason travels with the name (a footer - // that only listed them would be the "why not?" the rows exist to - // answer), but nothing here can ever be picked, so it sits under - // every row that can rather than above them. - list.push( + // What is doing the work, on this machine and in this build: the GPU + // half is asked of the driver through the plugin (a different answer on + // every machine, and "none" where there is no plugin at all), the build + // half is the crates that were compiled in. Last in the list, because it + // is what a user checks rather than what they pick -- and a listing + // rather than rows, since none of it can be clicked. + if self.export_grouped { + list.push(header("THIS MACHINE")); + } + let note = |text: String| { div() .flex_none() .px(px(6.)) .py(px(2.)) .text_size(px(11.)) .text_color(rgb(ink_secondary)) - .when_some(font_mono.clone(), |d, f| d.font(f)) - .child(format!("cannot write: {}", refusals.join(" · "))) - .into_any_element(), - ); - } - // What is doing the work, on this machine and in this build: the GPU - // half is asked of the driver through the plugin (a different answer on - // every machine, and "none" where there is no plugin at all), the build - // half is the crates that were compiled in. Last in the list, because it - // is what a user checks rather than what they pick -- and a listing - // rather than rows, since none of it can be clicked. - if self.export_grouped { - list.push(header("THIS MACHINE")); - } - let note = |text: String| { - div() - .flex_none() - .px(px(6.)) - .py(px(2.)) - .text_size(px(11.)) - .text_color(rgb(ink_secondary)) - .when_some(font_mono.clone(), |d, f| d.font(f)) - .child(text) - .into_any_element() - }; - list.push(note(format!( - "GPU: {}", - self.hw_caps.clone().unwrap_or_else(|| "asking…".into()) - ))); - list.push(note(format!("Built in: {}", engine::caps::software()))); + .when_some(mono_style.clone(), |d, style| { + d.font(style.font).text_size(style.size) + }) + .child(text) + .into_any_element() + }; + list.push(note(format!( + "GPU: {}", + self.hw_caps.clone().unwrap_or_else(|| "asking…".into()) + ))); + list.push(note(format!("Built in: {}", engine::caps::software()))); } // self.export_advanced_open // What the rows add up to, which is the one thing that has to be right: // codec, box, size, rate, sound, where it goes and about how big. Two @@ -762,8 +819,7 @@ impl Player { }, |(_, audio)| audio, ); - let settings = - export_settings( + let settings = export_settings( self.quality, self.custom_mbps, self.format, @@ -875,9 +931,11 @@ impl Player { div() .flex_none() .px(px(6.)) - .text_size(px(10.5)) .text_color(rgb(INK3())) - .type_style(type_scale::mono(10.5, gpui::FontWeight::MEDIUM)) + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MAX_PX, + gpui::FontWeight::MEDIUM, + )) .child(status_line), ) .child( @@ -894,8 +952,10 @@ impl Player { div() .flex_none() .px(px(6.)) - .text_size(px(11.)) - .type_style(type_scale::mono(10.5, gpui::FontWeight::MEDIUM)) + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MAX_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(INK2())) .child(head), ) @@ -903,7 +963,10 @@ impl Player { div() .flex_none() .px(px(6.)) - .type_style(type_scale::mono(10.5, gpui::FontWeight::MEDIUM)) + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MAX_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(INK3())) .child(format!( "RANGE {}\u{2013}{} ({})", @@ -916,7 +979,10 @@ impl Player { div() .flex_none() .px(px(6.)) - .type_style(type_scale::mono(10.5, gpui::FontWeight::MEDIUM)) + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MAX_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(INK3())) .child(tail), ) @@ -946,7 +1012,10 @@ impl Player { .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { this.start_export(cx) })) - .type_style(type_scale::label(11., gpui::FontWeight::MEDIUM)) + .type_style(type_scale::label( + type_scale::LABEL_ROW_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(match blocked.is_some() { true => INK4(), false => INK1(), @@ -956,7 +1025,7 @@ impl Player { d.child( div() .type_style(type_scale::mono( - 9.5, + type_scale::CHORD_METADATA_MIN_PX, gpui::FontWeight::MEDIUM, )) .text_color(rgb(INK3())) @@ -1143,8 +1212,12 @@ impl Player { .rounded(px(6.)) .bg(rgb(if dark { DARK_PANEL() } else { BG_RAISED() })) .when(dark, |d| d.border_1().border_color(rgba(DARK_SEAM()))) - .when(dark, |d| d.child(dark_card_head("Exporting", None, None, None, cx))) - .when(!dark, |d| d.child(div().flex_none().px(px(6.)).child("Exporting"))) + .when(dark, |d| { + d.child(dark_card_head("Exporting", None, None, None, cx)) + }) + .when(!dark, |d| { + d.child(div().flex_none().px(px(6.)).child("Exporting")) + }) // The bar itself: the same number as the percentage // below it, and it only ever moves forward -- the // worker's progress is a monotone `fetch_max`. @@ -1191,8 +1264,9 @@ impl Player { )) .child(note( match armed { - true => "cancelling deletes what has been written so far" - .to_string(), + true => { + "cancelling deletes what has been written so far".to_string() + } false => format!( "{} cancels · esc alone does nothing while this runs · the \ timeline is read-only until it finishes", @@ -1262,8 +1336,10 @@ impl Player { match armed { true => "stops the worker and deletes the part file" .to_string(), - false => "asks first -- one press only offers the choice" - .to_string(), + false => { + "asks first -- one press only offers the choice" + .to_string() + } }, true, cx.listener(move |this, _: &ClickEvent, _, cx| { @@ -1393,10 +1469,16 @@ impl Player { // tracked from. .id("eq-graph") .relative() - .when(graph_maximized, |d| d.flex_1().min_h(px(EQ_GRAPH_H)).max_h(px(EQ_GRAPH_MAX_H))) + .when(graph_maximized, |d| { + d.flex_1().min_h(px(EQ_GRAPH_H)).max_h(px(EQ_GRAPH_MAX_H)) + }) .when(!graph_maximized, |d| d.flex_none().h(px(eq_graph_h(false)))) .rounded(px(3.)) - .bg(rgb(if dark { DARK_HAIRLINE() } else { BG_HOVER_DIM() })) + .bg(rgb(if dark { + DARK_HAIRLINE() + } else { + BG_HOVER_DIM() + })) .cursor_pointer() // The press picks the band under it *and* is already the first // sample of the drag, so a plain click sets a value. A second click @@ -1488,25 +1570,37 @@ impl Player { // a box narrower than the text. `.whitespace_nowrap()` is // the platform's own backstop, so a mis-measured box clips // or overhangs instead of silently wrapping again. - let end_px = if dark { type_scale::CHORD_METADATA_MIN_PX } else { 9. }; + let end_px = if dark { + type_scale::CHORD_METADATA_MIN_PX + } else { + 9. + }; let div = div().absolute().bottom(px(1.)).whitespace_nowrap(); let div = if i == 0 { - div.w(px(eq_tick_end_w(label, end_px))).left(px(0.)).text_align(TextAlign::Left) + div.w(px(eq_tick_end_w(label, end_px))) + .left(px(0.)) + .text_align(TextAlign::Left) } else if i == EQ_TICKS.len() - 1 { - div.w(px(eq_tick_end_w(label, end_px))).right(px(0.)).text_align(TextAlign::Right) + div.w(px(eq_tick_end_w(label, end_px))) + .right(px(0.)) + .text_align(TextAlign::Right) } else { - div.w(px(24.)).left(relative(eq_x(*freq))).ml(px(-12.)).text_align(TextAlign::Center) + div.w(px(24.)) + .left(relative(eq_x(*freq))) + .ml(px(-12.)) + .text_align(TextAlign::Center) }; - div - .when(dark, |d| { - d.type_style(type_scale::mono( - type_scale::CHORD_METADATA_MIN_PX, - gpui::FontWeight::MEDIUM, - )) - .text_color(rgb(INK3())) - }) - .when(!dark, |d| d.text_size(px(9.)).text_color(rgb(FG_SECONDARY()))) - .child(*label) + div.when(dark, |d| { + d.type_style(type_scale::mono( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + )) + .text_color(rgb(INK3())) + }) + .when(!dark, |d| { + d.text_size(px(9.)).text_color(rgb(FG_SECONDARY())) + }) + .child(*label) })) .child( div() @@ -1520,7 +1614,9 @@ impl Player { )) .text_color(rgb(INK3())) }) - .when(!dark, |d| d.text_size(px(9.)).text_color(rgb(FG_SECONDARY()))) + .when(!dark, |d| { + d.text_size(px(9.)).text_color(rgb(FG_SECONDARY())) + }) .child(format!("+{EQ_GAIN_LIMIT:.0} dB")), ); // The bottom of the axis is not named: -12 dB would land in the same @@ -1835,7 +1931,11 @@ impl Player { /// arrows do the same three things, but a value only a key can change is a /// value a hand on the pointer cannot reach at all, which is the same reason /// [`Player::mbps_steppers`] exists. - pub(crate) fn eq_numbers(&self, picked: Option<&Band>, cx: &mut Context) -> impl IntoElement { + pub(crate) fn eq_numbers( + &self, + picked: Option<&Band>, + cx: &mut Context, + ) -> impl IntoElement { let dark = self.darkroom; let row = div() .flex_none() @@ -1858,9 +1958,8 @@ impl Player { label: &'static str, change: fn(&mut Band), cx: &mut Context| { - let on_click = cx.listener(move |this, _: &ClickEvent, _, cx| { - this.nudge_band(change, cx) - }); + let on_click = + cx.listener(move |this, _: &ClickEvent, _, cx| this.nudge_band(change, cx)); match dark { true => dark_step_glyph(id, label == "+", on_click).into_any_element(), false => div() @@ -1901,16 +2000,17 @@ impl Player { self.eq_params.bands.len() )) .into_any_element(), - false => format!("Band {} of {}", self.eq_band + 1, self.eq_params.bands.len()) - .into_any_element(), + false => format!( + "Band {} of {}", + self.eq_band + 1, + self.eq_params.bands.len() + ) + .into_any_element(), }) .child(number( band_label(&band), ("eq-freq-down", "eq-freq-up"), - ( - |b| b.freq_hz /= EQ_FREQ_STEP, - |b| b.freq_hz *= EQ_FREQ_STEP, - ), + (|b| b.freq_hz /= EQ_FREQ_STEP, |b| b.freq_hz *= EQ_FREQ_STEP), cx, )) .child(number( @@ -1939,11 +2039,9 @@ impl Player { .bg(rgb(BG_PANEL())) .cursor_pointer() .hover(|s| s.bg(rgb(BG_HOVER()))) - .on_click( - cx.listener(|this, _: &ClickEvent, _, cx| { - this.nudge_band(|b| b.gain_db = 0., cx) - }), - ) + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { + this.nudge_band(|b| b.gain_db = 0., cx) + })) .child("Flatten this"), ) } @@ -1959,7 +2057,11 @@ impl Player { /// the decoder is grading with, never a copy that could drift from it. The /// graph above them is counted off the frame that came *back* through that /// grade ([`histogram`]), so pulling exposure tilts it while the hand moves. - pub(crate) fn color_card(&self, viewport: Size, cx: &mut Context) -> Option { + pub(crate) fn color_card( + &self, + viewport: Size, + cx: &mut Context, + ) -> Option { let (lane, idx) = self.color_open?; let params = self.color_params(); let dark = self.darkroom; @@ -2040,7 +2142,9 @@ impl Player { .child( div() .w(px(44.)) - .when(dark, |d| d.child(dark_row_value(format!("{:.0}%", value * 100.)))) + .when(dark, |d| { + d.child(dark_row_value(format!("{:.0}%", value * 100.))) + }) .when(!dark, |d| { d.text_size(px(11.)) .text_color(rgb(FG_SECONDARY())) @@ -2058,7 +2162,12 @@ impl Player { .justify_center() .items_center() .bg(rgba(SCRIM())) - .when(self.card_maximized, |d| d.top(px(crate::ui::stance::maximized_card_top(f32::from(viewport.height), self.split_px(Split::Bench, viewport))))) + .when(self.card_maximized, |d| { + d.top(px(crate::ui::stance::maximized_card_top( + f32::from(viewport.height), + self.split_px(Split::Bench, viewport), + ))) + }) // Click away closes it, as on every card here. .on_mouse_down( MouseButton::Left, @@ -2071,7 +2180,11 @@ impl Player { .child( div() .w_full() - .max_w(px(card_max_w(COLOR_W, self.card_maximized, f32::from(viewport.width)))) + .max_w(px(card_max_w( + COLOR_W, + self.card_maximized, + f32::from(viewport.width), + ))) .on_mouse_down(MouseButton::Left, swallow) .flex() .flex_col() @@ -2081,7 +2194,13 @@ impl Player { .bg(rgb(if dark { DARK_PANEL() } else { BG_RAISED() })) .when(dark, |d| d.border_1().border_color(rgba(DARK_SEAM()))) .when(dark, |d| { - d.child(dark_card_head("Colour", Some(head_meta.clone()), Some(help_text.into()), Some(self.card_maximized), cx)) + d.child(dark_card_head( + "Colour", + Some(head_meta.clone()), + Some(help_text.into()), + Some(self.card_maximized), + cx, + )) }) .when(!dark, |d| { d.child(div().flex_none().px(px(6.)).child(format!( @@ -2109,7 +2228,11 @@ impl Player { .flex_none() .h(px(HIST_H)) .rounded(px(3.)) - .bg(rgb(if dark { DARK_HAIRLINE() } else { BG_HOVER_DIM() })) + .bg(rgb(if dark { + DARK_HAIRLINE() + } else { + BG_HOVER_DIM() + })) .relative() .child(hist_curves(self.histogram)), ) @@ -2151,7 +2274,11 @@ impl Player { /// The transform card: [`color_card`](Self::color_card)'s own shape, one /// row per [`TRANSFORM_BANDS`] entry instead of four, and no histogram -- /// there is nothing here a graded frame would tilt. - pub(crate) fn transform_card(&self, viewport: Size, cx: &mut Context) -> Option { + pub(crate) fn transform_card( + &self, + viewport: Size, + cx: &mut Context, + ) -> Option { let (lane, idx) = self.transform_open?; let params = self.transform_params(); let dark = self.darkroom; @@ -2222,13 +2349,16 @@ impl Player { ), ) .child( - div().w(px(44.)).when(dark, |d| { - d.child(dark_row_value(transform_row_value(i, value))) - }).when(!dark, |d| { - d.text_size(px(11.)) - .text_color(rgb(FG_SECONDARY())) - .child(transform_row_value(i, value)) - }), + div() + .w(px(44.)) + .when(dark, |d| { + d.child(dark_row_value(transform_row_value(i, value))) + }) + .when(!dark, |d| { + d.text_size(px(11.)) + .text_color(rgb(FG_SECONDARY())) + .child(transform_row_value(i, value)) + }), ) }) .collect(); @@ -2241,7 +2371,12 @@ impl Player { .justify_center() .items_center() .bg(rgba(SCRIM())) - .when(self.card_maximized, |d| d.top(px(crate::ui::stance::maximized_card_top(f32::from(viewport.height), self.split_px(Split::Bench, viewport))))) + .when(self.card_maximized, |d| { + d.top(px(crate::ui::stance::maximized_card_top( + f32::from(viewport.height), + self.split_px(Split::Bench, viewport), + ))) + }) .on_mouse_down( MouseButton::Left, cx.listener(|this, _: &MouseDownEvent, _, cx| { @@ -2253,7 +2388,11 @@ impl Player { .child( div() .w_full() - .max_w(px(card_max_w(TRANSFORM_W, self.card_maximized, f32::from(viewport.width)))) + .max_w(px(card_max_w( + TRANSFORM_W, + self.card_maximized, + f32::from(viewport.width), + ))) .on_mouse_down(MouseButton::Left, swallow) .flex() .flex_col() @@ -2263,7 +2402,13 @@ impl Player { .bg(rgb(if dark { DARK_PANEL() } else { BG_RAISED() })) .when(dark, |d| d.border_1().border_color(rgba(DARK_SEAM()))) .when(dark, |d| { - d.child(dark_card_head("Transform", Some(head_meta.clone()), Some(help_text.into()), Some(self.card_maximized), cx)) + d.child(dark_card_head( + "Transform", + Some(head_meta.clone()), + Some(help_text.into()), + Some(self.card_maximized), + cx, + )) }) .when(!dark, |d| { d.child(div().flex_none().px(px(6.)).child(format!( @@ -2326,7 +2471,11 @@ impl Player { /// /// Honest about what it does: the sound is *resampled*, so the pitch goes up /// with the rate, which is what the tape in the title means. - pub(crate) fn speed_card(&self, viewport: Size, cx: &mut Context) -> Option { + pub(crate) fn speed_card( + &self, + viewport: Size, + cx: &mut Context, + ) -> Option { let (lane, idx) = self.speed_open?; let speed = self.card_speed(); let session = self.session.as_ref()?; @@ -2365,8 +2514,7 @@ impl Player { }) .collect(); let head_meta: SharedString = format!("{} clip {}", lane.label(), idx + 1).into(); - 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"; + 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"; let tail_text: SharedString = format!( "{speed} — {} source frames over {} on the timeline ({})", clip.len(), @@ -2380,7 +2528,12 @@ impl Player { .justify_center() .items_center() .bg(rgba(SCRIM())) - .when(self.card_maximized, |d| d.top(px(crate::ui::stance::maximized_card_top(f32::from(viewport.height), self.split_px(Split::Bench, viewport))))) + .when(self.card_maximized, |d| { + d.top(px(crate::ui::stance::maximized_card_top( + f32::from(viewport.height), + self.split_px(Split::Bench, viewport), + ))) + }) // Click away closes it, as on every card here. .on_mouse_down( MouseButton::Left, @@ -2393,7 +2546,11 @@ impl Player { .child( div() .w_full() - .max_w(px(card_max_w(COLOR_W, self.card_maximized, f32::from(viewport.width)))) + .max_w(px(card_max_w( + COLOR_W, + self.card_maximized, + f32::from(viewport.width), + ))) .on_mouse_down(MouseButton::Left, swallow) .flex() .flex_col() @@ -2403,7 +2560,13 @@ impl Player { .bg(rgb(if dark { DARK_PANEL() } else { BG_RAISED() })) .when(dark, |d| d.border_1().border_color(rgba(DARK_SEAM()))) .when(dark, |d| { - d.child(dark_card_head("Speed (tape)", Some(head_meta.clone()), Some(help_text.into()), Some(self.card_maximized), cx)) + d.child(dark_card_head( + "Speed (tape)", + Some(head_meta.clone()), + Some(help_text.into()), + Some(self.card_maximized), + cx, + )) }) .when(!dark, |d| { d.child(div().flex_none().px(px(6.)).child(format!( @@ -2492,7 +2655,11 @@ impl Player { /// move it too. The rows scroll rather than the card growing past the /// window -- a timeline may hold more tracks than a 360 px window has room /// for faders. - pub(crate) fn mix_card(&self, viewport: Size, cx: &mut Context) -> Option { + pub(crate) fn mix_card( + &self, + viewport: Size, + cx: &mut Context, + ) -> Option { if !self.mix_open { return None; } @@ -2583,13 +2750,15 @@ impl Player { .bg(rgb(BG_PANEL())) .cursor_pointer() .hover(|s| s.bg(rgb(BG_HOVER()))) - .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { - // Picked as well as moved, the silence - // card's rule: the row a press lands on - // is the row the arrows carry on from. - this.mix_field = n; - this.nudge_mix(steps, cx); - })) + .on_click(cx.listener( + move |this, _: &ClickEvent, _, cx| { + // Picked as well as moved, the silence + // card's rule: the row a press lands on + // is the row the arrows carry on from. + this.mix_field = n; + this.nudge_mix(steps, cx); + }, + )) .child(match steps > 0 { true => "+", false => "−", @@ -2614,7 +2783,12 @@ impl Player { .justify_center() .items_center() .bg(rgba(SCRIM())) - .when(self.card_maximized, |d| d.top(px(crate::ui::stance::maximized_card_top(f32::from(viewport.height), self.split_px(Split::Bench, viewport))))) + .when(self.card_maximized, |d| { + d.top(px(crate::ui::stance::maximized_card_top( + f32::from(viewport.height), + self.split_px(Split::Bench, viewport), + ))) + }) // Click away closes it, as on every card here. .on_mouse_down( MouseButton::Left, @@ -2627,7 +2801,11 @@ impl Player { .child( div() .w_full() - .max_w(px(card_max_w(COLOR_W, self.card_maximized, f32::from(viewport.width)))) + .max_w(px(card_max_w( + COLOR_W, + self.card_maximized, + f32::from(viewport.width), + ))) .on_mouse_down(MouseButton::Left, swallow) .max_h(px(360. - 24.)) .flex() @@ -2637,7 +2815,15 @@ impl Player { .rounded(px(6.)) .bg(rgb(if dark { DARK_PANEL() } else { BG_RAISED() })) .when(dark, |d| d.border_1().border_color(rgba(DARK_SEAM()))) - .when(dark, |d| d.child(dark_card_head("Mix", None, Some(help_text.into()), Some(self.card_maximized), cx))) + .when(dark, |d| { + d.child(dark_card_head( + "Mix", + None, + Some(help_text.into()), + Some(self.card_maximized), + cx, + )) + }) .when(!dark, |d| { d.child( div() @@ -2690,13 +2876,25 @@ impl Player { /// card's shape for the same reason: app-global, kept in a file beside /// the theme, and drawn straight off `self.sub_text` / `self.sub_family` /// so a change is on the cue underneath before the card is closed. - pub(crate) fn subtitle_style_card(&self, viewport: Size, cx: &mut Context) -> Option { + pub(crate) fn subtitle_style_card( + &self, + viewport: Size, + cx: &mut Context, + ) -> Option { if !self.subtitle_style_open { return None; } let dark = self.darkroom; 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"; - let head = dark.then(|| dark_card_head("Subtitle style", None, Some(help_text.into()), Some(self.card_maximized), cx)); + let head = dark.then(|| { + dark_card_head( + "Subtitle style", + None, + Some(help_text.into()), + Some(self.card_maximized), + cx, + ) + }); let size_picked = self.subtitle_style_field == 0; let size_row = div() .id("subtitle-size-row") @@ -2707,7 +2905,9 @@ impl Player { .justify_between() .px(px(6.)) .rounded(px(3.)) - .when(dark && size_picked, |d| d.border_l_2().border_color(rgb(INK1()))) + .when(dark && size_picked, |d| { + d.border_l_2().border_color(rgb(INK1())) + }) .when(!dark, |d| { d.bg(rgb(match size_picked { true => BG_SELECTED(), @@ -2724,7 +2924,9 @@ impl Player { .flex() .items_center() .gap(px(4.)) - .when(dark, |d| d.child(dark_row_value(format!("{:.0}px", self.sub_text)))) + .when(dark, |d| { + d.child(dark_row_value(format!("{:.0}px", self.sub_text))) + }) .when(!dark, |d| d.child(format!("{:.0}px", self.sub_text))) .children([-1, 1].map(|steps: i32| { let id = ("subtitle-size-step", usize::from(steps > 0)); @@ -2771,7 +2973,9 @@ impl Player { .items_center() .px(px(6.)) .rounded(px(3.)) - .when(dark && default_picked, |d| d.border_l_2().border_color(rgb(INK1()))) + .when(dark && default_picked, |d| { + d.border_l_2().border_color(rgb(INK1())) + }) .when(!dark, |d| { d.bg(rgb(match default_picked { true => BG_SELECTED(), @@ -2783,7 +2987,9 @@ impl Player { .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { this.set_sub_family(None, cx); })) - .when(dark, |d| d.child(dark_row_label("System default", default_picked))) + .when(dark, |d| { + d.child(dark_row_label("System default", default_picked)) + }) .when(!dark, |d| d.child("System default")); let family_rows = self.subtitle_fonts.iter().enumerate().map(|(n, name)| { let picked = self.subtitle_style_field == n + 2 @@ -2820,7 +3026,12 @@ impl Player { .justify_center() .items_center() .bg(rgba(SCRIM())) - .when(self.card_maximized, |d| d.top(px(crate::ui::stance::maximized_card_top(f32::from(viewport.height), self.split_px(Split::Bench, viewport))))) + .when(self.card_maximized, |d| { + d.top(px(crate::ui::stance::maximized_card_top( + f32::from(viewport.height), + self.split_px(Split::Bench, viewport), + ))) + }) .on_mouse_down( MouseButton::Left, cx.listener(|this, _: &MouseDownEvent, _, cx| { @@ -2832,7 +3043,11 @@ impl Player { .child( div() .w_full() - .max_w(px(card_max_w(COLOR_W, self.card_maximized, f32::from(viewport.width)))) + .max_w(px(card_max_w( + COLOR_W, + self.card_maximized, + f32::from(viewport.width), + ))) .on_mouse_down(MouseButton::Left, swallow) .max_h(px(360. - 24.)) .flex() @@ -2883,12 +3098,24 @@ impl Player { /// *about* the timeline -- the marks under it are the whole preview -- so /// the bed stays readable and the card sits up in the picture area rather /// than over the lanes. - pub(crate) fn silence_card(&self, viewport: Size, cx: &mut Context) -> Option { + pub(crate) fn silence_card( + &self, + viewport: Size, + cx: &mut Context, + ) -> Option { let (lane, idx) = self.silence_open?; let dark = self.darkroom; let head_meta: SharedString = format!("{} clip {}", lane.label(), idx + 1).into(); 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"; - let head = dark.then(|| dark_card_head("Silences", Some(head_meta.clone()), Some(help_text.into()), Some(self.card_maximized), cx)); + let head = dark.then(|| { + dark_card_head( + "Silences", + Some(head_meta.clone()), + Some(help_text.into()), + Some(self.card_maximized), + cx, + ) + }); let cfg = self.silence; // The unit is a label, never a conversion: the threshold is a level // below full scale whichever of the two the row says (`silence_dbfs`). @@ -2926,7 +3153,10 @@ impl Player { let status = match &self.silence_scan { Some(scan) => silence_line( scan.seen as f32 / 10., - scan.progress.total.load(std::sync::atomic::Ordering::Relaxed) as f32 / 10., + scan.progress + .total + .load(std::sync::atomic::Ordering::Relaxed) as f32 + / 10., scan.started.elapsed().as_secs_f32(), scan.since.elapsed().as_secs_f32(), ), @@ -3005,14 +3235,16 @@ impl Player { .bg(rgb(BG_PANEL())) .cursor_pointer() .hover(|s| s.bg(rgb(BG_HOVER()))) - .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { - // Picked as well as moved: the row a - // press lands on is the row the arrows - // carry on from. - this.silence_field = n; - this.nudge_silence(steps); - cx.notify(); - })) + .on_click(cx.listener( + move |this, _: &ClickEvent, _, cx| { + // Picked as well as moved: the row a + // press lands on is the row the arrows + // carry on from. + this.silence_field = n; + this.nudge_silence(steps); + cx.notify(); + }, + )) .child(match steps > 0 { true => "+", false => "−", @@ -3064,7 +3296,12 @@ impl Player { // Light enough to read the lanes and the marks on them through: // the preview is the point of this card. .bg(rgba(SCRIM_LIGHT())) - .when(self.card_maximized, |d| d.top(px(crate::ui::stance::maximized_card_top(f32::from(viewport.height), self.split_px(Split::Bench, viewport))))) + .when(self.card_maximized, |d| { + d.top(px(crate::ui::stance::maximized_card_top( + f32::from(viewport.height), + self.split_px(Split::Bench, viewport), + ))) + }) // Click away closes it, as on every card here -- and the marks // go with it, which is what makes this one a call and not a flag. .on_mouse_down( @@ -3078,7 +3315,11 @@ impl Player { .child( div() .w_full() - .max_w(px(card_max_w(COLOR_W, self.card_maximized, f32::from(viewport.width)))) + .max_w(px(card_max_w( + COLOR_W, + self.card_maximized, + f32::from(viewport.width), + ))) .on_mouse_down(MouseButton::Left, swallow) .flex() .flex_col() diff --git a/crates/app/src/ui/dock_stance.rs b/crates/app/src/ui/dock_stance.rs index adf74e5..d4bacc4 100644 --- a/crates/app/src/ui/dock_stance.rs +++ b/crates/app/src/ui/dock_stance.rs @@ -11,8 +11,8 @@ //! still supply the row facts ([`library_rows`], [`source_tint`], //! [`clip_middle`]...), only the anatomy around them is new. -use crate::*; use crate::ui::type_scale::{self, head, label, mono}; +use crate::*; use gpui::FontWeight; /// Where the dock tab pick lives: one word beside the theme and the @@ -79,7 +79,12 @@ pub(crate) enum DockSort { } impl DockSort { - const ALL: [DockSort; 4] = [DockSort::Recent, DockSort::Name, DockSort::Usage, DockSort::Unused]; + const ALL: [DockSort; 4] = [ + DockSort::Recent, + DockSort::Name, + DockSort::Usage, + DockSort::Unused, + ]; fn label(self) -> &'static str { match self { DockSort::Recent => "Recent", @@ -156,7 +161,12 @@ fn ghost_verb( /// DESIGN §11's frequency check puts a lift and a mark far ahead of a tab /// switch -- wearing a chord this room does not answer to would be exactly /// the lie DESIGN §4 forbids, so the letters go instead. -fn dock_tab(id: &'static str, label_text: &'static str, active: bool, cx: &mut Context) -> impl IntoElement { +fn dock_tab( + id: &'static str, + label_text: &'static str, + active: bool, + cx: &mut Context, +) -> impl IntoElement { let style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM); div() .id(id) @@ -183,7 +193,7 @@ fn dock_tab(id: &'static str, label_text: &'static str, active: bool, cx: &mut C ) } -/// A 9px uppercase Archivo section head, `ink3` (DESIGN §3). +/// A 12px uppercase Archivo section head, `ink3` (DESIGN §3). fn section_head(text: impl Into) -> impl IntoElement { let style = head(); div() @@ -206,11 +216,20 @@ fn usage_line(player: &Player, source_idx: usize, placed: usize) -> String { session .lanes() .into_iter() - .filter(|lane| session.lane_clips(*lane).iter().any(|c| c.source == source_idx)) + .filter(|lane| { + session + .lane_clips(*lane) + .iter() + .any(|c| c.source == source_idx) + }) .map(Lane::label) .collect() }); - format!("{} · {placed} use{}", lanes.join(" "), if placed == 1 { "" } else { "s" }) + format!( + "{} · {placed} use{}", + lanes.join(" "), + if placed == 1 { "" } else { "s" } + ) } /// 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 { /// 2, wired in `render.rs`'s key handler since a row takes no keyboard focus /// of its own), double-click (gesture 3) and right-click the dot (gesture 4) /// all live here. -fn source_row(player: &Player, i: usize, row: &Row, placed: usize, picked: bool, cx: &mut Context) -> impl IntoElement { +fn source_row( + player: &Player, + i: usize, + row: &Row, + placed: usize, + picked: bool, + cx: &mut Context, +) -> impl IntoElement { let usable = row.unusable.is_none(); let name: SharedString = row.name.clone().into(); let under: String = match &row.unusable { Some(why) => why.clone(), - None => join_detail(&row.detail, &timecode(f64::from(row.frames) / player.fps, player.fps)), + None => join_detail( + &row.detail, + &timecode(f64::from(row.frames) / player.fps, player.fps), + ), }; let usage = usage_line(player, row.tint, placed); 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, /// Media/Audio/Text panel `library.rs` draws. That panel's row facts /// ([`library_rows`]) are still what every row here is built from. fn sources_tab(player: &Player, cx: &mut Context) -> impl IntoElement { - let sources = player.session.as_ref().map_or(&[][..], PlaybackSession::sources); + let sources = player + .session + .as_ref() + .map_or(&[][..], PlaybackSession::sources); let meta = player.session.as_ref().map(PlaybackSession::meta); - let all_rows: Vec = library_rows(sources, &player.streams, &player.decoders, player.timeline_audio(), |path| { - player.session.as_ref().map_or(0, |session| session.file_frames(path)) - }); + let all_rows: Vec = library_rows( + sources, + &player.streams, + &player.decoders, + player.timeline_audio(), + |path| { + player + .session + .as_ref() + .map_or(0, |session| session.file_frames(path)) + }, + ); let _ = meta; let unused_count = all_rows .iter() @@ -380,7 +421,9 @@ fn sources_tab(player: &Player, cx: &mut Context) -> impl IntoElement { .collect(); match player.dock_sort { DockSort::Recent => {} - DockSort::Name => rows.sort_by(|(a, _), (b, _)| a.name.to_lowercase().cmp(&b.name.to_lowercase())), + DockSort::Name => { + rows.sort_by(|(a, _), (b, _)| a.name.to_lowercase().cmp(&b.name.to_lowercase())) + } DockSort::Usage => rows.sort_by(|(_, a), (_, b)| b.cmp(a)), DockSort::Unused => rows.sort_by_key(|(_, placed)| *placed > 0), } @@ -395,7 +438,9 @@ fn sources_tab(player: &Player, cx: &mut Context) -> impl IntoElement { .gap(px(6.)) .p(px(8.)) .overflow_y_scroll() - .child(section_head(format!("SOURCES · {total} · {unused_count} UNUSED"))) + .child(section_head(format!( + "SOURCES · {total} · {unused_count} UNUSED" + ))) .child({ let style = mono(type_scale::CHORD_METADATA_MAX_PX, FontWeight::MEDIUM); div() @@ -404,7 +449,11 @@ fn sources_tab(player: &Player, cx: &mut Context) -> impl IntoElement { .cursor_text() .font(style.font) .text_size(style.size) - .text_color(rgb(if player.dock_filter_edit { INK1() } else { INK3() })) + .text_color(rgb(if player.dock_filter_edit { + INK1() + } else { + INK3() + })) .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { this.dock_filter_edit = true; cx.notify(); @@ -421,7 +470,7 @@ fn sources_tab(player: &Player, cx: &mut Context) -> impl IntoElement { .gap(px(4.)) .children(DockSort::ALL.map(|sort| { let on = sort == player.dock_sort; - let style = label(9.5, FontWeight::MEDIUM); + let style = label(type_scale::FLOOR_PX, FontWeight::MEDIUM); div() .id(("dock-sort", sort as usize)) .flex_none() @@ -458,7 +507,8 @@ fn sources_tab(player: &Player, cx: &mut Context) -> impl IntoElement { .text_size(style.size) .text_color(rgb(INK3())) .child(match player.dock_filter.is_empty() { - true => "No sources yet — Add files, or drop one on the window".to_string(), + true => "No sources yet — Add files, or drop one on the window" + .to_string(), false => "nothing matches the filter".to_string(), }), ) @@ -468,7 +518,10 @@ fn sources_tab(player: &Player, cx: &mut Context) -> impl IntoElement { .iter() .enumerate() .map(|(i, (row, placed))| { - let picked = player.selected_asset.as_ref().is_some_and(|p| *p == (row.path.clone(), row.stream)); + let picked = player + .selected_asset + .as_ref() + .is_some_and(|p| *p == (row.path.clone(), row.stream)); source_row(player, i, row, *placed, picked, cx).into_any_element() }) .collect(); @@ -501,11 +554,9 @@ fn sources_tab(player: &Player, cx: &mut Context) -> impl IntoElement { )), ) .child({ - // FAULT 2: metadata, not a row -- DESIGN §3's 9.5-10px band via - // the named constant (a bespoke 9px literal was neither the - // metadata size nor any other named role), and the quietest text - // in the dock: ink3, tight leading so it never competes with the - // 10.5px source rows above it. + // Metadata, not a row: DESIGN §3's metadata role, and the quietest + // text in the dock: ink3, tight leading so it never competes with + // the source rows above it. let style = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM); div() .flex_none() @@ -524,7 +575,12 @@ fn sources_tab(player: &Player, cx: &mut Context) -> impl IntoElement { /// these onto. Drag-while-playing and every other gesture on a row is /// whatever that card already does; nothing about the gesture is reimplemented /// here. -fn clip_tab(player: &Player, width: f32, window_size: Size, cx: &mut Context) -> impl IntoElement { +fn clip_tab( + player: &Player, + width: f32, + window_size: Size, + cx: &mut Context, +) -> impl IntoElement { // The room actually given here, not the window's: `eq_card_w`/ // `card_max_w` are asked "how wide may I draw" and answered with the // *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, cx: &mut Con /// pair). What degrades *inside* fixed width is the two tabs' own content: /// Sources scrolls its own row list; Clip's param rows are whatever their /// card already draws at this width. -pub(crate) fn render(player: &Player, width: f32, window_size: Size, cx: &mut Context) -> impl IntoElement { +pub(crate) fn render( + player: &Player, + width: f32, + window_size: Size, + cx: &mut Context, +) -> impl IntoElement { let src_active = player.dock_src_active; div() .id("stance-dock-body") diff --git a/crates/app/src/ui/spine_stance.rs b/crates/app/src/ui/spine_stance.rs index bab11f7..06cb66a 100644 --- a/crates/app/src/ui/spine_stance.rs +++ b/crates/app/src/ui/spine_stance.rs @@ -4,17 +4,13 @@ //! drew. `stance.rs::spine()` keeps the panel frame (width, surface, //! border); this module owns the rows inside it. -use crate::*; use crate::ui::type_scale::{self, Typeset}; +use crate::*; -/// The glyph icon itself: DESIGN §3 names no separate role for it, so this -/// keeps the size the module has always drawn it at (13px, the same number -/// as the hero timecode by coincidence, not by role) and routes only the -/// font family through [`type_scale`] (Archivo -- the glyph is a verb, the -/// room's voice, not something the film says). -const GLYPH_SIZE: f32 = 13.; +/// The glyph icon is a room verb, so it uses the label role rather than a +/// bespoke size: Archivo at `LABEL_ROW_PX`. -/// A group head: 9px uppercase Archivo 700 in `ink3`, +0.14em tracking +/// A group head: uppercase Archivo 700 in `ink3`, +0.14em tracking /// (DESIGN §3) -- reused as its own small fn rather than `stance::section_head` /// because that one is private to its module and carries a different /// vertical rhythm (a region label, not a spine group head). @@ -79,16 +75,21 @@ fn glyph( .when(on, |d| { d.cursor_pointer() .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) - .on_click(cx.listener(move |this, _: &ClickEvent, window, cx| { - this.act(action, window, cx) - })) + .on_click( + cx.listener(move |this, _: &ClickEvent, window, cx| { + this.act(action, window, cx) + }), + ) }) .child( div() .line_height(relative(1.05)) // FAULT 1: the glyph is the loudest thing in its row -- BOLD, // not the MEDIUM weight the chord beneath it also wears. - .type_style(type_scale::label(GLYPH_SIZE, gpui::FontWeight::BOLD)) + .type_style(type_scale::label( + type_scale::LABEL_ROW_PX, + gpui::FontWeight::BOLD, + )) .text_color(rgb(if active { INK1() } else if quiet { @@ -143,7 +144,10 @@ fn trim_control(active: bool, player: &Player, cx: &mut Context) -> impl .child( div() .line_height(relative(1.05)) - .type_style(type_scale::label(GLYPH_SIZE, gpui::FontWeight::BOLD)) + .type_style(type_scale::label( + type_scale::LABEL_ROW_PX, + gpui::FontWeight::BOLD, + )) .text_color(rgb(if active { INK1() } else { INK2() })) .child(txt), ) @@ -222,8 +226,24 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem .gap(px(1.)) .overflow_y_scroll() .child(group_head("edit")) - .child(glyph("spine-split", "||", ActionId::Cut, false, false, player, cx)) - .child(glyph("spine-delete", "⊂⊃", ActionId::Delete, false, false, player, cx)) + .child(glyph( + "spine-split", + "||", + ActionId::Cut, + false, + false, + player, + cx, + )) + .child(glyph( + "spine-delete", + "⊂⊃", + ActionId::Delete, + false, + false, + player, + cx, + )) .child(pair( glyph("spine-undo", "↺", ActionId::Undo, false, false, player, cx), // Redo had a legacy toolbar button (`toolbar.rs:347`) but no @@ -234,8 +254,24 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem )) .child(group_head("cut")) .child(pair( - glyph("spine-cut-prev", "‹", ActionId::WalkCutPrev, false, false, player, cx), - glyph("spine-cut-next", "›", ActionId::WalkCutNext, false, false, player, cx), + glyph( + "spine-cut-prev", + "‹", + ActionId::WalkCutPrev, + false, + false, + player, + cx, + ), + glyph( + "spine-cut-next", + "›", + ActionId::WalkCutNext, + false, + false, + player, + cx, + ), )) .child(trim_control(player.loop_trim.is_some(), player, cx)) .child(glyph( @@ -271,13 +307,53 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem // less than walking/trimming cuts above it. .child(group_head("view")) .child(pair( - glyph("spine-zoom-out", "−", ActionId::ZoomOut, false, false, player, cx), - glyph("spine-zoom-in", "+", ActionId::ZoomIn, false, false, player, cx), + glyph( + "spine-zoom-out", + "−", + ActionId::ZoomOut, + false, + false, + player, + cx, + ), + glyph( + "spine-zoom-in", + "+", + ActionId::ZoomIn, + false, + false, + player, + cx, + ), + )) + .child(glyph( + "spine-zoom-fit", + "⊡", + ActionId::ZoomFit, + false, + false, + player, + cx, )) - .child(glyph("spine-zoom-fit", "⊡", ActionId::ZoomFit, false, false, player, cx)) .child(group_head("track")) - .child(glyph("spine-add-video", "+V", ActionId::AddVideoLane, false, false, player, cx)) - .child(glyph("spine-add-audio", "+A", ActionId::AddAudioLane, false, false, player, cx)) + .child(glyph( + "spine-add-video", + "+V", + ActionId::AddVideoLane, + false, + false, + player, + cx, + )) + .child(glyph( + "spine-add-audio", + "+A", + ActionId::AddAudioLane, + false, + false, + player, + cx, + )) // The subtitle trio (homeless per this task's audit): AddSubtitleLane // joins +V/+A on the same "+letter" grammar per this task's own // instruction ("+S joins +V/+A in TRACK"); remove/import are "the @@ -291,12 +367,44 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem // ROOM cluster below: cue visibility is judged shot to shot, closer // in frequency to a view toggle used often than to a once-a-session // preference. - .child(glyph("spine-add-subtitle", "+S", ActionId::AddSubtitleLane, false, false, player, cx)) + .child(glyph( + "spine-add-subtitle", + "+S", + ActionId::AddSubtitleLane, + false, + false, + player, + cx, + )) .child(pair( - glyph("spine-remove-subtitle", "−S", ActionId::RemoveSubtitleLane, false, false, player, cx), - glyph("spine-import-subtitles", "↓S", ActionId::ImportSubtitles, false, false, player, cx), + glyph( + "spine-remove-subtitle", + "−S", + ActionId::RemoveSubtitleLane, + false, + false, + player, + cx, + ), + glyph( + "spine-import-subtitles", + "↓S", + ActionId::ImportSubtitles, + false, + false, + player, + cx, + ), + )) + .child(glyph( + "spine-toggle-subtitles", + "CC", + ActionId::ToggleSubtitles, + player.subs_on, + false, + player, + cx, )) - .child(glyph("spine-toggle-subtitles", "CC", ActionId::ToggleSubtitles, player.subs_on, false, player, cx)) // ROOM: the once-a-session/once-a-project acts this task's charter // names explicitly (theme, proxies, screenshot, fullscreen) -- ink- // 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) -> impl IntoElem .child(group_head("room")) .child(pair( glyph("spine-theme", "H", ActionId::Theme, false, true, player, cx), - glyph("spine-proxies", "P", ActionId::ToggleProxies, player.proxies_on, true, player, cx), + glyph( + "spine-proxies", + "P", + ActionId::ToggleProxies, + player.proxies_on, + true, + player, + cx, + ), )) .child(pair( - glyph("spine-auto-proxies", "AP", ActionId::ToggleAutoProxies, player.auto_proxies_on, true, player, cx), - glyph("spine-fullscreen", "FS", ActionId::Fullscreen, false, true, player, cx), + glyph( + "spine-auto-proxies", + "AP", + ActionId::ToggleAutoProxies, + player.auto_proxies_on, + true, + player, + cx, + ), + glyph( + "spine-fullscreen", + "FS", + ActionId::Fullscreen, + false, + true, + player, + cx, + ), + )) + .child(glyph( + "spine-screenshot", + "Sh", + ActionId::Screenshot, + false, + true, + player, + cx, )) - .child(glyph("spine-screenshot", "Sh", ActionId::Screenshot, false, true, player, cx)) // The settings page's own visible door (user complaint: "some // options are only reachable via keyboard shortcut") -- a chord // alone is a defect class this room has hit repeatedly, so this // glyph sits beside the other once-a-session ROOM acts even though // its chord (`^,`) is a preference, not a mnemonic. - .child(glyph("spine-settings", "St", ActionId::Settings, player.settings_open, true, player, cx)) + .child(glyph( + "spine-settings", + "St", + ActionId::Settings, + player.settings_open, + true, + player, + cx, + )) .child(div().flex_1()) } diff --git a/crates/app/src/ui/stance.rs b/crates/app/src/ui/stance.rs index 4d9ed30..c241a87 100644 --- a/crates/app/src/ui/stance.rs +++ b/crates/app/src/ui/stance.rs @@ -8,13 +8,13 @@ //! interaction, no cut machinery -- `// hook:` comments below mark where the //! later steps in DESIGN §12's package attach. -use crate::*; use crate::ui::bench_stance; use crate::ui::dock_stance; use crate::ui::settings_stance; -use crate::ui::timeband_stance; use crate::ui::spine_stance; +use crate::ui::timeband_stance; use crate::ui::type_scale::{self, Typeset}; +use crate::*; /// Left rail, full height (DESIGN §5). const SPINE_W: f32 = 56.; @@ -39,16 +39,13 @@ pub(crate) const DOCK_W: f32 = 280.; /// What [`bench`] spends above `bench_stance::render`'s own content: the /// `bench` div's own `.border_t_1()` (1px) + its `py(4.)` top padding + /// the section head's real line box -- `type_scale::head()` sizes text at -/// `SECTION_HEAD_PX` (10) but never calls `.line_height()`, so gpui's +/// `SECTION_HEAD_PX` (12) but never calls `.line_height()`, so gpui's /// default `TextStyle::line_height` (the golden ratio, `gpui::phi()` == /// `1.618034`, not 1x the font size) is what it actually draws: -/// `round(10. * 1.618034)` = `round(16.18034)` = `16`. A driven pass found -/// this constant undercounting that line box as a bare `10`, one of the two -/// causes of `layout::BENCH_MIN_H`'s third clip (see its own doc comment for -/// the other). `1 + 4 + 16` = `21`. Named and `pub(crate)` rather than the -/// `- 20.` it used to be inlined as, so `layout::BENCH_MIN_H` can add it -/// into its own derivation instead of guessing it back out. -pub(crate) const BENCH_CHROME_H: f32 = 21.; +/// `round(12. * 1.618034)` = `round(19.416408)` = `19`. +/// `1 + 4 + 19` = `24`. Named and `pub(crate)` rather than an inline +/// subtraction, so `layout::BENCH_MIN_H` can derive from the real chrome. +pub(crate) const BENCH_CHROME_H: f32 = 24.; /// The lowest a menu's top edge may sit and still land inside the /// bench/ledger/dock footprint below the screen (DESIGN §5, §9, §11 check 6): @@ -136,7 +133,10 @@ mod menu_floor_tests { let list_h = (396f32).min(f32::from(room.height)); assert!(list_h <= f32::from(room.height)); let (_, y) = crate::oracle::menu_at(at, viewport, list_h); - assert_eq!(y, floor, "the top edge must not be walked back above the floor"); + assert_eq!( + y, floor, + "the top edge must not be walked back above the floor" + ); } } @@ -196,7 +196,11 @@ thread_local! { /// reimplemented here. Split out from `picture_scale` so this arithmetic has /// a runnable check with no `Player`/window to stand up. fn fit_scale(bounds: Bounds, native: gpui::Size) -> Option { - if bounds.size.width <= px(0.) || bounds.size.height <= px(0.) || native.width.0 <= 0 || native.height.0 <= 0 { + if bounds.size.width <= px(0.) + || bounds.size.height <= px(0.) + || native.width.0 <= 0 + || native.height.0 <= 0 + { return None; } let fitted = gpui::ObjectFit::Contain.get_bounds(bounds, native); @@ -269,7 +273,7 @@ fn scale_plate(player: &Player) -> impl IntoElement { .child(div().text_color(rgb(INK1())).child(value)) } -/// A section head: 9px, uppercase, `ink3` -- DESIGN §3's scale for the label +/// A section head, uppercase, `ink3` -- DESIGN §3's scale for the label /// that names a region before anything else lives in it. fn section_head(label: &str) -> impl IntoElement { div() @@ -291,7 +295,10 @@ fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement { .gap(px(2.)) .py(px(6.)) .rounded(px(3.)) - .type_style(type_scale::label(13., gpui::FontWeight::MEDIUM)) + .type_style(type_scale::label( + type_scale::LABEL_ROW_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(INK2())) .child(glyph.to_string()) .child( @@ -352,43 +359,16 @@ fn keys_overlay(player: &Player) -> impl IntoElement { .flex_col() .gap(px(3.)) .child(section_head("all commands · hold ? · release to close")) - .children(keys_rows().into_iter().map(|row| match row { - KeyRow::Head(category) => div() - .flex_none() - .pt(px(4.)) - .type_style(type_scale::head()) - .text_color(rgb(INK3())) - .child(category.label().to_uppercase()) - .into_any_element(), - KeyRow::Act(action) => div() - .flex() - .justify_between() - .gap(px(12.)) - .child( - div() - .type_style(type_scale::label( - type_scale::CHORD_METADATA_MIN_PX, - gpui::FontWeight::MEDIUM, - )) - .text_color(rgb(INK2())) - .child(action.label()), - ) - .child( - div() - .type_style(type_scale::mono( - type_scale::CHORD_METADATA_MIN_PX, - gpui::FontWeight::MEDIUM, - )) - .text_color(rgb(INK3())) - // The keys overlay is the full-truth surface - // (FAULT 1): every chord an action answers to, - // not the badge's primary-only compact form. - .child(player.keymap.display(action)), - ) - .into_any_element(), - KeyRow::Fixed(i) => { - let f = &keymap::FIXED[i]; - div() + .children(keys_rows().into_iter().map(|row| { + match row { + KeyRow::Head(category) => div() + .flex_none() + .pt(px(4.)) + .type_style(type_scale::head()) + .text_color(rgb(INK3())) + .child(category.label().to_uppercase()) + .into_any_element(), + KeyRow::Act(action) => div() .flex() .justify_between() .gap(px(12.)) @@ -399,7 +379,7 @@ fn keys_overlay(player: &Player) -> impl IntoElement { gpui::FontWeight::MEDIUM, )) .text_color(rgb(INK2())) - .child(f.label), + .child(action.label()), ) .child( div() @@ -408,9 +388,38 @@ fn keys_overlay(player: &Player) -> impl IntoElement { gpui::FontWeight::MEDIUM, )) .text_color(rgb(INK3())) - .child(f.chord.clone()), + // The keys overlay is the full-truth surface + // (FAULT 1): every chord an action answers to, + // not the badge's primary-only compact form. + .child(player.keymap.display(action)), ) - .into_any_element() + .into_any_element(), + KeyRow::Fixed(i) => { + let f = &keymap::FIXED[i]; + div() + .flex() + .justify_between() + .gap(px(12.)) + .child( + div() + .type_style(type_scale::label( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + )) + .text_color(rgb(INK2())) + .child(f.label), + ) + .child( + div() + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + )) + .text_color(rgb(INK3())) + .child(f.chord.clone()), + ) + .into_any_element() + } } })), ) @@ -447,7 +456,12 @@ fn spine(player: &Player, cx: &mut Context) -> impl IntoElement { /// the two-up OUT|IN judging *below* it as a flex sibling (DESIGN §6) rather /// than layering plates over it: the picture's own `flex_1` shrinks to make /// room, so every picture pixel that is drawn stays visible. -fn screen(player: &mut Player, position: f64, window: &mut Window, cx: &mut Context) -> impl IntoElement { +fn screen( + player: &mut Player, + position: f64, + window: &mut Window, + cx: &mut Context, +) -> impl IntoElement { let two_up = player.two_up().map(IntoElement::into_any_element); div() .id("stance-screen") @@ -615,7 +629,10 @@ fn notice_plate(message: SharedString, bench_h: f32) -> impl IntoElement { // shape as the legacy notice bar's own tone stripe (`notice_bar`). .border_l(px(3.)) .border_color(rgb(notice_severity(&message))) - .type_style(type_scale::label(10., gpui::FontWeight::MEDIUM)) + .type_style(type_scale::label( + type_scale::LABEL_ROW_PX, + gpui::FontWeight::MEDIUM, + )) .text_color(rgb(INK1())) .child(message) } @@ -627,7 +644,14 @@ fn ledger(player: &Player, position: f64) -> impl IntoElement { true => "untitled".to_string(), false => file_name(&player.project_path), }; - let identity = format!("{name} · {}", if player.autosave_dirty { "unsaved" } else { "saved" }); + let identity = format!( + "{name} · {}", + if player.autosave_dirty { + "unsaved" + } else { + "saved" + } + ); let last_action = player.notices.back().cloned().unwrap_or_else(|| "—".into()); let export = player .exporting() @@ -698,7 +722,12 @@ fn ledger(player: &Player, position: f64) -> impl IntoElement { /// "ui fields are not stretchable" for the dock. `window_size` is threaded /// through so the maximize-in-place cards inside the dock (`dock_stance.rs`) /// see the real viewport rather than a fabricated `size(px(DOCK_W), h)`. -fn dock(player: &Player, dock_w: f32, window_size: Size, cx: &mut Context) -> impl IntoElement { +fn dock( + player: &Player, + dock_w: f32, + window_size: Size, + cx: &mut Context, +) -> impl IntoElement { div() .id("stance-dock") .flex_none() @@ -945,7 +974,9 @@ pub(crate) fn render( el.child(notice_plate(n, bench_h)) }) .when(player.keys_open, |el| el.child(keys_overlay(player))) - .when(player.settings_open, |el| el.child(settings_stance::render(player, cx))) + .when(player.settings_open, |el| { + el.child(settings_stance::render(player, cx)) + }) // The two menus (DESIGN §9: "verbs of the thing under the // cursor", plate styling, the same scrim-and-row component // the legacy tree already uses -- `library.rs`'s own doc diff --git a/crates/app/src/ui/timeband_stance.rs b/crates/app/src/ui/timeband_stance.rs index dbf448d..3687c9e 100644 --- a/crates/app/src/ui/timeband_stance.rs +++ b/crates/app/src/ui/timeband_stance.rs @@ -4,12 +4,9 @@ //! the strip; this module owns what fills it, the same split //! `dock_stance.rs`/`bench_stance.rs` already make for their regions. //! -//! Type note: DESIGN.md §3 says the hero timecode is 13px; the approved mock -//! (MOCK-SPEC.md) reads closer to ~20px. Kept at 13px here -- the binding -//! contract's own number, already what `stance.rs::time_band()` shipped -- -//! rather than silently picking the mock's, and named here per this task's -//! own instruction to say so when the two disagree. Every size in this -//! module now comes from `ui::type_scale` (role, not a bare `px()` literal). +//! Type note: DESIGN.md §3's approved scale gives the hero timecode 18px, +//! close to the mock's ~20px reading. Every size in this module comes from +//! `ui::type_scale` (role, not a bare `px()` literal). use crate::*; use crate::ui::type_scale::{self, label, mono}; @@ -28,7 +25,7 @@ thread_local! { } /// A stacked ghost command (DESIGN §4, MOCK-SPEC "Ghost transport"/"spine"): -/// glyph ~13px `ink2` over its chord ~9.5px `ink3`, read live off the keymap +/// glyph 18px `ink2` over its chord 13px `ink3`, read live off the keymap /// so a rebind can never leave the band showing a stroke that no longer /// fires it -- the same shape `stance::ghost` draws for the spine, kept local /// here so this module owns its own region end to end. diff --git a/crates/app/src/ui/type_scale.rs b/crates/app/src/ui/type_scale.rs index 169a6c8..594c083 100644 --- a/crates/app/src/ui/type_scale.rs +++ b/crates/app/src/ui/type_scale.rs @@ -37,20 +37,15 @@ pub const SPLINE_SANS_MONO: &str = "Spline Sans Mono"; /// DESIGN §3's scale, named so a call site reads the role, not a number. /// -/// Landed at a conservative +2px bump over the original half-pixel scale -/// (13/10.5/10-9.5/9/8 -> 15/13/12-11/10/9), chosen over a fuller -/// "readable at arm's length" candidate (18/15/14-13/12/10) to keep the -/// fixed-width dock/bench card labels clear of the truncation ladder -/// (DESIGN §7). To try the fuller scale, swap these six values for -/// 18./15./14./13./12./10. and update `the_scale_matches_design_3` (and -/// DESIGN.md §3) to match. -pub const HERO_TIMECODE_PX: f32 = 15.; -pub const LABEL_ROW_PX: f32 = 13.; -pub const CHORD_METADATA_MAX_PX: f32 = 12.; -pub const CHORD_METADATA_MIN_PX: f32 = 11.; -pub const SECTION_HEAD_PX: f32 = 10.; +/// The approved readable-at-arm's-length scale. Each role is a whole pixel: +/// fractional baselines blur cosmic-text's greyscale AA. +pub const HERO_TIMECODE_PX: f32 = 18.; +pub const LABEL_ROW_PX: f32 = 15.; +pub const CHORD_METADATA_MAX_PX: f32 = 14.; +pub const CHORD_METADATA_MIN_PX: f32 = 13.; +pub const SECTION_HEAD_PX: f32 = 12.; /// The floor DESIGN §3 sets: nothing in the room reads smaller than this. -pub const FLOOR_PX: f32 = 9.; +pub const FLOOR_PX: f32 = 10.; /// A family, weight and size together -- what a call site needs to paint /// text with `.font(style.font).text_size(style.size)`, and nothing it has @@ -90,7 +85,10 @@ impl WithWeight for Font { /// Archivo, at the given size and weight -- labels, verbs, section heads. /// No italics anywhere in the room (DESIGN §3), so this never offers one. pub fn label(size_px: f32, weight: FontWeight) -> TypeStyle { - debug_assert!(size_px >= FLOOR_PX, "below DESIGN §3's 8px floor: {size_px}"); + debug_assert!( + size_px >= FLOOR_PX, + "below DESIGN §3's 10px floor: {size_px}" + ); TypeStyle { font: family_font(ARCHIVO, weight, false), size: px(size_px), @@ -100,14 +98,17 @@ pub fn label(size_px: f32, weight: FontWeight) -> TypeStyle { /// Spline Sans Mono, at the given size and weight, tabular figures on -- /// everything the film says. pub fn mono(size_px: f32, weight: FontWeight) -> TypeStyle { - debug_assert!(size_px >= FLOOR_PX, "below DESIGN §3's 8px floor: {size_px}"); + debug_assert!( + size_px >= FLOOR_PX, + "below DESIGN §3's 10px floor: {size_px}" + ); TypeStyle { font: family_font(SPLINE_SANS_MONO, weight, true), size: px(size_px), } } -/// A 9px Archivo 700 section head, `ink3`. The caller still has to uppercase +/// A 12px Archivo 700 section head, `ink3`. The caller still has to uppercase /// its own text (`.to_uppercase()`) and paint `ink3` -- this module only /// owns type, not colour, and stays out of `ui::theme`'s door. /// @@ -122,7 +123,7 @@ pub fn head() -> TypeStyle { } /// Applies a [`TypeStyle`] to any styled element in one call -- -/// `div().type_style(mono(9.5, FontWeight::MEDIUM))` instead of the +/// `div().type_style(mono(CHORD_METADATA_MIN_PX, FontWeight::MEDIUM))` instead of the /// `.font(style.font).text_size(style.size)` pair spelled out at every call /// site. Blanket-implemented over `Styled` so every element in the room gets /// it for free. @@ -168,8 +169,10 @@ const EMBEDDED: &[(&[u8], &str)] = &[ /// runtime one -- these bytes are fixed at compile time -- so it panics /// rather than falling silently back to a system face DESIGN §3 forbids. pub fn register(cx: &App) { - let fonts: Vec> = - EMBEDDED.iter().map(|(bytes, _)| Cow::Borrowed(*bytes)).collect(); + let fonts: Vec> = EMBEDDED + .iter() + .map(|(bytes, _)| Cow::Borrowed(*bytes)) + .collect(); cx.text_system() .add_fonts(fonts) .expect("bundled Archivo / Spline Sans Mono TTFs failed to register"); @@ -181,7 +184,7 @@ mod tests { use gpui::FontStyle; /// The scale never drifts below DESIGN §3's floor, and role sizes match - /// the numbers §3 names -- a call site changing `15.` to `14.` for the + /// the numbers §3 names -- a call site changing `18.` to `17.` for the /// hero timecode is the design contract silently moving. /// /// Sizes are all whole pixels (raised from the original 13/10.5/9.5-10/9/8 @@ -192,11 +195,12 @@ mod tests { /// back into this scale. #[test] fn the_scale_matches_design_3() { - assert_eq!(HERO_TIMECODE_PX, 15.); - assert_eq!(LABEL_ROW_PX, 13.); - assert!((11. ..=12.).contains(&CHORD_METADATA_MIN_PX)); - assert_eq!(SECTION_HEAD_PX, 10.); - assert_eq!(FLOOR_PX, 9.); + assert_eq!(HERO_TIMECODE_PX, 18.); + assert_eq!(LABEL_ROW_PX, 15.); + assert_eq!(CHORD_METADATA_MAX_PX, 14.); + assert_eq!(CHORD_METADATA_MIN_PX, 13.); + assert_eq!(SECTION_HEAD_PX, 12.); + assert_eq!(FLOOR_PX, 10.); for size in [ HERO_TIMECODE_PX, LABEL_ROW_PX,