Class ListWidget

All Implemented Interfaces:
Drawable, Element, ParentElement

public class ListWidget extends AbstractParentElement implements Drawable
Shamelessly modified vanilla lists to support variable width. This is the lesser of two evils, at least this way I have vanilla compat.
  • Field Details

    • client

      protected final Minecraft client
    • width

      protected int width
    • height

      protected int height
    • top

      protected int top
    • bottom

      protected int bottom
    • left

      protected int left
    • padding

      public int padding
  • Constructor Details

    • ListWidget

      public ListWidget(Minecraft client, int width, int height, int top, int bottom)
  • Method Details

    • setRenderSelection

      public void setRenderSelection(boolean renderSelection)
    • getRowWidth

      public int getRowWidth()
    • getLogicalHeight

      public int getLogicalHeight()
    • getSelectedOrNull

      @Nullable public @Nullable ListWidget.Entry getSelectedOrNull()
    • setSelected

      public void setSelected(@Nullable @Nullable ListWidget.Entry entry)
    • children

      public final List<ListWidget.Entry> children()
      Description copied from interface: ParentElement
      Gets a list of all child GUI elements.
      Specified by:
      children in interface ParentElement
    • clearEntries

      protected final void clearEntries()
    • replaceEntries

      protected void replaceEntries(Collection<ListWidget.Entry> newEntries)
    • getEntry

      protected ListWidget.Entry getEntry(int index)
    • addEntry

      public int addEntry(ListWidget.Entry entry)
    • getEntryCount

      protected int getEntryCount()
    • isSelectedEntry

      protected boolean isSelectedEntry(int index)
    • getEntryAtPosition

      @Nullable protected final @Nullable ListWidget.Entry getEntryAtPosition(double x, double y)
    • updateSize

      public void updateSize(int width, int height, int top, int bottom)
    • setLeftPos

      public void setLeftPos(int left)
    • getMaxPosition

      protected int getMaxPosition()
    • render

      public void render(DrawContext draw, int mouseX, int mouseY, float delta)
      Specified by:
      render in interface Drawable
    • centerScrollOn

      public void centerScrollOn(ListWidget.Entry entry)
    • ensureVisible

      protected void ensureVisible(ListWidget.Entry entry)
    • getScrollAmount

      public double getScrollAmount()
    • setScrollAmount

      public void setScrollAmount(double amount)
    • getMaxScroll

      public int getMaxScroll()
    • updateScrollingState

      protected void updateScrollingState(double mouseX, double mouseY, int button)
    • getScrollbarPositionX

      protected int getScrollbarPositionX()
    • unfocusTextField

      public void unfocusTextField()
    • getFocusedTextField

      public TextFieldWidget getFocusedTextField()
    • mouseClicked

      public boolean mouseClicked(double mouseX, double mouseY, int button)
      Specified by:
      mouseClicked in interface Element
      Specified by:
      mouseClicked in interface ParentElement
    • mouseReleased

      public boolean mouseReleased(double mouseX, double mouseY, int button)
      Specified by:
      mouseReleased in interface Element
      Specified by:
      mouseReleased in interface ParentElement
    • mouseDragged

      public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY)
      Specified by:
      mouseDragged in interface Element
      Specified by:
      mouseDragged in interface ParentElement
    • mouseScrolled

      public boolean mouseScrolled(double mouseX, double mouseY, double amount)
      Specified by:
      mouseScrolled in interface Element
      Specified by:
      mouseScrolled in interface ParentElement
    • keyPressed

      public boolean keyPressed(int keyCode, int scanCode, int modifiers)
      Specified by:
      keyPressed in interface Element
      Specified by:
      keyPressed in interface ParentElement
    • moveSelection

      protected void moveSelection(ListWidget.MoveDirection direction)
    • ensureSelectedEntryVisible

      protected void ensureSelectedEntryVisible()
    • moveSelectionIf

      protected void moveSelectionIf(ListWidget.MoveDirection direction, Predicate<ListWidget.Entry> predicate)
      Moves the selection in the specified direction until the predicate returns true.
      Parameters:
      direction - the direction to move the selection
    • isMouseOver

      public boolean isMouseOver(double mouseX, double mouseY)
      Specified by:
      isMouseOver in interface Element
    • renderList

      protected void renderList(DrawContext draw, int x, int y, int mouseX, int mouseY, float delta)
    • getRowLeft

      public int getRowLeft()
    • getRowRight

      public int getRowRight()
    • getRowTop

      protected int getRowTop(int index)
    • isFocused

      public boolean isFocused()
      Specified by:
      isFocused in interface Element
      Specified by:
      isFocused in interface ParentElement
    • getType

    • getHoveredEntry

      @Nullable public @Nullable ListWidget.Entry getHoveredEntry()
    • getTotalHeight

      public int getTotalHeight()
    • setFocused

      public void setFocused(boolean focused)
      Specified by:
      setFocused in interface Element
      Specified by:
      setFocused in interface ParentElement