From 8134069e1fb4955a04f6e0ca4cdcb6e9e74cd4df Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Fri, 17 May 2024 01:08:39 -0400 Subject: [PATCH] Add Value and SetValue to ScrollContainer --- scrollcontainer.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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 (