From 667670f9c65670bf48034962d4d02119f8ad402a Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Mon, 15 Jul 2019 19:12:35 +0200 Subject: [PATCH] ui/layout: delete Constraints.Exact and rename ExactConstraints Exact was too special and can be expressed with RigidConstraints. RigidConstraints is a better name ("rigid" was in the comment!) Signed-off-by: Elias Naur --- ui/layout/layout.go | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/ui/layout/layout.go b/ui/layout/layout.go index 02e8655d..ebe8f6a9 100644 --- a/ui/layout/layout.go +++ b/ui/layout/layout.go @@ -58,29 +58,9 @@ func (c Constraint) loose() Constraint { return Constraint{Max: c.Max} } -func (c Constraints) Exact(width, height int) Constraints { - if height != 0 { - if c.Height.Min < height { - c.Height.Min = height - } - if height < c.Height.Max { - c.Height.Max = height - } - } - if width != 0 { - if c.Width.Min < width { - c.Width.Min = width - } - if width < c.Width.Max { - c.Width.Max = width - } - } - return c -} - -// ExactConstraints returns the rigid constraints that represents the -// given dimensions. -func ExactConstraints(size image.Point) Constraints { +// RigidConstraints returns the constraints that can only be +// satisfied by the given dimensions. +func RigidConstraints(size image.Point) Constraints { return Constraints{ Width: Constraint{Min: size.X, Max: size.X}, Height: Constraint{Min: size.Y, Max: size.Y},