|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.Group
com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
public class ScrollPane
A group that scrolls a child widget using scrollbars and/or mouse or touch dragging.
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.
Nested Class Summary | |
---|---|
static class |
ScrollPane.ScrollPaneStyle
The style for a scroll pane, see ScrollPane . |
Constructor Summary | |
---|---|
ScrollPane(Actor widget)
|
|
ScrollPane(Actor widget,
ScrollPane.ScrollPaneStyle style)
|
|
ScrollPane(Actor widget,
Skin skin)
|
|
ScrollPane(Actor widget,
Skin skin,
java.lang.String styleName)
|
Method Summary | |
---|---|
void |
act(float delta)
Updates the actor based on time. |
void |
addActor(Actor actor)
Adds an actor as a child of this group. |
void |
addActorAt(int index,
Actor actor)
Adds an actor as a child of this group, at a specific index. |
void |
addActorBefore(Actor actorBefore,
Actor actor)
Adds an actor as a child of this group, immediately before another child 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 |
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)
Returns the deepest actor that contains the specified point and is touchable and
visible , or null if no actor was hit. |
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. |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup |
---|
childrenChanged, getMaxHeight, getMaxWidth, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, validate |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Group |
---|
addActorAfter, applyTransform, clear, computeTransform, drawChildren, findActor, getChildren, isTransform, localToDescendantCoordinates, resetTransform, setCullingArea, setStage, setTransform, swapActor, swapActor |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor |
---|
addAction, addCaptureListener, addListener, clearActions, 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, translate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ScrollPane(Actor widget)
widget
- May be null.public ScrollPane(Actor widget, Skin skin)
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.Method Detail |
---|
public void setStyle(ScrollPane.ScrollPaneStyle style)
public ScrollPane.ScrollPaneStyle getStyle()
setStyle(ScrollPaneStyle)
is called.
public void act(float delta)
Actor
Stage.act(float)
.
The default implementation calls Action.act(float)
on each action and removes actions that are complete.
act
in class Group
delta
- Time in seconds since the last frame.public void layout()
Layout
Layout.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 Layout
layout
in class WidgetGroup
public void draw(SpriteBatch batch, float parentAlpha)
WidgetGroup
WidgetGroup.validate()
should be called to ensure the widget group is laid
out.
draw
in class WidgetGroup
parentAlpha
- Should be multipied with the actor's alpha, allowing a parent's alpha to affect all children.public float getPrefWidth()
getPrefWidth
in interface Layout
getPrefWidth
in class WidgetGroup
public float getPrefHeight()
getPrefHeight
in interface Layout
getPrefHeight
in class WidgetGroup
public float getMinWidth()
getMinWidth
in interface Layout
getMinWidth
in class WidgetGroup
public float getMinHeight()
getMinHeight
in interface Layout
getMinHeight
in class WidgetGroup
public 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)
Group
addActor
in class Group
Actor.remove()
public void addActorAt(int index, Actor actor)
Group
addActorAt
in class Group
index
- May be greater than the number of children.public void addActorBefore(Actor actorBefore, Actor actor)
Group
addActorBefore
in class Group
public boolean removeActor(Actor actor)
Group
cleared
so the actions will be returned to their
pool
, if any. This is not done automatically.
removeActor
in class Group
public Actor hit(float x, float y, boolean touchable)
Actor
touchable
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 events. If this method returns null, touchDown will not occur.
The default implementation returns this actor if the point is within this actor's bounds.
hit
in class Group
touchable
- If true, the hit detection will respect the touchability
.Touchable
protected 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.
|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |