Class ToolbarView

All Implemented Interfaces:
Accessible, Buildable, ConstraintTarget, Proxy

@Generated("org.javagi.JavaGI") public final class ToolbarView extends Widget implements Accessible, Buildable, ConstraintTarget

A widget containing a page, as well as top and/or bottom bars.

toolbar-view

AdwToolbarView has a single content widget and one or multiple top and bottom bars, shown at the top and bottom sides respectively.

Example of an AdwToolbarView UI definition:

<object class="AdwToolbarView">
  <child type="top">
    <object class="AdwHeaderBar"/>
  </child>
  <property name="content">
    <object class="AdwPreferencesPage">
      <!-- ... -->
    </object>
  </property>
</object>

The following kinds of top and bottom bars are supported:

By default, top and bottom bars are flat and scrolling content has a subtle undershoot shadow, same as when using the .undershoot-top and .undershoot-bottom style classes. This works well in most cases, e.g. with StatusPage or PreferencesPage, where the background at the top and bottom parts of the page is uniform. Additionally, windows with sidebars should always use this style.

ToolbarView:top-bar-style and ToolbarView:bottom-bar-style properties can be used add an opaque background and a persistent shadow to top and bottom bars, this can be useful for content such as utility panes, where some elements are adjacent to the top/bottom bars, or TabView, where each page can have a different background.

toolbar-view-flat-1 toolbar-view-flat-2 toolbar-view-raised

AdwToolbarView ensures the top and bottom bars have consistent backdrop styles and vertical spacing. For comparison:

toolbar-view-spacing toolbar-view-spacing-box

Any top and bottom bars can also be dragged to move the window, equivalent to putting them into a WindowHandle.

Content is typically place between top and bottom bars, but can also extend behind them. This is controlled with the ToolbarView:extend-content-to-top-edge and ToolbarView:extend-content-to-bottom-edge properties.

Top and bottom bars can be hidden and revealed with an animation using the ToolbarView:reveal-top-bars and ToolbarView:reveal-bottom-bars properties.

AdwToolbarView as GtkBuildable

The AdwToolbarView implementation of the Buildable interface supports adding a top bar by specifying “top” as the “type” attribute of a <child> element, or adding a bottom bar by specifying “bottom”.

Accessibility

AdwToolbarView uses the Gtk.AccessibleRole.group role.

