widget/material: ensure scrollbar within dimensions

This commit fixes a visual-only bug in the ListStyle that could
make the scrollbar float at the edge of the maximum constraints
when the list did not occupy the full constraints. The list
would still reserve layout space for the scrollbar in the correct
position, but the scrollbar would not be displayed there.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
Chris Waldon
2022-05-27 15:14:41 -04:00
committed by Elias Naur
parent 99d0332067
commit 87be31cbec
+6 -1
View File
@@ -281,7 +281,12 @@ func (l ListStyle) Layout(gtx layout.Context, length int, w layout.ListElement)
// layout.Direction respects the minimum, so ensure that the
// scrollbar will be drawn on the correct edge even if the provided
// layout.Context had a zero minimum constraint.
gtx.Constraints.Min = gtx.Constraints.Max
gtx.Constraints.Min = listDims.Size
if l.AnchorStrategy == Occupy {
min := l.state.Axis.Convert(gtx.Constraints.Min)
min.Y += barWidth
gtx.Constraints.Min = l.state.Axis.Convert(min)
}
anchoring.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return l.ScrollbarStyle.Layout(gtx, l.state.Axis, start, end)
})