java.lang.Object
com.ultikits.ultitools.abstracts.gui.declarative.core.Widget
com.ultikits.ultitools.abstracts.gui.declarative.widgets.GridView<T>
Type Parameters:
T - the data type (when built from a data list)

public class GridView<T> extends Widget
GridView is a grid-layout Widget that arranges its children in a grid.

Supports:

  • a specified starting slot and row/column count
  • automatic child Widget position calculation
  • automatic mapping from a data list

Usage example:


 // Manually specify child widgets
 GridView.builder()
     .startSlot(10)
     .columns(7)
     .children(buttons)
     .build();

 // Auto-generate from a data list
 GridView.<ItemStack>builder()
     .startSlot(10)
     .columns(7)
     .items(itemList)
     .itemBuilder(item -> ItemDisplay.builder(item).build())
     .build();
 
Since:
6.2.0
Version:
1.0.0
Author:
UltiTools Team
  • Field Details

    • startSlot

      private final int startSlot
    • columns

      private final int columns
    • children

      @NotNull private final @NotNull List<Widget> children
  • Constructor Details

  • Method Details

    • builder

      @NotNull public static <T> @NotNull GridView.Builder<T> builder()
      Creates a Builder.
      Type Parameters:
      T - the data type
      Returns:
      the Builder
    • getStartSlot

      public int getStartSlot()
    • getColumns

      public int getColumns()
    • getChildren

      @NotNull public @NotNull List<Widget> getChildren()
    • calculateSlotForChild

      public int calculateSlotForChild(int childIndex)
      Calculates the actual slot of a child Widget.
      Parameters:
      childIndex - the child Widget's index
      Returns:
      slot index
    • createElement

      @NotNull public @NotNull Element createElement()
      Description copied from class: Widget
      Creates the Element corresponding to this Widget.

      This is a framework-internal method; subclasses should return the Element implementation appropriate to the Widget type.

      Specified by:
      createElement in class Widget
      Returns:
      the corresponding Element instance