Gtk.Overlay

g GObject.GInterface GObject.GInterface Gtk.Accessible Gtk.Accessible GObject.GInterface->Gtk.Accessible Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.ConstraintTarget Gtk.ConstraintTarget GObject.GInterface->Gtk.ConstraintTarget GObject.InitiallyUnowned GObject.InitiallyUnowned Gtk.Widget Gtk.Widget GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Accessible->Gtk.Widget Gtk.Buildable->Gtk.Widget Gtk.ConstraintTarget->Gtk.Widget Gtk.Overlay Gtk.Overlay Gtk.Widget->Gtk.Overlay

Subclasses:

None

Methods

Inherited:

Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1)

Structs:

Gtk.WidgetClass (18), GObject.ObjectClass (5)

class

new ()

add_overlay (widget)

get_child ()

get_clip_overlay (widget)

get_measure_overlay (widget)

remove_overlay (widget)

set_child (child)

set_clip_overlay (widget, clip_overlay)

set_measure_overlay (widget, measure)

Virtual Methods

Inherited:

Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9)

Properties

Inherited:

Gtk.Widget (34), Gtk.Accessible (1)

Name

Type

Flags

Short Description

child

Gtk.Widget

r/w/en

Signals

Inherited:

Gtk.Widget (13), GObject.Object (1)

Name

Short Description

get-child-position

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

Fields

Inherited:

Gtk.Widget (13), GObject.Object (1)

Class Details

class Gtk.Overlay(**kwargs)
Bases:

Gtk.Widget

Abstract:

No

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

An example Gtk.Overlay

The position of each overlay widget is determined by its [property`Gtk`.Widget:halign] and [property`Gtk`.Widget: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 [signal`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.

Gtk.Overlay as Gtk.Buildable

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.

classmethod new()[source]
Returns:

a new GtkOverlay object.

Return type:

Gtk.Widget

Creates a new GtkOverlay.

add_overlay(widget)[source]
Parameters:

widget (Gtk.Widget) – a GtkWidget to be added to the container

Adds widget to self.

The widget will be stacked on top of the main widget added with [method`Gtk`.Overlay.set_child].

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

get_child()[source]
Returns:

the child widget of self

Return type:

Gtk.Widget or None

Gets the child widget of self.

get_clip_overlay(widget)[source]
Parameters:

widget (Gtk.Widget) – an overlay child of GtkOverlay

Returns:

whether the widget is clipped within the parent.

Return type:

bool

Gets whether widget should be clipped within the parent.

get_measure_overlay(widget)[source]
Parameters:

widget (Gtk.Widget) – an overlay child of GtkOverlay

Returns:

whether the widget is measured

Return type:

bool

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

remove_overlay(widget)[source]
Parameters:

widget (Gtk.Widget) – a GtkWidget to be removed

Removes an overlay that was added with Gtk.Overlay.add_overlay().

set_child(child)[source]
Parameters:

child (Gtk.Widget or None) – the child widget

Sets the child widget of self.

set_clip_overlay(widget, clip_overlay)[source]
Parameters:
  • widget (Gtk.Widget) – an overlay child of GtkOverlay

  • clip_overlay (bool) – whether the child should be clipped

Sets whether widget should be clipped within the parent.

set_measure_overlay(widget, measure)[source]
Parameters:
  • widget (Gtk.Widget) – an overlay child of GtkOverlay

  • measure (bool) – whether the child should be measured

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

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 self's allocation if they are too large.

Signal Details

Gtk.Overlay.signals.get_child_position(overlay, widget)
Signal Name:

get-child-position

Flags:

RUN_LAST

Parameters:
  • overlay (Gtk.Overlay) – The object which received the signal

  • widget (Gtk.Widget) – the child widget to position

Returns:

True if the allocation has been filled

allocation:

return location for the allocation

Return type:

(bool, allocation: Gdk.Rectangle)

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.

Property Details

Gtk.Overlay.props.child
Name:

child

Type:

Gtk.Widget

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The main child widget.