Skip to content

Ribbon: Font Size value is centered in its box (fixes #3155) - #3161

Merged
h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
kenkanuma:fix/3155-size-box-vertical-center
Nov 3, 2026
Merged

h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
kenkanuma:fix/3155-size-box-vertical-center

Conversation

@kenkanuma

@kenkanuma kenkanuma commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3155.

What changed

The Home ▸ Font Size box draws its value with a frameless TextEdit. It now aligns its text LEFT_CENTER (size_combo in ribbon/home.rs), so the value is vertically centered in the box, on the Font name label's baseline and level with the chevron.

Why

The theme floors a text edit at interact_size.y (22 pt, theme.rs), and egui's default TextEditStyle aligns the text LEFT_TOP. TextEdit::show takes its own align, then the style's, and only then the layout's, so the child layout's Align::Center was never used: the text edit was 22 pt tall, centered in the 24 pt frame, with the text at its top. Measured in a 2x offscreen render of main, the digits sat 3.5 pt above the center of the box and their baseline 4 pt above the baseline of "Calibri".

Verification

  • New test font_size_box::the_size_is_vertically_centered_in_its_box: the painted value is within 1 pt of the center of its box and of the Font name label. It fails without the change (value row 77 to 91 in a box 77 to 99) and passes with it.
  • Offscreen render (cargo run --release -p gridcraft-ui-egui --example snapshot -- --sample sales out.png, 2x), before and after: the baseline difference to "Calibri" goes from 8 px to 0, and the digits' rows from 160-177 to 168-185, the same rows as the label's.
  • cargo clippy -p gridcraft-ui-egui --all-targets -- -D warnings and rustfmt --check are clean.
  • cargo test -p gridcraft-ui-egui --no-fail-fast: the unit tests (267), doc_windows (15), header_autofit_fonts (2) and keytips (32) pass. it passes 972 and fails 3, which fail the same way on main without this change: interaction::column_autocomplete_folds_case_beyond_ascii and interaction::language_switch_renders_the_ribbon_and_persists (no glyph for "ẞ" and "ẻ" in the bundled fonts, CRAFT_FONTS_DIR not set) and ribbon_layout::big_split_button_separates_the_default_action_from_the_menu (its shortcut tooltip isn't found).
  • cargo xtask ci was not run in full locally (workspace tests, wasm, assets, layers); the remaining gates are left to this PR's checks.

Notes for reviewers

#2454 (the Font name is centered in its box; Excel left-aligns it) is in the same ribbon group. If that box becomes a text field, it needs the same align call so the two stay on one baseline.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Style
    • The font-size value is now vertically centered in its input box and aligned with the font name’s baseline, making the controls easier to scan. Font-size parsing and application remain unchanged.

The size box draws its value with a frameless TextEdit. The theme floors
a text edit at interact_size.y (22 pt), and egui's text edit style aligns
its text to the top of that, which wins over the child layout's
Align::Center. The digits sat 3.5 pt above the middle of the 24 pt box,
4 pt above the Font name's baseline. The text edit now aligns its text
LEFT_CENTER.

The new test checks that the value is centered in its box and on the
Font name label's baseline. It fails without the change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 488f998 and de254a0.

Files selected for processing: 2
  • crates/ui-egui/src/ribbon/home.rs
  • crates/ui-egui/tests/it/font_size_box.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

The Home ribbon font size text is vertically centered in its field. An integration test checks its vertical position and alignment with the font name.

Changes: Font size alignment

Layer / File(s) Summary
Center the font size text
crates/ui-egui/src/ribbon/home.rs, crates/ui-egui/tests/it/font_size_box.rs
size_combo aligns its text edit to the field’s vertical center. The integration test checks that the size value is centered and shares the font name’s baseline within 1.0 pixel.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: aiongg

Merge Risk: Minimal · up to de254

The font size value is centered as intended, with no concrete merge-blocking risk identified.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the ribbon Font Size value and the fix: it is centered in its box. The changeset sets LEFT_CENTER alignment on the size_combo TextEdit in ribbon/home.rs, adds a test that checks vertic…
Linked Issues check Passed Issue #3155 requires vertical centering of the Home ribbon Font Size value in its 24 pt box, with alignment to the Font name label and chevron. The PR applies Align2::LEFT_CENTER to size_combo in …
Out of Scope Changes check Passed The source change only sets the required text alignment. The added test, painting helper, and module documentation verify the same Font Size box behavior. The reported size parsing and application beh…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Title check

Explanation

The title names the ribbon Font Size value and the fix: it is centered in its box. The changeset sets LEFT_CENTER alignment on the size_combo TextEdit in ribbon/home.rs, adds a test that checks vertical centering, and updates the module docs. The title matches the main change and references issue #3155.

Full details: Linked Issues check

Explanation

Issue #3155 requires vertical centering of the Home ribbon Font Size value in its 24 pt box, with alignment to the Font name label and chevron. The PR applies Align2::LEFT_CENTER to size_combo in crates/ui-egui/src/ribbon/home.rs. The added font_size_box::the_size_is_vertically_centered_in_its_box test checks the value against the field center and the Calibri label. Issue #2454 is contextual and adds no active requirement.

Full details: Out of Scope Changes check

Explanation

The source change only sets the required text alignment. The added test, painting helper, and module documentation verify the same Font Size box behavior. The reported size parsing and application behavior remains unchanged. No unrelated change is identified.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@h-a-n-a-s-h-i
h-a-n-a-s-h-i merged commit 95d9ed1 into storytold:main Nov 3, 2026
1 check passed
@echelon

echelon commented Nov 3, 2026

Copy link
Copy Markdown
Member

Landed on main, thank you @kenkanuma! It's a tidy fix, and the test checks both the box centre and the Font name's baseline. If you haven't already, come join us on Discord: https://discord.gg/artcraft

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.

Font Size box: the value is not vertically centered (sits 4 pt above the Font name baseline)

3 participants