A lane row grows to fit its own dot, not just its label
Browse files at this commitdb9815b98c4c20cf4ff675529d6983751eb9b66dParent: e9946aa- fix
- a lane row grows to fit its own dot, not just its label
3 changed files +68 -6
- crates/app/src/layout.rs +7 -3
- crates/app/src/tests/layout.rs +29 -0
- crates/app/src/ui/bench_stance.rs +32 -3
crates/app/src/layout.rsmodified+7 -3
| @@ -445,9 +445,13 @@ pub(crate) const TIMELINE_MAX_SHARE: f32 = 0.7; | |||
| 445 | /// gap). Below this the `bench-lanes` column asks for more height than | 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 | 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 | 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 | 448 | +/// unscrolled -- A1's clip-bar border and status dot, first. `LANE_MIN_H` |
| 449 | -/// literal `80.` the shortfall was `82. - 80. == 2.`, the exact ~2px clip | 449 | +/// itself is now derived from what a lane head actually draws (its own |
| 450 | -/// this floor now closes. | 450 | +/// doc comment), not a number copied from nowhere: an earlier floor of |
| 451 | +/// `82.` used a `LANE_MIN_H` of `18.` that fit only the lane label and let | ||
| 452 | +/// every lane's status dot overflow into the row beneath it, invisible | ||
| 453 | +/// everywhere but the last lane, which has no next row to spill into and | ||
| 454 | +/// clipped straight into the ledger instead. | ||
| 451 | pub(crate) const BENCH_MIN_H: f32 = crate::ui::stance::BENCH_CHROME_H | 455 | pub(crate) const BENCH_MIN_H: f32 = crate::ui::stance::BENCH_CHROME_H |
| 452 | + crate::ui::bench_stance::RULER_H | 456 | + crate::ui::bench_stance::RULER_H |
| 453 | + crate::ui::bench_stance::ROW_GAP | 457 | + crate::ui::bench_stance::ROW_GAP |
crates/app/src/tests/layout.rsmodified+29 -0
| @@ -1817,6 +1817,35 @@ fn both_default_lanes_fit_the_bench_at_its_floor() { | |||
| 1817 | ); | 1817 | ); |
| 1818 | } | 1818 | } |
| 1819 | 1819 | ||
| 1820 | +/// 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 | ||
| 1822 | +/// survived it: at the old `LANE_MIN_H` of `18.` both lanes fit the bench | ||
| 1823 | +/// exactly while V1's status dot silently overflowed into A1's row (masked) | ||
| 1824 | +/// and A1's overflowed into the ledger (visible, since A1 has no next row). | ||
| 1825 | +/// This binary carries no `TestAppContext` to mount a real `lane_row` and | ||
| 1826 | +/// read its painted bounds back, so this recomputes the label's own line | ||
| 1827 | +/// box from the constants `lane_row` actually draws with (gpui's default | ||
| 1828 | +/// `TextStyle::line_height` is the golden ratio, not 1x the font size -- | ||
| 1829 | +/// see `LANE_MIN_H`'s own doc comment) rather than a literal, so a future | ||
| 1830 | +/// shrink of `LANE_MIN_H` or growth of the label size fails this instead of | ||
| 1831 | +/// silently clipping the last lane again. | ||
| 1832 | +#[test] | ||
| 1833 | +fn a_lane_row_fits_what_its_own_head_draws() { | ||
| 1834 | + use crate::ui::bench_stance::{LANE_DOT_D, LANE_HEAD_GAP, LANE_MIN_H}; | ||
| 1835 | + use crate::ui::type_scale::CHORD_METADATA_MIN_PX; | ||
| 1836 | + | ||
| 1837 | + let label_line_h = (CHORD_METADATA_MIN_PX * 1.618_034).round(); | ||
| 1838 | + let content = label_line_h + LANE_HEAD_GAP + LANE_DOT_D; | ||
| 1839 | + assert!( | ||
| 1840 | + LANE_MIN_H >= content, | ||
| 1841 | + "LANE_MIN_H ({LANE_MIN_H}) is shorter than what a lane head actually \ | ||
| 1842 | + draws ({content}px: {label_line_h}px label line box + \ | ||
| 1843 | + {LANE_HEAD_GAP}px gap + {LANE_DOT_D}px dot) -- the status dot \ | ||
| 1844 | + would spill past the row, invisible until it is the last lane \ | ||
| 1845 | + with no next row to spill into" | ||
| 1846 | + ); | ||
| 1847 | +} | ||
| 1848 | + | ||
| 1820 | /// The notice plate's own anchor ([`crate::ui::stance::notice_bottom_offset`]) | 1849 | /// 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 -- | 1850 | /// 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 | 1851 | /// because its bottom offset always lands at or above the bench's own top |
crates/app/src/ui/bench_stance.rsmodified+32 -3
| @@ -67,7 +67,29 @@ pub(crate) const ROW_GAP: f32 = 2.; | |||
| 67 | /// scrolls behind the pinned ruler and heads instead of compressing further. | 67 | /// scrolls behind the pinned ruler and heads instead of compressing further. |
| 68 | const LANES_COMPRESS: usize = 5; | 68 | const LANES_COMPRESS: usize = 5; |
| 69 | const LANE_FULL_H: f32 = 40.; | 69 | const LANE_FULL_H: f32 = 40.; |
| 70 | -pub(crate) const LANE_MIN_H: f32 = 18.; | 70 | +/// The gap `lane_row`'s pinned head column puts between the lane label and |
| 71 | +/// its status dot (its own `.gap(px(...))`), named so [`LANE_MIN_H`]'s | ||
| 72 | +/// derivation below doesn't repeat the literal blind. | ||
| 73 | +pub(crate) const LANE_HEAD_GAP: f32 = 2.; | ||
| 74 | +/// The status dot's own diameter (`lane_row`'s "Pinned track head" child, | ||
| 75 | +/// its own `.w(px(...)).h(px(...))`). | ||
| 76 | +pub(crate) const LANE_DOT_D: f32 = 4.; | ||
| 77 | +/// The lane label's own line box at [`type_scale::CHORD_METADATA_MIN_PX`]: | ||
| 78 | +/// gpui's default `TextStyle::line_height` is not 1x the font size but the | ||
| 79 | +/// golden ratio (`gpui::phi()` == `relative(1.618034)`), and `lane_row` | ||
| 80 | +/// never calls `.line_height()` on the head label to override it -- so this | ||
| 81 | +/// is what the label really occupies, not its glyph height. | ||
| 82 | +/// round(12. * 1.618034) would be wrong here: the head uses | ||
| 83 | +/// `CHORD_METADATA_MIN_PX` (11.), so round(11. * 1.618034) = round(17.798) | ||
| 84 | +/// = 18. | ||
| 85 | +const LANE_LABEL_LINE_H: f32 = 18.; | ||
| 86 | +/// The least a lane row may be: what its own head actually draws, not a | ||
| 87 | +/// number copied from nowhere. The old `18.` fit only the label's line box | ||
| 88 | +/// and let every lane's status dot overflow into the row beneath it -- | ||
| 89 | +/// invisible everywhere but the last lane, which has no next row to spill | ||
| 90 | +/// into and clipped straight into the ledger instead (adversarial pass on | ||
| 91 | +/// the `BENCH_MIN_H = 82` floor). | ||
| 92 | +pub(crate) const LANE_MIN_H: f32 = LANE_LABEL_LINE_H + LANE_HEAD_GAP + LANE_DOT_D; | ||
| 71 | 93 | ||
| 72 | /// One clip's degradation tier (DESIGN §7), picked off the clip's own worth | 94 | /// One clip's degradation tier (DESIGN §7), picked off the clip's own worth |
| 73 | /// in pixels (`span`, unclamped) rather than its drawn floor | 95 | /// in pixels (`span`, unclamped) rather than its drawn floor |
| @@ -596,7 +618,7 @@ fn lane_row( | |||
| 596 | .flex_col() | 618 | .flex_col() |
| 597 | .items_center() | 619 | .items_center() |
| 598 | .justify_center() | 620 | .justify_center() |
| 599 | - .gap(px(2.)) | 621 | + .gap(px(LANE_HEAD_GAP)) |
| 600 | .bg(rgb(DARK_PANEL())) | 622 | .bg(rgb(DARK_PANEL())) |
| 601 | .cursor(CursorStyle::OpenHand) | 623 | .cursor(CursorStyle::OpenHand) |
| 602 | .on_drag(LaneDrag(lane), move |_, _, _, cx| { | 624 | .on_drag(LaneDrag(lane), move |_, _, _, cx| { |
| @@ -609,7 +631,14 @@ fn lane_row( | |||
| 609 | )) | 631 | )) |
| 610 | .text_color(rgb(INK2())) | 632 | .text_color(rgb(INK2())) |
| 611 | .child(lane.label()) | 633 | .child(lane.label()) |
| 612 | - .child(div().flex_none().w(px(4.)).h(px(4.)).rounded(px(2.)).bg(rgb(dot))), | 634 | + .child( |
| 635 | + div() | ||
| 636 | + .flex_none() | ||
| 637 | + .w(px(LANE_DOT_D)) | ||
| 638 | + .h(px(LANE_DOT_D)) | ||
| 639 | + .rounded(px(LANE_DOT_D / 2.)) | ||
| 640 | + .bg(rgb(dot)), | ||
| 641 | + ), | ||
| 613 | ) | 642 | ) |
| 614 | .child( | 643 | .child( |
| 615 | // The bed: a drop target for the Sources tab (`AssetDrag`, | 644 | // The bed: a drop target for the Sources tab (`AssetDrag`, |