element/scrollarea: add optional draggable scrollbar#89
Conversation
83e81bb to
bcd1753
Compare
|
would it not be better to make the scrollbar actually part of the layout tree so it can receive input events and stuff? |
|
actually that's a good idea |
bcd1753 to
8829ccf
Compare
|
redid it as a real element in the tree. the thumb is draggable now, click on the track jumps and keeps dragging, and it brightens on hover. content goes into an inner scrolled layer so the bar can sit on top and take input. dropped the paintOver hook. |
|
it can still disappear, as long as its absolutely sized and not in a layout it wont reserve space. |
|
yep that's how it's set up. the strip is |
|
can you add a scroll area to the controls test? You could put the entire thing in a vertical scroll area for testing |
8829ccf to
f083826
Compare
|
done. the controls test already had everything in a vertical scroll area, so i turned the bar on there. it shows when the controls overflow the window and hides when they fit, and you can drag it. |
|
very jittery when scrolling down continuously, constantly jitters and snaps up and down. |
f083826 to
4ef0359
Compare
|
good catch. the snap was the new inner content layer getting laid out twice per reposition: fix is to measure the overflow once per reposition while the content is in its grown state ( reproduced it under hyprland on the controls scroll area: |
|
Still here, less jittery, but bugged. FWIW, I am using continuous scroll for this (touchpad) I scroll max down, and let go, then it snaps to the top. I start scrolling, it snaps to the bottom. |
showScrollbar(true) puts a real scrollbar in the element tree, so it takes input: drag the thumb or click the track to scroll, and the thumb brightens on hover. content moves into an inner layer that scrolls while the bar stays on top.
4ef0359 to
737cd58
Compare
|
fixed. the scroll offset only lived in a one-shot pass over the content layer's children, so when a content element scheduled its own reflow the window relaid that layer with no offset and it jumped to the top while |
|
thanks. All good now. In the future, if you wanna work on it a bit more:
|
Redone as a real element in the tree, per your suggestion.
showScrollbar(true)adds a track and a draggable thumb. The scroll offset is applied to every child, so the content now lives in an inner layer that scrolls, and the scrollbar sits on top as a sibling that stays put. The strip takes mouse input:Vertical and horizontal are both handled. The
paintOver()hook from the first version is gone.Tests (headless, hard assertions): scroll clamp, thumb size/position vs scroll, a tiny-viewport regression for a
std::clampabort that the first version hit, and a drag that asserts the scroll moves proportionally then stops on release.