mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
layout: include Expanded sizes in Stack size calculation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -83,6 +83,12 @@ func (s Stack) Layout(gtx *Context, children ...StackChild) {
|
||||
}
|
||||
dims := ctxLayout(gtx, cs, w.widget)
|
||||
m.Stop()
|
||||
if w := dims.Size.X; w > maxSZ.X {
|
||||
maxSZ.X = w
|
||||
}
|
||||
if h := dims.Size.Y; h > maxSZ.Y {
|
||||
maxSZ.Y = h
|
||||
}
|
||||
children[i].macro = m
|
||||
children[i].dims = dims
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package layout
|
||||
|
||||
import (
|
||||
"image"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestStack(t *testing.T) {
|
||||
var gtx Context
|
||||
gtx.Reset(nil, image.Point{X: 100, Y: 100})
|
||||
gtx.Constraints.Width.Min = 0
|
||||
gtx.Constraints.Height.Min = 0
|
||||
exp := image.Point{X: 60, Y: 70}
|
||||
Stack{Alignment: Center}.Layout(>x,
|
||||
Expanded(func() {
|
||||
gtx.Dimensions.Size = exp
|
||||
}),
|
||||
Stacked(func() {
|
||||
gtx.Dimensions.Size = image.Point{X: 50, Y: 50}
|
||||
}),
|
||||
)
|
||||
if got := gtx.Dimensions.Size; got != exp {
|
||||
t.Errorf("Stack ignored Expanded size, got %v expected %v", got, exp)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user