Package limn.scene
Record Class Constraints
java.lang.Object
java.lang.Record
limn.scene.Constraints
public record Constraints(float minWidth, float maxWidth, float minHeight, float maxHeight)
extends Record
Layout constraints handed down the tree (Flutter/Compose style): a widget's
measured size must fall inside
[minWidth..maxWidth] x
[minHeight..maxHeight]. UNBOUNDED_LIMIT marks an unbounded axis.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final floatSentinel for "no upper bound" (scrollables measure children with it). -
Constructor Summary
ConstructorsConstructorDescriptionConstraints(float minWidth, float maxWidth, float minHeight, float maxHeight) Creates an instance of aConstraintsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionconstrain(float width, float height) Clamps both axes, which is whatonMeasurenormally returns.floatconstrainHeight(float height) Clamps a height into[minHeight, maxHeight].floatconstrainWidth(float width) Clamps a width into[minWidth, maxWidth].final booleanIndicates whether some other object is "equal to" this one.booleanWhether the maximum height is finite.booleanWhether the maximum width is finite; unbounded means "take your intrinsic width".final inthashCode()Returns a hash code value for this object.static Constraintsloose(float width, float height) Anything from zero up towidth x height.loosened()floatReturns the value of themaxHeightrecord component.floatmaxWidth()Returns the value of themaxWidthrecord component.floatReturns the value of theminHeightrecord component.floatminWidth()Returns the value of theminWidthrecord component.static Constraintstight(float width, float height) Exactlywidth x height.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
UNBOUNDED_LIMIT
public static final float UNBOUNDED_LIMITSentinel for "no upper bound" (scrollables measure children with it).- See Also:
-
-
Constructor Details
-
Constraints
public Constraints(float minWidth, float maxWidth, float minHeight, float maxHeight) Creates an instance of aConstraintsrecord class.- Parameters:
minWidth- the value for theminWidthrecord componentmaxWidth- the value for themaxWidthrecord componentminHeight- the value for theminHeightrecord componentmaxHeight- the value for themaxHeightrecord component
-
-
Method Details
-
tight
Exactlywidth x height. -
loose
Anything from zero up towidth x height. -
hasBoundedWidth
public boolean hasBoundedWidth()Whether the maximum width is finite; unbounded means "take your intrinsic width". -
hasBoundedHeight
public boolean hasBoundedHeight()Whether the maximum height is finite. -
loosened
- Returns:
- these constraints with minimums dropped to zero
-
deflate
- Returns:
- constraints shrunk by the given insets (never below zero)
-
constrainWidth
public float constrainWidth(float width) Clamps a width into[minWidth, maxWidth]. -
constrainHeight
public float constrainHeight(float height) Clamps a height into[minHeight, maxHeight]. -
constrain
Clamps both axes, which is whatonMeasurenormally returns. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
minWidth
public float minWidth()Returns the value of theminWidthrecord component.- Returns:
- the value of the
minWidthrecord component
-
maxWidth
public float maxWidth()Returns the value of themaxWidthrecord component.- Returns:
- the value of the
maxWidthrecord component
-
minHeight
public float minHeight()Returns the value of theminHeightrecord component.- Returns:
- the value of the
minHeightrecord component
-
maxHeight
public float maxHeight()Returns the value of themaxHeightrecord component.- Returns:
- the value of the
maxHeightrecord component
-