Fix scroll handle extending outside of ScrollArea - #5286
Conversation
|
Preview available at https://egui-pr-preview.github.io/pr/5286-fix-scroll-handle-overlap |
|
While this is a improvement, now it will look like you're at the top while already scrolled done by some amount: Bildschirmaufnahme.2024-10-20.um.17.22.48.movIdeally, the scrollbar position would just be calculated correctly, taking the min size into account. |
|
Oh, you're totally right. I didn't notice this behaviour 🥲 I'll work on a fix for this |
|
I did an update to the PR. 1º - I extracted the handle_rect calculation to a function scroll_use.mp4 |
lucasmerlin
left a comment
There was a problem hiding this comment.
Awesome, it's working perfectly now, thank you for this! 🚀 I think we can merge this once the pipeline succeeds.
ScrollArea
|
I did two more commits: |
|
Seems like you'll need to do another format. Usually it makes more sense to run rustfmt last after any other changes |
|
Indeed. I'm using RusRover, and for some reason, the format is different than: cargo fmt. Maybe they are using some format of their own. |
|
Oh... That is nice. I'll toggle it. Thank you ^^ |
|
Sorry, totally forgot about this. I'll merge it now, thank you again! |
* [x] I have followed the instructions in the PR template * Closes emilk#3734 ## Info This PR addresses an issue where resizing a scroll handle can lead to unwanted overlap. It is also happening on the egui-demo.  ## Cause *Note: The following explanation assumes a vertical scroll; however, the logic applies equally to horizontal scrolling.* When the scroll handle is positioned at the top or bottom of the scroll area and the handle is resized to fit the minimum handle size, there is a risk of overlap. This occurs if the handle’s new size extends beyond the bounds of the scroll area. ## Proposed Solution 1. Check whether increasing the handle size will cause it to overlap with the scroll area. 2. If an overlap is detected, adjust the handle’s center position by the overlap amount, moving it towards the center of the scroll area.
Info
This PR addresses an issue where resizing a scroll handle can lead to unwanted overlap.
It is also happening on the egui-demo.
Cause
Note: The following explanation assumes a vertical scroll; however, the logic applies equally to horizontal scrolling.
When the scroll handle is positioned at the top or bottom of the scroll area and the handle is resized to fit the minimum handle size, there is a risk of overlap. This occurs if the handle’s new size extends beyond the bounds of the scroll area.
Proposed Solution