[PR #6349] [MERGED] Button, slider and title-screen labels wider than the widget scroll, as vanilla does #6817

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6349
Author: @MSedgeMC
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: fix/sv-button-scroll


📝 Commits (2)

  • 5057e98 Widgets scroll a label wider than themselves, as vanilla does
  • 26e6743 Title screens scroll a label wider than its button, as vanilla does

📊 Changes

3 files changed (+278 additions, -14 deletions)

View changed files

📝 crates/horizon-client-render/src/ui.rs (+211 -5)
📝 crates/horizon-client/src/title.rs (+23 -9)
📝 crates/horizon-client/src/title/tests.rs (+44 -0)

📄 Description

What and why

Vanilla slides the label of a button, a cycle button and a slider that is wider than the widget; Horizon cut it off after the last character that fitted, so the rest could never be read. Examples in English at a 150 px widget: Graphics API: Prefer Vulkan (Experimental) showed as Graphics API: Prefer Vulkan, Simulation Distance: 32 Chunks as Simulation Distance: 32 Chunk, and Key Binds' > Left Control < in its 75 px button as > Left Contro.

Fixes #6229.

ui::button, ui::button_as, ui::slider and ui::slider_ext (all of the Options pages, dialogs, Graphics/HDR pages, game rules, LAN, server links and the rest of the ~50 call sites) label through ui::centered_text, which clips by characters. They now label through ui::scrolling_text, the port of vanilla's helper:

  • AbstractWidget.extractScrollingStringOverContents (offsets 0-46): left = getX() + margin, right = getX() + getWidth() - margin, top = getY(), bottom = getY() + getHeight(). AbstractButton.extractDefaultLabel (offsets 6-7) and AbstractSliderButton.extractWidgetRenderState (offsets 90-95) both pass margin 2.
  • ActiveTextCollector.acceptScrollingWithDefaultCenter (offsets 0-13) centres on (left + right) / 2.
  • ActiveTextCollector.defaultScrollingHelper: offsets 14-24 room = right - left; if lineWidth > room, offsets 27-57 overflow = lineWidth - room and period = max(overflow * 0.5, 3) s of Util.getMillis; offsets 59-97 pos = sin(PI/2 * cos(TAU * t / period)) / 2 + 0.5 and lerp(0, overflow, pos); offsets 99-137 scissor (left, right, top, bottom) and draw LEFT at left - (int) pos. A label that fits is centred with Mth.clamp, offsets 140-157.
  • GuiGraphicsExtractor$RenderingTextCollector.acceptScrolling (offsets 30-32) passes the font's 9 px line height; the label's line is (top + bottom - 9) / 2 + 1, which is the y + 6 these widgets already used at 20 px, so no label moved.

ui::centered_text keeps its clipped centring and is now used only for titles and lines of text, which vanilla does not scroll; its doc comment said it scrolled, which it never did.

The title screens draw their own buttons, outside ui.rs, so they are fixed in the same pull request's second commit: Title::draw's loop used the label's own width as the button's, and a label wider than the button ran over the buttons beside it — so_so's Create World, World tab, World Type (150 px button, 590 px label) crossed the screen over the Customize button, hi_in's Multiplayer footer Join Server (100 px, 154 px) over Refresh, ta_in's Select World Re-Create (71 px, 92 px) over Edit. That loop (Title::buttons returns the Main Menu, Select World, Create World, world-management, confirm and Multiplayer footer buttons) now labels through Button::draw_label, which is ui::scrolling_text with vanilla's 2 px margin. A label that fits does not move: centered_left(left, right - left, width) equals the old (b.w / 2).floor() - (tw.ceil() / 2).floor() for every integer width the screens use, and the line stays at b.y + 6.0.

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

AbstractWidget.extractScrollingStringOverContents, AbstractButton.extractDefaultLabel, AbstractSliderButton.extractWidgetRenderState, ActiveTextCollector.acceptScrollingWithDefaultCenter, ActiveTextCollector.defaultScrollingHelper, GuiGraphicsExtractor$RenderingTextCollector.acceptScrolling, all in the 26.3 client jar (javap -p -c on /tmp/cj, offsets quoted above). No harness runs it: the parity checks that would need a client are listed under Not proven.

Other projects' code

none

Self-check

Run on the build VM through the shared checkout, in my worktree with the same diff:

Check Result
cargo test -q -p horizon-client-render --lib ui:: 93 passed, 0 failed, 2 ignored
cargo test -q -p horizon-client-lib --lib title::tests 55 passed, 0 failed
cargo clippy -q -p horizon-client-render --all-targets --locked -- -D warnings clean
cargo clippy -q -p horizon-client-lib --all-targets --locked -- -D warnings clean
rustfmt --edition 2024 --check crates/horizon-client-render/src/ui.rs clean

Proven: the label maths, against the formula above, and the drawing against a real atlas. cargo test -q -p horizon-client-render --lib ui:: -> 93 passed, 0 failed, 2 ignored. The new cases: an_overflowing_label_slides_from_its_end_to_its_start_and_back (period max(overflow * 0.5, 3) s, the sine's two ends and its bounds over 40 s), an_overflowing_label_is_drawn_left_less_the_integer_slide (left - (int) pos, cut not rounded), and a_label_wider_than_its_widget_stays_inside_it (every vertex of a 300+ px label inside the 10..106 widget box, and a label that fits drawn whole and centred, on a HudAtlas::build font).

The title screens are drawn on the same path: cargo test -q -p horizon-client-lib --lib title::tests -> 55 passed, 0 failed, including a_button_label_wider_than_its_button_stays_inside_it, which draws Create Backup and Load the World Anyway in a 100 px button and asserts every vertex stays inside x + 2 .. x + w - 2 and the button's 20 px height, then that Done still starts at the centred x.

Not proven: I did not watch a label slide in the running client, so the animation's smoothness and the shadow at the scissor edge are unchecked, and no vanilla 26.3 screen was compared pixel for pixel. The check that would prove it: a nightly horizon-windows-x64 run as in #6229 — Options > Video Settings with set simulation-distance 1.0 and two clicks on Graphics API, two screenshots 2.3 s apart, which must now differ (the label's end visible in one and its start in the other) instead of both showing Graphics API: Prefer Vulkan. The same two-shot check on Key Binds (> Left Control <), a 150 px slider whose label overflows, and the title screens: so_so (no worlds, so it opens Create World), World tab, World Type cycled to Large Biomes, where the 590 px label must stay inside its 150 px button and differ between the shots; likewise hi_in's Multiplayer footer and ta_in's Select World.

Screenshots

Not taken: this worktree renders on the build VM only, without the client's resources or a display.


🔄 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/6349 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/sv-button-scroll` --- ### 📝 Commits (2) - [`5057e98`](https://github.com/horizon-rust/horizon/commit/5057e98cd3c8ca4d2438e302fe040b5fbb2aa877) Widgets scroll a label wider than themselves, as vanilla does - [`26e6743`](https://github.com/horizon-rust/horizon/commit/26e6743fba8578b1698500da897f8b3b7d65b252) Title screens scroll a label wider than its button, as vanilla does ### 📊 Changes **3 files changed** (+278 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/ui.rs` (+211 -5) 📝 `crates/horizon-client/src/title.rs` (+23 -9) 📝 `crates/horizon-client/src/title/tests.rs` (+44 -0) </details> ### 📄 Description ## What and why Vanilla slides the label of a button, a cycle button and a slider that is wider than the widget; Horizon cut it off after the last character that fitted, so the rest could never be read. Examples in English at a 150 px widget: `Graphics API: Prefer Vulkan (Experimental)` showed as `Graphics API: Prefer Vulkan`, `Simulation Distance: 32 Chunks` as `Simulation Distance: 32 Chunk`, and Key Binds' `> Left Control <` in its 75 px button as `> Left Contro`. Fixes #6229. `ui::button`, `ui::button_as`, `ui::slider` and `ui::slider_ext` (all of the Options pages, dialogs, Graphics/HDR pages, game rules, LAN, server links and the rest of the ~50 call sites) label through `ui::centered_text`, which clips by characters. They now label through `ui::scrolling_text`, the port of vanilla's helper: - `AbstractWidget.extractScrollingStringOverContents` (offsets 0-46): `left = getX() + margin`, `right = getX() + getWidth() - margin`, `top = getY()`, `bottom = getY() + getHeight()`. `AbstractButton.extractDefaultLabel` (offsets 6-7) and `AbstractSliderButton.extractWidgetRenderState` (offsets 90-95) both pass margin `2`. - `ActiveTextCollector.acceptScrollingWithDefaultCenter` (offsets 0-13) centres on `(left + right) / 2`. - `ActiveTextCollector.defaultScrollingHelper`: offsets 14-24 `room = right - left`; if `lineWidth > room`, offsets 27-57 `overflow = lineWidth - room` and `period = max(overflow * 0.5, 3)` s of `Util.getMillis`; offsets 59-97 `pos = sin(PI/2 * cos(TAU * t / period)) / 2 + 0.5` and `lerp(0, overflow, pos)`; offsets 99-137 scissor `(left, right, top, bottom)` and draw LEFT at `left - (int) pos`. A label that fits is centred with `Mth.clamp`, offsets 140-157. - `GuiGraphicsExtractor$RenderingTextCollector.acceptScrolling` (offsets 30-32) passes the font's 9 px line height; the label's line is `(top + bottom - 9) / 2 + 1`, which is the `y + 6` these widgets already used at 20 px, so no label moved. `ui::centered_text` keeps its clipped centring and is now used only for titles and lines of text, which vanilla does not scroll; its doc comment said it scrolled, which it never did. The title screens draw their own buttons, outside `ui.rs`, so they are fixed in the same pull request's second commit: `Title::draw`'s loop used the label's own width as the button's, and a label wider than the button ran over the buttons beside it — `so_so`'s Create World, World tab, `World Type` (150 px button, 590 px label) crossed the screen over the Customize button, `hi_in`'s Multiplayer footer `Join Server` (100 px, 154 px) over `Refresh`, `ta_in`'s Select World `Re-Create` (71 px, 92 px) over `Edit`. That loop (`Title::buttons` returns the Main Menu, Select World, Create World, world-management, confirm and Multiplayer footer buttons) now labels through `Button::draw_label`, which is `ui::scrolling_text` with vanilla's 2 px margin. A label that fits does not move: `centered_left(left, right - left, width)` equals the old `(b.w / 2).floor() - (tw.ceil() / 2).floor()` for every integer width the screens use, and the line stays at `b.y + 6.0`. ## 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 `AbstractWidget.extractScrollingStringOverContents`, `AbstractButton.extractDefaultLabel`, `AbstractSliderButton.extractWidgetRenderState`, `ActiveTextCollector.acceptScrollingWithDefaultCenter`, `ActiveTextCollector.defaultScrollingHelper`, `GuiGraphicsExtractor$RenderingTextCollector.acceptScrolling`, all in the 26.3 client jar (`javap -p -c` on `/tmp/cj`, offsets quoted above). No harness runs it: the parity checks that would need a client are listed under Not proven. ## Other projects' code none ## Self-check Run on the build VM through the shared checkout, in my worktree with the same diff: | Check | Result | | --- | --- | | `cargo test -q -p horizon-client-render --lib ui::` | 93 passed, 0 failed, 2 ignored | | `cargo test -q -p horizon-client-lib --lib title::tests` | 55 passed, 0 failed | | `cargo clippy -q -p horizon-client-render --all-targets --locked -- -D warnings` | clean | | `cargo clippy -q -p horizon-client-lib --all-targets --locked -- -D warnings` | clean | | `rustfmt --edition 2024 --check crates/horizon-client-render/src/ui.rs` | clean | **Proven:** the label maths, against the formula above, and the drawing against a real atlas. `cargo test -q -p horizon-client-render --lib ui::` -> 93 passed, 0 failed, 2 ignored. The new cases: `an_overflowing_label_slides_from_its_end_to_its_start_and_back` (period `max(overflow * 0.5, 3)` s, the sine's two ends and its bounds over 40 s), `an_overflowing_label_is_drawn_left_less_the_integer_slide` (`left - (int) pos`, cut not rounded), and `a_label_wider_than_its_widget_stays_inside_it` (every vertex of a 300+ px label inside the 10..106 widget box, and a label that fits drawn whole and centred, on a `HudAtlas::build` font). The title screens are drawn on the same path: `cargo test -q -p horizon-client-lib --lib title::tests` -> 55 passed, 0 failed, including `a_button_label_wider_than_its_button_stays_inside_it`, which draws `Create Backup and Load the World Anyway` in a 100 px button and asserts every vertex stays inside `x + 2 .. x + w - 2` and the button's 20 px height, then that `Done` still starts at the centred x. **Not proven:** I did not watch a label slide in the running client, so the animation's smoothness and the shadow at the scissor edge are unchecked, and no vanilla 26.3 screen was compared pixel for pixel. The check that would prove it: a nightly `horizon-windows-x64` run as in #6229 — Options > Video Settings with `set simulation-distance 1.0` and two clicks on Graphics API, two screenshots 2.3 s apart, which must now differ (the label's end visible in one and its start in the other) instead of both showing `Graphics API: Prefer Vulkan`. The same two-shot check on Key Binds (`> Left Control <`), a 150 px slider whose label overflows, and the title screens: `so_so` (no worlds, so it opens Create World), World tab, World Type cycled to Large Biomes, where the 590 px label must stay inside its 150 px button and differ between the shots; likewise `hi_in`'s Multiplayer footer and `ta_in`'s Select World. ## Screenshots Not taken: this worktree renders on the build VM only, without the client's resources or a display. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:27:30 +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#6817
No description provided.