Class Clamp

All Implemented Interfaces:
PointerInterface

public class Clamp extends Widget
A widget constraining its child to a given size.

<picture>
<source srcset="clamp-wide-dark.png" media="(prefers-color-scheme: dark)">
<img src="clamp-wide.png" alt="clamp-wide">
</picture>
<picture>
<source srcset="clamp-narrow-dark.png" media="(prefers-color-scheme: dark)">
<img src="clamp-narrow.png" alt="clamp-narrow">
</picture>

The `AdwClamp` widget constrains the size of the widget 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 child from its minimum to its
maximum size is eased out for a smooth transition.

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

## CSS nodes

`AdwClamp` has a single CSS node with name `clamp`.

Its children will receive the style classes `.large` when the child reached
its maximum size, `.small` when the clamp allocates its full size to the
child, `.medium` in-between, or none if it hasn't computed its size yet.

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.Clamp.html

  • Constructor Details

    • Clamp

      public Clamp(PointerContainer pointer)
    • Clamp

      public Clamp()
      Creates a new `AdwClamp`.
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • getChild

      public Widget getChild()
      Gets the child widget of @self.
      Returns:
      the child widget of @self
    • getMaximumSize

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

      public int getTighteningThreshold()
      Gets the size above which the child is clamped.
      Returns:
      the size above which the child is clamped
    • setChild

      public void setChild(@Nullable Widget child)
      Sets the child widget of @self.
      Parameters:
      child - the child widget
    • setMaximumSize

      public void setMaximumSize(int maximum_size)
      Sets the maximum size allocated to the child.

      It is the width if the clamp is horizontal, or the height if it is vertical.
      Parameters:
      maximum_size - the maximum size
    • setTighteningThreshold

      public void setTighteningThreshold(int tightening_threshold)
      Sets the size above which the child is clamped.

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

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

      Effectively, tightening the grip on the child before it reaches its maximum
      size makes transitions to and from the maximum size smoother when resizing.
      Parameters:
      tightening_threshold - the tightening threshold
    • asAccessible

      public Accessible asAccessible()
      Implements interface Accessible. Call this to get access to interface functions.
      Overrides:
      asAccessible in class Widget
      Returns:
      Accessible
    • asBuildable

      public Buildable asBuildable()
      Implements interface Buildable. Call this to get access to interface functions.
      Overrides:
      asBuildable in class Widget
      Returns:
      Buildable
    • asConstraintTarget

      public ConstraintTarget asConstraintTarget()
      Implements interface ConstraintTarget. Call this to get access to interface functions.
      Overrides:
      asConstraintTarget in class Widget
      Returns:
      ConstraintTarget
    • asOrientable

      public Orientable asOrientable()
      Implements interface Orientable. Call this to get access to interface functions.
      Returns:
      Orientable
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()