About all my projects
Gnome::Gtk4::Overlay

Gnome::Gtk4::Overlay

Description

Gnome::Gtk4::Overlay is a container which contains a single main child, on top of which it can place “overlay” widgets.

No caption

The position of each overlay widget is determined by its halign defined in Gnome::Gtk4::Widget and valign defined in Gnome::Gtk4::Widget properties. E.g. a widget with both alignments set to GTK_ALIGN_START will be placed at the top left corner of the Gnome::Gtk4::Overlay container, whereas an overlay with halign set to GTK_ALIGN_CENTER and valign set to GTK_ALIGN_END will be placed a the bottom edge of the Gnome::Gtk4::Overlay, 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 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 Gnome::Gtk4::Overlay implementation of the Gnome::Gtk4::R-Buildable interface supports placing a child as an overlay by specifying “overlay” as the “type” attribute of a `<child>` element.

CSS nodes

Gnome::Gtk4::Overlay 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.

Class initialization

new

:native-object

Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.

multi method new ( N-Object :$native-object! )

new-overlay

Creates a new Gnome::Gtk4::Overlay.

method new-overlay ( --> Gnome::Gtk4::Overlay \)

Methods

add-overlay

Adds $widget to $overlay.

The widget will be stacked on top of the main widget added with .set-child().

The position at which $widget is placed is determined from its halign defined in Gnome::Gtk4::Widget and valign defined in Gnome::Gtk4::Widget properties.

method add-overlay ( N-Object() $widget )
  • $widget; a Gnome::Gtk4::Widget to be added to the container.

get-child

Gets the child widget of $overlay.

method get-child (--> N-Object )

Return value; the child widget of $overlay.

get-clip-overlay

Gets whether $widget should be clipped within the parent.

method get-clip-overlay ( N-Object() $widget --> Bool )
  • $widget; an overlay child of Gnome::Gtk4::Overlay.

Return value; whether the widget is clipped within the parent..

get-measure-overlay

Gets whether $widget's size is included in the measurement of $overlay.

method get-measure-overlay ( N-Object() $widget --> Bool )
  • $widget; an overlay child of Gnome::Gtk4::Overlay.

Return value; whether the widget is measured.

remove-overlay

Removes an overlay that was added with .add-overlay().

method remove-overlay ( N-Object() $widget )
  • $widget; a Gnome::Gtk4::Widget to be removed.

set-child

Sets the child widget of $overlay.

method set-child ( N-Object() $child )
  • $child; the child widget.

set-clip-overlay

Sets whether $widget should be clipped within the parent.

method set-clip-overlay ( N-Object() $widget, Bool() $clip-overlay )
  • $widget; an overlay child of Gnome::Gtk4::Overlay.

  • $clip-overlay; whether the child should be clipped.

set-measure-overlay

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.

method set-measure-overlay ( N-Object() $widget, Bool() $measure )
  • $widget; an overlay child of Gnome::Gtk4::Overlay.

  • $measure; whether the child should be measured.

Signals

get-child-position

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 GTK_ALIGN_FILL will cause the overlay to be full-width/height). If the main child is a Gnome::Gtk4::ScrolledWindow, the overlays are placed relative to its contents.

method handler (
  N-Object $widget,
   $allocation,
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gtk4::Overlay :$_widget,
  *C<user>-options
  --> gboolean
)
  • $widget; the child widget to position.

  • $allocation; return location for the allocation.

  • $_handle_id; The registered event handler id.

  • $_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::Overlay object.

  • $_widget; The object which registered the signal. User code may have left the object going out of scope.

  • user-options; A list of named arguments provided at the .register-signal() method from Gnome::GObject::Object.

Return value; True if the $allocation has been filled