Since:
1.4
  • Constructor Details

    • ToolbarView

      public ToolbarView(MemorySegment address)
      Create a ToolbarView instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • ToolbarView

      public ToolbarView()
      Create a new ToolbarView.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the ToolbarView class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected ToolbarView asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class Widget
      Returns:
      the instance as if it were its parent type
    • addBottomBar

      public void addBottomBar(Widget widget)
      Adds a bottom bar to self.
      Parameters:
      widget - a widget
      Since:
      1.4
    • addTopBar

      public void addTopBar(Widget widget)
      Adds a top bar to self.
      Parameters:
      widget - a widget
      Since:
      1.4
    • getBottomBarHeight

      public int getBottomBarHeight()

      Gets the current bottom bar height for self.

      Bottom bar height does change depending on ToolbarView:reveal-bottom-bars, including during the transition.

      See getTopBarHeight().

      Returns:
      the current bottom bar height
      Since:
      1.4
    • getBottomBarStyle

      public ToolbarStyle getBottomBarStyle()
      Gets appearance of the bottom bars for self.
      Returns:
      bottom bar style
      Since:
      1.4
    • getContent

      public @Nullable Widget getContent()
      Gets the content widget for self.
      Returns:
      the content widget
      Since:
      1.4
    • getExtendContentToBottomEdge

      public boolean getExtendContentToBottomEdge()
      Gets whether the content widget can extend behind bottom bars.
      Returns:
      whether content extends behind bottom bars
      Since:
      1.4
    • getExtendContentToTopEdge

      public boolean getExtendContentToTopEdge()
      Gets whether the content widget can extend behind top bars.
      Returns:
      whether content extends behind top bars
      Since:
      1.4
    • getRevealBottomBars

      public boolean getRevealBottomBars()
      Gets whether bottom bars are revealed for self.
      Returns:
      whether bottom bars are revealed
      Since:
      1.4
    • getRevealTopBars

      public boolean getRevealTopBars()
      Gets whether top bars are revealed for self.
      Returns:
      whether top bars are revealed
      Since:
      1.4
    • getTopBarHeight

      public int getTopBarHeight()

      Gets the current top bar height for self.

      Top bar height does change depending on ToolbarView:reveal-top-bars, including during the transition.

      See getBottomBarHeight().

      Returns:
      the current top bar height
      Since:
      1.4
    • getTopBarStyle

      public ToolbarStyle getTopBarStyle()
      Gets appearance of the top bars for self.
      Returns:
      top bar style
      Since:
      1.4
    • remove

      public void remove(Widget widget)
      Removes a child from self.
      Parameters:
      widget - the child to be removed
      Since:
      1.4
    • setBottomBarStyle

      public void setBottomBarStyle(ToolbarStyle style)

      Sets appearance of the bottom bars for self.

      If set to Adw.ToolbarStyle.flat, bottom bars are flat and scrolling content has a subtle undershoot shadow when touching them, same as the .undershoot-bottom style class. This works well for simple content, e.g. StatusPage or PreferencesPage, where the background at the bottom of the page is uniform. Additionally, windows with sidebars should always use this style.

      Undershoot shadow is only present if a bottom bar is actually present and visible. It is also never present if ToolbarView:extend-content-to-bottom-edge is set to TRUE.

      If set to Adw.ToolbarStyle.raised, bottom bars have an opaque background and a persistent shadow, this is suitable for content such as utility panes, where some elements are directly adjacent to the bottom bars, or TabView, where each page can have a different background.

      Adw.ToolbarStyle.raised-border is similar to Adw.ToolbarStyle.raised, but the shadow is replaced with a more subtle border. This can be useful for applications like image viewers.

      See also setTopBarStyle(ToolbarStyle).

      Parameters:
      style - bottom bar style
      Since:
      1.4
    • setContent

      public void setContent(@Nullable Widget content)
      Sets the content widget for self.
      Parameters:
      content - the content widget
      Since:
      1.4
    • setExtendContentToBottomEdge

      public void setExtendContentToBottomEdge(boolean extend)

      Sets whether the content widget can extend behind bottom bars.

      This can be used in combination with ToolbarView:reveal-bottom-bars to show and hide toolbars in fullscreen.

      See setExtendContentToTopEdge(boolean).

      Parameters:
      extend - whether content extends behind bottom bars
      Since:
      1.4
    • setExtendContentToTopEdge

      public void setExtendContentToTopEdge(boolean extend)

      Sets whether the content widget can extend behind top bars.

      This can be used in combination with ToolbarView:reveal-top-bars to show and hide toolbars in fullscreen.

      See setExtendContentToBottomEdge(boolean).

      Parameters:
      extend - whether content extends behind top bars
      Since:
      1.4
    • setRevealBottomBars

      public void setRevealBottomBars(boolean reveal)

      Sets whether bottom bars are revealed for self.

      The transition will be animated.

      This can be used in combination with ToolbarView:extend-content-to-bottom-edge to show and hide toolbars in fullscreen.

      See setRevealTopBars(boolean).

      Parameters:
      reveal - whether to reveal bottom bars
      Since:
      1.4
    • setRevealTopBars

      public void setRevealTopBars(boolean reveal)

      Sets whether top bars are revealed for self.

      The transition will be animated.

      This can be used in combination with ToolbarView:extend-content-to-top-edge to show and hide toolbars in fullscreen.

      See setRevealBottomBars(boolean).

      Parameters:
      reveal - whether to reveal top bars
      Since:
      1.4
    • setTopBarStyle

      public void setTopBarStyle(ToolbarStyle style)

      Sets appearance of the top bars for self.

      If set to Adw.ToolbarStyle.flat, top bars are flat and scrolling content has a subtle undershoot shadow when touching them, same as the .undershoot-top style class. This works well for simple content, e.g. StatusPage or PreferencesPage, where the background at the top of the page is uniform. Additionally, windows with sidebars should always use this style.

      Undershoot shadow is only present if a top bar is actually present and visible. It is also never present if ToolbarView:extend-content-to-top-edge is set to TRUE.

      If set to Adw.ToolbarStyle.raised, top bars have an opaque background and a persistent shadow, this is suitable for content such as utility panes, where some elements are directly adjacent to the top bars, or TabView, where each page can have a different background.

      Adw.ToolbarStyle.raised-border is similar to Adw.ToolbarStyle.raised, but the shadow is replaced with a more subtle border. This can be useful for applications like image viewers.

      See also setBottomBarStyle(ToolbarStyle).

      Parameters:
      style - top bar style
      Since:
      1.4
    • builder

      public static ToolbarView.Builder<? extends ToolbarView.Builder> builder()
      A ToolbarView.Builder object constructs a ToolbarView with the specified properties. Use the various set...() methods to set properties, and finish construction with ToolbarView.Builder.build().
      Returns:
      the builder object