~eliasnaur/gio

dac8ffc00271ae07c18dcfb1c608f284d9a7f7ea — Elias Naur 8 days ago 8a6d4f6
layout: add Exact for constructing rigid Constraints matching a size

Signed-off-by: Elias Naur <mail@eliasnaur.com>
1 files changed, 8 insertions(+), 0 deletions(-)

M layout/layout.go
M layout/layout.go => layout/layout.go +8 -0
@@ 58,6 58,14 @@ const (
	Vertical
)

// Exact returns the Constraints with the minimum and maximum size
// set to size.
func Exact(size image.Point) Constraints {
	return Constraints{
		Min: size, Max: size,
	}
}

// Constrain a size so each dimension is in the range [min;max].
func (c Constraints) Constrain(size image.Point) image.Point {
	if min := c.Min.X; size.X < min {