Gnome::Gtk4::CenterBox
Description
Gnome::Gtk4::CenterBox arranges three children in a row, keeping the middle child centered as well as possible.
To add children to Gnome::Gtk4::CenterBox, use .set-start-widget()
, .set-center-widget()
and .set-end-widget()
.
The sizing and positioning of children can be influenced with the align and expand properties of the children.
GtkCenterBox as GtkBuildable
The Gnome::Gtk4::CenterBox implementation of the Gnome::Gtk4::R-Buildable interface supports placing children in the 3 positions by specifying “start”, “center” or “end” as the “type” attribute of a `<child>` element.
CSS nodes
Gnome::Gtk4::CenterBox uses a single CSS node with the name “box”,
The first child of the Gnome::Gtk4::CenterBox will be allocated depending on the text direction, i.e. in left-to-right layouts it will be allocated on the left and in right-to-left layouts on the right.
In vertical orientation, the nodes of the children are arranged from top to bottom.
Accessibility
Until GTK 4.10, Gnome::Gtk4::CenterBox used the GTK_ACCESSIBLE_ROLE_GROUP role.
Starting from GTK 4.12, Gnome::Gtk4::CenterBox uses the GTK_ACCESSIBLE_ROLE_GENERIC role.
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-centerbox
Creates a new Gnome::Gtk4::CenterBox.
method new-centerbox ( --> Gnome::Gtk4::CenterBox \)
Methods
get-baseline-position
Gets the value set by .set-baseline-position()
.
method get-baseline-position (--> GtkBaselinePosition )
Return value; the baseline position.
get-center-widget
Gets the center widget, or undefined if there is none.
method get-center-widget (--> N-Object )
Return value; the center widget..
get-end-widget
Gets the end widget, or undefined if there is none.
method get-end-widget (--> N-Object )
Return value; the end widget..
get-shrink-center-last
Gets whether $self
shrinks the center widget after other children.
method get-shrink-center-last (--> Bool )
Return value; whether to shrink the center widget after others.
get-start-widget
Gets the start widget, or undefined if there is none.
method get-start-widget (--> N-Object )
Return value; the start widget..
set-baseline-position
Sets the baseline position of a center box.
This affects only horizontal boxes with at least one baseline aligned child. If there is more vertical space available than requested, and the baseline is not allocated by the parent then $position
is used to allocate the baseline wrt. the extra space available.
method set-baseline-position ( GtkBaselinePosition $position )
$position; a
enumeration GtkBaselinePosition defined in Gnome::Gtk4::T-enums
.
set-center-widget
Sets the center widget.
To remove the existing center widget, pass undefined.
method set-center-widget ( N-Object() $child )
$child; the new center widget.
set-end-widget
Sets the end widget.
To remove the existing end widget, pass undefined.
method set-end-widget ( N-Object() $child )
$child; the new end widget.
set-shrink-center-last
Sets whether to shrink the center widget after other children.
By default, when there's no space to give all three children their natural widths, the start and end widgets start shrinking and the center child keeps natural width until they reach minimum width.
If set to False
, start and end widgets keep natural width and the center widget starts shrinking instead.
method set-shrink-center-last ( Bool() $shrink-center-last )
$shrink-center-last; whether to shrink the center widget after others.
set-start-widget
Sets the start widget.
To remove the existing start widget, pass undefined.
method set-start-widget ( N-Object() $child )
$child; the new start widget.