[PR #6630] [MERGED] A TextAndIcon button's label stays clear of its icon; tab labels stay inside their tab #6997

Closed
opened 2026-11-03 06:31:23 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6630
Author: @mariuslozo-boop
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/text-and-icon-label


📝 Commits (1)

  • dd42828 A TextAndIcon button's label stays clear of its icon; tab labels stay inside their tab

📊 Changes

8 files changed (+297 additions, -40 deletions)

View changed files

📝 crates/horizon-client-render/src/ui.rs (+107 -8)
📝 crates/horizon-client/src/game/stats_screen.rs (+7 -13)
📝 crates/horizon-client/src/title.rs (+25 -5)
📝 crates/horizon-client/src/title/create_world.rs (+5 -6)
📝 crates/horizon-client/src/title/tests.rs (+145 -0)
📝 tools/port_map/client2-009.tsv (+6 -6)
📝 tools/port_map/client2-011.tsv (+1 -1)
📝 tools/port_map/client2-012.tsv (+1 -1)

📄 Description

🤖 Opened by mariuslozo-boop's AI agent (Claude Code, Claude Sonnet 5.5 + Claude Opus 5.5 review), not by mariuslozo-boop personally.

What and why

A follow-up to #6349 and to #6427 (closed: #6349 already made ui::button, the sliders and the title-screen buttons scroll their labels). This is the small PR #6427's closing comment invited, for the widgets that still cut or overflow their label on main: a button with a text and an icon, and the tabs.

A label under the icon. SpriteIconButton.TextAndIcon (the Music & Sounds, Accessibility Settings and Language buttons of the first-launch Accessibility screen, its only user in 26.3) hands its label to acceptScrolling with left = x + 2, right = x + width - spriteWidth - 4 and centerX = x + width / 2 (SpriteIconButton.java:266-278). defaultScrollingHelper then draws a label that fits at Mth.clamp(centerX, left + lineWidth / 2, right - lineWidth / 2) and slides a wider one inside left..right (ActiveTextCollector.java:62-87). Button::draw_label in title.rs used x + 2 .. x + width - 2 for every button, so:

  • a label that fits beside the icon but, centred on the button, reaches it (fil_ph "Settings sa Aksesibilidad...", 128 px of the 129 px beside the 15 px icon) ended under the icon: about 30 languages (ast_es, ca_es, cy_gb, es_cl, hi_in, hr_hr, ro_ro, sl_si, ta_in, ...);
  • a wider one (fr_ca "Paramètres d'accessibilité...", 137 px) slid to x + width - 2, its end under the icon: about 35 languages (da_dk, de_at, nl_nl, ru_ru, sr_cs, ...).

en_us is not affected: "Accessibility Settings..." is narrow enough to stay centred, clear of the icon. The counts are from the client's font widths over the 144 lang files, for the three labels of that screen.

Tab labels. MenuTabBar.MenuTabButton.renderLabel (MenuTabBar.java:141-147) hands the label to acceptScrollingWithDefaultCenter inside the tab less 1 px on each side, its box 3 px lower on an unselected tab; the label is the tab's getMessage(), gray only when the tab is inactive (AbstractWidget.WithInactiveMessage). Two screens use it:

  • Create World drew the label unclipped, so a label wider than its tab ran into the next one. No language overflows at the default size; it shows in a narrow window.
  • Statistics drew it unclipped too, at the selected tab's height on every tab (2 px too high on the unselected ones), and gray on every unselected tab although they are active.

What changes:

  • ui::scrolling_text_around_at: scrolling_text_at with an explicit centerX, clamped as vanilla does. scrolling_text_at calls it with (left + right) / 2, which draws a fitting label exactly where it did before, so its other callers don't move.
  • Button::draw_label_at: right = x + w - icon - 4 and centerX = x + w / 2 for a button with a trailing icon (draw_label is it at the current time).
  • ui::menu_tab_label: MenuTabButton.renderLabel, which the Create World and Statistics tab loops both call now.
  • Port ledger: the rows #6293 and #6349 left saying the text is clipped, not scrolled (acceptScrolling, RenderingTextCollector.acceptScrolling, acceptScrollingWithDefaultCenter, defaultScrollingHelper, extractScrollingStringOverContents, the slider's extractWidgetRenderState) say what is drawn; SpriteIconButton.TextAndIcon.extractContents was skip:other, no caller in 26.3, but the Accessibility screen is its caller; MenuTabButton.renderLabel points at ui::menu_tab_label. map-check reports no problems.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

  • SpriteIconButton.TextAndIcon.extractContents (SpriteIconButton.java:266-278); its callers AccessibilityOnboardingScreen.init (SpriteIconButton.builder(..., false) with a 16 px icon) and CommonButtons.language / accessibility with iconOnly false (15 px icons).
  • ActiveTextCollector.acceptScrolling, acceptScrollingWithDefaultCenter, defaultScrollingHelper (ActiveTextCollector.java:52-87), GuiGraphicsExtractor.RenderingTextCollector.acceptScrolling (GuiGraphicsExtractor.java:1437-1449).
  • MenuTabBar.MenuTabButton.renderLabel (MenuTabBar.java:141-147), AbstractWidget.WithInactiveMessage (AbstractWidget.java:314-336), and its users CreateWorldScreen and StatsScreen (setTabActiveStateAndTooltip).

Harness: none draws these widgets, so none is affected.

Other projects' code

none

Self-check

New tests, each failing on main (checked by drawing as main does in their place) and passing here:

  • title::tests::text_and_icon::a_label_that_fits_beside_the_icon_is_moved_clear_of_it: the widest label that fits beside a 16 px icon is drawn from right - width (vanilla's clamp) and does not scroll; the same label on a plain button stays centred. On main it is centred, under the icon.
  • title::tests::text_and_icon::a_label_wider_than_the_room_beside_the_icon_scrolls_clear_of_it: it scrolls, every vertex in x + 2 ..= x + w - icon - 4 over 40 s. On main a vertex reaches x + 131.
  • title::tests::a_create_world_tab_label_wider_than_its_tab_stays_inside_it: Create World in a 90 px window; every label vertex is inside its tab less 1 px, and every tab draws its label. On main a vertex is at x = -53.
  • ui::tests::a_tab_label_sits_lower_on_an_unselected_tab_and_is_gray_only_when_inactive: on a 24 px tab the text top is 8 when selected and 10 when not, white on an active tab and 0xA0A0A0 on an inactive one, at vanilla's centre. With the Statistics screen's old drawing it fails on the active unselected tab.
  • The existing a_button_label_wider_than_its_button_stays_inside_it still passes (a plain button is unchanged).

Real client, this branch (--offscreen, isolated home, 1280x720):

  • The first-launch Accessibility screen at GUI scale 2: in fil_ph "Settings sa Aksesibilidad..." ends just before the icon; in fr_ca "Paramètres d'accessibilité..." slides inside x + 2 .. x + w - icon - 4, clipped at both ends, and the icon stays clear; in hi_in the label ends before the icon; in en_us the labels are centred, clear of the icons.
  • The Statistics screen in a new world (GUI scale 3): the selected General tab's label is white at the top, the inactive Items and Mobs tabs' labels are gray and 2 px lower, as vanilla draws them; hovering an inactive tab shows "No statistics found." as before.

Main was not run for these screenshots; what main draws is what the tests' "on main" cases describe.

pr_ready (tools/pr_ready.py --quick --base upstream/main on PCDKBLENDER, against upstream/main at 8d93d68f1, 12 min 10 s)

Check Result
Scope ✅ 8 files, +297 −40
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 596 run, FAILED (errors=1, skipped=2) (58 s)
rustfmt ✅ (8 s)
clippy ✅ (44 s)
tests: horizon-client, horizon-client-lib, horizon-client-render ✅ 2914 passed (10 min 13 s)
doc tests ✅ 0 passed (4 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 112 affected, to run in CI (--quick): arrow, enchanting, friends_integration, lan_integration, management_protocol, online_mode, remote_fireball, remote_fireworks, replace_blobs, replace_block, resource_pack, restitution and 100 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)
  • Scope: about 100 lines of code, 190 of tests and 8 of the port ledger.
  • Python tests: the one error is test_world_input_capture.test_capture_lifecycle (its compiled fixture exits with 101). It fails the same on a clean checkout of 8d93d68f1: it came with #6410 and is not touched here.
  • Parity: listed for CI, not run (--quick). Since 5ebf42f7b the runner starts harnesses on Windows, but on this machine every one fails before it compares anything (its javac is JDK 21 and the oracles compile with --release 25), and the ones that start the game open a window.
  • Threads: RUST_TEST_THREADS=2 (the render tests can hang on Windows otherwise, #5238).

Not tested:

  • The Create World tab change in a real client: no language overflows a tab at usual window sizes, so the unit test is all there is.
  • Mouse hover on a scrolling label, and the narrator.

Found along the way, not changed here:

  • The Statistics tabs' focus underline spans the whole tab, 1 px higher than vanilla's and always white; MenuTabButton.renderFocusUnderline makes it as wide as the label (at most the tab less 4), 2 px above the tab's bottom, gray on an inactive tab. Create World already draws it that way.
  • The Music & Sounds icon (icon/music_notes) draws as a faint speckle on the Accessibility screen; not looked into.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RodDbPWCByh96WKcbiEQpB


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/6630 **Author:** [@mariuslozo-boop](https://github.com/mariuslozo-boop) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/text-and-icon-label` --- ### 📝 Commits (1) - [`dd42828`](https://github.com/horizon-rust/horizon/commit/dd428288d1dde74bbb45311f6132f110e2f70947) A TextAndIcon button's label stays clear of its icon; tab labels stay inside their tab ### 📊 Changes **8 files changed** (+297 additions, -40 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/ui.rs` (+107 -8) 📝 `crates/horizon-client/src/game/stats_screen.rs` (+7 -13) 📝 `crates/horizon-client/src/title.rs` (+25 -5) 📝 `crates/horizon-client/src/title/create_world.rs` (+5 -6) 📝 `crates/horizon-client/src/title/tests.rs` (+145 -0) 📝 `tools/port_map/client2-009.tsv` (+6 -6) 📝 `tools/port_map/client2-011.tsv` (+1 -1) 📝 `tools/port_map/client2-012.tsv` (+1 -1) </details> ### 📄 Description > 🤖 Opened by mariuslozo-boop's AI agent (Claude Code, Claude Sonnet 5.5 + Claude Opus 5.5 review), not by mariuslozo-boop personally. ## What and why A follow-up to #6349 and to #6427 (closed: #6349 already made `ui::button`, the sliders and the title-screen buttons scroll their labels). This is the small PR #6427's closing comment invited, for the widgets that still cut or overflow their label on main: a button with a text and an icon, and the tabs. **A label under the icon.** `SpriteIconButton.TextAndIcon` (the Music & Sounds, Accessibility Settings and Language buttons of the first-launch Accessibility screen, its only user in 26.3) hands its label to `acceptScrolling` with `left = x + 2`, `right = x + width - spriteWidth - 4` and `centerX = x + width / 2` (`SpriteIconButton.java:266-278`). `defaultScrollingHelper` then draws a label that fits at `Mth.clamp(centerX, left + lineWidth / 2, right - lineWidth / 2)` and slides a wider one inside `left..right` (`ActiveTextCollector.java:62-87`). `Button::draw_label` in `title.rs` used `x + 2 .. x + width - 2` for every button, so: - a label that fits beside the icon but, centred on the button, reaches it (`fil_ph` "Settings sa Aksesibilidad...", 128 px of the 129 px beside the 15 px icon) ended under the icon: about 30 languages (`ast_es`, `ca_es`, `cy_gb`, `es_cl`, `hi_in`, `hr_hr`, `ro_ro`, `sl_si`, `ta_in`, ...); - a wider one (`fr_ca` "Paramètres d'accessibilité...", 137 px) slid to `x + width - 2`, its end under the icon: about 35 languages (`da_dk`, `de_at`, `nl_nl`, `ru_ru`, `sr_cs`, ...). `en_us` is not affected: "Accessibility Settings..." is narrow enough to stay centred, clear of the icon. The counts are from the client's font widths over the 144 lang files, for the three labels of that screen. **Tab labels.** `MenuTabBar.MenuTabButton.renderLabel` (`MenuTabBar.java:141-147`) hands the label to `acceptScrollingWithDefaultCenter` inside the tab less 1 px on each side, its box 3 px lower on an unselected tab; the label is the tab's `getMessage()`, gray only when the tab is inactive (`AbstractWidget.WithInactiveMessage`). Two screens use it: - Create World drew the label unclipped, so a label wider than its tab ran into the next one. No language overflows at the default size; it shows in a narrow window. - Statistics drew it unclipped too, at the selected tab's height on every tab (2 px too high on the unselected ones), and gray on every unselected tab although they are active. What changes: - `ui::scrolling_text_around_at`: `scrolling_text_at` with an explicit `centerX`, clamped as vanilla does. `scrolling_text_at` calls it with `(left + right) / 2`, which draws a fitting label exactly where it did before, so its other callers don't move. - `Button::draw_label_at`: `right = x + w - icon - 4` and `centerX = x + w / 2` for a button with a trailing icon (`draw_label` is it at the current time). - `ui::menu_tab_label`: `MenuTabButton.renderLabel`, which the Create World and Statistics tab loops both call now. - Port ledger: the rows #6293 and #6349 left saying the text is clipped, not scrolled (`acceptScrolling`, `RenderingTextCollector.acceptScrolling`, `acceptScrollingWithDefaultCenter`, `defaultScrollingHelper`, `extractScrollingStringOverContents`, the slider's `extractWidgetRenderState`) say what is drawn; `SpriteIconButton.TextAndIcon.extractContents` was `skip:other, no caller in 26.3`, but the Accessibility screen is its caller; `MenuTabButton.renderLabel` points at `ui::menu_tab_label`. `map-check` reports no problems. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference - `SpriteIconButton.TextAndIcon.extractContents` (`SpriteIconButton.java:266-278`); its callers `AccessibilityOnboardingScreen.init` (`SpriteIconButton.builder(..., false)` with a 16 px icon) and `CommonButtons.language` / `accessibility` with `iconOnly` false (15 px icons). - `ActiveTextCollector.acceptScrolling`, `acceptScrollingWithDefaultCenter`, `defaultScrollingHelper` (`ActiveTextCollector.java:52-87`), `GuiGraphicsExtractor.RenderingTextCollector.acceptScrolling` (`GuiGraphicsExtractor.java:1437-1449`). - `MenuTabBar.MenuTabButton.renderLabel` (`MenuTabBar.java:141-147`), `AbstractWidget.WithInactiveMessage` (`AbstractWidget.java:314-336`), and its users `CreateWorldScreen` and `StatsScreen` (`setTabActiveStateAndTooltip`). Harness: none draws these widgets, so none is affected. ## Other projects' code none ## Self-check New tests, each failing on main (checked by drawing as main does in their place) and passing here: - `title::tests::text_and_icon::a_label_that_fits_beside_the_icon_is_moved_clear_of_it`: the widest label that fits beside a 16 px icon is drawn from `right - width` (vanilla's clamp) and does not scroll; the same label on a plain button stays centred. On main it is centred, under the icon. - `title::tests::text_and_icon::a_label_wider_than_the_room_beside_the_icon_scrolls_clear_of_it`: it scrolls, every vertex in `x + 2 ..= x + w - icon - 4` over 40 s. On main a vertex reaches `x + 131`. - `title::tests::a_create_world_tab_label_wider_than_its_tab_stays_inside_it`: Create World in a 90 px window; every label vertex is inside its tab less 1 px, and every tab draws its label. On main a vertex is at x = -53. - `ui::tests::a_tab_label_sits_lower_on_an_unselected_tab_and_is_gray_only_when_inactive`: on a 24 px tab the text top is 8 when selected and 10 when not, white on an active tab and `0xA0A0A0` on an inactive one, at vanilla's centre. With the Statistics screen's old drawing it fails on the active unselected tab. - The existing `a_button_label_wider_than_its_button_stays_inside_it` still passes (a plain button is unchanged). Real client, this branch (`--offscreen`, isolated home, 1280x720): - The first-launch Accessibility screen at GUI scale 2: in `fil_ph` "Settings sa Aksesibilidad..." ends just before the icon; in `fr_ca` "Paramètres d'accessibilité..." slides inside `x + 2 .. x + w - icon - 4`, clipped at both ends, and the icon stays clear; in `hi_in` the label ends before the icon; in `en_us` the labels are centred, clear of the icons. - The Statistics screen in a new world (GUI scale 3): the selected General tab's label is white at the top, the inactive Items and Mobs tabs' labels are gray and 2 px lower, as vanilla draws them; hovering an inactive tab shows "No statistics found." as before. Main was not run for these screenshots; what main draws is what the tests' "on main" cases describe. **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on PCDKBLENDER, against upstream/main at 8d93d68f1, 12 min 10 s) | Check | Result | | --- | --- | | Scope | ✅ 8 files, +297 −40 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 596 run, FAILED (errors=1, skipped=2) (58 s) | | rustfmt | ✅ (8 s) | | clippy | ✅ (44 s) | | tests: horizon-client, horizon-client-lib, horizon-client-render | ✅ 2914 passed (10 min 13 s) | | doc tests | ✅ 0 passed (4 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 112 affected, to run in CI (--quick): arrow, enchanting, friends_integration, lan_integration, management_protocol, online_mode, remote_fireball, remote_fireworks, replace_blobs, replace_block, resource_pack, restitution and 100 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | - **Scope:** about 100 lines of code, 190 of tests and 8 of the port ledger. - **Python tests:** the one error is `test_world_input_capture.test_capture_lifecycle` (its compiled fixture exits with 101). It fails the same on a clean checkout of `8d93d68f1`: it came with #6410 and is not touched here. - **Parity:** listed for CI, not run (`--quick`). Since 5ebf42f7b the runner starts harnesses on Windows, but on this machine every one fails before it compares anything (its `javac` is JDK 21 and the oracles compile with `--release 25`), and the ones that start the game open a window. - **Threads:** `RUST_TEST_THREADS=2` (the render tests can hang on Windows otherwise, #5238). Not tested: - The Create World tab change in a real client: no language overflows a tab at usual window sizes, so the unit test is all there is. - Mouse hover on a scrolling label, and the narrator. Found along the way, not changed here: - The Statistics tabs' focus underline spans the whole tab, 1 px higher than vanilla's and always white; `MenuTabButton.renderFocusUnderline` makes it as wide as the label (at most the tab less 4), 2 px above the tab's bottom, gray on an inactive tab. Create World already draws it that way. - The Music & Sounds icon (`icon/music_notes`) draws as a faint speckle on the Accessibility screen; not looked into. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01RodDbPWCByh96WKcbiEQpB --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:31:23 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#6997
No description provided.