[PR #453] [MERGED] Classic sliders follow the pointer and snap on release (#385) #2578

Closed
opened 2026-11-02 15:57:20 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/453
Author: @ludovic111
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/16/2026
Merged by: @ludovic111

Base: main ← Head: fix/slider-smooth-drag


📝 Commits (1)

  • 3c57aba Classic sliders follow the pointer and snap on release

📊 Changes

1 file changed (+97 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/options_ui.rs (+97 -7)

📄 Description

Fixes #385

What vanilla does (AbstractSliderButton, OptionInstance.OptionInstanceSliderButton)

  • setValueFromMouse sets the slider's own value straight from the pointer, so the handle follows it smoothly. The option and the label take the stepped value (applyValue → OptionInstance.set, updateMessage).
  • onRelease calls resetValue, which moves the handle onto the stepped value.
  • Sliders whose value set has applyValueImmediately false (Render Distance, Simulation Distance, Biome Blend, Scroll Sensitivity) apply 600 ms after the last change (delayedApplyAt) and then resetValue. Until then the handle stays where it was dropped.

Horizon drew the handle from the stepped setting, so on stepped sliders (FOV, Render Distance, Max Framerate, Biome Blend…) it jumped from step to step under the pointer.

Changes (options_ui.rs)

  • OptionsUi::slider_value keeps the pressed slider's raw position and when it last moved. Presses and drags set it.
  • slider_shown draws that position while the slider is held, or for the four delayed sliders until 600 ms after the last change. Otherwise it draws the stepped value.
  • Unchanged: Horizon still applies the delayed sliders immediately, as before. Only the handle's position follows vanilla's timing.

How it was verified

  • Unit test classic_sliders_follow_the_pointer_and_snap_on_release: the handle follows the press and the drag (even with the pointer off the widget). Other sliders keep their value, and release snaps. A Render Distance position holds until 600 ms after the change.
  • In game on the Mac mini (classic menus, offscreen, horizon-ctl drag-at): dragged Biome Blend to between steps 3 and 4. Right after release, the handle sat where the drag ended (≈10 px right of step 3) with the label at 7x7. One second later it had snapped onto step 3. drag-at releases at the end, so the held state of immediate sliders is covered by the test only.

Self-check (fmt, clippy, client tests, parity) for the whole batch: see the last comment.

🤖 Generated with Claude Code


🔄 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/453 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/slider-smooth-drag` --- ### 📝 Commits (1) - [`3c57aba`](https://github.com/horizon-rust/horizon/commit/3c57aba6c9951cda422e41dccc36b13cfde94e25) Classic sliders follow the pointer and snap on release ### 📊 Changes **1 file changed** (+97 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/options_ui.rs` (+97 -7) </details> ### 📄 Description Fixes #385 **What vanilla does** (`AbstractSliderButton`, `OptionInstance.OptionInstanceSliderButton`) - `setValueFromMouse` sets the slider's own `value` straight from the pointer, so the handle follows it smoothly. The option and the label take the stepped value (`applyValue` → `OptionInstance.set`, `updateMessage`). - `onRelease` calls `resetValue`, which moves the handle onto the stepped value. - Sliders whose value set has `applyValueImmediately` false (Render Distance, Simulation Distance, Biome Blend, Scroll Sensitivity) apply 600 ms after the last change (`delayedApplyAt`) and then `resetValue`. Until then the handle stays where it was dropped. Horizon drew the handle from the stepped setting, so on stepped sliders (FOV, Render Distance, Max Framerate, Biome Blend…) it jumped from step to step under the pointer. **Changes** (`options_ui.rs`) - `OptionsUi::slider_value` keeps the pressed slider's raw position and when it last moved. Presses and drags set it. - `slider_shown` draws that position while the slider is held, or for the four delayed sliders until 600 ms after the last change. Otherwise it draws the stepped value. - Unchanged: Horizon still applies the delayed sliders immediately, as before. Only the handle's position follows vanilla's timing. **How it was verified** - Unit test `classic_sliders_follow_the_pointer_and_snap_on_release`: the handle follows the press and the drag (even with the pointer off the widget). Other sliders keep their value, and release snaps. A Render Distance position holds until 600 ms after the change. - In game on the Mac mini (classic menus, offscreen, horizon-ctl `drag-at`): dragged Biome Blend to between steps 3 and 4. Right after release, the handle sat where the drag ended (≈10 px right of step 3) with the label at 7x7. One second later it had snapped onto step 3. `drag-at` releases at the end, so the held state of immediate sliders is covered by the test only. Self-check (fmt, clippy, client tests, parity) for the whole batch: see the last comment. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:57:20 +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#2578
No description provided.