A maximized clip card escapes the dock instead of the sliver inside it
Browse files at this commitb1ff91f376261ec7e4c0fed60baf7871b2d7975bParent: db1e199- fix
- a maximized clip card escapes the dock instead of the sliver inside it
3 changed files +124 -15
- crates/app/src/tests/cards.rs +66 -0
- crates/app/src/ui/dock_stance.rs +36 -14
- crates/app/src/ui/stance.rs +22 -1
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() { | |||
| 1756 | assert_eq!(eq_y(0.), eq_y(0.)); | 1756 | assert_eq!(eq_y(0.), eq_y(0.)); |
| 1757 | } | 1757 | } |
| 1758 | 1758 | ||
| 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 | + | ||
| 1759 | /// DESIGN's "a maximized scrim covers only the bench/ledger/time-band band, | 1825 | /// DESIGN's "a maximized scrim covers only the bench/ledger/time-band band, |
| 1760 | /// never the picture": the floor a maximized card's `.top()` is pinned to | 1826 | /// never the picture": the floor a maximized card's `.top()` is pinned to |
| 1761 | /// must leave exactly the picture's own height above it, for any bench | 1827 | /// 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 { | |||
| 525 | /// whatever that card already does; nothing about the gesture is reimplemented | 525 | /// whatever that card already does; nothing about the gesture is reimplemented |
| 526 | /// here. | 526 | /// here. |
| 527 | fn clip_tab(player: &Player, width: f32, window_size: Size<Pixels>, cx: &mut Context<Player>) -> impl IntoElement { | 527 | 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); | ||
| 529 | let none_open = player.eq_open.is_none() | 539 | let none_open = player.eq_open.is_none() |
| 530 | && player.color_open.is_none() | 540 | && player.color_open.is_none() |
| 531 | && player.transform_open.is_none() | 541 | && player.transform_open.is_none() |
| @@ -618,19 +628,31 @@ fn clip_tab(player: &Player, width: f32, window_size: Size<Pixels>, cx: &mut Con | |||
| 618 | .min_h(px(0.)) | 628 | .min_h(px(0.)) |
| 619 | .px(px(8.)) | 629 | .px(px(8.)) |
| 620 | .pb(px(8.)) | 630 | .pb(px(8.)) |
| 621 | - .children(player.eq_card(window_size, cx)) | 631 | + // Maximized is mounted at the window root instead |
| 622 | - .children(player.color_card(window_size, cx)) | 632 | + // (`ui::stance::render`'s `stance-centre`), not here: this |
| 623 | - .children(player.transform_card(window_size, cx)) | 633 | + // column is a ~280-390px strip, and an absolutely-positioned |
| 624 | - .children(player.speed_card(window_size, cx)) | 634 | + // child is sized against its *immediate* parent regardless of |
| 625 | - .children(player.silence_card(window_size, cx)) | 635 | + // any `.relative()` marker -- so a maximized card asking for |
| 626 | - .children(player.mix_card(window_size, cx)) | 636 | + // window-sized room while still parented here cannot get it, |
| 627 | - // Subtitle style has no verb row of its own here (see the | 637 | + // it only gets pushed around inside this narrow, short box |
| 628 | - // comment above the ghost verbs) but its card still has to | 638 | + // (the "maximize shrinks the card" defect). Un-maximized, the |
| 629 | - // be mounted somewhere in the darkroom or its chord (`y`) | 639 | + // seven cards below stay docked here exactly as before. |
| 630 | - // opens an invisible modal (GAP 2) -- this is that mount, | 640 | + .when(!player.card_maximized, |d| { |
| 631 | - // painted in the Clip tab like the six cards beside it until | 641 | + d.children(player.eq_card(room, cx)) |
| 632 | - // the subtitle lane grows the header that is its real home. | 642 | + .children(player.color_card(room, cx)) |
| 633 | - .children(player.subtitle_style_card(window_size, 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 | + }) | ||
| 634 | // A plate, not bare space: DESIGN §11's "states" checklist -- | 656 | // A plate, not bare space: DESIGN §11's "states" checklist -- |
| 635 | // nothing picked reads as a hint, not as a hole in the panel. | 657 | // nothing picked reads as a hint, not as a hole in the panel. |
| 636 | .when(none_open, |d| { | 658 | .when(none_open, |d| { |
crates/app/src/ui/stance.rsmodified+22 -1
| @@ -863,7 +863,28 @@ pub(crate) fn render( | |||
| 863 | // what draws it once open. | 863 | // what draws it once open. |
| 864 | .children(player.export_card(window_size, cx)) | 864 | .children(player.export_card(window_size, cx)) |
| 865 | .children(player.export_progress_card(cx)) | 865 | .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 | + }), | ||
| 867 | ) | 888 | ) |
| 868 | .child(divider(Split::Dock, cx)) | 889 | .child(divider(Split::Dock, cx)) |
| 869 | .child(dock(player, dock_w, window_size, cx)) | 890 | .child(dock(player, dock_w, window_size, cx)) |