layout: compute Position.Offset correctly for ScrollToEnd Lists

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-03-30 20:18:09 +02:00
parent 508330e818
commit afd39a6bfe
2 changed files with 20 additions and 2 deletions
+18
View File
@@ -25,6 +25,24 @@ func TestEmptyList(t *testing.T) {
}
}
func TestListScrollToEnd(t *testing.T) {
l := List{
ScrollToEnd: true,
}
gtx := Context{
Ops: new(op.Ops),
Constraints: Exact(image.Pt(20, 10)),
}
l.Layout(gtx, 1, func(gtx Context, idx int) Dimensions {
return Dimensions{
Size: image.Pt(10, 10),
}
})
if want, got := -10, l.Position.Offset; want != got {
t.Errorf("got offset %d, want %d", got, want)
}
}
func TestListPosition(t *testing.T) {
_s := func(e ...event.Event) []event.Event { return e }
r := new(router.Router)