The scroll wheel scrolls the scroll box

This commit is contained in:
2023-01-20 16:44:07 -05:00
parent b85285f326
commit 2f53c942ac
2 changed files with 38 additions and 16 deletions

View File

@@ -131,7 +131,10 @@ func (element *ScrollContainer) HandleMouseScroll (
x, y int,
deltaX, deltaY float64,
) {
// TODO: use this to scroll. do not pass this down to the child
scrollPoint := element.child.ScrollViewportBounds().Min.Add(image.Pt (
int(deltaX),
int(deltaY)))
element.child.ScrollTo(scrollPoint)
}
func (element *ScrollContainer) Selected () (selected bool) {
@@ -282,10 +285,10 @@ func (element *ScrollContainer) recalculate () {
}
// if the scroll bars are out of bounds, don't display them.
if !horizontal.bar.In(horizontal.gutter) {
if horizontal.bar.Dx() >= horizontal.gutter.Dx() {
horizontal.bar = image.Rectangle { }
}
if !vertical.bar.In(vertical.gutter) {
if vertical.bar.Dy() >= vertical.gutter.Dy() {
vertical.bar = image.Rectangle { }
}
}