mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 02:15:34 +00:00
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 <mail@eliasnaur.com>
This commit is contained in:
+3
-23
@@ -58,29 +58,9 @@ func (c Constraint) loose() Constraint {
|
|||||||
return Constraint{Max: c.Max}
|
return Constraint{Max: c.Max}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Constraints) Exact(width, height int) Constraints {
|
// RigidConstraints returns the constraints that can only be
|
||||||
if height != 0 {
|
// satisfied by the given dimensions.
|
||||||
if c.Height.Min < height {
|
func RigidConstraints(size image.Point) Constraints {
|
||||||
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 {
|
|
||||||
return Constraints{
|
return Constraints{
|
||||||
Width: Constraint{Min: size.X, Max: size.X},
|
Width: Constraint{Min: size.X, Max: size.X},
|
||||||
Height: Constraint{Min: size.Y, Max: size.Y},
|
Height: Constraint{Min: size.Y, Max: size.Y},
|
||||||
|
|||||||
Reference in New Issue
Block a user