Class AspectFrame

All Implemented Interfaces:
Accessible, Buildable, ConstraintTarget, Proxy

@Generated("org.javagi.JavaGI") public class AspectFrame extends Widget implements Accessible, Buildable, ConstraintTarget

Preserves the aspect ratio of its child.

The frame can respect the aspect ratio of the child widget, or use its own aspect ratio.

CSS nodes

GtkAspectFrame uses a CSS node with name aspectframe.

Accessibility

Until GTK 4.10, GtkAspectFrame used the Gtk.AccessibleRole.group role.

Starting from GTK 4.12, GtkAspectFrame uses the Gtk.AccessibleRole.generic role.

  • Constructor Details

    • AspectFrame

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

      public AspectFrame(float xalign, float yalign, float ratio, boolean obeyChild)
      Create a new GtkAspectFrame.
      Parameters:
      xalign - Horizontal alignment of the child within the parent. Ranges from 0.0 (left aligned) to 1.0 (right aligned)
      yalign - Vertical alignment of the child within the parent. Ranges from 0.0 (top aligned) to 1.0 (bottom aligned)
      ratio - The desired aspect ratio.
      obeyChild - If true, ratio is ignored, and the aspect ratio is taken from the requistion of the child.
    • AspectFrame

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

    • getType

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

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

      protected AspectFrame 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 Widget
      Returns:
      the instance as if it were its parent type
    • getChild

      public @Nullable Widget getChild()
      Gets the child widget of self.
      Returns:
      the child widget of this AspectFrame
    • getObeyChild

      public boolean getObeyChild()
      Returns whether the child's size request should override the set aspect ratio of the GtkAspectFrame.
      Returns:
      whether to obey the child's size request
    • getRatio

      public float getRatio()
      Returns the desired aspect ratio of the child.
      Returns:
      the desired aspect ratio
    • getXalign

      public float getXalign()
      Returns the horizontal alignment of the child within the allocation of the GtkAspectFrame.
      Returns:
      the horizontal alignment
    • getYalign

      public float getYalign()
      Returns the vertical alignment of the child within the allocation of the GtkAspectFrame.
      Returns:
      the vertical alignment
    • setChild

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

      public void setObeyChild(boolean obeyChild)
      Sets whether the aspect ratio of the child's size request should override the set aspect ratio of the GtkAspectFrame.
      Parameters:
      obeyChild - If true, ratio is ignored, and the aspect ratio is taken from the requisition of the child.
    • setRatio

      public void setRatio(float ratio)
      Sets the desired aspect ratio of the child.
      Parameters:
      ratio - aspect ratio of the child
    • setXalign

      public void setXalign(float xalign)
      Sets the horizontal alignment of the child within the allocation of the GtkAspectFrame.
      Parameters:
      xalign - horizontal alignment, from 0.0 (left aligned) to 1.0 (right aligned)
    • setYalign

      public void setYalign(float yalign)
      Sets the vertical alignment of the child within the allocation of the GtkAspectFrame.
      Parameters:
      yalign - horizontal alignment, from 0.0 (top aligned) to 1.0 (bottom aligned)
    • builder

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