The bench floor counts its own border and the ledger's
Browse files at this commitede1e2cbd1694e4bb7a6d647f2e09882e10d306aParent: db9815b- fix
- the bench floor counts its own border and the ledger's
3 changed files +113 -24
- crates/app/src/layout.rs +43 -18
- crates/app/src/tests/layout.rs +58 -1
- crates/app/src/ui/stance.rs +12 -5
crates/app/src/layout.rsmodified+43 -18
| @@ -432,31 +432,56 @@ pub(crate) const SIDE_MAX_FRAC: f32 = 1. / 3.; | |||
| 432 | /// timeline is asking on purpose, and the picture still keeps most of a third. | 432 | /// timeline is asking on purpose, and the picture still keeps most of a third. |
| 433 | pub(crate) const TIMELINE_MAX_SHARE: f32 = 0.7; | 433 | pub(crate) const TIMELINE_MAX_SHARE: f32 = 0.7; |
| 434 | 434 | ||
| 435 | +/// The room the ledger's own top border (`ui::stance::ledger`'s | ||
| 436 | +/// `.border_t_1()`) needs kept clear below the bench's own last content | ||
| 437 | +/// pixel. The ledger sits at a *fixed* distance from the window's own foot | ||
| 438 | +/// (`ui::stance::LEDGER_H`), not from wherever the bench's content happens | ||
| 439 | +/// to end, so if the bench's last lane row reaches exactly as far as the | ||
| 440 | +/// ledger's own top row, the ledger's border -- later in the same flex | ||
| 441 | +/// column, so it paints over whatever is already there -- wins the shared | ||
| 442 | +/// pixel rather than sitting cleanly below it. Driven, at [`BENCH_MIN_H`]'s | ||
| 443 | +/// own third clip: `bench=95` (the stack's exact content need, no spare row) | ||
| 444 | +/// still lost A1's status dot's last row to the rule; `bench=96` (one row of | ||
| 445 | +/// clearance) drew it whole. The 95-vs-96 tension is this term, not a | ||
| 446 | +/// rounding accident -- a bench exactly as tall as its content still shares | ||
| 447 | +/// its last row with the ledger's border. | ||
| 448 | +const LEDGER_SEAM_CLEARANCE: f32 = 1.; | ||
| 449 | + | ||
| 435 | /// The least the darkroom's bench may be dragged to: derived, not measured, | 450 | /// 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` | 451 | /// from the same stack `ui::stance::bench` and `ui::bench_stance::render` |
| 437 | /// actually build, top to bottom -- | 452 | /// actually build, top to bottom -- |
| 438 | -/// [`crate::ui::stance::BENCH_CHROME_H`] (the "bench" section head and its | 453 | +/// [`crate::ui::stance::BENCH_CHROME_H`] (the "bench" section head's real |
| 439 | -/// padding) + [`crate::ui::bench_stance::RULER_H`] (the pinned ruler) + | 454 | +/// line box, plus the bench div's own top border and top padding -- see its |
| 440 | -/// [`crate::ui::bench_stance::ROW_GAP`] (the gap `bench-content`'s flex | 455 | +/// own doc comment) + [`crate::ui::bench_stance::RULER_H`] (the pinned |
| 441 | -/// column puts between the ruler and the lane column) + two lane rows at | 456 | +/// ruler) + [`crate::ui::bench_stance::ROW_GAP`] (the gap `bench-content`'s |
| 442 | -/// [`crate::ui::bench_stance::LANE_MIN_H`] each (the darkroom's own floor of | 457 | +/// flex column puts between the ruler and the lane column) + two lane rows |
| 443 | -/// two lanes -- V1, A1, `bench_stance::render`'s own no-session fallback) | 458 | +/// at [`crate::ui::bench_stance::LANE_MIN_H`] each (the darkroom's own floor |
| 444 | -/// + one more `ROW_GAP` between those two rows (`bench-lanes`'s own flex | 459 | +/// of two lanes -- V1, A1, `bench_stance::render`'s own no-session |
| 445 | -/// gap). Below this the `bench-lanes` column asks for more height than | 460 | +/// fallback) + one more `ROW_GAP` between those two rows (`bench-lanes`'s |
| 446 | -/// `bench-content`'s flex_1 gives it, and since that column scrolls rather | 461 | +/// own flex gap) + [`LEDGER_SEAM_CLEARANCE`] (the row the ledger's own |
| 447 | -/// than clips visibly, the shortfall comes off the bottom row's own pixels | 462 | +/// border needs kept clear, see its own doc comment). Below this the |
| 448 | -/// unscrolled -- A1's clip-bar border and status dot, first. `LANE_MIN_H` | 463 | +/// `bench-lanes` column asks for more height than `bench-content`'s flex_1 |
| 449 | -/// itself is now derived from what a lane head actually draws (its own | 464 | +/// gives it, and since that column scrolls rather than clips visibly, the |
| 450 | -/// doc comment), not a number copied from nowhere: an earlier floor of | 465 | +/// shortfall comes off the bottom row's own pixels unscrolled -- A1's |
| 451 | -/// `82.` used a `LANE_MIN_H` of `18.` that fit only the lane label and let | 466 | +/// clip-bar border and status dot, first. `LANE_MIN_H` itself is derived |
| 452 | -/// every lane's status dot overflow into the row beneath it, invisible | 467 | +/// from what a lane head actually draws (its own doc comment), not a number |
| 453 | -/// everywhere but the last lane, which has no next row to spill into and | 468 | +/// copied from nowhere: an earlier floor of `82.` used a `LANE_MIN_H` of |
| 454 | -/// clipped straight into the ledger instead. | 469 | +/// `18.` that fit only the lane label and let every lane's status dot |
| 470 | +/// overflow into the row beneath it, invisible everywhere but the last | ||
| 471 | +/// lane, which has no next row to spill into and clipped straight into the | ||
| 472 | +/// ledger instead. | ||
| 473 | +/// | ||
| 474 | +/// A third driven pass at the next floor (`94.`, `BENCH_CHROME_H` still | ||
| 475 | +/// undercounted at `20.`) clipped A1's dot again, by one row -- two 1px | ||
| 476 | +/// causes stacked, not one 2px guess: `BENCH_CHROME_H`'s own undercount | ||
| 477 | +/// (`20.` vs its real `21.`) and this term, `LEDGER_SEAM_CLEARANCE`, which | ||
| 478 | +/// the formula never carried at all. `21 + 22 + 2 + 48 + 2 + 1` = `96.`. | ||
| 455 | pub(crate) const BENCH_MIN_H: f32 = crate::ui::stance::BENCH_CHROME_H | 479 | pub(crate) const BENCH_MIN_H: f32 = crate::ui::stance::BENCH_CHROME_H |
| 456 | + crate::ui::bench_stance::RULER_H | 480 | + crate::ui::bench_stance::RULER_H |
| 457 | + crate::ui::bench_stance::ROW_GAP | 481 | + crate::ui::bench_stance::ROW_GAP |
| 458 | + 2. * crate::ui::bench_stance::LANE_MIN_H | 482 | + 2. * crate::ui::bench_stance::LANE_MIN_H |
| 459 | - + crate::ui::bench_stance::ROW_GAP; | 483 | + + crate::ui::bench_stance::ROW_GAP |
| 484 | + + LEDGER_SEAM_CLEARANCE; | ||
| 460 | 485 | ||
| 461 | /// What a hand has done to the three seams: the size it dragged each panel to, | 486 | /// What a hand has done to the three seams: the size it dragged each panel to, |
| 462 | /// or `None` where nobody has touched one and the window's own share still | 487 | /// or `None` where nobody has touched one and the window's own share still |
crates/app/src/tests/layout.rsmodified+58 -1
| @@ -1808,7 +1808,11 @@ fn both_default_lanes_fit_the_bench_at_its_floor() { | |||
| 1808 | let box_h = BENCH_MIN_H - BENCH_CHROME_H; | 1808 | let box_h = BENCH_MIN_H - BENCH_CHROME_H; |
| 1809 | let avail = box_h - RULER_H - ROW_GAP; | 1809 | let avail = box_h - RULER_H - ROW_GAP; |
| 1810 | let h = row_h(2, avail); | 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"); | 1811 | + // Not an exact `LANE_MIN_H` any more: `BENCH_MIN_H` now carries one spare |
| 1812 | + // row (`layout::LEDGER_SEAM_CLEARANCE`) so the last lane's own last pixel | ||
| 1813 | + // never shares a row with the ledger's border, which lands here as | ||
| 1814 | + // `avail` being a touch over the two-rows-plus-gap tight fit. | ||
| 1815 | + assert!(h >= LANE_MIN_H, "the floor should give both lanes at least their own minimum ({h} < {LANE_MIN_H})"); | ||
| 1812 | let content = 2. * h + ROW_GAP; | 1816 | let content = 2. * h + ROW_GAP; |
| 1813 | assert!( | 1817 | assert!( |
| 1814 | content <= avail + 1e-4, | 1818 | content <= avail + 1e-4, |
| @@ -1817,6 +1821,59 @@ fn both_default_lanes_fit_the_bench_at_its_floor() { | |||
| 1817 | ); | 1821 | ); |
| 1818 | } | 1822 | } |
| 1819 | 1823 | ||
| 1824 | +/// `BENCH_CHROME_H` on its own: the previous test's `box_h = BENCH_MIN_H - | ||
| 1825 | +/// BENCH_CHROME_H` line trusts `BENCH_CHROME_H` to already be correct, so it | ||
| 1826 | +/// cannot catch `BENCH_CHROME_H` itself drifting -- which is exactly how the | ||
| 1827 | +/// third clip (this session's) survived it: the constant undercounted the | ||
| 1828 | +/// section head's real line box by 1px and this test's predecessor never | ||
| 1829 | +/// looked. Recomputes what `ui::stance::bench` actually draws above | ||
| 1830 | +/// `bench_stance::render`'s content -- the div's own `.border_t_1()` (1px) | ||
| 1831 | +/// + its `py(4.)` top padding + the section head's real line box at gpui's | ||
| 1832 | +/// golden-ratio line-height, not the label's bare font size (the same trap | ||
| 1833 | +/// `a_lane_row_fits_what_its_own_head_draws` already checks for the lane | ||
| 1834 | +/// heads) -- and then checks the *whole* stack -- chrome, ruler, both gaps, | ||
| 1835 | +/// both lanes, and the clear row the ledger's own fixed-position border | ||
| 1836 | +/// needs (`LEDGER_SEAM_CLEARANCE`, not exported, so this recomputes it as | ||
| 1837 | +/// `BENCH_MIN_H` minus every other named term) -- fits inside `BENCH_MIN_H` | ||
| 1838 | +/// with nothing left over uncounted. This binary carries no `TestAppContext` | ||
| 1839 | +/// to mount `ui::stance::bench` and `ui::stance::ledger` for real and read | ||
| 1840 | +/// painted bounds back, so it stays geometry-only, same as its neighbours. | ||
| 1841 | +#[test] | ||
| 1842 | +fn the_whole_bench_stack_fits_its_own_floor_with_the_ledger_seam_clear() { | ||
| 1843 | + use crate::BENCH_MIN_H; | ||
| 1844 | + use crate::ui::bench_stance::{LANE_MIN_H, ROW_GAP, RULER_H}; | ||
| 1845 | + use crate::ui::stance::BENCH_CHROME_H; | ||
| 1846 | + use crate::ui::type_scale::SECTION_HEAD_PX; | ||
| 1847 | + | ||
| 1848 | + const BENCH_BORDER_T: f32 = 1.; | ||
| 1849 | + const BENCH_PY_TOP: f32 = 4.; | ||
| 1850 | + let section_head_line_h = (SECTION_HEAD_PX * 1.618_034).round(); | ||
| 1851 | + let real_chrome = BENCH_BORDER_T + BENCH_PY_TOP + section_head_line_h; | ||
| 1852 | + assert_eq!( | ||
| 1853 | + BENCH_CHROME_H, real_chrome, | ||
| 1854 | + "BENCH_CHROME_H ({BENCH_CHROME_H}) does not match what `stance::bench` \ | ||
| 1855 | + actually draws above the content ({real_chrome}px: {BENCH_BORDER_T}px \ | ||
| 1856 | + border + {BENCH_PY_TOP}px padding + {section_head_line_h}px label line \ | ||
| 1857 | + box) -- bench_stance::render gets handed the wrong box_h and lays its \ | ||
| 1858 | + rows out past its own real space" | ||
| 1859 | + ); | ||
| 1860 | + | ||
| 1861 | + // The ledger's own fixed-position border needs one more clear row below | ||
| 1862 | + // the last lane, on top of chrome + ruler + both gaps + both lanes -- | ||
| 1863 | + // recomputed here rather than importing the private | ||
| 1864 | + // `layout::LEDGER_SEAM_CLEARANCE`, so this test fails if that term is | ||
| 1865 | + // ever silently dropped from `BENCH_MIN_H`'s own sum. | ||
| 1866 | + let content_need = real_chrome + RULER_H + ROW_GAP + 2. * LANE_MIN_H + ROW_GAP; | ||
| 1867 | + let ledger_seam_clearance = BENCH_MIN_H - content_need; | ||
| 1868 | + assert!( | ||
| 1869 | + ledger_seam_clearance >= 1. - 1e-4, | ||
| 1870 | + "BENCH_MIN_H ({BENCH_MIN_H}) leaves only {ledger_seam_clearance}px \ | ||
| 1871 | + between the last lane row and the ledger's own top border -- driven \ | ||
| 1872 | + at exactly the content's need (0px clearance) the border still won \ | ||
| 1873 | + the shared pixel and clipped the last lane's status dot" | ||
| 1874 | + ); | ||
| 1875 | +} | ||
| 1876 | + | ||
| 1820 | /// The previous test asserted lane ROWS fit the bench column -- not that a | 1877 | /// The previous test asserted lane ROWS fit the bench column -- not that a |
| 1821 | /// lane's own CONTENT fits its row, which is how the defect it fixed | 1878 | /// lane's own CONTENT fits its row, which is how the defect it fixed |
| 1822 | /// survived it: at the old `LANE_MIN_H` of `18.` both lanes fit the bench | 1879 | /// survived it: at the old `LANE_MIN_H` of `18.` both lanes fit the bench |
crates/app/src/ui/stance.rsmodified+12 -5
| @@ -36,11 +36,18 @@ pub(crate) const LEDGER_H: f32 = 28.; | |||
| 36 | /// role [`BENCH_H`] plays for the bench. | 36 | /// role [`BENCH_H`] plays for the bench. |
| 37 | pub(crate) const DOCK_W: f32 = 280.; | 37 | pub(crate) const DOCK_W: f32 = 280.; |
| 38 | /// What [`bench`] spends above `bench_stance::render`'s own content: the | 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 | 39 | +/// `bench` div's own `.border_t_1()` (1px) + its `py(4.)` top padding + |
| 40 | -/// bottom padding. Named and `pub(crate)` rather than the `- 20.` it used to | 40 | +/// the section head's real line box -- `type_scale::head()` sizes text at |
| 41 | -/// be inlined as, so `layout::BENCH_MIN_H` can add it into its own | 41 | +/// `SECTION_HEAD_PX` (10) but never calls `.line_height()`, so gpui's |
| 42 | -/// derivation instead of guessing it back out. | 42 | +/// default `TextStyle::line_height` (the golden ratio, `gpui::phi()` == |
| 43 | -pub(crate) const BENCH_CHROME_H: f32 = 20.; | 43 | +/// `1.618034`, not 1x the font size) is what it actually draws: |
| 44 | +/// `round(10. * 1.618034)` = `round(16.18034)` = `16`. A driven pass found | ||
| 45 | +/// this constant undercounting that line box as a bare `10`, one of the two | ||
| 46 | +/// causes of `layout::BENCH_MIN_H`'s third clip (see its own doc comment for | ||
| 47 | +/// the other). `1 + 4 + 16` = `21`. Named and `pub(crate)` rather than the | ||
| 48 | +/// `- 20.` it used to be inlined as, so `layout::BENCH_MIN_H` can add it | ||
| 49 | +/// into its own derivation instead of guessing it back out. | ||
| 50 | +pub(crate) const BENCH_CHROME_H: f32 = 21.; | ||
| 44 | 51 | ||
| 45 | /// The lowest a menu's top edge may sit and still land inside the | 52 | /// The lowest a menu's top edge may sit and still land inside the |
| 46 | /// bench/ledger/dock footprint below the screen (DESIGN §5, §9, §11 check 6): | 53 | /// bench/ledger/dock footprint below the screen (DESIGN §5, §9, §11 check 6): |