|
||||||||||
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,
String styleName)
|
Method Summary | |
---|---|
void |
act(float delta)
Updates the actor based on time. |
void |
addActor(Actor actor)
Deprecated. ScrollPane may have only a single child. |
void |
addActorAfter(Actor actorAfter,
Actor actor)
Deprecated. ScrollPane may have only a single child. |
void |
addActorAt(int index,
Actor actor)
Deprecated. ScrollPane may have only a single child. |
void |
addActorBefore(Actor actorBefore,
Actor actor)
Deprecated. ScrollPane may have only a single child. |
void |
cancel()
If currently scrolling by tracking a touch down, stop scrolling. |
void |
draw(Batch 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. |
void |
fling(float flingTime,
float velocityX,
float velocityY)
Generate fling gesture. |
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 |
getScrollHeight()
Returns the height of the scrolled viewport. |
float |
getScrollPercentX()
|
float |
getScrollPercentY()
|
float |
getScrollWidth()
Returns the width of the scrolled viewport. |
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. |
boolean |
getVariableSizeKnobs()
|
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 |
isForceScrollX()
|
boolean |
isForceScrollY()
|
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. |
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 |
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. |
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 |
setScrollBarPositions(boolean bottom,
boolean right)
Set the position of the vertical and horizontal scroll bars (if they exist). |
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 |
setVariableSizeKnobs(boolean variableSizeKnobs)
If true, the scroll knobs are sized based on getMaxX() or getMaxY() . |
void |
setVelocityX(float velocityX)
|
void |
setVelocityY(float velocityY)
|
void |
setWidget(Actor widget)
Sets the Actor embedded in this scroll pane. |
void |
updateVisualScroll()
Sets the visual scroll amount equal to the scroll amount. |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup |
---|
getMaxHeight, getMaxWidth, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, validate |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Group |
---|
clear, clearChildren, findActor, getChildren, hasChildren, isTransform, localToDescendantCoordinates, print, setCullingArea, setTransform, swapActor, swapActor |
Methods inherited from class java.lang.Object |
---|
equals, 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, String styleName)
widget
- May be null.public ScrollPane(Actor widget, ScrollPane.ScrollPaneStyle style)
widget
- May be null.Method Detail |
---|
public void cancel()
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(Batch batch, float parentAlpha)
WidgetGroup
WidgetGroup.validate()
should be called to ensure the widget group is laid
out.
draw
in class WidgetGroup
parentAlpha
- Should be multiplied with the actor's alpha, allowing a parent's alpha to affect all children.public void fling(float flingTime, float velocityX, float velocityY)
flingTime
- Time in seconds for which you want to fling last.velocityX
- Velocity for horizontal direction.velocityY
- Velocity for vertical direction.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
setWidget(Actor)
public void addActorAt(int index, Actor actor)
Group
addActorAt
in class Group
index
- May be greater than the number of children.setWidget(Actor)
public void addActorBefore(Actor actorBefore, Actor actor)
Group
addActorBefore
in class Group
setWidget(Actor)
public void addActorAfter(Actor actorAfter, Actor actor)
Group
addActorAfter
in class Group
setWidget(Actor)
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, 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 Group
touchable
- If true, the hit detection will respect the touchability
.Touchable
public void setScrollX(float pixels)
public float getScrollX()
public void setScrollY(float pixels)
public float getScrollY()
public void updateVisualScroll()
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 float getScrollWidth()
public float getScrollHeight()
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 setForceScroll(boolean x, boolean y)
public boolean isForceScrollX()
public boolean isForceScrollY()
public void setFlingTime(float flingTime)
public void setClamp(boolean clamp)
public void setScrollBarPositions(boolean bottom, boolean right)
bottom
- sets horizontal scroll bar to be at the bottom or the topright
- sets vertical scroll bar to be at the right or the leftpublic 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 boolean getVariableSizeKnobs()
public void setVariableSizeKnobs(boolean variableSizeKnobs)
getMaxX()
or getMaxY()
. If false, the scroll knobs are sized
based on Drawable.getMinWidth()
or Drawable.getMinHeight()
. Default is true.
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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |