Skip to content

ui: truncate long workbook titles in the title bar - #1560

Merged
aiongg merged 1 commit into
storytold:mainfrom
IsmaelEzequiel:fix/title-bar-truncation
Oct 22, 2026
Merged

aiongg merged 1 commit into
storytold:mainfrom
IsmaelEzequiel:fix/title-bar-truncation

Conversation

@IsmaelEzequiel

Copy link
Copy Markdown
Contributor

Fixes #1558

What

Long workbook titles ran under the title-bar controls. The title is now drawn after the
controls on both sides and limited to the space between them, so it stays centred on the
window and is cut with "…" when it doesn't fit. The unsaved-changes dot (•) stays visible
however short the title gets.

Tests

New tests in ribbon::title_bar_tests:

  • title_fits_between_the_controls
  • long_title_is_truncated_with_an_ellipsis
  • short_title_is_left_whole
  • unsaved_dot_survives_truncation
  • no_room_draws_nothing_but_does_not_crash

Also

A one-line test fix in crates/xlsx/src/tests/passthrough_tests.rs: clippy on newer Rust
flags nonminimal_bool there. Same meaning, rewritten with is_none_or.

Screenshots

Before / after

Screenshot 2026-10-15 at 12 48 55 Screenshot 2026-10-15 at 12 49 07

To get an "after" screenshot without opening a window, run:
cargo run -p gridcraft-ui-egui --example snapshot -- --sample sales after.png

The sample workbook has a short name, so the image won't show the truncation by itself. The best
"after" is a screenshot of the running app with your long file open:
cargo run --release -p gridcraft -- path/to/long-name.xlsx

@MichaelMuClaude

Copy link
Copy Markdown

Verified against main (applies clean). Like #1547/#1549, this adds brand-new layout helpers with no prior analog, so I read main's current code to confirm the bug first: title_bar unconditionally painted the full title text at rect.center() with ui.painter().text(...) before the right-side controls were laid out, with no truncation and no knowledge of the controls' actual width — a long title really would run under them, matching the screenshots.

  • Applied the full patch: ribbon::title_bar_tests → 6/6 passed, including the pre-existing mac_title_bar_centres_and_clears_the_traffic_lights test (no regression there) alongside the 5 new ones.
  • cargo test -p gridcraft-ui-egui --lib → 99/99. The bundled one-line passthrough_tests.rs clippy fix also verified: cargo test -p gridcraft-xlsx --lib kept_vml_drawings_are_charged_to_the_kept_total passes, and the rewrite is logically equivalent (!is_some_and(f) ≡ is_none_or(|x| !f(x))), not just silencing the lint.
  • cargo clippy -p gridcraft-ui-egui -p gridcraft-xlsx --lib --tests -- -D warnings and cargo fmt --check on both crates: clean.
  • The new layout_title test helper correctly drains frame.textures_delta.clear() after ctx.run_ui(...) (the same pattern this crate's theme.rs already uses for a headless egui::Context test) — worth calling out since a sibling PR in this same backlog (UI: Delete dismisses the AutoComplete proposal, and deleting text never brings it back (#1521) #1547) missed exactly this and panics on drop; this one got it right.
  • title_max_width's "overlapping controls leave no room rather than negative width" case and paint_title's dot-stays-visible-when-truncated behavior both have direct test coverage and both read correctly.

Correct, well-tested, and the bundled unrelated clippy fix is a reasonable rider rather than scope creep. Good to merge.

@aiongg
aiongg merged commit 8de6c83 into storytold:main Oct 22, 2026
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.

Long workbook title overlaps title-bar controls

3 participants