Scrollbar and ScrollContainer use ScrollTo correctly
This commit is contained in:
parent
224ca25000
commit
87e81c00d3
16
scrollbar.go
16
scrollbar.go
@ -98,9 +98,9 @@ func (this *Scrollbar) SetValue (value float64) {
|
|||||||
position := trackLength * value
|
position := trackLength * value
|
||||||
point := this.layout.linked.ContentBounds().Min
|
point := this.layout.linked.ContentBounds().Min
|
||||||
if this.layout.vertical {
|
if this.layout.vertical {
|
||||||
point.Y = int(position)
|
point.Y = -int(position)
|
||||||
} else {
|
} else {
|
||||||
point.X = int(position)
|
point.X = -int(position)
|
||||||
}
|
}
|
||||||
this.layout.linked.ScrollTo(point)
|
this.layout.linked.ScrollTo(point)
|
||||||
|
|
||||||
@ -173,15 +173,15 @@ func (this *Scrollbar) handleMouseDown (button input.Button) {
|
|||||||
}
|
}
|
||||||
case input.ButtonMiddle:
|
case input.ButtonMiddle:
|
||||||
if above {
|
if above {
|
||||||
this.scrollBy(-this.pageSize())
|
|
||||||
} else {
|
|
||||||
this.scrollBy(this.pageSize())
|
this.scrollBy(this.pageSize())
|
||||||
|
} else {
|
||||||
|
this.scrollBy(-this.pageSize())
|
||||||
}
|
}
|
||||||
case input.ButtonRight:
|
case input.ButtonRight:
|
||||||
if above {
|
if above {
|
||||||
this.scrollBy(-this.stepSize())
|
|
||||||
} else {
|
|
||||||
this.scrollBy(this.stepSize())
|
this.scrollBy(this.stepSize())
|
||||||
|
} else {
|
||||||
|
this.scrollBy(-this.stepSize())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,7 +200,7 @@ func (this *Scrollbar) handleScroll (x, y float64) {
|
|||||||
if this.layout.linked == nil { return }
|
if this.layout.linked == nil { return }
|
||||||
this.layout.linked.ScrollTo (
|
this.layout.linked.ScrollTo (
|
||||||
this.layout.linked.ContentBounds().Min.
|
this.layout.linked.ContentBounds().Min.
|
||||||
Add(image.Pt(int(x), int(y))))
|
Sub(image.Pt(int(x), int(y))))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Scrollbar) drag () {
|
func (this *Scrollbar) drag () {
|
||||||
@ -327,7 +327,7 @@ func (this scrollbarLayout) Arrange (hints tomo.LayoutHints, boxes []tomo.Box) {
|
|||||||
} else {
|
} else {
|
||||||
handleOffset = image.Pt(int(handlePosition), 0)
|
handleOffset = image.Pt(int(handlePosition), 0)
|
||||||
}
|
}
|
||||||
handle = handle.Add(handleOffset).Add(gutter.Min)
|
handle = handle.Sub(handleOffset).Add(gutter.Min)
|
||||||
|
|
||||||
// place handle
|
// place handle
|
||||||
boxes[0].SetBounds(handle)
|
boxes[0].SetBounds(handle)
|
||||||
|
@ -108,7 +108,7 @@ func (this *ScrollContainer) handleScroll (x, y float64) {
|
|||||||
if this.layout.root == nil { return }
|
if this.layout.root == nil { return }
|
||||||
this.layout.root.ScrollTo (
|
this.layout.root.ScrollTo (
|
||||||
this.layout.root.ContentBounds().Min.
|
this.layout.root.ContentBounds().Min.
|
||||||
Add(image.Pt(int(x), int(y))))
|
Sub(image.Pt(int(x), int(y))))
|
||||||
}
|
}
|
||||||
|
|
||||||
type scrollContainerLayout struct {
|
type scrollContainerLayout struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user