Class WScrollPanel
java.lang.Object
io.github.cottonmc.cotton.gui.widget.WWidget
io.github.cottonmc.cotton.gui.widget.WPanel
io.github.cottonmc.cotton.gui.widget.WClippedPanel
io.github.cottonmc.cotton.gui.widget.WScrollPanel
Similar to the JScrollPane in Swing, this widget represents a scrollable widget.
- Since:
- 2.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected WScrollBarThe horizontal scroll bar of this panel.protected WScrollBarThe vertical scroll bar of this panel. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionnet.fabricmc.fabric.api.util.TriStateReturns whether this scroll panel has a horizontal scroll bar.net.fabricmc.fabric.api.util.TriStateReturns whether this scroll panel has a vertical scroll bar.voidlayout()Uses this Panel's layout rules to reposition and resize components to fit nicely in the panel.onMouseScroll(int x, int y, double amount) Notifies this widget that the mouse has been scrolled inside its bounds.voidpaint(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int mouseX, int mouseY) Paints this widget.setScrollingHorizontally(net.fabricmc.fabric.api.util.TriState scrollingHorizontally) setScrollingVertically(net.fabricmc.fabric.api.util.TriState scrollingVertically) voidCreates component peers and initializes animation data for this Widget and all its children.Methods inherited from class io.github.cottonmc.cotton.gui.widget.WPanel
addPainters, canResize, cycleFocus, cycleFocus, expandToFit, expandToFit, getBackgroundPainter, hit, onHidden, onShown, remove, setBackgroundPainter, streamChildren, tick, toStringMethods 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, onMouseUp, releaseFocus, renderTooltip, requestFocus, setHost, setHovered, setLocation, setParent, setSize
-
Field Details
-
horizontalScrollBar
The horizontal scroll bar of this panel. -
verticalScrollBar
The vertical scroll bar of this panel.
-
-
Constructor Details
-
WScrollPanel
Creates a vertically scrolling panel.- Parameters:
widget- the viewed widget
-
-
Method Details
-
isScrollingHorizontally
public net.fabricmc.fabric.api.util.TriState isScrollingHorizontally()Returns whether this scroll panel has a horizontal scroll bar.- Returns:
- true if there is a horizontal scroll bar, default if a scroll bar should be added if needed, and false otherwise
-
setScrollingHorizontally
public WScrollPanel setScrollingHorizontally(net.fabricmc.fabric.api.util.TriState scrollingHorizontally) -
isScrollingVertically
public net.fabricmc.fabric.api.util.TriState isScrollingVertically()Returns whether this scroll panel has a vertical scroll bar.- Returns:
- true if there is a vertical scroll bar, * default if a scroll bar should be added if needed, * and false otherwise
-
setScrollingVertically
public WScrollPanel setScrollingVertically(net.fabricmc.fabric.api.util.TriState scrollingVertically) -
paint
@Environment(CLIENT) public void paint(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int mouseX, int mouseY) Description copied from class:WWidgetPaints this widget.- Overrides:
paintin classWClippedPanel- Parameters:
matrices- 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 cursor
-
layout
public void layout()Description copied from class:WPanelUses this Panel's layout rules to reposition and resize components to fit nicely in the panel. -
onMouseScroll
Description copied from class:WWidgetNotifies this widget that the mouse has been scrolled inside its bounds.- Overrides:
onMouseScrollin classWWidget- Parameters:
x- 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.- Returns:
InputResult.PROCESSEDif the event is handled,InputResult.IGNOREDotherwise.
-
validate
Description copied from class:WPanelCreates 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.
-