forked from joejulian/gio
widget/material: ensure List accounts for scrollbar size in dims
This commit ensures that the dimensions returned by material.List include the size of the scrollbar when the scrollbar is set to the Occupy AnchorStrategy. Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
+10
-2
@@ -247,9 +247,10 @@ func List(th *Theme, state *widget.List) ListStyle {
|
||||
func (l ListStyle) Layout(gtx layout.Context, length int, w layout.ListElement) layout.Dimensions {
|
||||
originalConstraints := gtx.Constraints
|
||||
|
||||
// Determine how much space the scrollbar occupies.
|
||||
barWidth := gtx.Px(l.Width(gtx.Metric))
|
||||
|
||||
if l.AnchorStrategy == Occupy {
|
||||
// Determine how much space the scrollbar occupies.
|
||||
barWidth := gtx.Px(l.Width(gtx.Metric))
|
||||
|
||||
// Reserve space for the scrollbar using the gtx constraints.
|
||||
max := l.state.Axis.Convert(gtx.Constraints.Max)
|
||||
@@ -290,5 +291,12 @@ func (l ListStyle) Layout(gtx layout.Context, length int, w layout.ListElement)
|
||||
l.state.List.Position.BeforeEnd = true
|
||||
}
|
||||
|
||||
if l.AnchorStrategy == Occupy {
|
||||
// Increase the width to account for the space occupied by the scrollbar.
|
||||
cross := l.state.Axis.Convert(listDims.Size)
|
||||
cross.Y += barWidth
|
||||
listDims.Size = l.state.Axis.Convert(cross)
|
||||
}
|
||||
|
||||
return listDims
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user