~eliasnaur/gio

33103593a1b4cdd30f6601fd98db7bf922c379cf — pierre 4 months ago 0416fff
layout: updated comment, avoid copying whole context in Flex

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

M layout/flex.go
M layout/flex.go => layout/flex.go +9 -9
@@ 65,9 65,10 @@ func Rigid(widget Widget) FlexChild {
	}
}

// Flexed returns a Flex child forced to take up w fraction of the
// of the space left over from Rigid children. The fraction is weight
// divided by the weight sum of all Flexed children.
// Flexed returns a Flex child forced to take up weight fraction of the
// space left over from Rigid children. The fraction is weight
// divided by either the weight sum of all Flexed children or the Flex
// WeightSum if non zero.
func Flexed(weight float32, widget Widget) FlexChild {
	return FlexChild{
		flex:   true,


@@ 86,6 87,7 @@ func (f Flex) Layout(gtx Context, children ...FlexChild) Dimensions {
	crossMin, crossMax := axisCrossConstraint(f.Axis, cs)
	remaining := mainMax
	var totalWeight float32
	cgtx := gtx
	// Lay out Rigid children.
	for i, child := range children {
		if child.flex {


@@ 93,9 95,8 @@ func (f Flex) Layout(gtx Context, children ...FlexChild) Dimensions {
			continue
		}
		macro := op.Record(gtx.Ops)
		gtx := gtx
		gtx.Constraints = axisConstraints(f.Axis, 0, remaining, crossMin, crossMax)
		dims := child.widget(gtx)
		cgtx.Constraints = axisConstraints(f.Axis, 0, remaining, crossMin, crossMax)
		dims := child.widget(cgtx)
		c := macro.Stop()
		sz := axisMain(f.Axis, dims.Size)
		size += sz


@@ 129,9 130,8 @@ func (f Flex) Layout(gtx Context, children ...FlexChild) Dimensions {
			}
		}
		macro := op.Record(gtx.Ops)
		gtx := gtx
		gtx.Constraints = axisConstraints(f.Axis, flexSize, flexSize, crossMin, crossMax)
		dims := child.widget(gtx)
		cgtx.Constraints = axisConstraints(f.Axis, flexSize, flexSize, crossMin, crossMax)
		dims := child.widget(cgtx)
		c := macro.Stop()
		sz := axisMain(f.Axis, dims.Size)
		size += sz