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
FieldsModifier and TypeFieldDescriptionThe widgets contained within this panel. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the default background painters to this widget and all children.booleanChecks whether this widget can be resized usingWWidget.setSize(int, int).protected voidExpands this panel be at least as large as the widget.protected voidexpandToFit(WWidget w, Insets insets) Expands this panel be at least as large as the widget.Gets the currentBackgroundPainterof this panel.hit(int x, int y) Finds the most specific child node at this location.voidlayout()Uses this Panel's layout rules to reposition and resize components to fit nicely in the panel.voidonHidden()Notifies this widget that it won't be drawn and hides any visible peers of itself and its children.voidonShown()Notifies this widget that it is visible and shows any hidden peers of itself and its children.voidpaint(DrawContext context, int x, int y, int mouseX, int mouseY) Paints this widget.voidRemoves the widget from this panel.setBackgroundPainter(BackgroundPainter painter) Sets theBackgroundPainterof this panel.voidsetHost(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.voidtick()Ticks all children of this panel.toString()voidCreates 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:WWidgetChecks whether this widget can be resized usingWWidget.setSize(int, int). -
setBackgroundPainter
Sets theBackgroundPainterof this panel.- Parameters:
painter- the new painter- Returns:
- this panel
-
getBackgroundPainter
Gets the currentBackgroundPainterof 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:WWidgetSets the host of this widget and all its children without creating peers. -
paint
Description copied from class:WWidgetPaints this widget. -
tick
@Environment(CLIENT) public void tick()Ticks all children of this panel. -
onShown
public void onShown()Description copied from class:WWidgetNotifies this widget that it is visible and shows any hidden peers of itself and its children. -
onHidden
public void onHidden()Description copied from class:WWidgetNotifies 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:
addPaintersin 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
-