Class GuiList<E>

All Implemented Interfaces:
ElementEvents, GuiParent<GuiList<E>>, TooltipHandler<GuiList<E>>

public class GuiList<E> extends GuiElement<GuiList<E>>
GuiList, as the name suggests allows you to display a list of objects. The list type can be whatever you want, and you can install a converter to map list objects to elements for display.

The default converter simply displays the toString() value of the object.

Element width will be fixed to the width of the GuiList, element height can be whatever you want.

Note on adding child elements to this: If any child elements extend beyond the bounds of this element, that part will be culled. Also, child elements will always end up bellow the list items when the list is updated.

Created by brandon3055 on 21/09/2023

  • Field Details

    • enableScissor

      public boolean enableScissor
      This is made available primarily for debugging purposes where it can be useful to see what's going on behind the scenes.
  • Constructor Details

    • GuiList

      public GuiList(@NotNull @NotNull GuiParent<?> parent)
  • Method Details

    • add

      public boolean add(E e)
    • remove

      public boolean remove(E e)
    • getList

      public List<E> getList()
      You are allowed to modify this list directly, but if you do you must call markDirty() otherwise the display elements will not get updated.
    • markDirty

      public void markDirty()
    • setDisplayBuilder

      public GuiList<E> setDisplayBuilder(BiFunction<GuiList<E>,E,? extends GuiElement<?>> displayBuilder)
    • setFilter

      public GuiList<E> setFilter(Predicate<E> filter)
    • setItemSpacing

      public GuiList<E> setItemSpacing(double itemSpacing)
    • scrollState

      public SliderState scrollState()
    • addHiddenScrollBar

      public GuiList<E> addHiddenScrollBar()
      You can choose to attach a scroll bar to this element the same way you would a GuiScrolling But sometimes you just want to be able to mouse-wheel scroll without an actual scroll bar.

      This method will add a hidden scroll bar to enable mouse wheel scrolling and middle-click dragging without the need for an actual scroll bar. The scroll bar will be an invisible zero width element on the right side of this list.

    • removeHiddenScrollBar

      public GuiList<E> removeHiddenScrollBar()
    • hiddenSize

      public double hiddenSize()
    • tick

      public void tick(double mouseX, double mouseY)
      Description copied from class: GuiElement
      Called every tick to update the element. Note this is called regardless of weather or not the element is actually enabled.
      Overrides:
      tick in class GuiElement<GuiList<E>>
      Parameters:
      mouseX - Current mouse X position
      mouseY - Current mouse Y position
    • rebuildElements

      public void rebuildElements()
    • getElementMap

      public Map<E,GuiElement<?>> getElementMap()
    • scrollTo

      public void scrollTo(E scrollTo)
    • blockMouseOver

      public boolean blockMouseOver(GuiElement<?> element, double mouseX, double mouseY)
      Description copied from interface: GuiParent
      Allows an element to override the GuiElement.isMouseOver() method of its children. This is primarily used for things like scroll elements where mouseover interactions need to be blocked outside the view area.
      Specified by:
      blockMouseOver in interface GuiParent<E>
      Overrides:
      blockMouseOver in class GuiElement<GuiList<E>>
      Parameters:
      element - The element on which isMouseOver is getting called.
      Returns:
      true if mouse-over interaction should be blocked for this child element.
    • render

      public void render(GuiRender render, double mouseX, double mouseY, float partialTicks)
      Description copied from class: GuiElement
      This is the main render method that handles rendering this element and any child elements it may have. This method almost never needs to be overridden, instead when creating custom elements with custom rendering, your element should implement BackgroundRender and / or ForegroundRender in or order to implement its rendering.

      Note: After the render is complete, the poseStack's z pos will be offset by the total depth of this element and its children. This is intended behavior,

      Overrides:
      render in class GuiElement<GuiList<E>>
      Parameters:
      render - Contains gui context information as well as essential render methods/utils including the PoseStack.
      mouseX - Current mouse X position
      mouseY - Current mouse Y position
      partialTicks - Partial render ticks