mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 10:25:37 +00:00
ui/layout: clean up after function scope change
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+2
-6
@@ -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.
|
// 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 {
|
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() {
|
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()
|
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.
|
// more reports whether more children are needed.
|
||||||
func (l *List) more() bool {
|
func (l *List) more() bool {
|
||||||
return l.dir != iterateNone
|
return l.dir != iterateNone
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ type Stack struct {
|
|||||||
ops *ui.Ops
|
ops *ui.Ops
|
||||||
constrained bool
|
constrained bool
|
||||||
cs Constraints
|
cs Constraints
|
||||||
begun bool
|
|
||||||
maxSZ image.Point
|
maxSZ image.Point
|
||||||
baseline int
|
baseline int
|
||||||
}
|
}
|
||||||
@@ -44,10 +43,6 @@ func (s *Stack) begin() {
|
|||||||
if !s.constrained {
|
if !s.constrained {
|
||||||
panic("must Init before adding a child")
|
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)
|
s.macro.Record(s.ops)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +67,6 @@ func (s *Stack) Expand(w Widget) StackChild {
|
|||||||
// End a child by specifying its dimensions.
|
// End a child by specifying its dimensions.
|
||||||
func (s *Stack) end(dims Dimensions) StackChild {
|
func (s *Stack) end(dims Dimensions) StackChild {
|
||||||
s.macro.Stop()
|
s.macro.Stop()
|
||||||
s.begun = false
|
|
||||||
if w := dims.Size.X; w > s.maxSZ.X {
|
if w := dims.Size.X; w > s.maxSZ.X {
|
||||||
s.maxSZ.X = w
|
s.maxSZ.X = w
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user