Class WPanel
java.lang.Object
io.github.cottonmc.cotton.gui.widget.WWidget
io.github.cottonmc.cotton.gui.widget.WPanel
- Direct Known Subclasses:
WCardPanel
,WClippedPanel
,WPanelWithInsets
,WScrollPanel
,WTabPanel
Panels are widgets that contain other widgets.
-
Field Summary
Modifier and TypeFieldDescriptionThe widgets contained within this panel. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the default background painters to this widget and all children.boolean
Checks whether this widget can be resized usingWWidget.setSize(int, int)
.protected void
Expands this panel be at least as large as the widget.protected void
expandToFit
(WWidget w, Insets insets) Expands this panel be at least as large as the widget.Gets the currentBackgroundPainter
of this panel.hit
(int x, int y) Finds the most specific child node at this location.void
layout()
Uses this Panel's layout rules to reposition and resize components to fit nicely in the panel.void
onHidden()
Notifies this widget that it won't be drawn and hides any visible peers of itself and its children.void
onShown()
Notifies this widget that it is visible and shows any hidden peers of itself and its children.void
paint
(DrawContext context, int x, int y, int mouseX, int mouseY) Paints this widget.void
Removes the widget from this panel.setBackgroundPainter
(BackgroundPainter painter) Sets theBackgroundPainter
of this panel.void
setHost
(GuiDescription host) Sets the host of this widget and all its children without creating peers.Returns a stream of all visible top-level widgets in this panel.void
tick()
Ticks all children of this panel.toString()
void
Creates component peers and initializes animation data for this Widget and all its children.Methods inherited from class io.github.cottonmc.cotton.gui.widget.WWidget
addNarrations, addTooltip, canFocus, canHover, getAbsoluteX, getAbsoluteY, getFocusModel, 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, setHovered, setLocation, setParent, setSize, shouldRenderInDarkMode
-
Field Details
-
children
The widgets contained within this panel.The list is mutable.
-
-
Constructor Details
-
WPanel
public WPanel()
-
-
Method Details
-
remove
Removes the widget from this panel.- Parameters:
w
- the removed widget
-
canResize
public boolean canResize()Description copied from class:WWidget
Checks whether this widget can be resized usingWWidget.setSize(int, int)
. -
setBackgroundPainter
Sets theBackgroundPainter
of this panel.- Parameters:
painter
- the new painter- Returns:
- this panel
-
getBackgroundPainter
Gets the currentBackgroundPainter
of this panel.- Returns:
- the painter
-
layout
public void layout()Uses this Panel's layout rules to reposition and resize components to fit nicely in the panel. -
expandToFit
Expands this panel be at least as large as the widget.- Parameters:
w
- the widget
-
expandToFit
Expands this panel be at least as large as the widget.- Parameters:
w
- the widgetinsets
- the layout insets- Since:
- 4.0.0
-
hit
Finds the most specific child node at this location. -
validate
Creates component peers and initializes animation data for this Widget and all its children. The host screen handler must clear any heavyweight peers from its records before this method is called.This method must be called on the root panel of any screen once the widgets have been initialized.
Subclasses should call
super.validate(c)
to ensure that children are validated. -
setHost
Description copied from class:WWidget
Sets the host of this widget and all its children without creating peers. -
paint
Description copied from class:WWidget
Paints this widget. -
tick
@Environment(CLIENT) public void tick()Ticks all children of this panel. -
onShown
public void onShown()Description copied from class:WWidget
Notifies this widget that it is visible and shows any hidden peers of itself and its children. -
onHidden
public void onHidden()Description copied from class:WWidget
Notifies this widget that it won't be drawn and hides any visible peers of itself and its children.The default implementation releases this widget's focus if it is focused. Overriding implementations might want to do this as well.
-
addPainters
@Environment(CLIENT) public void addPainters()Adds the default background painters to this widget and all children.Always called before
GuiDescription.addPainters()
to allow users to modify painters.Subclasses should call
super.addPainters()
to ensure that children have proper default painters.- Overrides:
addPainters
in classWWidget
- Since:
- 3.0.0
-
streamChildren
Returns a stream of all visible top-level widgets in this panel.- Returns:
- a stream of all visible top-level widgets in this panel
- Since:
- 4.2.0
-
toString
-