diff --git a/ui/overflow.go b/ui/overflow.go index abc2df4..037796b 100644 --- a/ui/overflow.go +++ b/ui/overflow.go @@ -17,6 +17,7 @@ type overflow struct { offset geom.PointF32 parent Control content Buffer + proxied Control hor *Scrollbar ver *Scrollbar @@ -84,7 +85,7 @@ func (o *overflow) Arrange(ctx Context, bounds geom.RectangleF32, offset geom.Po } if ver { o.ver.ContentLength = o.desired.Y - o.ver.Arrange(ctx, geom.RectF32(bounds.Min.X+contentW, bounds.Min.Y, bounds.Max.X, bounds.Max.Y), offset, o) + o.ver.Arrange(ctx, geom.RectF32(bounds.Min.X+contentW, bounds.Min.Y, bounds.Max.X, bounds.Min.Y+contentH), offset, o) } } @@ -95,6 +96,11 @@ func (o *overflow) DesiredSize(ctx Context) geom.PointF32 { } func (o *overflow) Handle(ctx Context, e Event) { + if o.Content != o.proxied { + o.hor.ContentOffset = 0 + o.ver.ContentOffset = 0 + o.proxied = o.Content + } hor, ver := o.shouldScroll(o.bounds) if hor { o.hor.Handle(ctx, e) diff --git a/ui/scrollbar.go b/ui/scrollbar.go index 7d80ec2..27fe8bb 100644 --- a/ui/scrollbar.go +++ b/ui/scrollbar.go @@ -55,6 +55,7 @@ func (s *Scrollbar) Handle(ctx Context, e Event) { } func (s *Scrollbar) Render(ctx Context) { + ctx.Renderer().FillRectangle(s.bounds, RGBA(0, 0, 0, 1)) s.handle.Render(ctx) } diff --git a/ui/stackpanel.go b/ui/stackpanel.go index a69d191..662753f 100644 --- a/ui/stackpanel.go +++ b/ui/stackpanel.go @@ -79,7 +79,7 @@ func (p *StackPanel) Render(ctx Context) { var bounds = p.Bounds() for _, child := range p.Children { var childB = child.Bounds() - if childB.Min.X >= bounds.Max.X || childB.Min.Y >= bounds.Max.Y || childB.Max.X < bounds.Min.X || childB.Max.Y < bounds.Min.Y { + if childB.Min.X >= bounds.Max.X || childB.Min.Y >= bounds.Max.Y || childB.Max.X < bounds.Min.X || childB.Max.Y < bounds.Min.Y || childB.Max.X < 0 || childB.Max.Y < 0 { continue } child.Render(ctx)