From 449c2b844a409d979d74b4b30ad54efc008bd43f Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 11 Jul 2019 18:44:44 +0200 Subject: [PATCH] ui/layout: drop FlexMode The type and argument to Flex.Flexible does not carry its weight; It is just as easy to expand the constraint directly. While we're here, rename the flex argument to weight which is clearer. --- ui/layout/flex.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/ui/layout/flex.go b/ui/layout/flex.go index 43abe7e8..a54b15ea 100644 --- a/ui/layout/flex.go +++ b/ui/layout/flex.go @@ -31,15 +31,9 @@ type FlexChild struct { type MainAxisSize uint8 -type FlexMode uint8 type MainAxisAlignment uint8 type CrossAxisAlignment uint8 -const ( - Loose FlexMode = iota - Fit -) - const ( Max MainAxisSize = iota Min @@ -89,17 +83,14 @@ func (f *Flex) Rigid() Constraints { return axisConstraints(f.Axis, Constraint{Max: mainMax}, f.crossConstraintChild(f.cs)) } -func (f *Flex) Flexible(flex float32, mode FlexMode) Constraints { +func (f *Flex) Flexible(weight float32) Constraints { f.begin() mainc := axisMainConstraint(f.Axis, f.cs) var flexSize int if mainc.Max != ui.Inf && mainc.Max > f.taken { flexSize = mainc.Max - f.taken } - submainc := Constraint{Max: int(float32(flexSize) * flex)} - if mode == Fit { - submainc.Min = submainc.Max - } + submainc := Constraint{Max: int(float32(flexSize) * weight)} return axisConstraints(f.Axis, submainc, f.crossConstraintChild(f.cs)) }