Repository navigation
Ribbon: Font Size value is centered in its box (fixes #3155) - #3161
Conversation
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>
|
No actionable comments were generated in the recent review.
|
| 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: 
5
-
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
#3155requires 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 appliesAlign2::LEFT_CENTERtosize_comboincrates/ui-egui/src/ribbon/home.rs. The addedfont_size_box::the_size_is_vertically_centered_in_its_boxtest checks the value against the field center and theCalibrilabel. Issue#2454is 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.
|
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 |
Fixes #3155.
What changed
The Home ▸ Font Size box draws its value with a frameless
TextEdit. It now aligns its textLEFT_CENTER(size_comboinribbon/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 defaultTextEditStylealigns the textLEFT_TOP.TextEdit::showtakes its ownalign, then the style's, and only then the layout's, so the child layout'sAlign::Centerwas 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 ofmain, the digits sat 3.5 pt above the center of the box and their baseline 4 pt above the baseline of "Calibri".Verification
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.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 warningsandrustfmt --checkare clean.cargo test -p gridcraft-ui-egui --no-fail-fast: the unit tests (267),doc_windows(15),header_autofit_fonts(2) andkeytips(32) pass.itpasses 972 and fails 3, which fail the same way onmainwithout this change:interaction::column_autocomplete_folds_case_beyond_asciiandinteraction::language_switch_renders_the_ribbon_and_persists(no glyph for "ẞ" and "ẻ" in the bundled fonts,CRAFT_FONTS_DIRnot set) andribbon_layout::big_split_button_separates_the_default_action_from_the_menu(its shortcut tooltip isn't found).cargo xtask ciwas 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
aligncall so the two stay on one baseline.🤖 Generated with Claude Code
Summary by CodeRabbit