public class ScrollPane extends WidgetGroup
The widget is sized to its preferred size. If the widget's preferred width or height is less than the size of this scroll pane, it is set to the size of this scroll pane. Scrollbars appear when the widget is larger than the scroll pane.
The scroll pane's preferred size is that of the child widget. At this size, the child widget will not need to scroll, so the scroll pane is typically sized by ignoring the preferred size in one or both directions.
| Modifier and Type | Class and Description |
|---|---|
static class |
ScrollPane.ScrollPaneStyle
The style for a scroll pane, see
ScrollPane. |
| Constructor and Description |
|---|
ScrollPane(Actor widget) |
ScrollPane(Actor widget,
ScrollPane.ScrollPaneStyle style) |
ScrollPane(Actor widget,
Skin skin) |
ScrollPane(Actor widget,
Skin skin,
java.lang.String styleName) |
| Modifier and Type | Method and Description |
|---|---|
void |
act(float delta)
Updates the actor based on time.
|
void |
addActor(Actor actor)
Deprecated.
|
void |
addActorAfter(Actor actorAfter,
Actor actor)
Deprecated.
|
void |
addActorAt(int index,
Actor actor)
Deprecated.
|
void |
addActorBefore(Actor actorBefore,
Actor actor)
Deprecated.
|
void |
draw(SpriteBatch batch,
float parentAlpha)
If this method is overridden, the super method or
WidgetGroup.validate() should be called to ensure the widget group is laid
out. |
float |
getMaxX()
Returns the maximum scroll value in the x direction.
|
float |
getMaxY()
Returns the maximum scroll value in the y direction.
|
float |
getMinHeight() |
float |
getMinWidth() |
float |
getPrefHeight() |
float |
getPrefWidth() |
float |
getScrollBarHeight() |
float |
getScrollBarWidth() |
float |
getScrollPercentX() |
float |
getScrollPercentY() |
float |
getScrollX()
Returns the x scroll position in pixels.
|
float |
getScrollY()
Returns the y scroll position in pixels.
|
ScrollPane.ScrollPaneStyle |
getStyle()
Returns the scroll pane's style.
|
float |
getVelocityX()
Gets the flick scroll y velocity.
|
float |
getVelocityY()
Gets the flick scroll y velocity.
|
float |
getVisualScrollX() |
float |
getVisualScrollY() |
Actor |
getWidget()
Returns the actor embedded in this scroll pane, or null.
|
Actor |
hit(float x,
float y,
boolean touchable)
|
boolean |
isDragging() |
boolean |
isFlinging() |
boolean |
isPanning() |
boolean |
isScrollX() |
boolean |
isScrollY() |
void |
layout()
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child,
calls
Layout.invalidate() any each child whose width or height has changed, and calls Layout.validate() on each child. |
boolean |
removeActor(Actor actor)
Removes an actor from this group.
|
void |
scrollTo(float x,
float y,
float width,
float height)
Sets the scroll offset so the specified rectangle is fully in view, if possible.
|
void |
scrollToCenter(float x,
float y,
float width,
float height)
Sets the scroll offset so the specified rectangle is fully in view and centered vertically in the scroll pane, if possible.
|
protected void |
scrollX(float pixelsX)
Called whenever the x scroll amount is changed.
|
protected void |
scrollY(float pixelsY)
Called whenever the y scroll amount is changed.
|
void |
setCancelTouchFocus(boolean cancelTouchFocus)
When true (default), the
Stage.cancelTouchFocus() touch focus} is cancelled when flick scrolling begins. |
void |
setClamp(boolean clamp)
For flick scroll, prevents scrolling out of the widget's bounds.
|
void |
setFadeScrollBars(boolean fadeScrollBars)
When true the scroll bars fade out after some time of not being used.
|
void |
setFlickScroll(boolean flickScroll) |
void |
setFlingTime(float flingTime)
For flick scroll, sets the amount of time in seconds that a fling will continue to scroll.
|
void |
setForceOverscroll(boolean x,
boolean y)
For flick scroll, forces the enabling of overscrolling in a direction, even if the contents do not exceed the bounds in that
direction.
|
void |
setOverscroll(boolean overscrollX,
boolean overscrollY)
For flick scroll, if true the widget can be scrolled slightly past its bounds and will animate back to its bounds when
scrolling is stopped.
|
void |
setScrollbarsOnTop(boolean scrollbarsOnTop)
When false (the default), the widget is clipped so it is not drawn under the scrollbars.
|
void |
setScrollingDisabled(boolean x,
boolean y)
Disables scrolling in a direction.
|
void |
setScrollPercentX(float percentX) |
void |
setScrollPercentY(float percentY) |
void |
setScrollX(float pixels) |
void |
setScrollY(float pixels) |
void |
setSmoothScrolling(boolean smoothScrolling) |
void |
setStyle(ScrollPane.ScrollPaneStyle style) |
void |
setupFadeScrollBars(float fadeAlphaSeconds,
float fadeDelaySeconds) |
void |
setupOverscroll(float distance,
float speedMin,
float speedMax)
For flick scroll, sets the overscroll distance in pixels and the speed it returns to the widget's bounds in seconds.
|
void |
setVelocityX(float velocityX) |
void |
setVelocityY(float velocityY) |
void |
setWidget(Actor widget)
Sets the
Actor embedded in this scroll pane. |
protected void |
visualScrollX(float pixelsX)
Called whenever the visual x scroll amount is changed.
|
protected void |
visualScrollY(float pixelsY)
Called whenever the visual y scroll amount is changed.
|
childrenChanged, getMaxHeight, getMaxWidth, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, validateapplyTransform, clear, clearChildren, computeTransform, drawChildren, findActor, getChildren, hasChildren, isTransform, localToDescendantCoordinates, print, resetTransform, setCullingArea, setStage, setTransform, swapActor, swapActoraddAction, addCaptureListener, addListener, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, fire, getActions, getCaptureListeners, getColor, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getWidth, getX, getY, getZIndex, hasParent, isAscendantOf, isDescendantOf, isVisible, localToAscendantCoordinates, localToParentCoordinates, localToStageCoordinates, notify, parentToLocalCoordinates, remove, removeAction, removeCaptureListener, removeListener, rotate, scale, scale, screenToLocalCoordinates, setBounds, setColor, setColor, setHeight, setName, setOrigin, setOriginX, setOriginY, setParent, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setVisible, setWidth, setX, setY, setZIndex, size, size, stageToLocalCoordinates, toBack, toFront, toString, translatepublic ScrollPane(Actor widget)
widget - May be null.public ScrollPane(Actor widget, Skin skin, java.lang.String styleName)
widget - May be null.public ScrollPane(Actor widget, ScrollPane.ScrollPaneStyle style)
widget - May be null.public void setStyle(ScrollPane.ScrollPaneStyle style)
public ScrollPane.ScrollPaneStyle getStyle()
setStyle(ScrollPaneStyle) is called.public void act(float delta)
ActorStage.act(float).
The default implementation calls Action.act(float) on each action and removes actions that are complete.
public void layout()
LayoutLayout.invalidate() any each child whose width or height has changed, and calls Layout.validate() on each child.
This method should almost never be called directly, instead Layout.validate() should be used.layout in interface Layoutlayout in class WidgetGrouppublic void draw(SpriteBatch batch, float parentAlpha)
WidgetGroupWidgetGroup.validate() should be called to ensure the widget group is laid
out.draw in class WidgetGroupparentAlpha - Should be multiplied with the actor's alpha, allowing a parent's alpha to affect all children.public float getPrefWidth()
getPrefWidth in interface LayoutgetPrefWidth in class WidgetGrouppublic float getPrefHeight()
getPrefHeight in interface LayoutgetPrefHeight in class WidgetGrouppublic float getMinWidth()
getMinWidth in interface LayoutgetMinWidth in class WidgetGrouppublic float getMinHeight()
getMinHeight in interface LayoutgetMinHeight in class WidgetGrouppublic void setWidget(Actor widget)
Actor embedded in this scroll pane.widget - May be null to remove any current actor.public Actor getWidget()
public void addActor(Actor actor)
GroupaddActor in class GroupActor.remove()public void addActorAt(int index,
Actor actor)
GroupaddActorAt in class Groupindex - May be greater than the number of children.public void addActorBefore(Actor actorBefore, Actor actor)
GroupaddActorBefore in class Grouppublic void addActorAfter(Actor actorAfter, Actor actor)
GroupaddActorAfter in class Grouppublic boolean removeActor(Actor actor)
Groupcleared so the actions will be returned to their
pool, if any. This is not done automatically.removeActor in class Grouppublic Actor hit(float x, float y, boolean touchable)
Actortouchable and
visible, or null if no actor was hit. The point is specified in the actor's local coordinate system (0,0
is the bottom left of the actor and width,height is the upper right).
This method is used to delegate touchDown, mouse, and enter/exit events. If this method returns null, those events will not occur on this Actor.
The default implementation returns this actor if the point is within this actor's bounds.
hit in class Grouptouchable - If true, the hit detection will respect the touchability.Touchableprotected void scrollX(float pixelsX)
protected void scrollY(float pixelsY)
protected void visualScrollX(float pixelsX)
protected void visualScrollY(float pixelsY)
public void setScrollX(float pixels)
public float getScrollX()
public void setScrollY(float pixels)
public float getScrollY()
public float getVisualScrollX()
public float getVisualScrollY()
public float getScrollPercentX()
public void setScrollPercentX(float percentX)
public float getScrollPercentY()
public void setScrollPercentY(float percentY)
public void setFlickScroll(boolean flickScroll)
public void scrollTo(float x,
float y,
float width,
float height)
public void scrollToCenter(float x,
float y,
float width,
float height)
public float getMaxX()
public float getMaxY()
public float getScrollBarHeight()
public float getScrollBarWidth()
public boolean isScrollX()
public boolean isScrollY()
public void setScrollingDisabled(boolean x,
boolean y)
public boolean isDragging()
public boolean isPanning()
public boolean isFlinging()
public void setVelocityX(float velocityX)
public float getVelocityX()
public void setVelocityY(float velocityY)
public float getVelocityY()
public void setOverscroll(boolean overscrollX,
boolean overscrollY)
public void setupOverscroll(float distance,
float speedMin,
float speedMax)
public void setForceOverscroll(boolean x,
boolean y)
public void setFlingTime(float flingTime)
public void setClamp(boolean clamp)
public void setFadeScrollBars(boolean fadeScrollBars)
public void setupFadeScrollBars(float fadeAlphaSeconds,
float fadeDelaySeconds)
public void setSmoothScrolling(boolean smoothScrolling)
public void setScrollbarsOnTop(boolean scrollbarsOnTop)
setFadeScrollBars(boolean) is
true, the scroll bars are always drawn on top.public void setCancelTouchFocus(boolean cancelTouchFocus)
Stage.cancelTouchFocus() touch focus} is cancelled when flick scrolling begins. This causes
widgets inside the scrollpane that have received touchDown to receive touchUp when flick scrolling begins.