ui/layout: drop Flex.MainAxisSize setting and MainAxisSize type

The setting doesn't bear its own weight; it's simpler for the client
to adjust the constraints itself.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-07-11 19:15:17 +02:00
parent c7e85efc27
commit 10ef4576e7
+1 -13
View File
@@ -13,7 +13,6 @@ type Flex struct {
Axis Axis Axis Axis
MainAxisAlignment MainAxisAlignment MainAxisAlignment MainAxisAlignment
CrossAxisAlignment CrossAxisAlignment CrossAxisAlignment CrossAxisAlignment
MainAxisSize MainAxisSize
ops *ui.Ops ops *ui.Ops
cs Constraints cs Constraints
@@ -29,18 +28,11 @@ type FlexChild struct {
dims Dimens dims Dimens
} }
type MainAxisSize uint8
type MainAxisAlignment uint8 type MainAxisAlignment uint8
type CrossAxisAlignment uint8 type CrossAxisAlignment uint8
type flexMode uint8 type flexMode uint8
const (
Max MainAxisSize = iota
Min
)
const ( const (
Start = 100 + iota Start = 100 + iota
End End
@@ -136,11 +128,7 @@ func (f *Flex) Layout(children ...FlexChild) Dimens {
mainc := axisMainConstraint(f.Axis, f.cs) mainc := axisMainConstraint(f.Axis, f.cs)
crossSize := axisCrossConstraint(f.Axis, f.cs).Constrain(f.maxCross) crossSize := axisCrossConstraint(f.Axis, f.cs).Constrain(f.maxCross)
var space int var space int
if mainc.Max != ui.Inf && f.MainAxisSize == Max { if mainc.Min > f.size {
if mainc.Max > f.size {
space = mainc.Max - f.size
}
} else if mainc.Min > f.size {
space = mainc.Min - f.size space = mainc.Min - f.size
} }
var mainSize int var mainSize int