Overlay#
Superclasses: Widget, InitiallyUnowned, Object
Implemented Interfaces: Accessible, Buildable, ConstraintTarget
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 START
will be placed at the top left corner of the GtkOverlay container,
whereas an overlay with halign set to CENTER and valign set
to 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.
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.
Constructors#
Methods#
- class Overlay
- add_overlay(widget: Widget) None#
Adds
widgettooverlay.The widget will be stacked on top of the main widget added with
set_child.The position at which
widgetis placed is determined from itshalignandvalignproperties.- Parameters:
widget – a
GtkWidgetto be added to the container
- get_clip_overlay(widget: Widget) bool#
Gets whether
widgetshould be clipped within the parent.- Parameters:
widget – an overlay child of
GtkOverlay
- get_measure_overlay(widget: Widget) bool#
Gets whether
widget's size is included in the measurement ofoverlay.- Parameters:
widget – an overlay child of
GtkOverlay
- remove_overlay(widget: Widget) None#
Removes an overlay that was added with
add_overlay().- Parameters:
widget – a
GtkWidgetto be removed
- set_child(child: Widget | None = None) None#
Sets the child widget of
overlay.- Parameters:
child – the child widget
- set_clip_overlay(widget: Widget, clip_overlay: bool) None#
Sets whether
widgetshould be clipped within the parent.- Parameters:
widget – an overlay child of
GtkOverlayclip_overlay – whether the child should be clipped
- set_measure_overlay(widget: Widget, measure: bool) None#
Sets whether
widgetis included in the measured size ofoverlay.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 ofoverlay's allocation if they are too large.- Parameters:
widget – an overlay child of
GtkOverlaymeasure – whether the child should be measured