APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.badlogic.gdx.scenes.scene2d.ui

public Class ScrollPane

extends WidgetGroup
implements Styleable<ScrollPane.ScrollPaneStyle>
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.scenes.scene2d.ui.Styleable
Known Direct Subclasses
com.badlogic.gdx.scenes.scene2d.ui.SelectBox.SelectBoxScrollPane
Imports
com.badlogic.gdx.Gdx, com.badlogic.gdx.graphics.Color, com.badlogic.gdx.graphics.g2d.Batch, com.badlogic.gdx.graphics.glutils.ShapeRenderer, com.badlogic.gdx.math.Interpolation, .MathUtils, .Rectangle, .Vector2, com.badlogic.gdx.scenes.scene2d.Actor, .Event, .InputEvent, .InputListener, .Stage, .Touchable, com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener, .Cullable, .Drawable, .Layout, com.badlogic.gdx.utils.Null

A group that scrolls a child actor using scrollbars and/or mouse or touch dragging.

The actor is sized to its preferred size. If the actor'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 actor is larger than the scroll pane.

The scroll pane's preferred size is that of the child actor. At this size, the child actor will not need to scroll, so the scroll pane is typically sized by ignoring the preferred size in one or both directions.

If the scroll pane contains widgets that respond to drag, a listener that calls Event#stop() in touchDown can be added to the widgets to prevent the scroll pane from panning when setScrollBarTouch(boolean) is true.

Authors
mzechner, Nathan Sweet

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ScrollPane.ScrollPaneStyle

The style for a scroll pane, see ScrollPane.

Field Summary

Modifier and TypeField and Description
private Actor
pack-priv final Rectangle
private final Rectangle
pack-priv float
pack-priv float
pack-priv boolean
private boolean
pack-priv boolean
pack-priv boolean
pack-priv int
pack-priv float
pack-priv float
pack-priv float
pack-priv float
pack-priv boolean
pack-priv boolean
private ActorGestureListener
pack-priv float
pack-priv float
private boolean
private boolean
pack-priv final Rectangle
pack-priv final Rectangle
pack-priv boolean
pack-priv final Vector2
pack-priv float
pack-priv float
private float
private float
private float
private boolean
private boolean
private boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
private ScrollPane.ScrollPaneStyle
pack-priv boolean
pack-priv boolean
private boolean
pack-priv float
pack-priv float
pack-priv float
pack-priv float
pack-priv final Rectangle
pack-priv final Rectangle
pack-priv boolean

Constructor Summary

AccessConstructor and Description
public
ScrollPane(Actor
May be null.
actor
)

public
ScrollPane(Actor
May be null.
actor
,
Skin skin)

public
ScrollPane(Actor
May be null.
actor
,
Skin skin, String styleName)

public
ScrollPane(Actor
May be null.
actor
,
ScrollPane.ScrollPaneStyle style)

Method Summary

Modifier and TypeMethod and Description
public void
act(float delta)

Overrides com.badlogic.gdx.scenes.scene2d.Group.act.

Updates the actor based on time.

public void
addActor(Actor actor)

Overrides com.badlogic.gdx.scenes.scene2d.Group.addActor.

Deprecated ScrollPane may have only a single child.

Adds an actor as a child of this group, removing it from its previous parent.

public void
addActorAfter(Actor actorAfter, Actor actor)

Overrides com.badlogic.gdx.scenes.scene2d.Group.addActorAfter.

Deprecated ScrollPane may have only a single child.

Adds an actor as a child of this group immediately after another child actor, removing it from its previous parent.

public void
addActorAt(int index, Actor actor)

Overrides com.badlogic.gdx.scenes.scene2d.Group.addActorAt.

Deprecated ScrollPane may have only a single child.

Adds an actor as a child of this group at a specific index, removing it from its previous parent.

public void
addActorBefore(Actor actorBefore, Actor actor)

Overrides com.badlogic.gdx.scenes.scene2d.Group.addActorBefore.

Deprecated ScrollPane may have only a single child.

Adds an actor as a child of this group immediately before another child actor, removing it from its previous parent.

protected void
protected void
public void
cancel()

If currently scrolling by tracking a touch down, stop scrolling.

public void
cancelTouchFocus()

Cancels the stage's touch focus for all listeners except this scroll pane's flick scroll listener.

pack-priv void
public void
draw(Batch batch, float parentAlpha)

Overrides com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup.draw.

If this method is overridden, the super method or validate() should be called to ensure the widget group is laid out.

public void
drawDebug(ShapeRenderer shapes)

Overrides com.badlogic.gdx.scenes.scene2d.Group.drawDebug.

Draws this actor's debug lines if getDebug() is true and, regardless of getDebug(), calls Actor#drawDebug(ShapeRenderer) on each child.

protected void
drawScrollBars(Batch batch, float r, float g, float b, float a)

Renders the scrollbars after the children have been drawn.

public void
fling(float
Time in seconds for which you want to fling last.
flingTime
,
float
Velocity for horizontal direction.
velocityX
,
float
Velocity for vertical direction.
velocityY
)

Generate fling gesture.

public Actor
getActor()

Returns the actor embedded in this scroll pane, or null.

public boolean
protected ActorGestureListener
getFlickScrollListener()

Called by constructor.

public float
getMaxX()

Returns the maximum scroll value in the x direction.

public float
getMaxY()

Returns the maximum scroll value in the y direction.

public float
public float
protected float
getMouseWheelX()

Returns the amount to scroll horizontally when the mouse wheel is scrolled.

