forge
Explore
Log in

Don't you dare go Hollow

A maximized clip card escapes the dock instead of the sliver inside it

Browse files at this commit

b1ff91f376261ec7e4c0fed60baf7871b2d7975bAhmet Kaan GümüşParent: db1e199
  • fix
    • a maximized clip card escapes the dock instead of the sliver inside it
Show full message
fix(ui): a maximized clip card escapes the dock instead of the sliver inside it

The maximize offset (`below_picture_floor`) is a window-space y, but every
param card (EQ/Colour/Transform/Speed/Silence/Mix/Subtitle style) was
mounted inside `dock_stance.rs`'s "dock-clip-rows" -- a ~280-390px, less-
than-window-tall strip. An absolutely-positioned child is sized against its
own immediate parent regardless of any `.relative()` upstream, so the
window-space offset was applied inside that short box and shoved the card
to a ~120px sliver at the bottom, with the graph never on screen: maximize
made every card smaller.

The seven cards now mount two ways depending on `card_maximized`:
un-maximized, they stay in `dock_stance.rs`'s dock column exactly as
before; maximized, they mount at `ui::stance::render`'s "stance-centre"
instead, the same window-space root `context_card`/`library_card`/
`export_card`/`picker_card` already render from.

Also: `dock_stance::clip_tab` ignored its own `width` parameter and fed the
whole window's width into `eq_card_w`, so an un-maximized EQ card asked for
up to 720px inside a ~390px column and overflowed past the window edge
(the "480 in 280" shape of bug this feature already tried to fix once).
It now feeds the dock's real width.

Guard: `a_maximized_cards_room_is_bigger_than_the_docked_rooms_not_smaller`
(tests/cards.rs) checks in pure values that the maximized mount's room is
wider than the docked room it escaped, using the same width formulas
production code calls. This binary has no `TestAppContext` to mount the
real tree and read painted rects back, so it cannot see the div nesting
itself -- only driving the app proves the fix lands on screen; the test's
own doc comment says so.

The legacy tree (`OLD_GUI=1`) has the same class of bug in
`ui/inspector.rs` (the maximize width formulas want more room than the
fixed inspector column can give), but an existing structural test
(`an_inspector_section_occludes_no_timeline`) forbids these cards from
ever mounting at the legacy root -- fixing it needs an in-place answer
within the inspector's own box, not an escape, and is left as a follow-up.
crates/app/src/tests/cards.rsmodified+66 -0
@@ -1756,6 +1756,72 @@ fn maximizing_a_card_grows_its_box_without_moving_where_a_value_sits_in_it() {
17561756 assert_eq!(eq_y(0.), eq_y(0.));
17571757 }
17581758
1759+/// The regression the previous test could not see: `eq_card_w`/`eq_graph_h`
1760+/// growing with `maximized` proved nothing about where the box that receives
1761+/// those numbers actually sits. It sat inside `dock_stance.rs`'s
1762+/// "dock-clip-rows" -- a ~280-390px, less-than-window-tall strip -- and an
1763+/// absolutely-positioned child is sized against its own *immediate* parent
1764+/// regardless of any `.relative()` marker upstream, so `below_picture_floor`
1765+/// (a window-space y) landed inside that short box and shoved the card to a
1766+/// ~120px sliver at the bottom. Every one of `eq_card_w`/`card_max_w`'s own
1767+/// unit tests stayed green throughout, because none of them knew a
1768+/// containing box existed at all -- the same class of gap as `canvas()`
1769+/// silently rendering black under a `Block` parent.
1770+///
1771+/// This binary has no `TestAppContext` to mount `dock_stance::clip_tab` /
1772+/// `ui::stance::render` for real and read painted rects back, so it cannot
1773+/// see the div nesting itself -- only driving the app and screenshotting it
1774+/// proves the fix actually lands on screen (this is that admission, not a
1775+/// substitute for it). What this test *can* pin down in pure values is the
1776+/// room each mount site is fed after the fix: [`dock_stance`]'s un-maximized
1777+/// mount is handed the dock's own real width (not the window's, the "480 in
1778+/// 280" shape of the width-clip bug), and a maximized card is handed
1779+/// `stance-centre`'s width -- the window minus the spine and the dock it
1780+/// escaped -- which must come out *larger*, not smaller, than the docked
1781+/// room it replaces. A future change that re-nests the maximize mount back
1782+/// inside the dock, or hands it the dock's width again, fails this.
1783+#[test]
1784+fn a_maximized_cards_room_is_bigger_than_the_docked_rooms_not_smaller() {
1785+ use crate::layout::{Split, split_size};
1786+ use crate::SPLIT_W;
1787+
1788+ // Mirrors `ui/stance.rs`'s private `SPINE_W` (56.) and `layout::SPLIT_W`
1789+ // (the one divider between `stance-centre` and the dock): recomputed
1790+ // rather than imported, same as this test file's other private-constant
1791+ // checks, so a change to either number is felt here too.
1792+ const SPINE_W: f32 = 56.;
1793+
1794+ for window_w in [960., 1280., 1920.] {
1795+ let window = size(px(window_w), px(720.));
1796+ // `split_size`'s own default/floor/ceiling for the dock, with no
1797+ // hand having dragged the seam -- the exact width `dock_stance.rs`
1798+ // now feeds its un-maximized cards as their "room".
1799+ let dock_w = split_size(Split::Dock, None, 2, window, false);
1800+ let docked_room_w = dock_w;
1801+ let maximized_room_w = window_w - SPINE_W - SPLIT_W - dock_w;
1802+
1803+ assert!(
1804+ maximized_room_w > docked_room_w,
1805+ "at a {window_w}px window a maximized card's room ({maximized_room_w}px, \
1806+ stance-centre) is not wider than the docked room it escaped \
1807+ ({docked_room_w}px, dock-clip-rows) -- maximize would be making \
1808+ the card smaller again"
1809+ );
1810+ assert!(
1811+ maximized_room_w <= window_w,
1812+ "a maximized card's room ({maximized_room_w}px) exceeds the whole \
1813+ window ({window_w}px) -- it is being measured in the wrong space"
1814+ );
1815+ // The concrete pixel gain a driving agent should actually see: the
1816+ // EQ graph's own width formula, fed each mount's real room.
1817+ assert!(
1818+ eq_card_w(maximized_room_w, true) > eq_card_w(docked_room_w, false),
1819+ "maximizing the EQ card at a {window_w}px window does not grow \
1820+ eq_card_w's output"
1821+ );
1822+ }
1823+}
1824+
17591825 /// DESIGN's "a maximized scrim covers only the bench/ledger/time-band band,
17601826 /// never the picture": the floor a maximized card's `.top()` is pinned to
17611827 /// must leave exactly the picture's own height above it, for any bench
crates/app/src/ui/dock_stance.rsmodified+36 -14
@@ -525,7 +525,17 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
525525 /// whatever that card already does; nothing about the gesture is reimplemented
526526 /// here.
527527 fn clip_tab(player: &Player, width: f32, window_size: Size<Pixels>, cx: &mut Context<Player>) -> impl IntoElement {
528- let _ = width;
528+ // The room actually given here, not the window's: `eq_card_w`/
529+ // `card_max_w` are asked "how wide may I draw" and answered with the
530+ // *whole viewport's* width when handed `window_size` verbatim -- but this
531+ // tab is a ~280-390px strip inside the dock, not the window, so a card
532+ // capped at up to 720px overflowed past the window's own right edge
533+ // (`20k` rendered as `20`, the `Spectrum on s` button cut mid-glyph).
534+ // Height stays the window's: none of the un-maximized cards' own
535+ // arithmetic uses it (`below_picture_floor` only fires once maximized,
536+ // and a maximized card is mounted at `ui::stance::render` instead, never
537+ // through this `room`).
538+ let room = Size::new(px(width), window_size.height);
529539 let none_open = player.eq_open.is_none()
530540 && player.color_open.is_none()
531541 && player.transform_open.is_none()
@@ -618,19 +628,31 @@ fn clip_tab(player: &Player, width: f32, window_size: Size<Pixels>, cx: &mut Con
618628 .min_h(px(0.))
619629 .px(px(8.))
620630 .pb(px(8.))
621- .children(player.eq_card(window_size, cx))
622- .children(player.color_card(window_size, cx))
623- .children(player.transform_card(window_size, cx))
624- .children(player.speed_card(window_size, cx))
625- .children(player.silence_card(window_size, cx))
626- .children(player.mix_card(window_size, cx))
627- // Subtitle style has no verb row of its own here (see the
628- // comment above the ghost verbs) but its card still has to
629- // be mounted somewhere in the darkroom or its chord (`y`)
630- // opens an invisible modal (GAP 2) -- this is that mount,
631- // painted in the Clip tab like the six cards beside it until
632- // the subtitle lane grows the header that is its real home.
633- .children(player.subtitle_style_card(window_size, cx))
631+ // Maximized is mounted at the window root instead
632+ // (`ui::stance::render`'s `stance-centre`), not here: this
633+ // column is a ~280-390px strip, and an absolutely-positioned
634+ // child is sized against its *immediate* parent regardless of
635+ // any `.relative()` marker -- so a maximized card asking for
636+ // window-sized room while still parented here cannot get it,
637+ // it only gets pushed around inside this narrow, short box
638+ // (the "maximize shrinks the card" defect). Un-maximized, the
639+ // seven cards below stay docked here exactly as before.
640+ .when(!player.card_maximized, |d| {
641+ d.children(player.eq_card(room, cx))
642+ .children(player.color_card(room, cx))
643+ .children(player.transform_card(room, cx))
644+ .children(player.speed_card(room, cx))
645+ .children(player.silence_card(room, cx))
646+ .children(player.mix_card(room, cx))
647+ // Subtitle style has no verb row of its own here (see
648+ // the comment above the ghost verbs) but its card
649+ // still has to be mounted somewhere in the darkroom
650+ // or its chord (`y`) opens an invisible modal (GAP
651+ // 2) -- this is that mount, painted in the Clip tab
652+ // like the six cards beside it until the subtitle
653+ // lane grows the header that is its real home.
654+ .children(player.subtitle_style_card(room, cx))
655+ })
634656 // A plate, not bare space: DESIGN §11's "states" checklist --
635657 // nothing picked reads as a hint, not as a hole in the panel.
636658 .when(none_open, |d| {
crates/app/src/ui/stance.rsmodified+22 -1
@@ -863,7 +863,28 @@ pub(crate) fn render(
863863 // what draws it once open.
864864 .children(player.export_card(window_size, cx))
865865 .children(player.export_progress_card(cx))
866- .children(player.picker_card(window_size, cx)),
866+ .children(player.picker_card(window_size, cx))
867+ // A maximized clip param card (EQ/Colour/Transform/Speed/
868+ // Silence/Mix/Subtitle style) escapes the dock to mount here
869+ // instead, the same window-space `stance-centre` context
870+ // every card above already renders in -- `below_picture_floor`
871+ // is a window coordinate, and `dock_stance.rs`'s
872+ // "dock-clip-rows" is a ~280-390px strip whose own box is the
873+ // containing block for anything absolutely positioned inside
874+ // it, `.relative()` or not, so a card asking for the room
875+ // below the picture cannot get it there. Un-maximized, the
876+ // same seven functions stay mounted in the dock
877+ // (`dock_stance::clip_tab`'s own `.when(!card_maximized, ...)`
878+ // guard keeps this from ever double-mounting one).
879+ .when(player.card_maximized, |el| {
880+ el.children(player.eq_card(window_size, cx))
881+ .children(player.color_card(window_size, cx))
882+ .children(player.transform_card(window_size, cx))
883+ .children(player.speed_card(window_size, cx))
884+ .children(player.silence_card(window_size, cx))
885+ .children(player.mix_card(window_size, cx))
886+ .children(player.subtitle_style_card(window_size, cx))
887+ }),
867888 )
868889 .child(divider(Split::Dock, cx))
869890 .child(dock(player, dock_w, window_size, cx))