From e9946aac9400a4c820f219b72bcfe40661f354c4 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 00:46:22 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(ui):=20the=20bench=20floor?= =?UTF-8?q?=20stops=20clipping=20A1,=20and=20a=20notice=20stops=20hiding?= =?UTF-8?q?=20the=20lanes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BENCH_MIN_H was a guessed literal (80.) 2px short of the actual stack the bench builds top to bottom (section head + padding, ruler, two lane rows at their own floor, and the gaps between them); derive it from those same constants instead so A1's clip-bar border and status dot are no longer cut off unscrolled at the floor. The transient notice plate was anchored a fixed LEDGER_H + 6. off the ledger, which put it directly over the V1/A1 lane chips whenever the bench was short enough. Anchor it bench_h further up instead, so its bottom edge always sits at the bench's own top edge -- above the bench, never over it, at any height. --- crates/app/src/layout.rs | 26 ++++++++++++--- crates/app/src/tests/layout.rs | 53 +++++++++++++++++++++++++++++++ crates/app/src/ui/bench_stance.rs | 8 ++--- crates/app/src/ui/stance.rs | 34 +++++++++++++++++--- 4 files changed, 107 insertions(+), 14 deletions(-) diff --git a/crates/app/src/layout.rs b/crates/app/src/layout.rs index 52ebec7..11339bd 100644 --- a/crates/app/src/layout.rs +++ b/crates/app/src/layout.rs @@ -432,11 +432,27 @@ pub(crate) const SIDE_MAX_FRAC: f32 = 1. / 3.; /// timeline is asking on purpose, and the picture still keeps most of a third. pub(crate) const TIMELINE_MAX_SHARE: f32 = 0.7; -/// The least the darkroom's bench may be dragged to: driven and measured -/// against a real project -- below this the V1 lane's own chip clips and -/// the A1 lane drops off the bench entirely, which a floor exists to make -/// unreachable. -pub(crate) const BENCH_MIN_H: f32 = 80.; +/// The least the darkroom's bench may be dragged to: derived, not measured, +/// from the same stack `ui::stance::bench` and `ui::bench_stance::render` +/// actually build, top to bottom -- +/// [`crate::ui::stance::BENCH_CHROME_H`] (the "bench" section head and its +/// padding) + [`crate::ui::bench_stance::RULER_H`] (the pinned ruler) + +/// [`crate::ui::bench_stance::ROW_GAP`] (the gap `bench-content`'s flex +/// column puts between the ruler and the lane column) + two lane rows at +/// [`crate::ui::bench_stance::LANE_MIN_H`] each (the darkroom's own floor of +/// two lanes -- V1, A1, `bench_stance::render`'s own no-session fallback) +/// + one more `ROW_GAP` between those two rows (`bench-lanes`'s own flex +/// gap). Below this the `bench-lanes` column asks for more height than +/// `bench-content`'s flex_1 gives it, and since that column scrolls rather +/// than clips visibly, the shortfall comes off the bottom row's own pixels +/// unscrolled -- A1's clip-bar border and status dot, first. At the old +/// literal `80.` the shortfall was `82. - 80. == 2.`, the exact ~2px clip +/// this floor now closes. +pub(crate) const BENCH_MIN_H: f32 = crate::ui::stance::BENCH_CHROME_H + + crate::ui::bench_stance::RULER_H + + crate::ui::bench_stance::ROW_GAP + + 2. * crate::ui::bench_stance::LANE_MIN_H + + crate::ui::bench_stance::ROW_GAP; /// What a hand has done to the three seams: the size it dragged each panel to, /// or `None` where nobody has touched one and the window's own share still diff --git a/crates/app/src/tests/layout.rs b/crates/app/src/tests/layout.rs index 37218e4..2902fc0 100644 --- a/crates/app/src/tests/layout.rs +++ b/crates/app/src/tests/layout.rs @@ -1792,6 +1792,59 @@ fn the_darkroom_seams_stop_before_either_side_disappears() { ); } +/// At the bench's floor, both default lanes' rows actually fit inside the +/// `bench-lanes` column `bench_stance::render` gives them -- not just each +/// row's own clamped height, but their *sum plus the gap between them*, +/// since `bench-lanes` scrolls rather than clipping visibly and a sum that +/// overruns the column loses its bottom row's pixels off-screen, unscrolled +/// (this session's F1: the A1 lane's clip-bar border and status dot, cut by +/// ~2px at the old `BENCH_MIN_H = 80.`). +#[test] +fn both_default_lanes_fit_the_bench_at_its_floor() { + use crate::BENCH_MIN_H; + use crate::ui::bench_stance::{LANE_MIN_H, ROW_GAP, RULER_H, row_h}; + use crate::ui::stance::BENCH_CHROME_H; + + let box_h = BENCH_MIN_H - BENCH_CHROME_H; + let avail = box_h - RULER_H - ROW_GAP; + let h = row_h(2, avail); + assert_eq!(h, LANE_MIN_H, "the floor should give both lanes exactly their own minimum -- no more, no less"); + let content = 2. * h + ROW_GAP; + assert!( + content <= avail + 1e-4, + "the two lane rows ({content}px) overrun the column ({avail}px) -- \ + the bottom lane's pixels get cut, unscrolled" + ); +} + +/// The notice plate's own anchor ([`crate::ui::stance::notice_bottom_offset`]) +/// keeps it off the bench, at *any* bench height -- not merely the floor -- +/// because its bottom offset always lands at or above the bench's own top +/// edge. `Player`'s live tree has no `TestAppContext` in this binary to mount +/// a real `notice_plate` in and read its painted bounds back, so this checks +/// the pure geometry the anchor is built from instead (F2: previously the +/// plate sat at a fixed `LEDGER_H + 6.` off the ledger and covered the +/// V1/A1 lane chips whenever the bench was short enough for the plate's own +/// height to reach past it). +#[test] +fn the_notice_plate_cannot_reach_the_bench_at_any_height() { + use crate::BENCH_MIN_H; + use crate::ui::stance::{BENCH_H, LEDGER_H, notice_bottom_offset}; + + for bench_h in [BENCH_MIN_H, BENCH_H, 400.] { + let notice_bottom = notice_bottom_offset(bench_h); + // The bench sits directly above the ledger in the centre column, so + // its own top edge (measured the same way, from the column's foot) + // is exactly `LEDGER_H + bench_h`. + let bench_top = LEDGER_H + bench_h; + assert!( + notice_bottom >= bench_top, + "notice bottom {notice_bottom} sits below the bench's top {bench_top} \ + at bench_h={bench_h} -- the plate can cover a lane row" + ); + } +} + /// A round trip through the file: what is saved is what the next load reads /// back, one seam touched and the other left at its default -- a scratch /// path, not the real config, the same isolation `keymap::tests`' own diff --git a/crates/app/src/ui/bench_stance.rs b/crates/app/src/ui/bench_stance.rs index 0adc56d..c9ab7ac 100644 --- a/crates/app/src/ui/bench_stance.rs +++ b/crates/app/src/ui/bench_stance.rs @@ -45,7 +45,7 @@ use crate::ui::widgets::*; /// The pinned ruler's own height, above the lane stack -- tall enough for a /// tick line plus a mono `MM:SS` label under it (DESIGN §5's "tick marks with /// mono ink3 timecodes"). -const RULER_H: f32 = 22.; +pub(crate) const RULER_H: f32 = 22.; /// The stops a tick interval is picked from (DESIGN §5, the previous /// builder's own note): the smallest one whose pixel width at the current /// zoom still clears [`TICK_MIN_PX`]. @@ -62,12 +62,12 @@ const PLATE_W: f32 = 74.; /// the legacy timeline's `HEADER_W` since a darkroom lane carries no mix/eye /// button yet (deferred with the rest of the header's verbs). const HEAD_W: f32 = 28.; -const ROW_GAP: f32 = 2.; +pub(crate) const ROW_GAP: f32 = 2.; /// DESIGN §7: lanes compress evenly up to this many rows before the column /// scrolls behind the pinned ruler and heads instead of compressing further. const LANES_COMPRESS: usize = 5; const LANE_FULL_H: f32 = 40.; -const LANE_MIN_H: f32 = 18.; +pub(crate) const LANE_MIN_H: f32 = 18.; /// One clip's degradation tier (DESIGN §7), picked off the clip's own worth /// in pixels (`span`, unclamped) rather than its drawn floor @@ -141,7 +141,7 @@ fn tier(span: f32) -> Tier { /// The lane stack's own height budget, split evenly across up to /// [`LANES_COMPRESS`] rows before the column scrolls instead (DESIGN §7). -fn row_h(lanes: usize, box_h: f32) -> f32 { +pub(crate) fn row_h(lanes: usize, box_h: f32) -> f32 { let n = lanes.clamp(1, LANES_COMPRESS) as f32; ((box_h - (n - 1.) * ROW_GAP) / n).clamp(LANE_MIN_H, LANE_FULL_H) } diff --git a/crates/app/src/ui/stance.rs b/crates/app/src/ui/stance.rs index b918bba..af198b8 100644 --- a/crates/app/src/ui/stance.rs +++ b/crates/app/src/ui/stance.rs @@ -35,6 +35,12 @@ pub(crate) const LEDGER_H: f32 = 28.; /// The dock's untouched width -- [`Split::Dock`]'s own default, the same /// role [`BENCH_H`] plays for the bench. pub(crate) const DOCK_W: f32 = 280.; +/// What [`bench`] spends above `bench_stance::render`'s own content: the +/// section head (`type_scale::head`, 10px Archivo) plus its `py(4.)` top and +/// bottom padding. Named and `pub(crate)` rather than the `- 20.` it used to +/// be inlined as, so `layout::BENCH_MIN_H` can add it into its own +/// derivation instead of guessing it back out. +pub(crate) const BENCH_CHROME_H: f32 = 20.; /// The lowest a menu's top edge may sit and still land inside the /// bench/ledger/dock footprint below the screen (DESIGN §5, §9, §11 check 6): @@ -452,7 +458,7 @@ fn bench(player: &mut Player, bench_h: f32, cx: &mut Context) -> impl In .px(px(12.)) .py(px(4.)) .child(section_head("bench")) - .child(bench_stance::render(player, bench_h - 20., cx)) + .child(bench_stance::render(player, bench_h - BENCH_CHROME_H, cx)) } /// Which of the three §8 severities a notice's own words carry. Reuses @@ -473,22 +479,40 @@ fn notice_severity(message: &str) -> u32 { } } -/// A notice plate (DESIGN §8): one at a time, rising above the ledger, its +/// [`notice_plate`]'s own `bottom` offset, pulled out as a pure function so +/// a `TestAppContext`-less test binary (this crate's own, no live `Context` +/// to mount a real `notice_plate` in) can still check the plate never lands +/// over the bench, for any `bench_h` -- without duplicating the arithmetic +/// by hand and risking the two drifting apart. +pub(crate) fn notice_bottom_offset(bench_h: f32) -> f32 { + LEDGER_H + bench_h + 6. +} + +/// A notice plate (DESIGN §8): one at a time, rising above the *bench*, its /// severity a 3px left spine rather than a colour flood. Fed by the same /// [`Player::notify_user`]/`notices` queue the legacy bar reads /// ([`Player::notice_bar`]) -- no second notice channel. Dismissal is /// already wired: [`render`]'s `on_key_down` calls `dismiss_notice()` on /// every stroke, the same door the legacy handler uses. /// +/// Anchored off `bench_h` rather than a fixed offset off the ledger: at the +/// bench's floor a fixed `LEDGER_H + 6.` bottom offset put the plate right +/// over the V1/A1 lane chips -- a transient message hiding the lanes for as +/// long as it sat there. Floating it `bench_h` further up puts its bottom +/// edge at the bench's own *top* edge for any bench height, so it always +/// sits in the divider/time-band's slack above the bench rather than over +/// the lanes, and never has to reserve room in the bench itself for a +/// message that is not always there. +/// /// corner-cut: amber's "carries a jump action" is not wired -- the queue /// only ever held plain text, no structured jump target, in either the /// legacy bar or here. Ceiling: give `notify_user` an optional jump payload /// once a call site actually has one to carry. -fn notice_plate(message: SharedString) -> impl IntoElement { +fn notice_plate(message: SharedString, bench_h: f32) -> impl IntoElement { div() .id("stance-notice") .absolute() - .bottom(px(LEDGER_H + 6.)) + .bottom(px(notice_bottom_offset(bench_h))) .left(px(12.)) .max_w(px(360.)) .flex() @@ -809,7 +833,7 @@ pub(crate) fn render( .child(bench(player, bench_h, cx)) .child(ledger(player, position)) .when_some(player.notices.front().cloned(), |el, n| { - el.child(notice_plate(n)) + el.child(notice_plate(n, bench_h)) }) .when(player.keys_open, |el| el.child(keys_overlay(player))) // The two menus (DESIGN §9: "verbs of the thing under the