libgdx API

com.badlogic.gdx.scenes.scene2d.ui
Class ScrollPane

java.lang.Object
  extended by com.badlogic.gdx.scenes.scene2d.Actor
      extended by com.badlogic.gdx.scenes.scene2d.Group
          extended by com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
              extended by com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
All Implemented Interfaces:
Cullable, Layout

public class ScrollPane
extends WidgetGroup

A group that scrolls a child widget using scroll bars.

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.

Author:
mzechner, Nathan Sweet

Nested Class Summary
static class ScrollPane.ScrollPaneStyle
          The style for a scroll pane, see ScrollPane.
 
Field Summary
 
Fields inherited from class com.badlogic.gdx.scenes.scene2d.Group
batchTransform, children, cullingArea, debug, debugTexture, groups, immutableChildren, immutableGroups, lastTouchedChild, localTransform, namesToActors, oldBatchTransform, point, transform, worldTransform
 
Fields inherited from class com.badlogic.gdx.scenes.scene2d.Actor
actions, color, height, name, originX, originY, parent, rotation, scaleX, scaleY, stage, touchable, visible, width, x, y
 
Constructor Summary
ScrollPane(Actor widget, ScrollPane.ScrollPaneStyle style)
           
ScrollPane(Actor widget, ScrollPane.ScrollPaneStyle style, java.lang.String name)
           
ScrollPane(Actor widget, Skin skin)
           
ScrollPane(Skin skin)
           
 
Method Summary
 void addActor(Actor actor)
          Adds an Actor to this Group.
 void addActorAt(int index, Actor actor)
          Adds an Actor at the given index in the group.
 void addActorBefore(Actor actorBefore, Actor actor)
          Adds an Actor before the given Actor.
 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 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.
 Actor hit(float x, float y)
           
 void layout()
          Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child and calls Layout.invalidate() and then Layout.validate() on each one.
 void removeActor(Actor actor)
          Removes an Actor from this Group.
 void removeActorRecursive(Actor actor)
          Removes an Actor from this Group recursively by checking if the Actor is in this group or one of its child-groups.
 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 setStyle(ScrollPane.ScrollPaneStyle style)
           
 void setWidget(Actor widget)
          Sets the Actor embedded in this scroll pane.
 boolean touchDown(float x, float y, int pointer)
           
 void touchDragged(float x, float y, int pointer)
           
 void touchUp(float x, float y, int pointer)
           
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
childrenChanged, getMaxHeight, getMaxWidth, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, validate
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Group
act, addActorAfter, applyTransform, clear, disableDebugging, drawChild, drawChildren, enableDebugging, findActor, getActors, getGroups, isDescendant, resetTransform, setCullingArea, sortChildren, swapActor, swapActor, toChildCoordinates, toLocalCoordinates, touchMoved, updateTransform
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
action, clearActions, getStage, isMarkedToRemove, keyDown, keyTyped, keyUp, markToRemove, remove, scrolled, toLocalCoordinates, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScrollPane

public ScrollPane(Skin skin)

ScrollPane

public ScrollPane(Actor widget,
                  Skin skin)
Parameters:
widget - May be null.

ScrollPane

public ScrollPane(Actor widget,
                  ScrollPane.ScrollPaneStyle style)
Parameters:
widget - May be null.

ScrollPane

public ScrollPane(Actor widget,
                  ScrollPane.ScrollPaneStyle style,
                  java.lang.String name)
Parameters:
widget - May be null.
Method Detail

setStyle

public void setStyle(ScrollPane.ScrollPaneStyle style)

getStyle

public ScrollPane.ScrollPaneStyle getStyle()
Returns the scroll pane's style. Modifying the returned style may not have an effect until setStyle(ScrollPaneStyle) is called.


layout

public void layout()
Description copied from interface: Layout
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child and calls Layout.invalidate() and then Layout.validate() on each one. Usually this should not be called directly, instead Layout.validate() should be used.

Specified by:
layout in interface Layout
Overrides:
layout in class WidgetGroup

draw

public void draw(SpriteBatch batch,
                 float parentAlpha)
Description copied from class: WidgetGroup
If this method is overridden, the super method or WidgetGroup.validate() should be called to ensure the widget group is laid out.

Overrides:
draw in class WidgetGroup
Parameters:
batch - the spritebatch to render with
parentAlpha - the parent's alpha value.

getPrefWidth

public float getPrefWidth()

getPrefHeight

public float getPrefHeight()

getMinWidth

public float getMinWidth()
Specified by:
getMinWidth in interface Layout
Overrides:
getMinWidth in class WidgetGroup

getMinHeight

public float getMinHeight()
Specified by:
getMinHeight in interface Layout
Overrides:
getMinHeight in class WidgetGroup

touchDown

public boolean touchDown(float x,
                         float y,
                         int pointer)
Overrides:
touchDown in class Group

touchUp

public void touchUp(float x,
                    float y,
                    int pointer)
Overrides:
touchUp in class Actor

touchDragged

public void touchDragged(float x,
                         float y,
                         int pointer)
Overrides:
touchDragged in class Actor

setWidget

public void setWidget(Actor widget)
Sets the Actor embedded in this scroll pane.

Parameters:
widget - the Actor

addActor

public void addActor(Actor actor)
Description copied from class: Group
Adds an Actor to this Group. The order Actors are added is reversed for hit testing.

Overrides:
addActor in class Group
Parameters:
actor - the Actor

addActorAt

public void addActorAt(int index,
                       Actor actor)
Description copied from class: Group
Adds an Actor at the given index in the group. The first Actor added will be at index 0 and so on. Throws an IndexOutOfBoundsException in case the index is invalid.

Overrides:
addActorAt in class Group
Parameters:
index - the index to add the actor at.

addActorBefore

public void addActorBefore(Actor actorBefore,
                           Actor actor)
Description copied from class: Group
Adds an Actor before the given Actor.

Overrides:
addActorBefore in class Group
Parameters:
actorBefore - the Actor to add the other actor in front of
actor - the Actor to add

removeActor

public void removeActor(Actor actor)
Description copied from class: Group
Removes an Actor from this Group.

Overrides:
removeActor in class Group

removeActorRecursive

public void removeActorRecursive(Actor actor)
Description copied from class: Group
Removes an Actor from this Group recursively by checking if the Actor is in this group or one of its child-groups.

Overrides:
removeActorRecursive in class Group
Parameters:
actor - the Actor

hit

public Actor hit(float x,
                 float y)
Overrides:
hit in class Group

setScrollX

public void setScrollX(float pixels)

getScrollX

public float getScrollX()
Returns the x scroll position in pixels.


setScrollY

public void setScrollY(float pixels)

getScrollY

public float getScrollY()
Returns the y scroll position in pixels.


getScrollPercentX

public float getScrollPercentX()

setScrollPercentX

public void setScrollPercentX(float percentX)

getScrollPercentY

public float getScrollPercentY()

setScrollPercentY

public void setScrollPercentY(float percentY)

getMaxX

public float getMaxX()
Returns the maximum scroll value in the x direction.


getMaxY

public float getMaxY()
Returns the maximum scroll value in the y direction.


setScrollingDisabled

public void setScrollingDisabled(boolean x,
                                 boolean y)
Disables scrolling in a direction. The widget will be sized to the FlickScrollPane in the disabled direction.


libgdx API

Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)