Class ClampLayout

All Implemented Interfaces:
Orientable, Proxy

@Generated("org.javagi.JavaGI") public final class ClampLayout extends LayoutManager implements Orientable

A layout manager constraining its children to a given size.

clamp-wide clamp-narrow

AdwClampLayout constraints the size of the widgets it contains to a given maximum size. It will constrain the width if it is horizontal, or the height if it is vertical. The expansion of the children from their minimum to their maximum size is eased out for a smooth transition.

If a child requires more than the requested maximum size, it will be allocated the minimum size it can fit in instead.

AdwClampLayout can scale with the text scale factor, use the ClampLayout:unit property to enable that behavior.

See also: Clamp, ClampScrollable.

  • Constructor Details

    • ClampLayout

      public ClampLayout(MemorySegment address)
      Create a ClampLayout instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • ClampLayout

      public ClampLayout()
      Create a new ClampLayout.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the ClampLayout class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected ClampLayout asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class LayoutManager
      Returns:
      the instance as if it were its parent type
    • getMaximumSize

      public int getMaximumSize()
      Gets the maximum size allocated to the children.
      Returns:
      the maximum size to allocate to the children
    • getTighteningThreshold

      public int getTighteningThreshold()
      Gets the size above which the children are clamped.
      Returns:
      the size above which the children are clamped
    • getUnit

      public LengthUnit getUnit()
      Gets the length unit for maximum size and tightening threshold.
      Returns:
      the length unit
      Since:
      1.4
    • setMaximumSize

      public void setMaximumSize(int maximumSize)

      Sets the maximum size allocated to the children.

      It is the width if the layout is horizontal, or the height if it is vertical.

      Parameters:
      maximumSize - the maximum size
    • setTighteningThreshold

      public void setTighteningThreshold(int tighteningThreshold)

      Sets the size above which the children are clamped.

      Starting from this size, the layout will tighten its grip on the children, slowly allocating less and less of the available size up to the maximum allocated size. Below that threshold and below the maximum size, the children will be allocated all the available size.

      If the threshold is greater than the maximum size to allocate to the children, they will be allocated the whole size up to the maximum. If the threshold is lower than the minimum size to allocate to the children, that size will be used as the tightening threshold.

      Effectively, tightening the grip on a child before it reaches its maximum size makes transitions to and from the maximum size smoother when resizing.

      Parameters:
      tighteningThreshold - the tightening threshold
    • setUnit

      public void setUnit(LengthUnit unit)

      Sets the length unit for maximum size and tightening threshold.

      Allows the sizes to vary depending on the text scale factor.

      Parameters:
      unit - the length unit
      Since:
      1.4
    • builder

      public static ClampLayout.Builder<? extends ClampLayout.Builder> builder()
      A ClampLayout.Builder object constructs a ClampLayout with the specified properties. Use the various set...() methods to set properties, and finish construction with ClampLayout.Builder.build().
      Returns:
      the builder object