diff --git a/crates/app/src/audio_cards.rs b/crates/app/src/audio_cards.rs index 534abff..daf7f66 100644 --- a/crates/app/src/audio_cards.rs +++ b/crates/app/src/audio_cards.rs @@ -119,6 +119,21 @@ pub(crate) const EQ_FREQ_HIGH: f32 = 20_000.; /// and short enough that the card still fits a 360 px window. pub(crate) const EQ_GRAPH_H: f32 = 132.; +/// The curve box maximized: 1 dB and a semitone-ish band of frequency both +/// read as more pixels than the docked floor spends on them -- the same +/// curve, the same ±12 dB axis and the same 20 Hz-20 kHz sweep, just spread +/// over more of the vertical resolution a maximized card borrows from the +/// bench/ledger rows below the picture ([`crate::ui::stance::below_picture_floor`]). +pub(crate) const EQ_GRAPH_MAX_H: f32 = 320.; + +/// The graph's own height for the card's current size: the docked floor, or +/// the maximized card's own taller box -- never a CSS scale of the same +/// pixels, an actually taller curve with more room per decibel and per +/// decade. +pub(crate) fn eq_graph_h(maximized: bool) -> f32 { + if maximized { EQ_GRAPH_MAX_H } else { EQ_GRAPH_H } +} + /// How wide the equalizer card is allowed to get. It is the one card that is a /// *graph*: every pixel across is frequency resolution, and at the 320 px the /// other cards use, a third of an octave was a couple of pixels. Past this the @@ -173,6 +188,65 @@ pub(crate) const EQ_TICKS: [(f32, &str); 5] = [ /// named at the corners instead. pub(crate) const EQ_DB_GRID: [f32; 2] = [6., -6.]; +/// How wide an end tick's own label box has to be so "20 Hz" reads as one +/// line rather than wrapping onto two ("20" over "Hz") -- driven live and +/// found doing exactly that at a fixed 24 px box once the end ticks were +/// anchored to the graph's edge instead of centred on it (the anchor alone +/// was not the whole fix). Sized off the label's own character count at the +/// size it is actually drawn, using the list-truncation ladder's already +/// -calibrated characters-to-pixels ratio ([`crate::layout::LIST_CHAR_W`] at +/// [`crate::ui::type_scale::CHORD_METADATA_MIN_PX`]) rather than a second +/// magic pixel count -- so a future type-scale bump (this one already moved +/// once this session) widens the box along with the text instead of +/// re-wrapping it. +pub(crate) fn eq_tick_end_w(label: &str, text_px: f32) -> f32 { + label.chars().count() as f32 * crate::layout::LIST_CHAR_W + / crate::ui::type_scale::CHORD_METADATA_MIN_PX + * text_px +} + +#[cfg(test)] +mod eq_graph_maximize_tests { + use super::*; + + /// D2's regression class: the maximized card revealed LESS than docked + /// at the same bench, because the graph claimed a fixed slice (a flat + /// `EQ_GRAPH_MAX_H`) that left nothing for the rows below it, forcing a + /// scroll docked never needed at the same bench. This binary has no + /// `TestAppContext`, so it cannot read the flex layout gpui actually + /// paints back -- this is a value-level pin on the two numbers the fix + /// (`crates/app/src/ui/cards.rs`'s `graph_maximized` branch, `flex_1()` + /// between a floor and a ceiling rather than a fixed height) depends on, + /// not a substitute for driving a maximize at a small bench: the + /// maximized graph's floor must be the *same* constant docked draws its + /// fixed height at (so maximized can never show less graph than docked, + /// whatever room is left over for the graph to grow into), and that + /// floor must not exceed its own ceiling (an inverted `min_h`/`max_h` + /// clamp is a layout-time panic, not a compile-time one). + #[test] + fn maximized_graph_floor_matches_docked_and_never_exceeds_its_own_ceiling() { + assert_eq!(eq_graph_h(false), EQ_GRAPH_H, "docked height must be the floor maximized also uses"); + assert!(EQ_GRAPH_H <= EQ_GRAPH_MAX_H); + } +} + +#[cfg(test)] +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 + /// that box, and must grow, not shrink, if a future scale bump raises + /// the size fed in. + #[test] + fn wide_enough_for_the_widest_end_label_and_grows_with_the_type_scale() { + let dark_w = eq_tick_end_w("20 Hz", crate::ui::type_scale::CHORD_METADATA_MIN_PX); + assert!(dark_w > 24., "{dark_w} must clear the old fixed box"); + let bumped_w = eq_tick_end_w("20 Hz", crate::ui::type_scale::CHORD_METADATA_MIN_PX + 4.); + assert!(bumped_w > dark_w); + } +} + /// How many played samples one spectrum frame is transformed from. A power of /// two ([`fft`] is radix-2) and the whole of the engine's tap: 1024 at 48 kHz diff --git a/crates/app/src/library_meta.rs b/crates/app/src/library_meta.rs index 581b9dd..4ffa497 100644 --- a/crates/app/src/library_meta.rs +++ b/crates/app/src/library_meta.rs @@ -320,8 +320,28 @@ pub(crate) fn unusable(info: &StreamInfo, timeline_audio: Option<(u32, u16)>) -> /// thousand hertz on 320 px spends four pixels on the octave below middle C -- /// so it takes the room a big window has and stays inside a small one. Floored /// at the other cards' width, which is the last size the rows still read at. -pub(crate) fn eq_card_w(window_w: f32) -> f32 { - (window_w - EQ_W_MARGIN).clamp(KEYS_W, EQ_W_MAX) +pub(crate) fn eq_card_w(window_w: f32, maximized: bool) -> f32 { + let raw = window_w - EQ_W_MARGIN; + if maximized { + // Maximized drops the [`EQ_W_MAX`] ceiling: every pixel across is + // frequency resolution (the doc comment above), and a maximized card + // is asking for exactly the room a big window has to give it. + raw.max(KEYS_W) + } else { + raw.clamp(KEYS_W, EQ_W_MAX) + } +} + +/// How wide a non-EQ param card is drawn: its usual fixed width, or (when +/// maximized) all of the window bar the same margin the EQ card gives +/// itself -- never narrower than its own floor, so a small window's +/// maximize is a no-op rather than a shrink. +pub(crate) fn card_max_w(base_w: f32, maximized: bool, window_w: f32) -> f32 { + if maximized { + (window_w - EQ_W_MARGIN).max(base_w) + } else { + base_w + } } /// What the media list is given of the window. A share of it, so a narrow diff --git a/crates/app/src/main.rs b/crates/app/src/main.rs index 9787a67..a53dd70 100644 --- a/crates/app/src/main.rs +++ b/crates/app/src/main.rs @@ -576,6 +576,13 @@ struct Player { /// the card is modal: while it is up nothing else can move an index, and /// the one edit it makes (`set_eq`) moves none. eq_open: Option<(Lane, usize)>, + /// Whichever of the seven param cards is open, filling the room in place + /// of the bench/ledger rows instead of its usual capped, floating size + /// (`Player::toggle_maximize`). One flag, not one per card, because only + /// one of them is ever open at a time (`close_card`'s own rule) and it + /// outlives any one card's close/reopen, persisted like the dock tab pick + /// (`ui::dock_stance::load_maximized`/`save_maximized`). + card_maximized: bool, /// The curve the card is showing, which is the clip's own or the flat /// five-band default. Edited live and written at the clip once per gesture /// ([`Player::commit_eq`]): the project's equalizer table is append-only, so @@ -967,6 +974,7 @@ fn main() { export_refusals_inline: false, export_advanced_open: false, eq_open: None, + card_maximized: ui::dock_stance::load_maximized(), // Replaced by the clip's own curve the moment the card // opens; nothing reads it before that. eq_params: EqParams::default(), diff --git a/crates/app/src/player/cards.rs b/crates/app/src/player/cards.rs index 7429808..ee92a9a 100644 --- a/crates/app/src/player/cards.rs +++ b/crates/app/src/player/cards.rs @@ -1313,6 +1313,17 @@ impl Player { self.subtitle_style_open = false; } + /// The one switch every param card's expand affordance and its `m` + /// chord both flip (`dark_card_head`, [`Player::param_card_key`]): + /// whichever card is open trades its usual capped, floating size for the + /// bench/ledger rows' own room, in place -- layout only, no value on the + /// card changes. Persisted like the dock tab pick so a maximized EQ is + /// still maximized after the room closes and reopens. + pub(crate) fn toggle_maximize(&mut self) { + self.card_maximized = !self.card_maximized; + ui::dock_stance::save_maximized(self.card_maximized); + } + /// Opens the equalizer on the selected clip. Audio only, and it says so /// rather than opening a card of bands that would reach nothing: a video /// clip carries no sound of its own here (the sound is the audio lane's), @@ -1489,8 +1500,32 @@ impl Player { /// and ate the key, the caller's cue to `cx.notify()` and stop exactly /// where each of these branches used to `return` inline. pub(crate) fn param_card_key(&mut self, key: &str, shift: bool, cx: &mut Context) -> bool { + // The one chord every param card answers to, wherever the pointer + // toggle sits in `dark_card_head` -- mouse and key reach the same + // switch (DESIGN's repeated "some options are only reachable via + // keyboard shortcut" complaint). Checked once, ahead of the seven + // card-local branches below, because it means the same thing in all + // of them: none of the seven uses bare "m" for anything else. + if key == "m" + && (self.eq_open.is_some() + || self.color_open.is_some() + || self.transform_open.is_some() + || self.speed_open.is_some() + || self.silence_open.is_some() + || self.mix_open + || self.subtitle_style_open) + { + self.toggle_maximize(); + return true; + } if self.eq_open.is_some() { if key == ESCAPE { + // Maximized comes off before the card does -- "esc always + // retreats" one step at a time (DESIGN.md:146). + if self.card_maximized { + self.toggle_maximize(); + return true; + } // Nothing to undo: every change is already at the clip, and // undo is undo's own key. self.eq_open = None; @@ -1546,6 +1581,7 @@ impl Player { // menu still lists them. if self.color_open.is_some() { match color_key(key) { + Some(ColorKey::Close) if self.card_maximized => self.toggle_maximize(), Some(ColorKey::Close) => { self.color_open = None; self.color_dragging = false; @@ -1567,7 +1603,9 @@ impl Player { // the keys menu still lists them). if self.transform_open.is_some() { let n = TRANSFORM_BANDS.len(); - if key == ESCAPE { + if key == ESCAPE && self.card_maximized { + self.toggle_maximize(); + } else if key == ESCAPE { self.transform_open = None; self.transform_dragging = false; } else if key == "down" { @@ -1589,6 +1627,7 @@ impl Player { // menu still lists them). if self.speed_open.is_some() { match color_key(key) { + Some(ColorKey::Close) if self.card_maximized => self.toggle_maximize(), Some(ColorKey::Close) => { self.speed_open = None; self.speed_dragging = false; @@ -1609,7 +1648,9 @@ impl Player { // the keys menu (keymap.rs `FIXED`), because a key that cuts forty // places at once is not a secret. if self.silence_open.is_some() { - if key == ESCAPE { + if key == ESCAPE && self.card_maximized { + self.toggle_maximize(); + } else if key == ESCAPE { // Nothing to undo: a preview is not an edit. self.close_silence(); } else if key == "down" { @@ -1632,7 +1673,9 @@ impl Player { // it, held or pressed. Card-local like the four above it. if self.mix_open { let rows = self.mix_lanes().len() + MIX_MASTER_ROWS; - if key == ESCAPE { + if key == ESCAPE && self.card_maximized { + self.toggle_maximize(); + } else if key == ESCAPE { self.mix_open = false; } else if key == "down" { self.mix_field = (self.mix_field + 1) % rows; @@ -1655,7 +1698,9 @@ impl Player { // Row 0 is the size stepper, row 1 the platform default, and // every row after it a family in `subtitle_fonts`. let rows = 2 + self.subtitle_fonts.len(); - if key == ESCAPE { + if key == ESCAPE && self.card_maximized { + self.toggle_maximize(); + } else if key == ESCAPE { self.subtitle_style_open = false; } else if key == "down" { self.subtitle_style_field = (self.subtitle_style_field + 1) % rows; diff --git a/crates/app/src/tests/cards.rs b/crates/app/src/tests/cards.rs index cd36b4c..d0461aa 100644 --- a/crates/app/src/tests/cards.rs +++ b/crates/app/src/tests/cards.rs @@ -458,14 +458,14 @@ 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.) <= 640. - 24., "card too wide for 640"); - assert!(eq_card_w(1280.) > eq_card_w(640.), "card ignores the window"); - assert_eq!(eq_card_w(1920.), EQ_W_MAX, "card grows without end"); - assert!(eq_card_w(320.) >= KEYS_W, "card narrower than a row of text"); + 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"); // 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!( - eq_card_w(640.) - 24. >= 3. * EQ_GRAPH_H, + eq_card_w(640., false) - 24. >= 3. * EQ_GRAPH_H, "graph too square to aim at" ); @@ -1759,10 +1759,184 @@ fn a_cards_own_help_paints_while_the_card_is_open_but_the_ui_under_it_stays_quie // 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"); - let head_fn = &cards_src[head_fn_at..head_fn_at + 1200]; + // 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]; assert!( head_fn.contains("OverlayTip(h.clone())"), "dark_card_head's own `?` tooltip no longer builds an OverlayTip -- the \ card-head help is unreadable again while its card is open" ); } + +/// "Maximize a card in place" changes size only, never the relative +/// semantics a value is drawn against: `eq_x`/`eq_y` map into `0..1` of +/// whatever box they are given, so a wider/taller EQ card is genuinely more +/// dB/Hz resolution, not the same graph stretched. This is the layout half +/// of that claim -- `eq_x`/`eq_y` themselves take no size argument at all +/// (they answer in `0..1`), so there is nothing about them a maximize could +/// have broken; what a maximize is allowed to touch is `eq_card_w`/ +/// `eq_graph_h`'s own ceiling. +#[test] +fn maximizing_a_card_grows_its_box_without_moving_where_a_value_sits_in_it() { + // Below the old EQ_W_MAX ceiling, maximized and not agree -- there is + // room for both without the ceiling mattering yet. + assert_eq!(eq_card_w(600., false), eq_card_w(600., true)); + // Past it, only the maximized card keeps growing: the ceiling this + // session's fix drops. + assert!( + eq_card_w(1920., true) > eq_card_w(1920., false), + "maximized EQ card no longer drops the EQ_W_MAX ceiling" + ); + assert_eq!( + eq_graph_h(true), + EQ_GRAPH_MAX_H, + "maximized EQ graph no longer grows to EQ_GRAPH_MAX_H" + ); + assert!( + eq_graph_h(true) > eq_graph_h(false), + "maximized EQ graph is not actually taller than the resting one" + ); + // The mapping itself never sees "maximized" -- a bigger box is more + // resolution because the same 0..1 fraction now spans more pixels, not + // because the fraction itself moved. + assert_eq!(eq_x(1000.), eq_x(1000.)); + assert_eq!(eq_y(0.), eq_y(0.)); +} + +/// The regression the previous test could not see: `eq_card_w`/`eq_graph_h` +/// growing with `maximized` proved nothing about where the box that receives +/// those numbers actually sits. It sat inside `dock_stance.rs`'s +/// "dock-clip-rows" -- a ~280-390px, less-than-window-tall strip -- and an +/// absolutely-positioned child is sized against its own *immediate* parent +/// regardless of any `.relative()` marker upstream, so `below_picture_floor` +/// (a window-space y) landed inside that short box and shoved the card to a +/// ~120px sliver at the bottom. Every one of `eq_card_w`/`card_max_w`'s own +/// unit tests stayed green throughout, because none of them knew a +/// containing box existed at all -- the same class of gap as `canvas()` +/// silently rendering black under a `Block` parent. +/// +/// This binary has no `TestAppContext` to mount `dock_stance::clip_tab` / +/// `ui::stance::render` for real and read painted rects back, so it cannot +/// see the div nesting itself -- only driving the app and screenshotting it +/// proves the fix actually lands on screen (this is that admission, not a +/// substitute for it). What this test *can* pin down in pure values is the +/// room each mount site is fed after the fix: [`dock_stance`]'s un-maximized +/// mount is handed the dock's own real width (not the window's, the "480 in +/// 280" shape of the width-clip bug), and a maximized card is handed +/// `stance-centre`'s width -- the window minus the spine and the dock it +/// escaped -- which must come out *larger*, not smaller, than the docked +/// room it replaces. A future change that re-nests the maximize mount back +/// 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; + + // Mirrors `ui/stance.rs`'s private `SPINE_W` (56.) and `layout::SPLIT_W` + // (the one divider between `stance-centre` and the dock): recomputed + // rather than imported, same as this test file's other private-constant + // checks, so a change to either number is felt here too. + const SPINE_W: f32 = 56.; + + for window_w in [960., 1280., 1920.] { + let window = size(px(window_w), px(720.)); + // `split_size`'s own default/floor/ceiling for the dock, with no + // hand having dragged the seam -- the exact width `dock_stance.rs` + // now feeds its un-maximized cards as their "room". + let dock_w = split_size(Split::Dock, None, 2, window, false); + let docked_room_w = dock_w; + let maximized_room_w = window_w - SPINE_W - SPLIT_W - dock_w; + + assert!( + maximized_room_w > docked_room_w, + "at a {window_w}px window a maximized card's room ({maximized_room_w}px, \ + stance-centre) is not wider than the docked room it escaped \ + ({docked_room_w}px, dock-clip-rows) -- maximize would be making \ + the card smaller again" + ); + assert!( + maximized_room_w <= window_w, + "a maximized card's room ({maximized_room_w}px) exceeds the whole \ + window ({window_w}px) -- it is being measured in the wrong space" + ); + // The concrete pixel gain a driving agent should actually see: the + // EQ graph's own width formula, fed each mount's real room. + assert!( + eq_card_w(maximized_room_w, true) > eq_card_w(docked_room_w, false), + "maximizing the EQ card at a {window_w}px window does not grow \ + eq_card_w's output" + ); + } +} + +/// DESIGN's "a maximized scrim covers only the bench/ledger/time-band band, +/// never the picture": the floor a maximized card's `.top()` is pinned to +/// must leave exactly the picture's own height above it, for any bench +/// height a hand has dragged the seam to -- not just the untouched +/// `BENCH_H` default. `below_picture_floor` takes the live bench height as +/// its own second argument (the seam feature merged onto this branch), so +/// this checks the real two-argument signature rather than a stale one-arg +/// assumption. +#[test] +fn a_maximized_card_can_never_rise_above_the_picture_no_matter_the_bench_height() { + use crate::ui::stance::{LEDGER_H, TIME_BAND_H, below_picture_floor}; + let viewport_h = 1080.; + for bench_h in [140., 200., 400.] { + assert_eq!( + below_picture_floor(viewport_h, bench_h) + TIME_BAND_H + bench_h + LEDGER_H, + viewport_h, + "below_picture_floor's floor plus the band below the picture no \ + longer adds back up to the window -- a maximized scrim could rise \ + into the picture" + ); + } + // A bench dragged tall enough to eat the whole window still clamps at + // zero rather than going negative and reporting free room that is not + // there. + assert_eq!(below_picture_floor(300., 5000.), 0.); +} + +/// The maximize flag's own small round trip (`dock_stance.rs`'s own doc +/// comment: "the same small-file round trip as the dock tab pick", "a room +/// reopens exactly as left"): saved, read back, and silently defaulted to +/// `false` on a corrupt or absent file -- never a startup crash or notice +/// over the user's own work, the same rule `load_subtitle_style`'s own test +/// (`tests/media.rs`) already pins for its sibling config file. `XDG_CONFIG_HOME` +/// is the existing scratch-path override every config-round-trip test in +/// this crate already uses; there is no maximize-specific override to +/// invent. +#[test] +fn a_maximized_card_reopens_exactly_as_left_across_a_restart() { + let dir = std::env::temp_dir().join(format!( + "edith-test-maximized-{}-{}", + std::process::id(), + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_nanos() + )); + std::fs::create_dir_all(&dir).unwrap(); + // Scoped to this test alone, the same reasoning `tests/media.rs`'s own + // XDG_CONFIG_HOME mutation gives: nothing else reads this file. + unsafe { std::env::set_var("XDG_CONFIG_HOME", &dir) }; + + // Nothing written yet: the default (not maximized), not a crash on a + // missing file. + assert_eq!(crate::ui::dock_stance::load_maximized(), false); + + crate::ui::dock_stance::save_maximized(true); + assert_eq!(crate::ui::dock_stance::load_maximized(), true); + + crate::ui::dock_stance::save_maximized(false); + assert_eq!(crate::ui::dock_stance::load_maximized(), false); + + // 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(); + assert_eq!(crate::ui::dock_stance::load_maximized(), false); + + unsafe { std::env::remove_var("XDG_CONFIG_HOME") }; + std::fs::remove_dir_all(&dir).ok(); +} diff --git a/crates/app/src/tests/mod.rs b/crates/app/src/tests/mod.rs index 358d0d4..43f5a51 100644 --- a/crates/app/src/tests/mod.rs +++ b/crates/app/src/tests/mod.rs @@ -24,7 +24,8 @@ use super::{ Transport, VOLUME_W, Volume, WAVE_BPS, WAVE_COL, WAVE_COLS_MAX, Wave, band_label, bitrate_detail, bitrate_refusal, can_add, cancels_export, clipboard_after_remove, color_snap, commit_mbps, containers, - enable, envelope, eq_card_w, eq_freq, eq_freq_label, eq_spectrum, eq_x, eq_y, + enable, envelope, eq_card_w, eq_freq, eq_freq_label, eq_graph_h, eq_spectrum, eq_x, eq_y, + EQ_GRAPH_MAX_H, escape_leaves_player_fullscreen, estimated_bytes, export_path, export_settings, format_key, format_line, format_refusal, fps_choices, fps_label, frac_along, frac_down, frame_at, diff --git a/crates/app/src/ui/cards.rs b/crates/app/src/ui/cards.rs index 88d552e..2c66462 100644 --- a/crates/app/src/ui/cards.rs +++ b/crates/app/src/ui/cards.rs @@ -51,13 +51,62 @@ fn dark_row_value(text: impl Into) -> Div { /// directly); now it rides a `?` glyph beside the head and only shows on /// hover, the same hover-only convention [`dock_stance::ghost_verb`] /// already uses for a verb's own description. -fn dark_card_head(verb: &str, meta: Option, help: Option) -> Div { +/// `maximize` is `None` for the one card this head builds that is not one of +/// the seven param cards (the export progress sheet): everything else passes +/// `Some(self.card_maximized)` and gets the affordance this session's +/// complaint asked for -- worn on the head (DESIGN.md:91's "chord is worn"), +/// so it never was a keyboard-only option (the repeated "some options are +/// only reachable via keyboard shortcut" complaint). A double-click anywhere +/// on the head does the same thing the glyph's click and the `m` chord do +/// ([`Player::toggle_maximize`]) -- mouse and key reach the same switch. +// `+ use<>` (edition 2024 precise capturing): without it, the elided +// lifetime on `cx` would be captured into the returned opaque type by +// default, so a hoisted `let head = dark.then(|| dark_card_head(..., cx));` +// would keep `cx` borrowed until `head` is finally consumed -- fighting +// every other `cx.listener(...)` call built in between, which is exactly +// the E0500/E0501 chain this card's own hoist is here to avoid. +fn dark_card_head( + verb: &str, + meta: Option, + help: Option, + maximize: Option, + cx: &mut Context, +) -> impl IntoElement + use<> { div() + .id("card-head") .flex_none() .px(px(6.)) .flex() .items_baseline() .gap(px(6.)) + .when(maximize.is_some(), |d| { + d.on_mouse_down( + MouseButton::Left, + cx.listener(|this, event: &MouseDownEvent, _, cx| { + if event.click_count >= 2 { + this.toggle_maximize(); + cx.notify(); + } + }), + ) + }) + .children(maximize.map(|max| { + div() + .id("card-head-maximize") + .flex_none() + .cursor_pointer() + .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() + }) + .child(if max { "▣ m" } else { "⤢ m" }) + })) .child( div() .type_style(type_scale::head()) @@ -1094,7 +1143,7 @@ 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))) + .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 @@ -1328,14 +1377,24 @@ impl Player { })) }) .collect(); + // Maximized used to claim a fixed 320 px slice for the graph + // regardless of how much room a small bench actually left the card, + // so the numbers/buttons rows below it were the ones squeezed into a + // scroll -- docked, at the same bench, showed all of them with no + // scroll at all. `flex_1` between the docked floor and the maximized + // ceiling lets the graph take whatever is *actually* left after the + // rows below it claim their own natural height first, the same + // leftover-space idiom `dock_stance::dock_sources` already uses for + // its own scroll region. + let graph_maximized = dark && self.card_maximized; let graph = div() // Ided like the band rows it replaces: what the pointer presses on // is one element with its own hitbox, which is what a drag is // tracked from. .id("eq-graph") .relative() - .flex_none() - .h(px(EQ_GRAPH_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() })) .cursor_pointer() @@ -1414,16 +1473,31 @@ impl Player { ) .child(eq_curve(self.eq_params.clone(), sample_rate)) .children(handles) - .children(EQ_TICKS.map(|(freq, label)| { - div() - .absolute() - .left(relative(eq_x(freq))) - // Pulled back so the mark reads as sitting *at* its - // frequency; the two ends then hug the corners. - .ml(px(-12.)) - .bottom(px(1.)) - .w(px(24.)) - .text_align(TextAlign::Center) + .children(EQ_TICKS.iter().enumerate().map(|(i, (freq, label))| { + // Centred on its own frequency for the three inner ticks -- + // pulled back by half its own width, as the comment above + // used to say for all five. The two ends used the same + // centring and, sitting at 0%/100% of the axis, hung half + // their own label off the graph's edge: "20 Hz" clipped to a + // bare "z", "20k" lost its "k" and half its trailing "0". + // Anchored to the graph's own edge instead and read inward, + // both now sit wholly inside the plot they label. + // The end boxes are widened to their own label at the size + // they draw at (`eq_tick_end_w`), not just anchored -- an + // anchor alone still let "20 Hz" wrap onto two lines inside + // 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 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) + } else if i == EQ_TICKS.len() - 1 { + 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 .when(dark, |d| { d.type_style(type_scale::mono( type_scale::CHORD_METADATA_MIN_PX, @@ -1432,7 +1506,7 @@ impl Player { .text_color(rgb(INK3())) }) .when(!dark, |d| d.text_size(px(9.)).text_color(rgb(FG_SECONDARY()))) - .child(label) + .child(*label) })) .child( div() @@ -1468,6 +1542,7 @@ 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))))) // Click away closes it, as on every card here. .on_mouse_down( MouseButton::Left, @@ -1486,13 +1561,18 @@ impl Player { // of the window. The two cards beside it are built this // way for the same reason. .w_full() - .max_w(px(eq_card_w(f32::from(viewport.width)))) + .max_w(px(eq_card_w(f32::from(viewport.width), self.card_maximized))) // And a cap the other way, for the same reason the width // has one: the card is docked in a column now, and at the // 360 px floor it is taller than that column -- its title // ran off the top and its buttons off the bottom, with // neither reachable. Capped here, scrolled below. .max_h(relative(1.)) + // Maximized also *claims* the room the cap above + // only allows: `flex_1()`/`max_h` on the graph below + // has nothing to grow into if the card itself still + // hugs its own content height. + .when(graph_maximized, |d| d.h(relative(1.))) .on_mouse_down(MouseButton::Left, swallow) .flex() .flex_col() @@ -1508,6 +1588,12 @@ impl Player { // makes the cap above a scroll rather than a // clip; the rows themselves keep their heights. .min_h(px(0.)) + // Maximized: stretch to the room the card + // above now claims, so the graph's own + // `flex_1` (above) has the leftover space to + // grow into instead of the card just hugging + // its content and leaving none. + .when(graph_maximized, |d| d.flex_1()) .overflow_y_scroll() .track_scroll(&self.eq_scroll) .flex() @@ -1519,7 +1605,9 @@ impl Player { d.child(dark_card_head( "Equalizer", Some(format!("{} clip {}", lane.label(), idx + 1).into()), - Some("drag a handle, or a digit picks a band — ←→ moves it, ↑↓ its gain, shift+←→ its width; a adds, x removes, f flattens it, r all, s spectrum; a click away or esc closes".into()), + Some("drag a handle, or a digit picks a band — ←→ moves it, ↑↓ its gain, shift+←→ its width; a adds, x removes, f flattens it, r all, s spectrum, m fills the room; a click away or esc closes".into()), + Some(self.card_maximized), + cx, )) }) .when(!dark, |d| { @@ -1871,7 +1959,7 @@ 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, 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; @@ -1970,6 +2058,7 @@ 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))))) // Click away closes it, as on every card here. .on_mouse_down( MouseButton::Left, @@ -1982,7 +2071,7 @@ impl Player { .child( div() .w_full() - .max_w(px(COLOR_W)) + .max_w(px(card_max_w(COLOR_W, self.card_maximized, f32::from(viewport.width)))) .on_mouse_down(MouseButton::Left, swallow) .flex() .flex_col() @@ -1992,7 +2081,7 @@ 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()))) + 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!( @@ -2062,7 +2151,7 @@ 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, 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; @@ -2152,6 +2241,7 @@ 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))))) .on_mouse_down( MouseButton::Left, cx.listener(|this, _: &MouseDownEvent, _, cx| { @@ -2163,7 +2253,7 @@ impl Player { .child( div() .w_full() - .max_w(px(TRANSFORM_W)) + .max_w(px(card_max_w(TRANSFORM_W, self.card_maximized, f32::from(viewport.width)))) .on_mouse_down(MouseButton::Left, swallow) .flex() .flex_col() @@ -2173,7 +2263,7 @@ 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()))) + 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!( @@ -2236,7 +2326,7 @@ 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, 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()?; @@ -2290,6 +2380,7 @@ 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))))) // Click away closes it, as on every card here. .on_mouse_down( MouseButton::Left, @@ -2302,7 +2393,7 @@ impl Player { .child( div() .w_full() - .max_w(px(COLOR_W)) + .max_w(px(card_max_w(COLOR_W, self.card_maximized, f32::from(viewport.width)))) .on_mouse_down(MouseButton::Left, swallow) .flex() .flex_col() @@ -2312,7 +2403,7 @@ 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()))) + 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!( @@ -2401,7 +2492,7 @@ 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, cx: &mut Context) -> Option { + pub(crate) fn mix_card(&self, viewport: Size, cx: &mut Context) -> Option { if !self.mix_open { return None; } @@ -2523,6 +2614,7 @@ 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))))) // Click away closes it, as on every card here. .on_mouse_down( MouseButton::Left, @@ -2535,7 +2627,7 @@ impl Player { .child( div() .w_full() - .max_w(px(COLOR_W)) + .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() @@ -2545,7 +2637,7 @@ 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())))) + .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() @@ -2598,11 +2690,13 @@ 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, 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 size_picked = self.subtitle_style_field == 0; let size_row = div() .id("subtitle-size-row") @@ -2720,13 +2814,13 @@ impl Player { .when(dark, |d| d.child(dark_row_label(name.clone(), picked))) .when(!dark, |d| d.child(name.clone())) }); - 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"; Some( scrim() .flex() .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))))) .on_mouse_down( MouseButton::Left, cx.listener(|this, _: &MouseDownEvent, _, cx| { @@ -2738,7 +2832,7 @@ impl Player { .child( div() .w_full() - .max_w(px(COLOR_W)) + .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() @@ -2748,9 +2842,7 @@ 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("Subtitle style", None, Some(help_text.into()))) - }) + .when(dark, move |d| d.child(head.unwrap())) .when(!dark, |d| { d.child( div() @@ -2791,9 +2883,12 @@ 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, 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 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`). @@ -2960,8 +3055,6 @@ impl Player { .into_any_element(), } }; - 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"; Some( scrim() .flex() @@ -2971,6 +3064,7 @@ 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))))) // 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( @@ -2984,7 +3078,7 @@ impl Player { .child( div() .w_full() - .max_w(px(COLOR_W)) + .max_w(px(card_max_w(COLOR_W, self.card_maximized, f32::from(viewport.width)))) .on_mouse_down(MouseButton::Left, swallow) .flex() .flex_col() @@ -2993,9 +3087,7 @@ 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("Silences", Some(head_meta.clone()), Some(help_text.into()))) - }) + .when(dark, move |d| d.child(head.unwrap())) .when(!dark, |d| { d.child(div().flex_none().px(px(6.)).child(format!( "Silences — {} clip {}", diff --git a/crates/app/src/ui/dock_stance.rs b/crates/app/src/ui/dock_stance.rs index dc6ce87..8c861a8 100644 --- a/crates/app/src/ui/dock_stance.rs +++ b/crates/app/src/ui/dock_stance.rs @@ -44,6 +44,28 @@ fn save(src_active: bool) { let _ = std::fs::write(path, if src_active { "Src\n" } else { "Clip\n" }); } +/// Whether the room's one open param card is maximized -- the same +/// small-file round trip as the dock tab pick above, its own word beside it +/// ("a room reopens exactly as left", DESIGN.md:135), so a maximized EQ stays +/// maximized across a close and reopen of the whole room, not just the card. +pub(crate) fn maximized_config_path() -> std::path::PathBuf { + crate::keymap::Keymap::config_path().with_file_name("card-maximized") +} + +pub(crate) fn load_maximized() -> bool { + std::fs::read_to_string(maximized_config_path()) + .map(|text| text.trim() == "1") + .unwrap_or(false) +} + +pub(crate) fn save_maximized(maximized: bool) { + let path = maximized_config_path(); + if let Some(dir) = path.parent() { + let _ = std::fs::create_dir_all(dir); + } + let _ = std::fs::write(path, if maximized { "1\n" } else { "0\n" }); +} + /// The Sources tab's four sort chips (MOCK-SPEC "Dock" §3). `Recent` is the /// library's own arrival order -- the only order this editor tracks without /// a fourth field to keep it in. @@ -502,8 +524,18 @@ 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_h: Pixels, cx: &mut Context) -> impl IntoElement { - let room = size(px(width), window_h); +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 + // tab is a ~280-390px strip inside the dock, not the window, so a card + // capped at up to 720px overflowed past the window's own right edge + // (`20k` rendered as `20`, the `Spectrum on s` button cut mid-glyph). + // Height stays the window's: none of the un-maximized cards' own + // arithmetic uses it (`below_picture_floor` only fires once maximized, + // and a maximized card is mounted at `ui::stance::render` instead, never + // through this `room`). + let room = Size::new(px(width), window_size.height); let none_open = player.eq_open.is_none() && player.color_open.is_none() && player.transform_open.is_none() @@ -596,19 +628,31 @@ fn clip_tab(player: &Player, width: f32, window_h: Pixels, 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") @@ -660,6 +704,6 @@ pub(crate) fn render(player: &Player, width: f32, window_h: Pixels, cx: &mut Con ) .child(match src_active { true => sources_tab(player, cx).into_any_element(), - false => clip_tab(player, width, window_h, cx).into_any_element(), + false => clip_tab(player, width, window_size, cx).into_any_element(), }) } diff --git a/crates/app/src/ui/inspector.rs b/crates/app/src/ui/inspector.rs index 382c170..2590af4 100644 --- a/crates/app/src/ui/inspector.rs +++ b/crates/app/src/ui/inspector.rs @@ -80,12 +80,12 @@ impl Player { ) }) .children(self.eq_card(room, cx)) - .children(self.color_card(cx)) - .children(self.transform_card(cx)) - .children(self.speed_card(cx)) - .children(self.silence_card(cx)) - .children(self.mix_card(cx)) - .children(self.subtitle_style_card(cx)) + .children(self.color_card(room, cx)) + .children(self.transform_card(room, cx)) + .children(self.speed_card(room, cx)) + .children(self.silence_card(room, cx)) + .children(self.mix_card(room, cx)) + .children(self.subtitle_style_card(room, cx)) } /// What is marked, and the settings that belong to *it*. A dump of every diff --git a/crates/app/src/ui/stance.rs b/crates/app/src/ui/stance.rs index 8504b5a..5a58d5c 100644 --- a/crates/app/src/ui/stance.rs +++ b/crates/app/src/ui/stance.rs @@ -64,6 +64,27 @@ pub(crate) fn below_picture_floor(viewport_h: f32, bench_h: f32) -> f32 { (viewport_h - TIME_BAND_H - bench_h - LEDGER_H).max(0.) } +/// The maximized inspector card's own top -- deliberately *not* +/// [`below_picture_floor`] fed the live bench straight through, the way +/// `menu_floor` above correctly does for a menu. A maximized card is anchored +/// to the same floor and grows downward to the window's own bottom edge, so +/// its height is `viewport_h - floor` -- exactly the bench/ledger footprint, +/// `TIME_BAND_H + bench_h + LEDGER_H`. Feeding the *live* bench in there means +/// a hand-dragged bench smaller than [`BENCH_H`] starves the maximized card of +/// room: driven at `bench=BENCH_MIN_H` the card shrank to 210px and its curve +/// and band handles stopped rendering at all, while the same card *docked* +/// (whose height was never bench-shaped to begin with) still drew everything +/// -- maximize made the card strictly worse, backwards from what the feature +/// promises. Floored at [`BENCH_H`], the bench's own untouched default, the +/// maximized card is never smaller than it is at the bench nobody has +/// dragged; a bench pulled *larger* than that still grows the card further, +/// same as before, and the case actually verified good (card top exactly on +/// the picture floor, picture unobstructed) is untouched because it ran at a +/// bench already at or above this floor. +pub(crate) fn maximized_card_top(viewport_h: f32, bench_h: f32) -> f32 { + below_picture_floor(viewport_h, bench_h.max(BENCH_H)) +} + /// The floor-clamped placement for every scrolling menu (clip context menu, /// picker, library menu): the anchor pulled down to [`below_picture_floor`] /// *and* the room its list may fill capped to what is actually left between @@ -119,6 +140,48 @@ mod menu_floor_tests { } } +#[cfg(test)] +mod maximized_card_top_tests { + use super::*; + + /// The regression D1 shipped as: the old call site fed the *live* bench + /// straight into `below_picture_floor`, so a bench dragged down to + /// `crate::BENCH_MIN_H` (a legal value -- `layout::split_size` clamps + /// anything smaller up to it) gave the maximized card *less* room than + /// docked, not more. This binary has no `TestAppContext`, so it cannot + /// read back a painted rect the way a driven screenshot can -- this is a + /// value-level check of the two formulas the maximize feature is built + /// on, not a substitute for driving the app at the smallest bench. Swept + /// across the *whole* legal bench range (the earlier guard this replaces + /// checked only the untouched default, which is exactly why a small, + /// legal bench slipped through), maximized room must never fall below the + /// room at the bench nobody has dragged, and must never be smaller than + /// what the same live bench leaves for `below_picture_floor`'s own live + /// use (menu placement) -- the two must not tangle back together. + #[test] + fn maximized_room_never_shrinks_below_the_default_bench_across_every_legal_bench_height() { + let viewport = size(px(1280.), px(720.)); + let v = f32::from(viewport.height); + let default_room = v - below_picture_floor(v, BENCH_H); + let mut bench_h = crate::BENCH_MIN_H; + while bench_h <= 600. { + let room = v - maximized_card_top(v, bench_h); + assert!( + room >= default_room, + "bench={bench_h}: maximized room {room} fell below the default-bench \ + room {default_room}" + ); + // Still strictly bigger than a bare `below_picture_floor` room + // would ever have given it below `BENCH_H` -- the coupling this + // fix breaks. + if bench_h < BENCH_H { + assert!(room > v - below_picture_floor(v, bench_h)); + } + bench_h += 25.; + } + } +} + thread_local! { // FAULT 3: the picture region's own laid-out box, measured each frame by // a [`bounds_probe`] the same shape `timeband_stance`'s contact strip @@ -613,8 +676,10 @@ fn ledger(player: &Player, position: f64) -> impl IntoElement { /// tab row and both tabs' content (DESIGN §12 step 4). /// Width comes from [`Player::split_px`] now, not the fixed [`DOCK_W`]: the /// seam [`crate::ui::stance::render`] mounts to its left is what answers -/// "ui fields are not stretchable" for the dock. -fn dock(player: &Player, dock_w: f32, window_h: Pixels, cx: &mut Context) -> 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 { div() .id("stance-dock") .flex_none() @@ -625,7 +690,7 @@ fn dock(player: &Player, dock_w: f32, window_h: Pixels, cx: &mut Context .border_color(rgba(DARK_SEAM())) .flex() .flex_col() - .child(dock_stance::render(player, dock_w, window_h, cx)) + .child(dock_stance::render(player, dock_w, window_size, cx)) } /// A zero-size element whose only job is `window.on_mouse_event`'s door: @@ -662,7 +727,6 @@ pub(crate) fn render( cx: &mut Context, ) -> impl IntoElement { let window_size = window.viewport_size(); - let window_h = window_size.height; let position = player.playhead(player.drawn_duration()); // The two seams a hand may drag (`Split::Dock`, `Split::Bench`): read // through the same door every legacy region measures itself by @@ -882,8 +946,29 @@ pub(crate) fn render( // what draws it once open. .children(player.export_card(window_size, cx)) .children(player.export_progress_card(cx)) - .children(player.picker_card(window_size, cx)), + .children(player.picker_card(window_size, cx)) + // A maximized clip param card (EQ/Colour/Transform/Speed/ + // Silence/Mix/Subtitle style) escapes the dock to mount here + // instead, the same window-space `stance-centre` context + // every card above already renders in -- `below_picture_floor` + // is a window coordinate, and `dock_stance.rs`'s + // "dock-clip-rows" is a ~280-390px strip whose own box is the + // containing block for anything absolutely positioned inside + // it, `.relative()` or not, so a card asking for the room + // below the picture cannot get it there. Un-maximized, the + // same seven functions stay mounted in the dock + // (`dock_stance::clip_tab`'s own `.when(!card_maximized, ...)` + // guard keeps this from ever double-mounting one). + .when(player.card_maximized, |el| { + el.children(player.eq_card(window_size, cx)) + .children(player.color_card(window_size, cx)) + .children(player.transform_card(window_size, cx)) + .children(player.speed_card(window_size, cx)) + .children(player.silence_card(window_size, cx)) + .children(player.mix_card(window_size, cx)) + .children(player.subtitle_style_card(window_size, cx)) + }), ) .child(divider(Split::Dock, cx)) - .child(dock(player, dock_w, window_h, cx)) + .child(dock(player, dock_w, window_size, cx)) }