Add Value and SetValue to ScrollContainer

This commit is contained in:
Sasha Koshka 2024-05-17 01:08:39 -04:00
parent dca1eaefb5
commit 8134069e1f

View File

@ -104,6 +104,29 @@ func (this *ScrollContainer) SetRoot (root tomo.ContentBox) {
} }
} }
// SetValue sets the horizontal and vertical scrollbar values where 0 is all the
// way to the left/top, and 1 is all the way to the right/bottom.
func (this *ScrollContainer) SetValue (x, y float64) {
if this.layout.horizontal != nil {
this.layout.horizontal.SetValue(x)
}
if this.layout.vertical != nil {
this.layout.vertical.SetValue(y)
}
}
// Value returns the horizontal and vertical scrollbar values where 0 is all the
// way to the left/top, and 1 is all the way to the right/bottom.
func (this *ScrollContainer) Value () (x, y float64) {
if this.layout.horizontal != nil {
x = this.layout.horizontal.Value()
}
if this.layout.vertical != nil {
y = this.layout.vertical.Value()
}
return x, y
}
func (this *ScrollContainer) handleScroll (x, y float64) { 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 (