mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 02:15:34 +00:00
layout: layout one invisible child at each end of a List
A recent change added automatic scrolling to move focused widgets into view. This change modifies List to layout an extra child at each of its ends, to enable focus to move to them and trigger automatic scrolling of the list. For https://github.com/tailscale/tailscale/issues/4278. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -140,3 +140,21 @@ func TestListPosition(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtraChildren(t *testing.T) {
|
||||
var l List
|
||||
l.Position.First = 1
|
||||
gtx := Context{
|
||||
Ops: new(op.Ops),
|
||||
Constraints: Exact(image.Pt(10, 10)),
|
||||
}
|
||||
count := 0
|
||||
const all = 3
|
||||
l.Layout(gtx, all, func(gtx Context, idx int) Dimensions {
|
||||
count++
|
||||
return Dimensions{Size: image.Pt(10, 10)}
|
||||
})
|
||||
if count != all {
|
||||
t.Errorf("laid out %d of %d children", count, all)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user