About all my projects
Gnome::Gtk4::Stack

Gnome::Gtk4::Stack

Description

Gnome::Gtk4::Stack is a container which only shows one of its children at a time.

In contrast to Gnome::Gtk4::Notebook, Gnome::Gtk4::Stack does not provide a means for users to change the visible child. Instead, a separate widget such as Gnome::Gtk4::StackSwitcher or Gnome::Gtk4::StackSidebar can be used with Gnome::Gtk4::Stack to provide this functionality.

Transitions between pages can be animated as slides or fades. This can be controlled with .set-transition-type(). These animations respect the gtk-enable-animations defined in Gnome::Gtk4::Settings setting.

Gnome::Gtk4::Stack maintains a Gnome::Gtk4::StackPage object for each added child, which holds additional per-child properties. You obtain the Gnome::Gtk4::StackPage for a child with .get-page() and you can obtain a Gnome::Gtk4::R-SelectionModel containing all the pages with .get-pages().

GtkStack as GtkBuildable

To set child-specific properties in a .ui file, create Gnome::Gtk4::StackPage objects explicitly, and set the child widget as a property on it:

CSS nodes

Gnome::Gtk4::Stack has a single CSS node named stack.

Accessibility

Gnome::Gtk4::Stack uses the GTK_ACCESSIBLE_ROLE_TAB_PANEL for the stack pages, which are the accessible parent objects of the child widgets.

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-stack

Creates a new Gnome::Gtk4::Stack.

method new-stack ( --> Gnome::Gtk4::Stack \)

Methods

add-child

Adds a child to $stack.

method add-child ( N-Object() $child --> N-Object )
  • $child; the widget to add.

Return value; the Gnome::Gtk4::StackPage for $child.

add-named

Adds a child to $stack.

The child is identified by the $name.

method add-named ( N-Object() $child, Str $name --> N-Object )
  • $child; the widget to add.

  • $name; the name for $child.

Return value; the Gnome::Gtk4::StackPage for $child.

add-titled

Adds a child to $stack.

The child is identified by the $name. The $title will be used by Gnome::Gtk4::StackSwitcher to represent $child in a tab bar, so it should be short.

method add-titled ( N-Object() $child, Str $name, Str $title --> N-Object )
  • $child; the widget to add.

  • $name; the name for $child.

  • $title; a human-readable title for $child.

Return value; the Gnome::Gtk4::StackPage for $child.

get-child-by-name

Finds the child with the name given as the argument.

Returns undefined if there is no child with this name.

method get-child-by-name ( Str $name --> N-Object )
  • $name; the name of the child to find.

Return value; the requested child of the Gnome::Gtk4::Stack.

get-hhomogeneous

Gets whether $stack is horizontally homogeneous.

method get-hhomogeneous (--> Bool )

Return value; whether $stack is horizontally homogeneous..

get-interpolate-size

Returns whether the Gnome::Gtk4::Stack is set up to interpolate between the sizes of children on page switch.

method get-interpolate-size (--> Bool )

Return value; True if child sizes are interpolated.

get-page

Returns the Gnome::Gtk4::StackPage object for $child.

method get-page ( N-Object() $child --> N-Object )
  • $child; a child of $stack.

Return value; the Gnome::Gtk4::StackPage for $child.

get-pages

Returns a Gnome::Gio::R-ListModel that contains the pages of the stack.

This can be used to keep an up-to-date view. The model also implements Gnome::Gtk4::R-SelectionModel and can be used to track and modify the visible page.

method get-pages (--> N-Object )

Return value; a Gnome::Gtk4::R-SelectionModel for the stack's children.

get-transition-duration

Returns the amount of time (in milliseconds) that transitions between pages in $stack will take.

method get-transition-duration (--> UInt )

Return value; the transition duration.

get-transition-running

Returns whether the $stack is currently in a transition from one page to another.

method get-transition-running (--> Bool )

Return value; True if the transition is currently running, False otherwise..

get-transition-type

Gets the type of animation that will be used for transitions between pages in $stack.

method get-transition-type (--> GtkStackTransitionType )

Return value; the current transition type of $stack.

get-vhomogeneous

Gets whether $stack is vertically homogeneous.

method get-vhomogeneous (--> Bool )

Return value; whether $stack is vertically homogeneous..

get-visible-child

Gets the currently visible child of $stack.

Returns undefined if there are no visible children.

method get-visible-child (--> N-Object )

Return value; the visible child of the Gnome::Gtk4::Stack.

get-visible-child-name

Returns the name of the currently visible child of $stack.

Returns undefined if there is no visible child.

method get-visible-child-name (--> Str )

Return value; the name of the visible child of the Gnome::Gtk4::Stack.

remove

Removes a child widget from $stack.

method remove ( N-Object() $child )
  • $child; the child to remove.

set-hhomogeneous

Sets the Gnome::Gtk4::Stack to be horizontally homogeneous or not.

If it is homogeneous, the Gnome::Gtk4::Stack will request the same width for all its children. If it isn't, the stack may change width when a different child becomes visible.

method set-hhomogeneous ( Bool() $hhomogeneous )
  • $hhomogeneous; True to make $stack horizontally homogeneous.

set-interpolate-size

Sets whether or not $stack will interpolate its size when changing the visible child.

If the interpolate-size property is set to True, $stack will interpolate its size between the current one and the one it'll take after changing the visible child, according to the set transition duration.

method set-interpolate-size ( Bool() $interpolate-size )
  • $interpolate-size; the new value.

set-transition-duration

Sets the duration that transitions between pages in $stack will take.

method set-transition-duration ( UInt() $duration )
  • $duration; the new duration, in milliseconds.

set-transition-type

Sets the type of animation that will be used for transitions between pages in $stack.

Available types include various kinds of fades and slides.

The transition type can be changed without problems at runtime, so it is possible to change the animation based on the page that is about to become current.

method set-transition-type ( GtkStackTransitionType $transition )
  • $transition; the new transition type.

set-vhomogeneous

Sets the Gnome::Gtk4::Stack to be vertically homogeneous or not.

If it is homogeneous, the Gnome::Gtk4::Stack will request the same height for all its children. If it isn't, the stack may change height when a different child becomes visible.

method set-vhomogeneous ( Bool() $vhomogeneous )
  • $vhomogeneous; True to make $stack vertically homogeneous.

set-visible-child

Makes $child the visible child of $stack.

If $child is different from the currently visible child, the transition between the two will be animated with the current transition type of $stack.

Note that the $child widget has to be visible itself (see .show() in class Gnome::Gtk4::Widget) in order to become the visible child of $stack.

method set-visible-child ( N-Object() $child )
  • $child; a child of $stack.

set-visible-child-full

Makes the child with the given name visible.

Note that the child widget has to be visible itself (see .show() in class Gnome::Gtk4::Widget) in order to become the visible child of $stack.

method set-visible-child-full ( Str $name, GtkStackTransitionType $transition )
  • $name; the name of the child to make visible.

  • $transition; the transition type to use.

set-visible-child-name

Makes the child with the given name visible.

If $child is different from the currently visible child, the transition between the two will be animated with the current transition type of $stack.

Note that the child widget has to be visible itself (see .show() in class Gnome::Gtk4::Widget) in order to become the visible child of $stack.

method set-visible-child-name ( Str $name )
  • $name; the name of the child to make visible.