diff --git a/crates/app/src/ui/cards.rs b/crates/app/src/ui/cards.rs index 0fcf02d..de1e0f2 100644 --- a/crates/app/src/ui/cards.rs +++ b/crates/app/src/ui/cards.rs @@ -1463,16 +1463,24 @@ 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. + let div = div().absolute().bottom(px(1.)).w(px(24.)); + let div = if i == 0 { + div.left(px(0.)).text_align(TextAlign::Left) + } else if i == EQ_TICKS.len() - 1 { + div.right(px(0.)).text_align(TextAlign::Right) + } else { + div.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, @@ -1481,7 +1489,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() @@ -1517,7 +1525,7 @@ impl Player { .justify_center() .items_center() .bg(rgba(SCRIM())) - .when(self.card_maximized, |d| d.top(px(crate::ui::stance::below_picture_floor(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, @@ -2022,7 +2030,7 @@ impl Player { .justify_center() .items_center() .bg(rgba(SCRIM())) - .when(self.card_maximized, |d| d.top(px(crate::ui::stance::below_picture_floor(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, @@ -2205,7 +2213,7 @@ impl Player { .justify_center() .items_center() .bg(rgba(SCRIM())) - .when(self.card_maximized, |d| d.top(px(crate::ui::stance::below_picture_floor(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| { @@ -2344,7 +2352,7 @@ impl Player { .justify_center() .items_center() .bg(rgba(SCRIM())) - .when(self.card_maximized, |d| d.top(px(crate::ui::stance::below_picture_floor(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, @@ -2578,7 +2586,7 @@ impl Player { .justify_center() .items_center() .bg(rgba(SCRIM())) - .when(self.card_maximized, |d| d.top(px(crate::ui::stance::below_picture_floor(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, @@ -2784,7 +2792,7 @@ impl Player { .justify_center() .items_center() .bg(rgba(SCRIM())) - .when(self.card_maximized, |d| d.top(px(crate::ui::stance::below_picture_floor(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| { @@ -3028,7 +3036,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::below_picture_floor(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( diff --git a/crates/app/src/ui/stance.rs b/crates/app/src/ui/stance.rs index 6e91e07..7c98d60 100644 --- a/crates/app/src/ui/stance.rs +++ b/crates/app/src/ui/stance.rs @@ -63,6 +63,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 @@ -118,6 +139,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