GtkOverlay — A container which overlays widgets on top of each other
GtkWidget * | gtk_overlay_new () |
void | gtk_overlay_set_child () |
GtkWidget * | gtk_overlay_get_child () |
void | gtk_overlay_add_overlay () |
void | gtk_overlay_remove_overlay () |
gboolean | gtk_overlay_get_measure_overlay () |
void | gtk_overlay_set_measure_overlay () |
gboolean | gtk_overlay_get_clip_overlay () |
void | gtk_overlay_set_clip_overlay () |
gboolean | get-child-position | Run Last |
GObject ╰── GInitiallyUnowned ╰── GtkWidget ╰── GtkOverlay
GtkOverlay implements GtkAccessible, GtkBuildable and GtkConstraintTarget.
#include <gtk/gtk.h>
GtkOverlay is a container which contains a single main child, on top of which it can place “overlay” widgets. The position of each overlay widget is determined by its “halign” and “valign” properties. E.g. a widget with both alignments set to GTK_ALIGN_START
will be placed at the top left corner of the GtkOverlay 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 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 “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.
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.
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.
GtkWidget *
gtk_overlay_new (void
);
Creates a new GtkOverlay.
a new GtkOverlay object.
void gtk_overlay_set_child (GtkOverlay *overlay
,GtkWidget *child
);
Sets the child widget of overlay
.
overlay | ||
child | the child widget. | [allow-none] |
GtkWidget *
gtk_overlay_get_child (GtkOverlay *overlay
);
Gets the child widget of overlay
.
overlay |
the child widget of overlay
.
[nullable][transfer none]
void gtk_overlay_add_overlay (GtkOverlay *overlay
,GtkWidget *widget
);
Adds widget
to overlay
.
The widget will be stacked on top of the main widget added with gtk_overlay_set_child()
.
The position at which widget
is placed is determined from its “halign” and “valign” properties.
overlay | ||
widget | a GtkWidget to be added to the container |
void gtk_overlay_remove_overlay (GtkOverlay *overlay
,GtkWidget *widget
);
Removes an overlay that was added with gtk_overlay_add_overlay()
.
overlay | ||
widget | a GtkWidget to be removed |
gboolean gtk_overlay_get_measure_overlay (GtkOverlay *overlay
,GtkWidget *widget
);
Gets whether widget
's size is included in the measurement of overlay
.
overlay | ||
widget | an overlay child of GtkOverlay |
whether the widget is measured
void gtk_overlay_set_measure_overlay (GtkOverlay *overlay
,GtkWidget *widget
,gboolean 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.
overlay | ||
widget | an overlay child of GtkOverlay | |
measure | whether the child should be measured |
gboolean gtk_overlay_get_clip_overlay (GtkOverlay *overlay
,GtkWidget *widget
);
Gets whether widget
should be clipped within the parent.
overlay | ||
widget | an overlay child of GtkOverlay |
whether the widget is clipped within the parent.
void gtk_overlay_set_clip_overlay (GtkOverlay *overlay
,GtkWidget *widget
,gboolean clip_overlay
);
Sets whether widget
should be clipped within the parent.
overlay | ||
widget | an overlay child of GtkOverlay | |
clip_overlay | whether the child should be clipped |
typedef struct _GtkOverlay GtkOverlay;
“get-child-position”
signalgboolean user_function (GtkOverlay *overlay, GtkWidget *widget, GdkRectangle *allocation, gpointer user_data)
The ::get-child-position signal is 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 GtkScrolledWindow, the overlays are placed relative to its contents.
overlay | the GtkOverlay | |
widget | the child widget to position | |
allocation | return location for the allocation. | [type Gdk.Rectangle][out caller-allocates] |
user_data | user data set when the signal handler was connected. |
TRUE
if the allocation
has been filled
Flags: Run Last
© 2005–2020 The GNOME Project
Licensed under the GNU Lesser General Public License version 2.1 or later.
https://developer.gnome.org/gtk4/4.0/GtkOverlay.html