From b1ff91f376261ec7e4c0fed60baf7871b2d7975b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 21 Aug 2026 02:13:40 +0300 Subject: [PATCH] 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.rs | 66 ++++++++++++++++++++++++++++++++ crates/app/src/ui/dock_stance.rs | 50 +++++++++++++++++------- crates/app/src/ui/stance.rs | 23 ++++++++++- 3 files changed, 124 insertions(+), 15 deletions(-) diff --git a/crates/app/src/tests/cards.rs b/crates/app/src/tests/cards.rs index 8a81772..f8843cd 100644 --- a/crates/app/src/tests/cards.rs +++ b/crates/app/src/tests/cards.rs @@ -1756,6 +1756,72 @@ fn maximizing_a_card_grows_its_box_without_moving_where_a_value_sits_in_it() { 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 diff --git a/crates/app/src/ui/dock_stance.rs b/crates/app/src/ui/dock_stance.rs index 530ca59..8c861a8 100644 --- a/crates/app/src/ui/dock_stance.rs +++ b/crates/app/src/ui/dock_stance.rs @@ -525,7 +525,17 @@ fn sources_tab(player: &Player, cx: &mut Context) -> impl IntoElement { /// whatever that card already does; nothing about the gesture is reimplemented /// here. fn clip_tab(player: &Player, width: f32, window_size: Size, cx: &mut Context) -> impl IntoElement { - let _ = width; + // 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() @@ -618,19 +628,31 @@ fn clip_tab(player: &Player, width: f32, window_size: Size, cx: &mut Con .min_h(px(0.)) .px(px(8.)) .pb(px(8.)) - .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)) - // Subtitle style has no verb row of its own here (see the - // comment above the ghost verbs) but its card still has to - // be mounted somewhere in the darkroom or its chord (`y`) - // opens an invisible modal (GAP 2) -- this is that mount, - // painted in the Clip tab like the six cards beside it until - // the subtitle lane grows the header that is its real home. - .children(player.subtitle_style_card(window_size, cx)) + // Maximized is mounted at the window root instead + // (`ui::stance::render`'s `stance-centre`), not here: this + // column is a ~280-390px strip, and an absolutely-positioned + // child is sized against its *immediate* parent regardless of + // any `.relative()` marker -- so a maximized card asking for + // window-sized room while still parented here cannot get it, + // it only gets pushed around inside this narrow, short box + // (the "maximize shrinks the card" defect). Un-maximized, the + // seven cards below stay docked here exactly as before. + .when(!player.card_maximized, |d| { + d.children(player.eq_card(room, cx)) + .children(player.color_card(room, cx)) + .children(player.transform_card(room, cx)) + .children(player.speed_card(room, cx)) + .children(player.silence_card(room, cx)) + .children(player.mix_card(room, cx)) + // Subtitle style has no verb row of its own here (see + // the comment above the ghost verbs) but its card + // still has to be mounted somewhere in the darkroom + // or its chord (`y`) opens an invisible modal (GAP + // 2) -- this is that mount, painted in the Clip tab + // like the six cards beside it until the subtitle + // lane grows the header that is its real home. + .children(player.subtitle_style_card(room, cx)) + }) // A plate, not bare space: DESIGN ยง11's "states" checklist -- // nothing picked reads as a hint, not as a hole in the panel. .when(none_open, |d| { diff --git a/crates/app/src/ui/stance.rs b/crates/app/src/ui/stance.rs index 69b1955..6e91e07 100644 --- a/crates/app/src/ui/stance.rs +++ b/crates/app/src/ui/stance.rs @@ -863,7 +863,28 @@ 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_size, cx))