mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
layout: compute Position.Offset correctly for ScrollToEnd Lists
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user