Class Squeezer

All Implemented Interfaces:
PointerInterface

public class Squeezer extends Widget
A best fit container.

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

The `AdwSqueezer` widget is a container which only shows the first of its
children that fits in the available size. It is convenient to offer different
widgets to represent the same data with different levels of detail, making
the widget seem to squeeze itself to fit in the available space.

Transitions between children can be animated as fades. This can be controlled
with [property@Squeezer:transition-type].

## CSS nodes

`AdwSqueezer` has a single CSS node with name `squeezer`.

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

  • Constructor Details

    • Squeezer

      public Squeezer(PointerContainer pointer)
    • Squeezer

      public Squeezer()
      Creates a new `AdwSqueezer`.
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • add

      public SqueezerPage add(@Nonnull Widget child)
      Adds a child to @self.
      Parameters:
      child - the widget to add
      Returns:
      the [class@SqueezerPage] for @child
    • getAllowNone

      public boolean getAllowNone()
      Gets whether to allow squeezing beyond the last child's minimum size.
      Returns:
      whether @self allows squeezing beyond the last child
    • getHomogeneous

      public boolean getHomogeneous()
      Gets whether all children have the same size for the opposite orientation.
      Returns:
      whether @self is homogeneous
    • getInterpolateSize

      public boolean getInterpolateSize()
      Gets whether @self interpolates its size when changing the visible child.
      Returns:
      whether the size is interpolated
    • getPage

      public SqueezerPage getPage(@Nonnull Widget child)
      Returns the [class@SqueezerPage] object for @child.
      Parameters:
      child - a child of @self
      Returns:
      the page object for @child
    • getPages

      public SelectionModel getPages()
      Returns a [iface@Gio.ListModel] that contains the pages of @self.

      This can be used to keep an up-to-date view. The model also implements
      [iface@Gtk.SelectionModel] and can be used to track the visible page.
      Returns:
      a `GtkSelectionModel` for the squeezer's children
    • getSwitchThresholdPolicy

      public int getSwitchThresholdPolicy()
      Gets the switch threshold policy for @self.
      Returns:
    • getTransitionDuration

      public int getTransitionDuration()
      Gets the transition animation duration for @self.
      Returns:
      the transition duration, in milliseconds
    • getTransitionRunning

      public boolean getTransitionRunning()
      Gets whether a transition is currently running for @self.

      If a transition is impossible, the property value will be set to `TRUE` and
      then immediately to `FALSE`, so it's possible to rely on its notifications
      to know that a transition has happened.
      Returns:
      whether a transition is currently running
    • getTransitionType

      public int getTransitionType()
      Gets the type of animation used for transitions between children in @self.
      Returns:
      the current transition type of @self
    • getVisibleChild

      public Widget getVisibleChild()
      Gets the currently visible child of @self.
      Returns:
      the visible child
    • getXalign

      public float getXalign()
      Gets the horizontal alignment, from 0 (start) to 1 (end).
      Returns:
      the alignment value
    • getYalign

      public float getYalign()
      Gets the vertical alignment, from 0 (top) to 1 (bottom).
      Returns:
      the alignment value
    • remove

      public void remove(@Nonnull Widget child)
      Removes a child widget from @self.
      Parameters:
      child - the child to remove
    • setAllowNone

      public void setAllowNone(boolean allow_none)
      Sets whether to allow squeezing beyond the last child's minimum size.

      If set to `TRUE`, the squeezer can shrink to the point where no child can be
      shown. This is functionally equivalent to appending a widget with 0×0 minimum
      size.
      Parameters:
      allow_none - whether @self allows squeezing beyond the last child
    • setHomogeneous

      public void setHomogeneous(boolean homogeneous)
      Sets whether all children have the same size for the opposite orientation.

      For example, if a squeezer is horizontal and is homogeneous, it will request
      the same height for all its children. If it isn't, the squeezer may change
      size when a different child becomes visible.
      Parameters:
      homogeneous - whether @self is homogeneous
    • setInterpolateSize

      public void setInterpolateSize(boolean interpolate_size)
      Sets whether @self interpolates its size when changing the visible child.

      If `TRUE`, the squeezer will interpolate its size between the one of the
      previous visible child and the one of the new visible child, according to the
      set transition duration and the orientation, e.g. if the squeezer is
      horizontal, it will interpolate the its height.
      Parameters:
      interpolate_size - whether to interpolate the size
    • setSwitchThresholdPolicy

      public void setSwitchThresholdPolicy(int policy)
      Sets the switch threshold policy for @self.

      Determines when the squeezer will switch children.

      If set to `ADW_FOLD_THRESHOLD_POLICY_MINIMUM`, it will only switch when the
      visible child cannot fit anymore. With `ADW_FOLD_THRESHOLD_POLICY_NATURAL`,
      it will switch as soon as the visible child doesn't get their natural size.

      This can be useful if you have a long ellipsizing label and want to let it
      ellipsize instead of immediately switching.
      Parameters:
      policy - the policy to use
    • setTransitionDuration

      public void setTransitionDuration(int duration)
      Sets the transition animation duration for @self.
      Parameters:
      duration - the new duration, in milliseconds
    • setTransitionType

      public void setTransitionType(int transition)
      Sets the type of animation used for transitions between children in @self.
      Parameters:
      transition - the new transition type
    • setXalign

      public void setXalign(float xalign)
      Sets the horizontal alignment, from 0 (start) to 1 (end).

      This affects the children allocation during transitions, when they exceed the
      size of the squeezer.

      For example, 0.5 means the child will be centered, 0 means it will keep the
      start side aligned and overflow the end side, and 1 means the opposite.
      Parameters:
      xalign - the new alignment value
    • setYalign

      public void setYalign(float yalign)
      Sets the vertical alignment, from 0 (top) to 1 (bottom).

      This affects the children allocation during transitions, when they exceed the
      size of the squeezer.

      For example, 0.5 means the child will be centered, 0 means it will keep the
      top side aligned and overflow the bottom side, and 1 means the opposite.
      Parameters:
      yalign - the new alignment value
    • 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()