layout: default List scroll bounds to infinity

Before, List would only report the remaining scrollable area of the visible
children when positioned close to either end. Now, List always report infinite
scroll bounds *unless* it is positioned at an extremum.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-03-30 20:12:33 +02:00
parent d34544cc22
commit a699fb89ac
+11 -9
View File
@@ -302,17 +302,19 @@ func (l *List) layout(ops *op.Ops, macro op.MacroOp) Dimensions {
call := macro.Stop() call := macro.Stop()
defer clip.Rect(image.Rectangle{Max: dims}).Push(ops).Pop() defer clip.Rect(image.Rectangle{Max: dims}).Push(ops).Pop()
var min, max int min, max := int(-inf), int(inf)
if o := l.Position.Offset; o > 0 { if l.Position.First == 0 {
// Use the size of the invisible part as scroll boundary. // Use the size of the invisible part as scroll boundary.
min = -o min = -l.Position.Offset
} else if l.Position.First > 0 { if min > 0 {
min = -inf min = 0
}
} }
if o := l.Position.OffsetLast; o < 0 { if l.Position.First+l.Position.Count == l.len {
max = -o max = -l.Position.OffsetLast
} else if l.Position.First+l.Position.Count < l.len { if max < 0 {
max = inf max = 0
}
} }
scrollRange := image.Rectangle{ scrollRange := image.Rectangle{
Min: l.Axis.Convert(image.Pt(min, 0)), Min: l.Axis.Convert(image.Pt(min, 0)),