mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
layout: add Exact for constructing rigid Constraints matching a size
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user