Class Overlay

All Implemented Interfaces:
Accessible, Buildable, ConstraintTarget, Proxy

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

Places “overlay” widgets on top of a single main child.

An example GtkOverlay

The position of each overlay widget is determined by its Gtk.Widget:halign and Gtk.Widget:valign properties. E.g. a widget with both alignments set to Align.START will be placed at the top left corner of the GtkOverlay container, whereas an overlay with halign set to Align.CENTER and valign set to Align.END will be placed a the bottom edge of the GtkOverlay, horizontally centered. The position can be adjusted by setting the margin properties of the child to non-zero values.

More complicated placement of overlays is possible by connecting to the Gtk.Overlay::get-child-position signal.

An overlay’s minimum and natural sizes are those of its main child. The sizes of overlay children are not considered when measuring these preferred sizes.

GtkOverlay as GtkBuildable

The GtkOverlay implementation of the GtkBuildable interface supports placing a child as an overlay by specifying “overlay” as the “type” attribute of a <child> element.

CSS nodes

GtkOverlay has a single CSS node with the name “overlay”. Overlay children whose alignments cause them to be positioned at an edge get the style classes “.left”, “.right”, “.top”, and/or “.bottom” according to their position.

  • Constructor Details

    • Overlay

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

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

    • getType

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

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

      protected Overlay 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
    • addOverlay

      public void addOverlay(Widget widget)

      Adds widget to overlay.

      The widget will be stacked on top of the main widget added with setChild(Widget).

      The position at which widget is placed is determined from its Gtk.Widget:halign and Gtk.Widget:valign properties.

      Parameters:
      widget - a GtkWidget to be added to the container
    • getChild

      public @Nullable Widget getChild()
      Gets the child widget of overlay.
      Returns:
      the child widget of this Overlay
    • getClipOverlay

      public boolean getClipOverlay(Widget widget)
      Gets whether widget should be clipped within the parent.
      Parameters:
      widget - an overlay child of GtkOverlay
      Returns:
      whether the widget is clipped within the parent.
    • getMeasureOverlay

      public boolean getMeasureOverlay(Widget widget)
      Gets whether widget's size is included in the measurement of overlay.
      Parameters:
      widget - an overlay child of GtkOverlay
      Returns:
      whether the widget is measured
    • removeOverlay

      public void removeOverlay(Widget widget)
      Removes an overlay that was added with gtk_overlay_add_overlay().
      Parameters:
      widget - a GtkWidget to be removed
    • setChild

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

      public void setClipOverlay(Widget widget, boolean clipOverlay)
      Sets whether widget should be clipped within the parent.
      Parameters:
      widget - an overlay child of GtkOverlay
      clipOverlay - whether the child should be clipped
    • setMeasureOverlay

      public void setMeasureOverlay(Widget widget, boolean measure)

      Sets whether widget is included in the measured size of overlay.

      The overlay will request the size of the largest child that has this property set to true. Children who are not included may be drawn outside of overlay's allocation if they are too large.

      Parameters:
      widget - an overlay child of GtkOverlay
      measure - whether the child should be measured
    • onGetChildPosition

      Emitted to determine the position and size of any overlay child widgets.

      A handler for this signal should fill allocation with the desired position and size for widget, relative to the 'main' child of overlay.

      The default handler for this signal uses the widget's halign and valign properties to determine the position and gives the widget its natural size (except that an alignment of Align.FILL will cause the overlay to be full-width/height). If the main child is a GtkScrolledWindow, the overlays are placed relative to its contents.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitGetChildPosition

      public boolean emitGetChildPosition(@Nullable Widget widget, @Nullable Rectangle allocation)
      Emits the "get-child-position" signal. See onGetChildPosition(Overlay.GetChildPositionCallback).
    • builder

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