Places "overlay" widgets on top of a single main child.
<picture> <source srcset="overlay-dark.png" media="(prefers-color-scheme: dark)"> <img alt="An example GtkOverlay" src="overlay.png"> </picture> The position of each overlay widget is determined by its [propertyGtk.Widget:halign] and [propertyGtk.Widget:valign] properties. E.g. a widget with both alignments set to Gtk.Widget.Align_Start will be placed at the top left corner of the GtkOverlay container, whereas an overlay with halign set to Gtk.Widget.Align_Center and valign set to Gtk.Widget.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 [signalGtk.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.
<group>Layout containers</group> <gtkada_demo>create_overlay.adb</gtkada_demo>
function "+"
(Widget : access Gtk_Overlay_Record'Class)
return Gtk.Accessible.Gtk_Accessible
function "+"
(Widget : access Gtk_Overlay_Record'Class)
return Gtk.Buildable.Gtk_Buildable
function "+"
(Widget : access Gtk_Overlay_Record'Class)
return Gtk.Constraint_Target.Gtk_Constraint_Target
function "-"
(Interf : Gtk.Accessible.Gtk_Accessible)
return Gtk_Overlay
function "-"
(Interf : Gtk.Buildable.Gtk_Buildable)
return Gtk_Overlay
function "-"
(Interf : Gtk.Constraint_Target.Gtk_Constraint_Target)
return Gtk_Overlay
procedure Add_Overlay
(Self : not null access Gtk_Overlay_Record;
Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class)
Adds Widget to Overlay. The widget will be stacked on top of the main widget added with [methodGtk.Overlay.set_child]. The position at which Widget is placed is determined from its [propertyGtk.Widget:halign] and [propertyGtk.Widget:valign] properties.
a GtkWidget to be added to the container
procedure Announce
(Self : not null access Gtk_Overlay_Record;
Message : UTF8_String;
Priority : Gtk.Accessible.Gtk_Accessible_Announcement_Priority)
type Cb_GObject_Gtk_Widget_Gdk_Rectangle_Boolean is not null access function
(Self : access Glib.Object.GObject_Record'Class;
Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class;
Allocation : out Gdk.Rectangle.Gdk_Rectangle)
return Boolean;
type Cb_Gtk_Overlay_Gtk_Widget_Gdk_Rectangle_Boolean is not null access function
(Self : access Gtk_Overlay_Record'Class;
Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class;
Allocation : out Gdk.Rectangle.Gdk_Rectangle)
return Boolean;
Child_Property : constant Glib.Properties.Property_Object;
Type: Gtk.Widget.Gtk_Widget The main child widget.
function Get_Accessible_Id
(Self : not null access Gtk_Overlay_Record) return UTF8_String
function Get_Accessible_Parent
(Self : not null access Gtk_Overlay_Record)
return Gtk.Accessible.Gtk_Accessible
function Get_Accessible_Role
(Self : not null access Gtk_Overlay_Record)
return Gtk.Accessible.Gtk_Accessible_Role
function Get_At_Context
(Self : not null access Gtk_Overlay_Record)
return Gtk.Atcontext.Gtk_Atcontext
function Get_Bounds
(Self : not null access Gtk_Overlay_Record;
X : out Glib.Gint;
Y : out Glib.Gint;
Width : out Glib.Gint;
Height : out Glib.Gint) return Boolean
function Get_Child
(Self : not null access Gtk_Overlay_Record)
return Gtk.Widget.Gtk_Widget
Gets the child widget of Overlay.
the child widget of Overlay. Has transfer-ownership='none'.
function Get_Clip_Overlay
(Self : not null access Gtk_Overlay_Record;
Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class)
return Boolean
Gets whether Widget should be clipped within the parent.
an overlay child of GtkOverlay
whether the widget is clipped within the parent.
function Get_First_Accessible_Child
(Self : not null access Gtk_Overlay_Record)
return Gtk.Accessible.Gtk_Accessible
function Get_Measure_Overlay
(Self : not null access Gtk_Overlay_Record;
Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class)
return Boolean
Gets whether Widget's size is included in the measurement of Overlay.
an overlay child of GtkOverlay
whether the widget is measured
function Get_Next_Accessible_Sibling
(Self : not null access Gtk_Overlay_Record)
return Gtk.Accessible.Gtk_Accessible
function Get_Platform_State
(Self : not null access Gtk_Overlay_Record;
State : Gtk.Accessible.Gtk_Accessible_Platform_State) return Boolean
function Get_Type return Glib.GType
procedure Gtk_New (Self : out Gtk_Overlay)
Creates a new GtkOverlay. Initialize does nothing if the object was already created with another call to Initialize* or G_New.
type Gtk_Overlay is access all Gtk_Overlay_Record'Class;
function Gtk_Overlay_New return Gtk_Overlay
Creates a new GtkOverlay.
type Gtk_Overlay_Record is new Gtk_Widget_Record with null record;
package Implements_Gtk_Accessible is new Glib.Types.Implements
(Gtk.Accessible.Gtk_Accessible, Gtk_Overlay_Record, Gtk_Overlay);
package Implements_Gtk_Buildable is new Glib.Types.Implements
(Gtk.Buildable.Gtk_Buildable, Gtk_Overlay_Record, Gtk_Overlay);
package Implements_Gtk_Constraint_Target is new Glib.Types.Implements
(Gtk.Constraint_Target.Gtk_Constraint_Target, Gtk_Overlay_Record, Gtk_Overlay);
procedure Initialize (Self : not null access Gtk_Overlay_Record'Class)
Creates a new GtkOverlay. Initialize does nothing if the object was already created with another call to Initialize* or G_New.
procedure On_Get_Child_Position
(Self : not null access Gtk_Overlay_Record;
Call : Cb_GObject_Gtk_Widget_Gdk_Rectangle_Boolean;
Slot : not null access Glib.Object.GObject_Record'Class;
After : Boolean := False)
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.Widget.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.
Callback parameters: -- @param Widget the child widget to position -- @param Allocation return location for the allocation
procedure On_Get_Child_Position
(Self : not null access Gtk_Overlay_Record;
Call : Cb_Gtk_Overlay_Gtk_Widget_Gdk_Rectangle_Boolean;
After : Boolean := False)
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.Widget.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.
Callback parameters: -- @param Widget the child widget to position -- @param Allocation return location for the allocation
procedure Remove_Overlay
(Self : not null access Gtk_Overlay_Record;
Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class)
Removes an overlay that was added with Gtk.Overlay.Add_Overlay.
a GtkWidget to be removed
procedure Reset_Property
(Self : not null access Gtk_Overlay_Record;
Property : Gtk.Accessible.Gtk_Accessible_Property)
procedure Reset_Relation
(Self : not null access Gtk_Overlay_Record;
Relation : Gtk.Accessible.Gtk_Accessible_Relation)
procedure Reset_State
(Self : not null access Gtk_Overlay_Record;
State : Gtk.Accessible.Gtk_Accessible_State)
procedure Set_Accessible_Parent
(Self : not null access Gtk_Overlay_Record;
Parent : Gtk.Accessible.Gtk_Accessible;
Next_Sibling : Gtk.Accessible.Gtk_Accessible)
procedure Set_Child
(Self : not null access Gtk_Overlay_Record;
Child : access Gtk.Widget.Gtk_Widget_Record'Class)
Sets the child widget of Overlay.
the child widget
procedure Set_Clip_Overlay
(Self : not null access Gtk_Overlay_Record;
Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class;
Clip_Overlay : Boolean)
Sets whether Widget should be clipped within the parent.
an overlay child of GtkOverlay
whether the child should be clipped
procedure Set_Measure_Overlay
(Self : not null access Gtk_Overlay_Record;
Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class;
Measure : Boolean)
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.
an overlay child of GtkOverlay
whether the child should be measured
Signal_Get_Child_Position : constant Glib.Signal_Name := "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.Widget.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.
Callback parameters: -- @param Widget the child widget to position -- @param Allocation return location for the allocation
procedure Update_Next_Accessible_Sibling
(Self : not null access Gtk_Overlay_Record;
New_Sibling : Gtk.Accessible.Gtk_Accessible)
procedure Update_Platform_State
(Self : not null access Gtk_Overlay_Record;
State : Gtk.Accessible.Gtk_Accessible_Platform_State)