forge
Explore
Log in

Don't you dare go Hollow

Maximized eq/color/etc cards stop shrinking with a small bench

Browse files at this commit

f429c6e78da57c59084a7a8ecac34a345580aeb1Ahmet Kaan GümüşParent: b1ff91f
  • fix
    • maximized eq/color/etc cards stop shrinking with a small bench
Show full message
fix(ui): maximized eq/color/etc cards stop shrinking with a small bench

below_picture_floor fed the *live* bench straight into the maximized
card's top, so a bench dragged down to BENCH_MIN_H (legal, and the
value the user's own stance-splits held) gave the maximized card LESS
room than docked -- backwards from what maximize promises, and its
curve/handles stopped rendering entirely. maximized_card_top floors
the bench at BENCH_H (the untouched default) before computing the
floor, so a small bench can no longer starve it; a larger bench still
grows it further, unchanged.

Also insets the EQ frequency axis's two end labels ("20 Hz", "20k")
to the graph's own edges instead of centering them on 0%/100%, which
hung half of each off the plot and clipped it.
crates/app/src/ui/cards.rsmodified+26 -18
@@ -1463,16 +1463,24 @@ impl Player {
1463 )1463 )
1464 .child(eq_curve(self.eq_params.clone(), sample_rate))1464 .child(eq_curve(self.eq_params.clone(), sample_rate))
1465 .children(handles)1465 .children(handles)
1466- .children(EQ_TICKS.map(|(freq, label)| {1466+ .children(EQ_TICKS.iter().enumerate().map(|(i, (freq, label))| {
1467- div()1467+ // Centred on its own frequency for the three inner ticks --
1468- .absolute()1468+ // pulled back by half its own width, as the comment above
1469- .left(relative(eq_x(freq)))1469+ // used to say for all five. The two ends used the same
1470- // Pulled back so the mark reads as sitting *at* its1470+ // centring and, sitting at 0%/100% of the axis, hung half
1471- // frequency; the two ends then hug the corners.1471+ // their own label off the graph's edge: "20 Hz" clipped to a
1472- .ml(px(-12.))1472+ // bare "z", "20k" lost its "k" and half its trailing "0".
1473- .bottom(px(1.))1473+ // Anchored to the graph's own edge instead and read inward,
1474- .w(px(24.))1474+ // both now sit wholly inside the plot they label.
1475- .text_align(TextAlign::Center)1475+ let div = div().absolute().bottom(px(1.)).w(px(24.));
1476+ let div = if i == 0 {
1477+ div.left(px(0.)).text_align(TextAlign::Left)
1478+ } else if i == EQ_TICKS.len() - 1 {
1479+ div.right(px(0.)).text_align(TextAlign::Right)
1480+ } else {
1481+ div.left(relative(eq_x(*freq))).ml(px(-12.)).text_align(TextAlign::Center)
1482+ };
1483+ div
1476 .when(dark, |d| {1484 .when(dark, |d| {
1477 d.type_style(type_scale::mono(1485 d.type_style(type_scale::mono(
1478 type_scale::CHORD_METADATA_MIN_PX,1486 type_scale::CHORD_METADATA_MIN_PX,
@@ -1481,7 +1489,7 @@ impl Player {
1481 .text_color(rgb(INK3()))1489 .text_color(rgb(INK3()))
1482 })1490 })
1483 .when(!dark, |d| d.text_size(px(9.)).text_color(rgb(FG_SECONDARY())))1491 .when(!dark, |d| d.text_size(px(9.)).text_color(rgb(FG_SECONDARY())))
1484- .child(label)1492+ .child(*label)
1485 }))1493 }))
1486 .child(1494 .child(
1487 div()1495 div()
@@ -1517,7 +1525,7 @@ impl Player {
1517 .justify_center()1525 .justify_center()
1518 .items_center()1526 .items_center()
1519 .bg(rgba(SCRIM()))1527 .bg(rgba(SCRIM()))
1520- .when(self.card_maximized, |d| d.top(px(crate::ui::stance::below_picture_floor(f32::from(viewport.height), self.split_px(Split::Bench, viewport)))))1528+ .when(self.card_maximized, |d| d.top(px(crate::ui::stance::maximized_card_top(f32::from(viewport.height), self.split_px(Split::Bench, viewport)))))
1521 // Click away closes it, as on every card here.1529 // Click away closes it, as on every card here.
1522 .on_mouse_down(1530 .on_mouse_down(
1523 MouseButton::Left,1531 MouseButton::Left,
@@ -2022,7 +2030,7 @@ impl Player {
2022 .justify_center()2030 .justify_center()
2023 .items_center()2031 .items_center()
2024 .bg(rgba(SCRIM()))2032 .bg(rgba(SCRIM()))
2025- .when(self.card_maximized, |d| d.top(px(crate::ui::stance::below_picture_floor(f32::from(viewport.height), self.split_px(Split::Bench, viewport)))))2033+ .when(self.card_maximized, |d| d.top(px(crate::ui::stance::maximized_card_top(f32::from(viewport.height), self.split_px(Split::Bench, viewport)))))
2026 // Click away closes it, as on every card here.2034 // Click away closes it, as on every card here.
2027 .on_mouse_down(2035 .on_mouse_down(
2028 MouseButton::Left,2036 MouseButton::Left,
@@ -2205,7 +2213,7 @@ impl Player {
2205 .justify_center()2213 .justify_center()
2206 .items_center()2214 .items_center()
2207 .bg(rgba(SCRIM()))2215 .bg(rgba(SCRIM()))
2208- .when(self.card_maximized, |d| d.top(px(crate::ui::stance::below_picture_floor(f32::from(viewport.height), self.split_px(Split::Bench, viewport)))))2216+ .when(self.card_maximized, |d| d.top(px(crate::ui::stance::maximized_card_top(f32::from(viewport.height), self.split_px(Split::Bench, viewport)))))
2209 .on_mouse_down(2217 .on_mouse_down(
2210 MouseButton::Left,2218 MouseButton::Left,
2211 cx.listener(|this, _: &MouseDownEvent, _, cx| {2219 cx.listener(|this, _: &MouseDownEvent, _, cx| {
@@ -2344,7 +2352,7 @@ impl Player {
2344 .justify_center()2352 .justify_center()
2345 .items_center()2353 .items_center()
2346 .bg(rgba(SCRIM()))2354 .bg(rgba(SCRIM()))
2347- .when(self.card_maximized, |d| d.top(px(crate::ui::stance::below_picture_floor(f32::from(viewport.height), self.split_px(Split::Bench, viewport)))))2355+ .when(self.card_maximized, |d| d.top(px(crate::ui::stance::maximized_card_top(f32::from(viewport.height), self.split_px(Split::Bench, viewport)))))
2348 // Click away closes it, as on every card here.2356 // Click away closes it, as on every card here.
2349 .on_mouse_down(2357 .on_mouse_down(
2350 MouseButton::Left,2358 MouseButton::Left,
@@ -2578,7 +2586,7 @@ impl Player {
2578 .justify_center()2586 .justify_center()
2579 .items_center()2587 .items_center()
2580 .bg(rgba(SCRIM()))2588 .bg(rgba(SCRIM()))
2581- .when(self.card_maximized, |d| d.top(px(crate::ui::stance::below_picture_floor(f32::from(viewport.height), self.split_px(Split::Bench, viewport)))))2589+ .when(self.card_maximized, |d| d.top(px(crate::ui::stance::maximized_card_top(f32::from(viewport.height), self.split_px(Split::Bench, viewport)))))
2582 // Click away closes it, as on every card here.2590 // Click away closes it, as on every card here.
2583 .on_mouse_down(2591 .on_mouse_down(
2584 MouseButton::Left,2592 MouseButton::Left,
@@ -2784,7 +2792,7 @@ impl Player {
2784 .justify_center()2792 .justify_center()
2785 .items_center()2793 .items_center()
2786 .bg(rgba(SCRIM()))2794 .bg(rgba(SCRIM()))
2787- .when(self.card_maximized, |d| d.top(px(crate::ui::stance::below_picture_floor(f32::from(viewport.height), self.split_px(Split::Bench, viewport)))))2795+ .when(self.card_maximized, |d| d.top(px(crate::ui::stance::maximized_card_top(f32::from(viewport.height), self.split_px(Split::Bench, viewport)))))
2788 .on_mouse_down(2796 .on_mouse_down(
2789 MouseButton::Left,2797 MouseButton::Left,
2790 cx.listener(|this, _: &MouseDownEvent, _, cx| {2798 cx.listener(|this, _: &MouseDownEvent, _, cx| {
@@ -3028,7 +3036,7 @@ impl Player {
3028 // Light enough to read the lanes and the marks on them through:3036 // Light enough to read the lanes and the marks on them through:
3029 // the preview is the point of this card.3037 // the preview is the point of this card.
3030 .bg(rgba(SCRIM_LIGHT()))3038 .bg(rgba(SCRIM_LIGHT()))
3031- .when(self.card_maximized, |d| d.top(px(crate::ui::stance::below_picture_floor(f32::from(viewport.height), self.split_px(Split::Bench, viewport)))))3039+ .when(self.card_maximized, |d| d.top(px(crate::ui::stance::maximized_card_top(f32::from(viewport.height), self.split_px(Split::Bench, viewport)))))
3032 // Click away closes it, as on every card here -- and the marks3040 // Click away closes it, as on every card here -- and the marks
3033 // go with it, which is what makes this one a call and not a flag.3041 // go with it, which is what makes this one a call and not a flag.
3034 .on_mouse_down(3042 .on_mouse_down(
crates/app/src/ui/stance.rsmodified+63 -0
@@ -63,6 +63,27 @@ pub(crate) fn below_picture_floor(viewport_h: f32, bench_h: f32) -> f32 {
63 (viewport_h - TIME_BAND_H - bench_h - LEDGER_H).max(0.)63 (viewport_h - TIME_BAND_H - bench_h - LEDGER_H).max(0.)
64 }64 }
65 65
66+/// The maximized inspector card's own top -- deliberately *not*
67+/// [`below_picture_floor`] fed the live bench straight through, the way
68+/// `menu_floor` above correctly does for a menu. A maximized card is anchored
69+/// to the same floor and grows downward to the window's own bottom edge, so
70+/// its height is `viewport_h - floor` -- exactly the bench/ledger footprint,
71+/// `TIME_BAND_H + bench_h + LEDGER_H`. Feeding the *live* bench in there means
72+/// a hand-dragged bench smaller than [`BENCH_H`] starves the maximized card of
73+/// room: driven at `bench=BENCH_MIN_H` the card shrank to 210px and its curve
74+/// and band handles stopped rendering at all, while the same card *docked*
75+/// (whose height was never bench-shaped to begin with) still drew everything
76+/// -- maximize made the card strictly worse, backwards from what the feature
77+/// promises. Floored at [`BENCH_H`], the bench's own untouched default, the
78+/// maximized card is never smaller than it is at the bench nobody has
79+/// dragged; a bench pulled *larger* than that still grows the card further,
80+/// same as before, and the case actually verified good (card top exactly on
81+/// the picture floor, picture unobstructed) is untouched because it ran at a
82+/// bench already at or above this floor.
83+pub(crate) fn maximized_card_top(viewport_h: f32, bench_h: f32) -> f32 {
84+ below_picture_floor(viewport_h, bench_h.max(BENCH_H))
85+}
86+
66 /// The floor-clamped placement for every scrolling menu (clip context menu,87 /// The floor-clamped placement for every scrolling menu (clip context menu,
67 /// picker, library menu): the anchor pulled down to [`below_picture_floor`]88 /// picker, library menu): the anchor pulled down to [`below_picture_floor`]
68 /// *and* the room its list may fill capped to what is actually left between89 /// *and* the room its list may fill capped to what is actually left between
@@ -118,6 +139,48 @@ mod menu_floor_tests {
118 }139 }
119 }140 }
120 141
142+#[cfg(test)]
143+mod maximized_card_top_tests {
144+ use super::*;
145+
146+ /// The regression D1 shipped as: the old call site fed the *live* bench
147+ /// straight into `below_picture_floor`, so a bench dragged down to
148+ /// `crate::BENCH_MIN_H` (a legal value -- `layout::split_size` clamps
149+ /// anything smaller up to it) gave the maximized card *less* room than
150+ /// docked, not more. This binary has no `TestAppContext`, so it cannot
151+ /// read back a painted rect the way a driven screenshot can -- this is a
152+ /// value-level check of the two formulas the maximize feature is built
153+ /// on, not a substitute for driving the app at the smallest bench. Swept
154+ /// across the *whole* legal bench range (the earlier guard this replaces
155+ /// checked only the untouched default, which is exactly why a small,
156+ /// legal bench slipped through), maximized room must never fall below the
157+ /// room at the bench nobody has dragged, and must never be smaller than
158+ /// what the same live bench leaves for `below_picture_floor`'s own live
159+ /// use (menu placement) -- the two must not tangle back together.
160+ #[test]
161+ fn maximized_room_never_shrinks_below_the_default_bench_across_every_legal_bench_height() {
162+ let viewport = size(px(1280.), px(720.));
163+ let v = f32::from(viewport.height);
164+ let default_room = v - below_picture_floor(v, BENCH_H);
165+ let mut bench_h = crate::BENCH_MIN_H;
166+ while bench_h <= 600. {
167+ let room = v - maximized_card_top(v, bench_h);
168+ assert!(
169+ room >= default_room,
170+ "bench={bench_h}: maximized room {room} fell below the default-bench \
171+ room {default_room}"
172+ );
173+ // Still strictly bigger than a bare `below_picture_floor` room
174+ // would ever have given it below `BENCH_H` -- the coupling this
175+ // fix breaks.
176+ if bench_h < BENCH_H {
177+ assert!(room > v - below_picture_floor(v, bench_h));
178+ }
179+ bench_h += 25.;
180+ }
181+ }
182+}
183+
121 thread_local! {184 thread_local! {
122 // FAULT 3: the picture region's own laid-out box, measured each frame by185 // FAULT 3: the picture region's own laid-out box, measured each frame by
123 // a [`bounds_probe`] the same shape `timeband_stance`'s contact strip186 // a [`bounds_probe`] the same shape `timeband_stance`'s contact strip