ui/layout: clean up after function scope change

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-09-18 22:03:08 +02:00
parent 1767588028
commit 31f7f04181
2 changed files with 2 additions and 12 deletions
+2 -6
View File
@@ -98,7 +98,8 @@ func (l *List) init(cfg ui.Config, q input.Queue, ops *ui.Ops, cs Constraints, l
// Layout the List and return its dimensions.
func (l *List) Layout(c ui.Config, q input.Queue, ops *ui.Ops, cs Constraints, len int, w ListElement) Dimensions {
for l.init(c, q, ops, cs, len); l.more(); l.next() {
l.end(w(l.constraints(), l.index()))
cs := axisConstraints(l.Axis, Constraint{Max: inf}, axisCrossConstraint(l.Axis, l.cs))
l.end(w(cs, l.index()))
}
return l.layout()
}
@@ -145,11 +146,6 @@ func (l *List) index() int {
}
}
// constraints is the constraints for the current child.
func (l *List) constraints() Constraints {
return axisConstraints(l.Axis, Constraint{Max: inf}, axisCrossConstraint(l.Axis, l.cs))
}
// more reports whether more children are needed.
func (l *List) more() bool {
return l.dir != iterateNone
-6
View File
@@ -19,7 +19,6 @@ type Stack struct {
ops *ui.Ops
constrained bool
cs Constraints
begun bool
maxSZ image.Point
baseline int
}
@@ -44,10 +43,6 @@ func (s *Stack) begin() {
if !s.constrained {
panic("must Init before adding a child")
}
if s.begun {
panic("must End before adding a child")
}
s.begun = true
s.macro.Record(s.ops)
}
@@ -72,7 +67,6 @@ func (s *Stack) Expand(w Widget) StackChild {
// End a child by specifying its dimensions.
func (s *Stack) end(dims Dimensions) StackChild {
s.macro.Stop()
s.begun = false
if w := dims.Size.X; w > s.maxSZ.X {
s.maxSZ.X = w
}