Class WListPanel<D,W extends WWidget>


public class WListPanel<D,W extends WWidget> extends WClippedPanel
Similar to the RecyclerView in Android, this widget represents a scrollable list of items.

D is the type of data represented. The data must reside in some ordered backing List<D>. D's *must* have working equals and hashCode methods to distinguish them from each other!

W is the WWidget class that will represent a single D of data.

  • Field Details

    • data

      protected List<D> data
      The list of data that this list represents.
    • supplier

      protected Supplier<W extends WWidget> supplier
      The supplier of new empty widgets.
    • configurator

      protected BiConsumer<D,W extends WWidget> configurator
      The widget configurator that configures the passed widget to display the passed data.
    • configured

      protected HashMap<D,W extends WWidget> configured
    • unconfigured

      protected List<W extends WWidget> unconfigured
    • cellHeight

      protected int cellHeight
      The height of each child cell.
    • fixedHeight

      protected boolean fixedHeight
      Whether this list has a fixed height for items.
    • margin

      protected int margin
    • scrollBar

      protected WScrollBar scrollBar
      The scroll bar of this list.
  • Constructor Details

    • WListPanel

      public WListPanel(List<D> data, Supplier<W> supplier, BiConsumer<D,W> configurator)
      Constructs a list panel.
      Parameters:
      data - the list data
      supplier - the widget supplier that creates unconfigured widgets
      configurator - the widget configurator that configures widgets to display the passed data
  • Method Details

    • paint

      @Environment(CLIENT) public void paint(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int mouseX, int mouseY)
      Description copied from class: WWidget
      Paints this widget.
      Overrides:
      paint in class WClippedPanel
      Parameters:
      matrices - the rendering matrix stack
      x - this widget's X coordinate on the screen
      y - this widget's Y coordinate on the screen
      mouseX - the X coordinate of the cursor
      mouseY - the X coordinate of the cursor
    • layout

      public void layout()
      Description copied from class: WPanel
      Uses this Panel's layout rules to reposition and resize components to fit nicely in the panel.
      Overrides:
      layout in class WPanel
    • setListItemHeight

      public WListPanel<D,W> setListItemHeight(int height)
      Sets the height of this list's items to a constant value.
      Parameters:
      height - the item height
      Returns:
      this list
    • onMouseScroll

      public InputResult onMouseScroll(int x, int y, double amount)
      Description copied from class: WWidget
      Notifies this widget that the mouse has been scrolled inside its bounds.
      Overrides:
      onMouseScroll in class WWidget
      Parameters:
      x - The X coordinate of the event, in widget-space (0 is the left edge of this widget)
      y - The Y coordinate of the event, in widget-space (0 is the top edge of this widget)
      amount - The scrolled amount. Positive values are up and negative values are down.
      Returns:
      InputResult.PROCESSED if the event is handled, InputResult.IGNORED otherwise.
    • getScrollBar

      public WScrollBar getScrollBar()
      Gets the WScrollBar attached to this panel.
      Returns:
      the scroll bar bundled
      Since:
      5.3.0