Class WListPanel<D,W extends WWidget>
java.lang.Object
io.github.cottonmc.cotton.gui.widget.WWidget
io.github.cottonmc.cotton.gui.widget.WPanel
io.github.cottonmc.cotton.gui.widget.WClippedPanel
io.github.cottonmc.cotton.gui.widget.WListPanel<D,W>
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 Summary
FieldsModifier and TypeFieldDescriptionprotected intThe height of each child cell.protected BiConsumer<D, W> The widget configurator that configures the passed widget to display the passed data.The list of data that this list represents.protected booleanWhether this list has a fixed height for items.protected intprotected WScrollBarThe scroll bar of this list.The supplier of new empty widgets. -
Constructor Summary
ConstructorsConstructorDescriptionWListPanel(List<D> data, Supplier<W> supplier, BiConsumer<D, W> configurator) Constructs a list panel. -
Method Summary
Modifier and TypeMethodDescriptionGets theWScrollBarattached to this panel.voidlayout()Uses this Panel's layout rules to reposition and resize components to fit nicely in the panel.onMouseScroll(int x, int y, double amount) Notifies this widget that the mouse has been scrolled inside its bounds.voidpaint(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int mouseX, int mouseY) Paints this widget.WListPanel<D, W> setListItemHeight(int height) Sets the height of this list's items to a constant value.Methods inherited from class io.github.cottonmc.cotton.gui.widget.WPanel
addPainters, canResize, cycleFocus, cycleFocus, expandToFit, expandToFit, getBackgroundPainter, hit, onHidden, onShown, remove, setBackgroundPainter, streamChildren, tick, toString, validateMethods inherited from class io.github.cottonmc.cotton.gui.widget.WWidget
addNarrations, addTooltip, canFocus, canHover, getAbsoluteX, getAbsoluteY, getHeight, getHost, getParent, getWidth, getX, getY, hoveredProperty, isActivationKey, isFocused, isHovered, isNarratable, isWithinBounds, onCharTyped, onClick, onFocusGained, onFocusLost, onKeyPressed, onKeyReleased, onMouseDown, onMouseDrag, onMouseMove, onMouseUp, releaseFocus, renderTooltip, requestFocus, setHost, setHovered, setLocation, setParent, setSize
-
Field Details
-
data
The list of data that this list represents. -
supplier
The supplier of new empty widgets. -
configurator
The widget configurator that configures the passed widget to display the passed data. -
configured
-
unconfigured
-
cellHeight
protected int cellHeightThe height of each child cell. -
fixedHeight
protected boolean fixedHeightWhether this list has a fixed height for items. -
margin
protected int margin -
scrollBar
The scroll bar of this list.
-
-
Constructor Details
-
WListPanel
Constructs a list panel.- Parameters:
data- the list datasupplier- the widget supplier that creates unconfigured widgetsconfigurator- 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:WWidgetPaints this widget.- Overrides:
paintin classWClippedPanel- Parameters:
matrices- the rendering matrix stackx- this widget's X coordinate on the screeny- this widget's Y coordinate on the screenmouseX- the X coordinate of the cursormouseY- the X coordinate of the cursor
-
layout
public void layout()Description copied from class:WPanelUses this Panel's layout rules to reposition and resize components to fit nicely in the panel. -
setListItemHeight
Sets the height of this list's items to a constant value.- Parameters:
height- the item height- Returns:
- this list
-
onMouseScroll
Description copied from class:WWidgetNotifies this widget that the mouse has been scrolled inside its bounds.- Overrides:
onMouseScrollin classWWidget- 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.PROCESSEDif the event is handled,InputResult.IGNOREDotherwise.
-
getScrollBar
Gets theWScrollBarattached to this panel.- Returns:
- the scroll bar bundled
- Since:
- 5.3.0
-