mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
layout: do not reset cross axis constraints in Direction for N, S, E and W
Fixes #268 Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
This commit is contained in:
@@ -29,3 +29,36 @@ func TestStack(t *testing.T) {
|
||||
t.Errorf("Stack ignored Expanded size, got %v expected %v", got, exp)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDirection(t *testing.T) {
|
||||
max := image.Pt(100, 100)
|
||||
for _, tc := range []struct {
|
||||
dir Direction
|
||||
exp image.Point
|
||||
}{
|
||||
{N, image.Pt(max.X, 0)},
|
||||
{S, image.Pt(max.X, 0)},
|
||||
{E, image.Pt(0, max.Y)},
|
||||
{W, image.Pt(0, max.Y)},
|
||||
{NW, image.Pt(0, 0)},
|
||||
{NE, image.Pt(0, 0)},
|
||||
{SE, image.Pt(0, 0)},
|
||||
{SW, image.Pt(0, 0)},
|
||||
{Center, image.Pt(0, 0)},
|
||||
} {
|
||||
t.Run(tc.dir.String(), func(t *testing.T) {
|
||||
gtx := Context{
|
||||
Ops: new(op.Ops),
|
||||
Constraints: Exact(max),
|
||||
}
|
||||
var min image.Point
|
||||
tc.dir.Layout(gtx, func(gtx Context) Dimensions {
|
||||
min = gtx.Constraints.Min
|
||||
return Dimensions{}
|
||||
})
|
||||
if got, exp := min, tc.exp; got != exp {
|
||||
t.Errorf("got %v; expected %v", got, exp)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user