mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
layout: avoid copying whole constraints in Stack
Signed-off-by: pierre <pierre.curto@gmail.com>
This commit is contained in:
+5
-8
@@ -50,14 +50,14 @@ func Expanded(w Widget) StackChild {
|
|||||||
func (s Stack) Layout(gtx Context, children ...StackChild) Dimensions {
|
func (s Stack) Layout(gtx Context, children ...StackChild) Dimensions {
|
||||||
var maxSZ image.Point
|
var maxSZ image.Point
|
||||||
// First lay out Stacked children.
|
// First lay out Stacked children.
|
||||||
|
cgtx := gtx
|
||||||
|
cgtx.Constraints.Min = image.Point{}
|
||||||
for i, w := range children {
|
for i, w := range children {
|
||||||
if w.expanded {
|
if w.expanded {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
macro := op.Record(gtx.Ops)
|
macro := op.Record(gtx.Ops)
|
||||||
gtx := gtx
|
dims := w.widget(cgtx)
|
||||||
gtx.Constraints.Min = image.Pt(0, 0)
|
|
||||||
dims := w.widget(gtx)
|
|
||||||
call := macro.Stop()
|
call := macro.Stop()
|
||||||
if w := dims.Size.X; w > maxSZ.X {
|
if w := dims.Size.X; w > maxSZ.X {
|
||||||
maxSZ.X = w
|
maxSZ.X = w
|
||||||
@@ -74,11 +74,8 @@ func (s Stack) Layout(gtx Context, children ...StackChild) Dimensions {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
macro := op.Record(gtx.Ops)
|
macro := op.Record(gtx.Ops)
|
||||||
gtx := gtx
|
cgtx.Constraints.Min = maxSZ
|
||||||
gtx.Constraints = Constraints{
|
dims := w.widget(cgtx)
|
||||||
Min: maxSZ, Max: gtx.Constraints.Max,
|
|
||||||
}
|
|
||||||
dims := w.widget(gtx)
|
|
||||||
call := macro.Stop()
|
call := macro.Stop()
|
||||||
if w := dims.Size.X; w > maxSZ.X {
|
if w := dims.Size.X; w > maxSZ.X {
|
||||||
maxSZ.X = w
|
maxSZ.X = w
|
||||||
|
|||||||
Reference in New Issue
Block a user