forge
Explore
Log in

Don't you dare go Hollow

The bench floor stops clipping A1, and a notice stops hiding the lanes

Browse files at this commit

e9946aac9400a4c820f219b72bcfe40661f354c4Ahmet Kaan GümüşParent: 563ade6
  • fix
    • the bench floor stops clipping A1, and a notice stops hiding the lanes
Show full message
🐛 fix(ui): the bench floor stops clipping A1, and a notice stops hiding the lanes

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.rsmodified+21 -5
@@ -432,11 +432,27 @@ pub(crate) const SIDE_MAX_FRAC: f32 = 1. / 3.;
432432 /// timeline is asking on purpose, and the picture still keeps most of a third.
433433 pub(crate) const TIMELINE_MAX_SHARE: f32 = 0.7;
434434
435-/// The least the darkroom's bench may be dragged to: driven and measured
436-/// against a real project -- below this the V1 lane's own chip clips and
437-/// the A1 lane drops off the bench entirely, which a floor exists to make
438-/// unreachable.
439-pub(crate) const BENCH_MIN_H: f32 = 80.;
435+/// The least the darkroom's bench may be dragged to: derived, not measured,
436+/// from the same stack `ui::stance::bench` and `ui::bench_stance::render`
437+/// actually build, top to bottom --
438+/// [`crate::ui::stance::BENCH_CHROME_H`] (the "bench" section head and its
439+/// padding) + [`crate::ui::bench_stance::RULER_H`] (the pinned ruler) +
440+/// [`crate::ui::bench_stance::ROW_GAP`] (the gap `bench-content`'s flex
441+/// column puts between the ruler and the lane column) + two lane rows at
442+/// [`crate::ui::bench_stance::LANE_MIN_H`] each (the darkroom's own floor of
443+/// two lanes -- V1, A1, `bench_stance::render`'s own no-session fallback)
444+/// + one more `ROW_GAP` between those two rows (`bench-lanes`'s own flex
445+/// gap). Below this the `bench-lanes` column asks for more height than
446+/// `bench-content`'s flex_1 gives it, and since that column scrolls rather
447+/// than clips visibly, the shortfall comes off the bottom row's own pixels
448+/// unscrolled -- A1's clip-bar border and status dot, first. At the old
449+/// literal `80.` the shortfall was `82. - 80. == 2.`, the exact ~2px clip
450+/// this floor now closes.
451+pub(crate) const BENCH_MIN_H: f32 = crate::ui::stance::BENCH_CHROME_H
452+ + crate::ui::bench_stance::RULER_H
453+ + crate::ui::bench_stance::ROW_GAP
454+ + 2. * crate::ui::bench_stance::LANE_MIN_H
455+ + crate::ui::bench_stance::ROW_GAP;
440456
441457 /// What a hand has done to the three seams: the size it dragged each panel to,
442458 /// or `None` where nobody has touched one and the window's own share still
crates/app/src/tests/layout.rsmodified+53 -0
@@ -1792,6 +1792,59 @@ fn the_darkroom_seams_stop_before_either_side_disappears() {
17921792 );
17931793 }
17941794
1795+/// At the bench's floor, both default lanes' rows actually fit inside the
1796+/// `bench-lanes` column `bench_stance::render` gives them -- not just each
1797+/// row's own clamped height, but their *sum plus the gap between them*,
1798+/// since `bench-lanes` scrolls rather than clipping visibly and a sum that
1799+/// overruns the column loses its bottom row's pixels off-screen, unscrolled
1800+/// (this session's F1: the A1 lane's clip-bar border and status dot, cut by
1801+/// ~2px at the old `BENCH_MIN_H = 80.`).
1802+#[test]
1803+fn both_default_lanes_fit_the_bench_at_its_floor() {
1804+ use crate::BENCH_MIN_H;
1805+ use crate::ui::bench_stance::{LANE_MIN_H, ROW_GAP, RULER_H, row_h};
1806+ use crate::ui::stance::BENCH_CHROME_H;
1807+
1808+ let box_h = BENCH_MIN_H - BENCH_CHROME_H;
1809+ let avail = box_h - RULER_H - ROW_GAP;
1810+ let h = row_h(2, avail);
1811+ assert_eq!(h, LANE_MIN_H, "the floor should give both lanes exactly their own minimum -- no more, no less");
1812+ let content = 2. * h + ROW_GAP;
1813+ assert!(
1814+ content <= avail + 1e-4,
1815+ "the two lane rows ({content}px) overrun the column ({avail}px) -- \
1816+ the bottom lane's pixels get cut, unscrolled"
1817+ );
1818+}
1819+
1820+/// The notice plate's own anchor ([`crate::ui::stance::notice_bottom_offset`])
1821+/// keeps it off the bench, at *any* bench height -- not merely the floor --
1822+/// because its bottom offset always lands at or above the bench's own top
1823+/// edge. `Player`'s live tree has no `TestAppContext` in this binary to mount
1824+/// a real `notice_plate` in and read its painted bounds back, so this checks
1825+/// the pure geometry the anchor is built from instead (F2: previously the
1826+/// plate sat at a fixed `LEDGER_H + 6.` off the ledger and covered the
1827+/// V1/A1 lane chips whenever the bench was short enough for the plate's own
1828+/// height to reach past it).
1829+#[test]
1830+fn the_notice_plate_cannot_reach_the_bench_at_any_height() {
1831+ use crate::BENCH_MIN_H;
1832+ use crate::ui::stance::{BENCH_H, LEDGER_H, notice_bottom_offset};
1833+
1834+ for bench_h in [BENCH_MIN_H, BENCH_H, 400.] {
1835+ let notice_bottom = notice_bottom_offset(bench_h);
1836+ // The bench sits directly above the ledger in the centre column, so
1837+ // its own top edge (measured the same way, from the column's foot)
1838+ // is exactly `LEDGER_H + bench_h`.
1839+ let bench_top = LEDGER_H + bench_h;
1840+ assert!(
1841+ notice_bottom >= bench_top,
1842+ "notice bottom {notice_bottom} sits below the bench's top {bench_top} \
1843+ at bench_h={bench_h} -- the plate can cover a lane row"
1844+ );
1845+ }
1846+}
1847+
17951848 /// A round trip through the file: what is saved is what the next load reads
17961849 /// back, one seam touched and the other left at its default -- a scratch
17971850 /// path, not the real config, the same isolation `keymap::tests`' own
crates/app/src/ui/bench_stance.rsmodified+4 -4
@@ -45,7 +45,7 @@ use crate::ui::widgets::*;
4545 /// The pinned ruler's own height, above the lane stack -- tall enough for a
4646 /// tick line plus a mono `MM:SS` label under it (DESIGN §5's "tick marks with
4747 /// mono ink3 timecodes").
48-const RULER_H: f32 = 22.;
48+pub(crate) const RULER_H: f32 = 22.;
4949 /// The stops a tick interval is picked from (DESIGN §5, the previous
5050 /// builder's own note): the smallest one whose pixel width at the current
5151 /// zoom still clears [`TICK_MIN_PX`].
@@ -62,12 +62,12 @@ const PLATE_W: f32 = 74.;
6262 /// the legacy timeline's `HEADER_W` since a darkroom lane carries no mix/eye
6363 /// button yet (deferred with the rest of the header's verbs).
6464 const HEAD_W: f32 = 28.;
65-const ROW_GAP: f32 = 2.;
65+pub(crate) const ROW_GAP: f32 = 2.;
6666 /// DESIGN §7: lanes compress evenly up to this many rows before the column
6767 /// scrolls behind the pinned ruler and heads instead of compressing further.
6868 const LANES_COMPRESS: usize = 5;
6969 const LANE_FULL_H: f32 = 40.;
70-const LANE_MIN_H: f32 = 18.;
70+pub(crate) const LANE_MIN_H: f32 = 18.;
7171
7272 /// One clip's degradation tier (DESIGN §7), picked off the clip's own worth
7373 /// in pixels (`span`, unclamped) rather than its drawn floor
@@ -141,7 +141,7 @@ fn tier(span: f32) -> Tier {
141141
142142 /// The lane stack's own height budget, split evenly across up to
143143 /// [`LANES_COMPRESS`] rows before the column scrolls instead (DESIGN §7).
144-fn row_h(lanes: usize, box_h: f32) -> f32 {
144+pub(crate) fn row_h(lanes: usize, box_h: f32) -> f32 {
145145 let n = lanes.clamp(1, LANES_COMPRESS) as f32;
146146 ((box_h - (n - 1.) * ROW_GAP) / n).clamp(LANE_MIN_H, LANE_FULL_H)
147147 }
crates/app/src/ui/stance.rsmodified+29 -5
@@ -35,6 +35,12 @@ pub(crate) const LEDGER_H: f32 = 28.;
3535 /// The dock's untouched width -- [`Split::Dock`]'s own default, the same
3636 /// role [`BENCH_H`] plays for the bench.
3737 pub(crate) const DOCK_W: f32 = 280.;
38+/// What [`bench`] spends above `bench_stance::render`'s own content: the
39+/// section head (`type_scale::head`, 10px Archivo) plus its `py(4.)` top and
40+/// bottom padding. Named and `pub(crate)` rather than the `- 20.` it used to
41+/// be inlined as, so `layout::BENCH_MIN_H` can add it into its own
42+/// derivation instead of guessing it back out.
43+pub(crate) const BENCH_CHROME_H: f32 = 20.;
3844
3945 /// The lowest a menu's top edge may sit and still land inside the
4046 /// 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<Player>) -> impl In
452458 .px(px(12.))
453459 .py(px(4.))
454460 .child(section_head("bench"))
455- .child(bench_stance::render(player, bench_h - 20., cx))
461+ .child(bench_stance::render(player, bench_h - BENCH_CHROME_H, cx))
456462 }
457463
458464 /// Which of the three §8 severities a notice's own words carry. Reuses
@@ -473,22 +479,40 @@ fn notice_severity(message: &str) -> u32 {
473479 }
474480 }
475481
476-/// A notice plate (DESIGN §8): one at a time, rising above the ledger, its
482+/// [`notice_plate`]'s own `bottom` offset, pulled out as a pure function so
483+/// a `TestAppContext`-less test binary (this crate's own, no live `Context`
484+/// to mount a real `notice_plate` in) can still check the plate never lands
485+/// over the bench, for any `bench_h` -- without duplicating the arithmetic
486+/// by hand and risking the two drifting apart.
487+pub(crate) fn notice_bottom_offset(bench_h: f32) -> f32 {
488+ LEDGER_H + bench_h + 6.
489+}
490+
491+/// A notice plate (DESIGN §8): one at a time, rising above the *bench*, its
477492 /// severity a 3px left spine rather than a colour flood. Fed by the same
478493 /// [`Player::notify_user`]/`notices` queue the legacy bar reads
479494 /// ([`Player::notice_bar`]) -- no second notice channel. Dismissal is
480495 /// already wired: [`render`]'s `on_key_down` calls `dismiss_notice()` on
481496 /// every stroke, the same door the legacy handler uses.
482497 ///
498+/// Anchored off `bench_h` rather than a fixed offset off the ledger: at the
499+/// bench's floor a fixed `LEDGER_H + 6.` bottom offset put the plate right
500+/// over the V1/A1 lane chips -- a transient message hiding the lanes for as
501+/// long as it sat there. Floating it `bench_h` further up puts its bottom
502+/// edge at the bench's own *top* edge for any bench height, so it always
503+/// sits in the divider/time-band's slack above the bench rather than over
504+/// the lanes, and never has to reserve room in the bench itself for a
505+/// message that is not always there.
506+///
483507 /// corner-cut: amber's "carries a jump action" is not wired -- the queue
484508 /// only ever held plain text, no structured jump target, in either the
485509 /// legacy bar or here. Ceiling: give `notify_user` an optional jump payload
486510 /// once a call site actually has one to carry.
487-fn notice_plate(message: SharedString) -> impl IntoElement {
511+fn notice_plate(message: SharedString, bench_h: f32) -> impl IntoElement {
488512 div()
489513 .id("stance-notice")
490514 .absolute()
491- .bottom(px(LEDGER_H + 6.))
515+ .bottom(px(notice_bottom_offset(bench_h)))
492516 .left(px(12.))
493517 .max_w(px(360.))
494518 .flex()
@@ -809,7 +833,7 @@ pub(crate) fn render(
809833 .child(bench(player, bench_h, cx))
810834 .child(ledger(player, position))
811835 .when_some(player.notices.front().cloned(), |el, n| {
812- el.child(notice_plate(n))
836+ el.child(notice_plate(n, bench_h))
813837 })
814838 .when(player.keys_open, |el| el.child(keys_overlay(player)))
815839 // The two menus (DESIGN §9: "verbs of the thing under the