diff --git a/scrollcontainer.go b/scrollcontainer.go index f1b4ebe..b51b498 100644 --- a/scrollcontainer.go +++ b/scrollcontainer.go @@ -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) { if this.layout.root == nil { return } this.layout.root.ScrollTo (