~eliasnaur/gio

e9cd8958de7ce1cae350ed5659e791c336fc445e — pierre 5 months ago 69cc2c7
layout: fixed divisions by zero in Flex.Layout

Signed-off-by: pierre <pierre.curto@gmail.com>
1 files changed, 12 insertions(+), 4 deletions(-)

M layout/flex.go
M layout/flex.go => layout/flex.go +12 -4
@@ 165,7 165,9 @@ func (f Flex) Layout(gtx Context, children ...FlexChild) Dimensions {
	case SpaceEvenly:
		mainSize += space / (1 + len(children))
	case SpaceAround:
		mainSize += space / (len(children) * 2)
		if len(children) > 0 {
			mainSize += space / (len(children) * 2)
		}
	}
	for i, child := range children {
		dims := child.dims


@@ 191,9 193,13 @@ func (f Flex) Layout(gtx Context, children ...FlexChild) Dimensions {
			case SpaceEvenly:
				mainSize += space / (1 + len(children))
			case SpaceAround:
				mainSize += space / len(children)
				if len(children) > 0 {
					mainSize += space / len(children)
				}
			case SpaceBetween:
				mainSize += space / (len(children) - 1)
				if len(children) > 1 {
					mainSize += space / (len(children) - 1)
				}
			}
		}
	}


@@ 205,7 211,9 @@ func (f Flex) Layout(gtx Context, children ...FlexChild) Dimensions {
	case SpaceEvenly:
		mainSize += space / (1 + len(children))
	case SpaceAround:
		mainSize += space / (len(children) * 2)
		if len(children) > 0 {
			mainSize += space / (len(children) * 2)
		}
	}
	sz := axisPoint(f.Axis, mainSize, maxCross)
	return Dimensions{Size: sz, Baseline: sz.Y - maxBaseline}