Add vertical slider support to bevy_ui_widgets slider#21827
Merged
alice-i-cecile merged 8 commits intobevyengine:mainfrom Dec 9, 2025
Merged
Add vertical slider support to bevy_ui_widgets slider#21827alice-i-cecile merged 8 commits intobevyengine:mainfrom
alice-i-cecile merged 8 commits intobevyengine:mainfrom
Conversation
Contributor
|
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
| return; | ||
| } | ||
|
|
||
| // Detect orientation: vertical if height > width |
Member
There was a problem hiding this comment.
This is a clever idea and I want to keep it, but we should call this out in the docs somewhere.
alice-i-cecile
requested changes
Nov 16, 2025
Member
alice-i-cecile
left a comment
There was a problem hiding this comment.
A quick note on docs, and I would like a vertical slider in one of our examples so we can quickly test this please.
viridia
approved these changes
Nov 16, 2025
…ed after the example something was wrong)
Contributor
Author
|
Made a fix to slider.rs and created the example |
Contributor
Author
|
I don't think I can do anything about the failing check |
alice-i-cecile
approved these changes
Nov 17, 2025
Member
|
Yep, that's an upstream problem. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Solution
The slider widget now automatically detects its orientation based on the node's dimensions (
height > widthfor vertical, otherwise horizontal) and adjusts its interaction behavior accordingly:Orientation Detection: Added automatic detection of slider orientation by comparing
node.size().ytonode.size().xin bothslider_on_pointer_downandslider_on_dragfunctions.Drag Direction Fix:
distance.y) instead of X-axisthumb.size().yfor vertical sliders instead of always usingthumb.size().xClick Position Fix:
local_pos.yfrom[-height/2, +height/2]to[0, height]before calculating the slider valueTrack Size Calculation: Uses
node.size().y - thumb_sizefor vertical sliders andnode.size().x - thumb_sizefor horizontal sliders when calculating the available track space.The changes are backward compatible - horizontal sliders continue to work exactly as before, and the orientation detection is transparent to users of the API.
Testing
Manual Testing: Created test application with both vertical and horizontal sliders to verify:
Edge Cases Tested:
Areas that may need more testing:
How reviewers can test:
Platforms tested:
Showcase
Before
before.mov
After
after.mov
Code Example
The orientation is automatically detected based on the node dimensions - no API changes required!