mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
layout: respect minimum constraint size in Flex.Layout
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -216,6 +216,7 @@ func (f Flex) Layout(gtx Context, children ...FlexChild) Dimensions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sz := f.Axis.Convert(image.Pt(mainSize, maxCross))
|
sz := f.Axis.Convert(image.Pt(mainSize, maxCross))
|
||||||
|
sz = cs.Constrain(sz)
|
||||||
return Dimensions{Size: sz, Baseline: sz.Y - maxBaseline}
|
return Dimensions{Size: sz, Baseline: sz.Y - maxBaseline}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,20 @@ func TestStack(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFlex(t *testing.T) {
|
||||||
|
gtx := Context{
|
||||||
|
Ops: new(op.Ops),
|
||||||
|
Constraints: Constraints{
|
||||||
|
Min: image.Pt(100, 100),
|
||||||
|
Max: image.Pt(100, 100),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
dims := Flex{}.Layout(gtx)
|
||||||
|
if got := dims.Size; got != gtx.Constraints.Min {
|
||||||
|
t.Errorf("Flex ignored minimum constraints, got %v expected %v", got, gtx.Constraints.Min)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestDirection(t *testing.T) {
|
func TestDirection(t *testing.T) {
|
||||||
max := image.Pt(100, 100)
|
max := image.Pt(100, 100)
|
||||||
for _, tc := range []struct {
|
for _, tc := range []struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user