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.WPanelWithInsets
io.github.cottonmc.cotton.gui.widget.WGridPanel
A panel that positions children in a grid.
-
Field Summary
FieldsFields inherited from class io.github.cottonmc.cotton.gui.widget.WPanelWithInsets
insets -
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
Methods inherited from class io.github.cottonmc.cotton.gui.widget.WPanelWithInsets
getInsetsMethods inherited from class io.github.cottonmc.cotton.gui.widget.WPanel
addPainters, canResize, cycleFocus, cycleFocus, expandToFit, expandToFit, getBackgroundPainter, hit, layout, onHidden, onShown, paint, 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, onMouseScroll, onMouseUp, releaseFocus, renderTooltip, requestFocus, setHost, setHovered, 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
-
setInsets
Description copied from class:WPanelWithInsetsSets the layout insets of this panel. Subclasses are encouraged to override this method to return their more specific type (such asWGridPanel).If there are already widgets in this panel when the insets are modified, the panel is resized and the widgets are moved according to the insets.
- Overrides:
setInsetsin classWPanelWithInsets- Parameters:
insets- the insets, should not be null- Returns:
- this panel
-