-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add vertical slider support to bevy_ui_widgets slider #21827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a clever idea and I want to keep it, but we should call this out in the docs somewhere.
alice-i-cecile
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A quick note on docs, and I would like a vertical slider in one of our examples so we can quickly test this please.
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!