Class ViewSwitcherTitle

All Implemented Interfaces:
PointerInterface

public class ViewSwitcherTitle extends Widget
A view switcher title.

<picture>
<source srcset="view-switcher-title-dark.png" media="(prefers-color-scheme: dark)">
<img src="view-switcher-title.png" alt="view-switcher-title">
</picture>

A widget letting you switch between multiple views contained by a
[class@ViewStack] via an [class@ViewSwitcher].

It is designed to be used as the title widget of a [class@HeaderBar], and
will display the window's title when the window is too narrow to fit the view
switcher e.g. on mobile phones, or if there are less than two views.

In order to center the title in narrow windows, the header bar should have
[property@HeaderBar:centering-policy] set to
`ADW_CENTERING_POLICY_STRICT`.

`AdwViewSwitcherTitle` is intended to be used together with
[class@ViewSwitcherBar].

A common use case is to bind the [property@ViewSwitcherBar:reveal] property
to [property@ViewSwitcherTitle:title-visible] to automatically reveal the
view switcher bar when the title label is displayed in place of the view
switcher, as follows:

```xml
<object class="GtkWindow">
<property name="titlebar">
<object class="AdwHeaderBar">
<property name="centering-policy">strict</property>
<property name="title-widget">
<object class="AdwViewSwitcherTitle" id="title">
<property name="stack">stack</property>
</object>
</property>
</object>
</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="AdwViewStack" id="stack"/>
</child>
<child>
<object class="AdwViewSwitcherBar">
<property name="stack">stack</property>
<binding name="reveal">
<lookup name="title-visible">title</lookup>
</binding>
</object>
</child>
</object>
</property>
</object>
```

## CSS nodes

`AdwViewSwitcherTitle` has a single CSS node with name `viewswitchertitle`.

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.ViewSwitcherTitle.html

  • Constructor Details

    • ViewSwitcherTitle

      public ViewSwitcherTitle(PointerContainer pointer)
    • ViewSwitcherTitle

      public ViewSwitcherTitle()
      Creates a new `AdwViewSwitcherTitle`.
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • getStack

      public ViewStack getStack()
      Gets the stack controlled by @self.
      Returns:
      the stack
    • getSubtitle

      public Str getSubtitle()
      Gets the subtitle of @self.
      Returns:
      the subtitle
    • getTitle

      public Str getTitle()
      Gets the title of @self.
      Returns:
      the title
    • getTitleVisible

      public boolean getTitleVisible()
      Gets whether the title of @self is currently visible.

      If the title is visible, it means the view switcher is hidden an it may be
      wanted to show an alternative switcher, e.g. a [class@ViewSwitcherBar].
      Returns:
      whether the title of @self is currently visible
    • getViewSwitcherEnabled

      public boolean getViewSwitcherEnabled()
      Gets whether @self's view switcher is enabled.
      Returns:
      whether the view switcher is enabled
    • setStack

      public void setStack(@Nullable ViewStack stack)
      Sets the stack controlled by @self.
      Parameters:
      stack - a stack
    • setSubtitle

      public void setSubtitle(@Nonnull Str subtitle)
      Sets the subtitle of @self.

      The subtitle should give the user additional details.
      Parameters:
      subtitle - a subtitle
    • setSubtitle

      public void setSubtitle(String subtitle)
      Sets the subtitle of @self.

      The subtitle should give the user additional details.
      Parameters:
      subtitle - a subtitle
    • setTitle

      public void setTitle(@Nonnull Str title)
      Sets the title of @self.

      The title typically identifies the current view or content item, and
      generally does not use the application name.
      Parameters:
      title - a title
    • setTitle

      public void setTitle(String title)
      Sets the title of @self.

      The title typically identifies the current view or content item, and
      generally does not use the application name.
      Parameters:
      title - a title
    • setViewSwitcherEnabled

      public void setViewSwitcherEnabled(boolean enabled)
      Sets whether @self's view switcher is enabled.

      If it is disabled, the title will be displayed instead. This allows to
      programmatically hide the view switcher even if it fits in the available
      space.

      This can be used e.g. to ensure the view switcher is hidden below a certain
      window width, or any other constraint you find suitable.
      Parameters:
      enabled - whether the view switcher is enabled
    • asAccessible

      public Accessible asAccessible()
      Implements interface Accessible. Call this to get access to interface functions.
      Overrides:
      asAccessible in class Widget
      Returns:
      Accessible
    • asBuildable

      public Buildable asBuildable()
      Implements interface Buildable. Call this to get access to interface functions.
      Overrides:
      asBuildable in class Widget
      Returns:
      Buildable
    • asConstraintTarget

      public ConstraintTarget asConstraintTarget()
      Implements interface ConstraintTarget. Call this to get access to interface functions.
      Overrides:
      asConstraintTarget in class Widget
      Returns:
      ConstraintTarget
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()