Class WGridPanel
java.lang.Object
io.github.cottonmc.cotton.gui.widget.WWidget
io.github.cottonmc.cotton.gui.widget.WPanel
io.github.cottonmc.cotton.gui.widget.WGridPanel
A panel that positions children in a grid.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a grid panel with the default grid size.WGridPanel(int gridSize)Constructs a grid panel with a custom grid size. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a widget to this panel.voidAdds a widget to this panel and resizes it to a custom size.Gets the layout insets of this panel.Sets the layout insets of this panel.Methods inherited from class io.github.cottonmc.cotton.gui.widget.WPanel
addPainters, canResize, createPeers, cycleFocus, cycleFocus, expandToFit, expandToFit, getBackgroundPainter, hit, layout, onHidden, onShown, paint, remove, setBackgroundPainter, tick, toString, validateMethods inherited from class io.github.cottonmc.cotton.gui.widget.WWidget
addTooltip, canFocus, getAbsoluteX, getAbsoluteY, getHeight, getHost, getParent, getWidth, getX, getY, isActivationKey, isFocused, isWithinBounds, onCharTyped, onClick, onFocusGained, onFocusLost, onKeyPressed, onKeyReleased, onMouseDown, onMouseDrag, onMouseMove, onMouseScroll, onMouseUp, releaseFocus, renderTooltip, requestFocus, setHost, setLocation, setParent, setSize
-
Field Details
-
grid
protected int gridThe grid size in pixels. Defaults to 18, which is the size of one item slot.
-
-
Constructor Details
-
WGridPanel
public WGridPanel()Constructs a grid panel with the default grid size. -
WGridPanel
public WGridPanel(int gridSize)Constructs a grid panel with a custom grid size.- Parameters:
gridSize- the grid size in pixels
-
-
Method Details
-
add
Adds a widget to this panel.If the widget can be resized, it will be resized to (
grid,grid).- Parameters:
w- the widgetx- the X position in grid cellsy- the Y position in grid cells
-
add
Adds a widget to this panel and resizes it to a custom size.- Parameters:
w- the widgetx- the X position in grid cellsy- the Y position in grid cellswidth- the new width in grid cellsheight- the new height in grid cells
-
getInsets
Gets the layout insets of this panel.- Returns:
- the insets
- Since:
- 4.0.0
-
setInsets
Sets the layout insets of this panel.The insets should be set before adding any widgets to this panel.
- Parameters:
insets- the insets, should not be null- Returns:
- this panel
- Since:
- 4.0.0
-