Class MultiLayoutView

All Implemented Interfaces:
Accessible, Buildable, ConstraintTarget, Proxy

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

A widget for switching between different layouts.

AdwMultiLayoutView contains layouts and children. Each child has an ID, each layout has slots inside it, each slot also has an ID. When switching layouts, children are inserted into slots with matching IDs. The Gtk.Widget:visible property of each slot is updated to match that of the inserted child.

This can be useful for rearranging children when it's difficult to do so otherwise, for example to move a child from a sidebar to a bottom bar.

The currently used layout can be switched using the MultiLayoutView:layout or MultiLayoutView:layout-name properties. For example, it can be done via a Breakpoint setter to change layouts depending on the window size.

AdwMultiLayoutView as GtkBuildable

The AdwMultiLayoutView implementation of the Buildable interface supports adding layouts via <child> element with the type attribute omitted.

It also supports setting children via <child type="ID">.

Example of an AdwMultiLayoutView UI definition that can display a secondary child as either a sidebar or a bottom sheet.

<object class="AdwMultiLayoutView">
  <child>
    <object class="AdwLayout">
      <property name="name">sidebar</property>
      <property name="content">
        <object class="AdwOverlaySplitView">
          <property name="sidebar">
            <object class="AdwLayoutSlot">
              <property name="id">secondary</property>
            </object>
          </property>
          <property name="content">
            <object class="AdwLayoutSlot">
              <property name="id">primary</property>
            </object>
          </property>
        </object>
      </property>
    </object>
  </child>
  <child>
    <object class="AdwLayout">
      <property name="name">bottom-sheet</property>
      <property name="content">
        <object class="AdwBottomSheet">
          <property name="open">True</property>
          <property name="content">
            <object class="AdwLayoutSlot">
              <property name="id">primary</property>
            </object>
          </property>
          <property name="sheet">
            <object class="AdwLayoutSlot">
              <property name="id">secondary</property>
            </object>
          </property>
        </object>
      </property>
    </object>
  </child>
  <child type="primary">
    <!-- ... -->
  </child>
  <child type="secondary">
    <!-- ... -->
  </child>
</object>

CSS nodes

AdwMultiLayoutView has a single CSS node with name multi-layout-view.

Since:
1.6
  • Constructor Details

    • MultiLayoutView

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

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

    • getType

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

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

      protected MultiLayoutView 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
    • addLayout

      public void addLayout(Layout layout)
      Adds layout to self.
      Parameters:
      layout - the layout to add
      Since:
      1.6
    • getChild

      public @Nullable Widget getChild(String id)
      Gets the child for id to self.
      Parameters:
      id - the id of the child
      Returns:
      the child for id
      Since:
      1.6
    • getLayout

      public @Nullable Layout getLayout()
      Gets the currently used layout of self.
      Returns:
      the current layout
      Since:
      1.6
    • getLayoutByName

      public @Nullable Layout getLayoutByName(String name)

      Gets layout with the name name from self, or NULL if it doesn't exist.

      See Layout:name.

      Parameters:
      name - the name of the layout
      Returns:
      the layout with name
      Since:
      1.6
    • getLayoutName

      public @Nullable String getLayoutName()
      Returns the name of the currently used layout of self.
      Returns:
      the name of the current layout
      Since:
      1.6
    • removeLayout

      public void removeLayout(Layout layout)
      Removes layout from self.
      Parameters:
      layout - the layout to add
      Since:
      1.6
    • setChild

      public void setChild(String id, Widget child)

      Sets child as the child for id in self.

      When changing layouts, it will be inserted into the slot with id.

      Parameters:
      id - the id of the child
      child - the child to set
      Since:
      1.6
    • setLayout

      public void setLayout(Layout layout)
      Makes layout the current layout of self.
      Parameters:
      layout - a layout in this MultiLayoutView
      Since:
      1.6
    • setLayoutName

      public void setLayoutName(String name)

      Makes the layout with name the current layout of self.

      See Layout:name.

      Parameters:
      name - the name of the layout
      Since:
      1.6
    • builder

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