public class WListPanel<D,W extends WWidget> extends WClippedPanel
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.
| Modifier and Type | Field and Description |
|---|---|
protected int |
cellHeight
The height of each child cell.
|
protected java.util.function.BiConsumer<D,W> |
configurator
The widget configurator that configures the passed widget
to display the passed data.
|
protected java.util.HashMap<D,W> |
configured |
protected java.util.List<D> |
data
The list of data that this list represents.
|
protected boolean |
fixedHeight
Whether this list has a fixed height for items.
|
protected int |
margin |
protected WScrollBar |
scrollBar
The scroll bar of this list.
|
protected java.util.function.Supplier<W> |
supplier
The supplier of new empty widgets.
|
protected java.util.List<W> |
unconfigured |
| Constructor and Description |
|---|
WListPanel(java.util.List<D> data,
java.util.function.Supplier<W> supplier,
java.util.function.BiConsumer<D,W> configurator)
Constructs a list panel.
|
| Modifier and Type | Method and Description |
|---|---|
void |
layout()
Uses this Panel's layout rules to reposition and resize components to fit nicely in the panel.
|
InputResult |
onMouseScroll(int x,
int y,
double amount)
Notifies this widget that the mouse has been scrolled inside its bounds.
|
void |
paint(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.
|
addPainters, canResize, createPeers, cycleFocus, cycleFocus, expandToFit, expandToFit, getBackgroundPainter, hit, onHidden, onShown, remove, setBackgroundPainter, tick, toString, validateaddTooltip, canFocus, getAbsoluteX, getAbsoluteY, getHeight, getHost, getParent, getWidth, getX, getY, isActivationKey, isFocused, isWithinBounds, onCharTyped, onClick, onFocusGained, onFocusLost, onKeyPressed, onKeyReleased, onMouseDown, onMouseDrag, onMouseMove, onMouseUp, releaseFocus, renderTooltip, requestFocus, setHost, setLocation, setParent, setSizeprotected java.util.List<D> data
protected java.util.function.Supplier<W extends WWidget> supplier
protected java.util.function.BiConsumer<D,W extends WWidget> configurator
protected int cellHeight
protected boolean fixedHeight
protected int margin
protected WScrollBar scrollBar
public WListPanel(java.util.List<D> data, java.util.function.Supplier<W> supplier, java.util.function.BiConsumer<D,W> configurator)
data - the list datasupplier - the widget supplier that creates unconfigured widgetsconfigurator - the widget configurator that configures widgets to display the passed data@Environment(value=CLIENT)
public void paint(net.minecraft.client.util.math.MatrixStack matrices,
int x,
int y,
int mouseX,
int mouseY)
WWidgetpaint in class WClippedPanelmatrices - 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 cursorpublic void layout()
WPanelpublic WListPanel<D,W> setListItemHeight(int height)
height - the item heightpublic InputResult onMouseScroll(int x, int y, double amount)
WWidgetonMouseScroll in class WWidgetx - 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.InputResult.PROCESSED if the event is handled, InputResult.IGNORED otherwise.