Skip to content

Implement grow/shrink/wrap/scroll policy in build_staff_layout - #5

Merged
systemfreund merged 1 commit into
mainfrom
staff-layout-grow-shrink-wrap
Aug 2, 2026
Merged

systemfreund merged 1 commit into
mainfrom
staff-layout-grow-shrink-wrap

Conversation

@systemfreund

Copy link
Copy Markdown
Owner

Summary

  • Measures now pack greedily into rows: grow to fill available width, shrink toward a legibility floor before that, wrap into a new row once a row can't fit more measures even at the floor, and only overflow into horizontal scroll when a single measure alone doesn't fit at the floor.
  • Growth stretches note spacing only (glyph size untouched, so the pre-existing single-system grow-to-fill behavior is unchanged); shrinking scales glyph size (em) and width together via new StaffOpts::rescaled/GlyphMetrics::scaled, since shrinking width alone would just make same-size glyphs collide.
  • measure_panel.rs: ScrollArea widened to both(); hit_test_staff is now row-aware (Pos2 instead of f32 x-only).
  • Legibility floor locked at 48em (LEGIBILITY_FLOOR_EM in crates/layout/src/staff_layout.rs) — see linked wayfinder map/tickets #1, #2, #3, #4 for the full decision trail.

Test plan

  • cargo test --workspace (excluding grooph-measure, which fails to compile on this toolchain for an unrelated, pre-existing reason confirmed present on main before this change)
  • cargo fmt --check
  • New/updated tests in crates/layout/src/staff_layout.rs: fits-one-row regression, multi-row wrap, single-measure-too-wide scroll fallback, row-aware hit-testing
  • Manual visual check of wrapping in the running app (not feasible in this headless environment — startup smoke-tested under Xvfb with no panic)

🤖 Generated with Claude Code

Measures now pack into rows via greedy fill, growing to fill available
width and shrinking toward a legibility floor (48em) before wrapping into
a new row; a single measure too wide even at the floor is left to overflow
into horizontal scroll. Growth only stretches note spacing (glyph size
unaffected, preserving prior single-system behavior); shrinking scales
glyph size and width together, since that's the only direction that
actually risks illegibility.

Adds StaffOpts::rescaled/GlyphMetrics::scaled so the renderer's font and
metrics track the scale build_staff_layout used. Widens measure_panel's
ScrollArea to both() and makes hit_test_staff row-aware.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@systemfreund
systemfreund merged commit 5f64d26 into main Aug 2, 2026
1 check failed
@systemfreund
systemfreund deleted the staff-layout-grow-shrink-wrap branch August 2, 2026 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant