mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 15:45:38 +00:00
7bf3265ccd
Instead of
type Contraints struct {
Width, Height Constraint
}
use
type Constraints struct {
Min, Max image.Point
}
which leads to simpler use. For example, the Min method is trivally replaced by
the field, and the RigidConstraints constructor is no longer a net win.
API Change. Rewrites:
gofmt -r 'gtx.Constraints.Min() -> gtx.Constraints.Min'
gofmt -r 'gtx.Constraints.Width.Min -> gtx.Constraints.Min.X'
gofmt -r 'gtx.Constraints.Height.Min -> gtx.Constraints.Min.Y'
gofmt -r 'gtx.Constraints.Height.Max -> gtx.Constraints.Max.Y'
gofmt -r 'gtx.Constraints.Width.Max -> gtx.Constraints.Max.X'
Signed-off-by: Elias Naur <mail@eliasnaur.com>
27 lines
558 B
Go
27 lines
558 B
Go
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
package layout
|
|
|
|
import (
|
|
"image"
|
|
"testing"
|
|
)
|
|
|
|
func TestStack(t *testing.T) {
|
|
var gtx Context
|
|
gtx.Reset(nil, nil, image.Point{X: 100, Y: 100})
|
|
gtx.Constraints.Min = image.Point{}
|
|
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)
|
|
}
|
|
}
|