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.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 TypeMethodDescriptionReturns this scroll panel's horizontal scroll bar.Returns the layout insets used for the viewed widget.Returns this scroll panel's vertical scroll bar.net.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 horizontalAmount, double verticalAmount) Notifies this widget that the mouse has been scrolled inside its bounds.voidpaint(DrawContext context, int x, int y, int mouseX, int mouseY) Paints this widget.setHorizontalScrollBar(WScrollBar horizontalScrollBar) Sets this scroll panel's horizontal scroll bar.Sets the layout insets used for the viewed widget.setScrollingHorizontally(net.fabricmc.fabric.api.util.TriState scrollingHorizontally) setScrollingVertically(net.fabricmc.fabric.api.util.TriState scrollingVertically) setVerticalScrollBar(WScrollBar verticalScrollBar) Sets this scroll panel's vertical scroll bar.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, expandToFit, expandToFit, getBackgroundPainter, hit, onHidden, onShown, remove, setBackgroundPainter, setHost, streamChildren, tick, toStringMethods 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, onMouseUp, releaseFocus, renderTooltip, requestFocus, setHovered, setLocation, setParent, setSize, shouldRenderInDarkMode
-
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
-
getHorizontalScrollBar
Returns this scroll panel's horizontal scroll bar.- Returns:
- the horizontal scroll bar
- Since:
- 9.1.0
-
setHorizontalScrollBar
Sets this scroll panel's horizontal scroll bar.- Parameters:
horizontalScrollBar- the new horizontal scroll bar- Returns:
- this scroll panel
- Throws:
NullPointerException- if the horizontalScrollBar is null- Since:
- 9.1.0
-
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) -
getVerticalScrollBar
Returns this scroll panel's vertical scroll bar.- Returns:
- the vertical scroll bar
- Since:
- 9.1.0
-
setVerticalScrollBar
Sets this scroll panel's vertical scroll bar.- Parameters:
verticalScrollBar- the new vertical scroll bar- Returns:
- this scroll panel
- Throws:
NullPointerException- if the verticalScrollBar is null- Since:
- 9.1.0
-
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
Description copied from class:WWidgetPaints this widget. -
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)horizontalAmount- The scrolled horizontal amount. Positive values are right and negative values are left.verticalAmount- The scrolled vertical 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. -
getInsets
Returns the layout insets used for the viewed widget.- Returns:
- the layout insets used for the viewed widget
- Since:
- 9.1.0
-
setInsets
Sets the layout insets used for the viewed widget.- Parameters:
insets- the layout insets- Returns:
- this scroll panel
- Since:
- 9.1.0
-