Class PagedLayer<T>
java.lang.Object
com.github.darksoulq.abyssallib.world.gui.layer.PagedLayer<T>
- Type Parameters:
T- the type of data being paginated
- All Implemented Interfaces:
GuiLayer
-
Constructor Summary
ConstructorsConstructorDescriptionPagedLayer(List<T> source, int[] slots, GuiView.Segment segment) Constructs a PagedLayer for direct GuiElement pagination.PagedLayer(List<T> source, int[] slots, GuiView.Segment segment, BiFunction<T, Integer, GuiElement> mapper) Constructs a PagedLayer with a custom data-to-element mapper. -
Method Summary
Modifier and TypeMethodDescriptionvoidCleans up the rendered items and removed mapped elements.intgetPage()Gets the current page index.intCalculates the total number of pages based on filtered data size.voidForces the layer to re-render.voidAdvances to the next page of content.static PagedLayer<GuiElement> of(List<GuiElement> elements, int[] slots, GuiView.Segment segment) Static helper for creating an element-specific PagedLayer.static <T> PagedLayer<T> of(List<T> source, int[] slots, GuiView.Segment segment, BiFunction<T, Integer, GuiElement> mapper) Static helper for creating a generic PagedLayer.voidReturns to the previous page of content.voidRenders the current page of data as GUI elements.voidUpdates the data filter and resets the view to the first page.
-
Constructor Details
-
PagedLayer
public PagedLayer(List<T> source, int[] slots, GuiView.Segment segment, BiFunction<T, Integer, GuiElement> mapper) Constructs a PagedLayer with a custom data-to-element mapper.- Parameters:
source- the master data listslots- the target slots for itemssegment- the target inventory segmentmapper- the function creating elements from data
-
PagedLayer
Constructs a PagedLayer for direct GuiElement pagination.- Parameters:
source- the list of GUI elementsslots- the target slots for itemssegment- the target inventory segment
-
-
Method Details
-
setFilter
-
next
Advances to the next page of content.- Parameters:
view- the active GUI view context
-
previous
Returns to the previous page of content.- Parameters:
view- the active GUI view context
-
renderTo
-
cleanup
-
getPageCount
public int getPageCount()Calculates the total number of pages based on filtered data size.- Returns:
- the total page count
-
getPage
public int getPage()Gets the current page index.- Returns:
- current page
-
invalidate
public void invalidate()Forces the layer to re-render. -
of
public static <T> PagedLayer<T> of(List<T> source, int[] slots, GuiView.Segment segment, BiFunction<T, Integer, GuiElement> mapper) Static helper for creating a generic PagedLayer.- Type Parameters:
T- data type- Parameters:
source- data sourceslots- target slotssegment- target segmentmapper- mapping function- Returns:
- a new PagedLayer
-
of
public static PagedLayer<GuiElement> of(List<GuiElement> elements, int[] slots, GuiView.Segment segment) Static helper for creating an element-specific PagedLayer.- Parameters:
elements- list of GUI elementsslots- target slotssegment- target segment- Returns:
- a new PagedLayer for GUI elements
-