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
Modifier and TypeFieldDescriptionprotected WScrollBar
The horizontal scroll bar of this panel.protected WScrollBar
The vertical scroll bar of this panel. -
Constructor Summary
-
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.TriState
Returns whether this scroll panel has a horizontal scroll bar.net.fabricmc.fabric.api.util.TriState
Returns whether this scroll panel has a vertical scroll bar.void
layout()
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.void
paint
(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.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.WPanel
addPainters, canResize, expandToFit, expandToFit, getBackgroundPainter, hit, onHidden, onShown, remove, setBackgroundPainter, setHost, streamChildren, tick, toString
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, 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:WWidget
Paints this widget. -
layout
public void layout()Description copied from class:WPanel
Uses this Panel's layout rules to reposition and resize components to fit nicely in the panel. -
onMouseScroll
Description copied from class:WWidget
Notifies this widget that the mouse has been scrolled inside its bounds.- Overrides:
onMouseScroll
in 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.PROCESSED
if the event is handled,InputResult.IGNORED
otherwise.
-
validate
Description copied from class:WPanel
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. -
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
-