protected float
getMouseWheelY()

Returns the amount to scroll vertically when the mouse wheel is scrolled.

public float
public float
public float
public float
public float
public float
getScrollHeight()

Returns the height of the scrolled viewport.

public float
public float
public float
getScrollWidth()

Returns the width of the scrolled viewport.

public float
getScrollX()

Returns the x scroll position in pixels, where 0 is the left of the scroll pane.

public float
getScrollY()

Returns the y scroll position in pixels, where 0 is the top of the scroll pane.

public ScrollPane.ScrollPaneStyle
getStyle()

Implements com.badlogic.gdx.scenes.scene2d.ui.Styleable.getStyle.

Returns the scroll pane's style.

public boolean
public float
getVelocityX()

Gets the flick scroll x velocity.

public float
getVelocityY()

Gets the flick scroll y velocity.

public float
public float
public float
public float
public Actor
getWidget()
Deprecated Use getActor().

public Actor
hit(float x, float y, boolean touchable)

Overrides com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup.hit.

If this method is overridden, the super method or validate() should be called to ensure the widget group is laid out.

public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
isScrollX()

Returns true if the actor is larger than the scroll pane horizontally.

public boolean
isScrollY()

Returns true if the actor is larger than the scroll pane vertically.

public boolean
public void
layout()

Overrides com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup.layout.

Implements com.badlogic.gdx.scenes.scene2d.utils.Layout.layout.

Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, calls invalidate() on any each child whose width or height has changed, and calls validate() on each child.

public boolean
removeActor(Actor actor)

Overrides com.badlogic.gdx.scenes.scene2d.Group.removeActor.

Removes an actor from this group and unfocuses it.

public boolean
removeActor(Actor actor, boolean unfocus)

Overrides com.badlogic.gdx.scenes.scene2d.Group.removeActor.

Removes an actor from this group.

public Actor
removeActorAt(int index, boolean unfocus)

Overrides com.badlogic.gdx.scenes.scene2d.Group.removeActorAt.

Removes an actor from this group.

public void
scrollTo(float x, float y, float width, float height)

Sets the scroll offset so the specified rectangle is fully in view, if possible.

public void
scrollTo(float x, float y, float width, float height, boolean centerHorizontal, boolean centerVertical)

Sets the scroll offset so the specified rectangle is fully in view, and optionally centered vertically and/or horizontally, 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.

public void
setActor(Actor
May be null to remove any current actor.
actor
)

Sets the Actor embedded in this scroll pane.

public void
setCancelTouchFocus(boolean cancelTouchFocus)

When true (default) and flick scrolling begins, cancelTouchFocus() is called.

public void
setClamp(boolean clamp)

For flick scroll, prevents scrolling out of the actor's bounds.

public void
setFadeScrollBars(boolean fadeScrollBars)

When true the scrollbars don't reduce the scrollable size and fade out after some time of not being used.

public void
setFlickScroll(boolean flickScroll)

public void
setFlickScrollTapSquareSize(float halfTapSquareSize)

public void
setFlingTime(float flingTime)

For flick scroll, sets the amount of time in seconds that a fling will continue to scroll.

public void
setForceScroll(boolean x, boolean y)

Forces enabling scrollbars (for non-flick scroll) and overscrolling (for flick scroll) in a direction, even if the contents do not exceed the bounds in that direction.

public void
setOverscroll(boolean overscrollX, boolean overscrollY)

For flick scroll, if true the actor can be scrolled slightly past its bounds and will animate back to its bounds when scrolling is stopped.

public void
setScrollBarPositions(boolean bottom, boolean right)

Set the position of the vertical and horizontal scroll bars.

public void
setScrollbarsOnTop(boolean scrollbarsOnTop)

When false (the default), the actor is clipped so it is not drawn under the scrollbars.

public void
setScrollbarsVisible(boolean visible)

Shows or hides the scrollbars for when using setFadeScrollBars(boolean).

public void
setScrollBarTouch(boolean scrollBarTouch)

When false, the scroll bars don't respond to touch or mouse events.

public void
setScrollingDisabled(boolean x, boolean y)

Disables scrolling in a direction.

public void
setScrollPercentX(float percentX)

public void
setScrollPercentY(float percentY)

public void
setScrollX(float pixels)

public void
setScrollY(float pixels)

public void
setSmoothScrolling(boolean smoothScrolling)

When true, the visual scroll position is transitioned to the actual position over time using smoothScroll(float, float).

public void
public void
setupFadeScrollBars(float fadeAlphaSeconds, float fadeDelaySeconds)

public void
setupOverscroll(float distance, float speedMin, float speedMax)

For flick scroll, sets the overscroll distance in pixels and the speed it returns to the actor's bounds in seconds.

public void
setVariableSizeKnobs(boolean variableSizeKnobs)

If true, the scroll knobs are sized based on getMaxX() or getMaxY().

public void
setVelocityX(float velocityX)

public void
setVelocityY(float velocityY)

public void
setWidget(Actor actor)
Deprecated Use setActor(Actor).

protected float
smoothScroll(float
The absolute difference between the visual scroll position and the actual position.
difference
,
float
Time in seconds since last frame.
delta
)

Returns the amount to adjust the visual scroll position each frame.

private void
public void
updateVisualScroll()

Sets the visual scroll amount equal to the scroll amount.

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.

Inherited from com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup:
childrenChangedgetMaxHeightgetMaxWidthinvalidateinvalidateHierarchyneedsLayoutpacksetFillParentsetLayoutEnabledsizeChangedvalidate