Package com.prineside.tdi2.scene2d.ui
Class ScrollPane
java.lang.Object
com.prineside.tdi2.scene2d.Actor
com.prineside.tdi2.scene2d.Group
com.prineside.tdi2.scene2d.ui.WidgetGroup
com.prineside.tdi2.scene2d.ui.ScrollPane
- Direct Known Subclasses:
SelectBox.SelectBoxScrollPane
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.
- Author:
- mzechner, Nathan Sweet
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionScrollPane
(Actor actor) ScrollPane
(Actor actor, ScrollPane.ScrollPaneStyle style) -
Method Summary
Modifier and TypeMethodDescriptionvoid
act
(float delta) Updates the actor based on time.void
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
Cancels the stage's touch focus for all listeners except this scroll pane's flick scroll listener.void
If this method is overridden, the super method orWidgetGroup.validate()
should be called to ensure the widget group is laid out.void
drawDebug
(ShapeRenderer shapes) Draws this actor's debug lines ifActor.getDebug()
is true and, regardless ofActor.getDebug()
, callsActor.drawDebug(ShapeRenderer)
on each child.void
fling
(float flingTime, float velocityX, float velocityY) Generate fling gesture.getActor()
Returns the actor embedded in this scroll pane, or null.boolean
float
getMaxX()
Returns the maximum scroll value in the x direction.float
getMaxY()
Returns the maximum scroll value in the y direction.float
float
float
float
float
float
float
float
Returns the height of the scrolled viewport.float
float
float
Returns the width of the scrolled viewport.float
Returns the x scroll position in pixels, where 0 is the left of the scroll pane.float
Returns the y scroll position in pixels, where 0 is the top of the scroll pane.getStyle()
Returns the scroll pane's style.boolean
float
Gets the flick scroll x velocity.float
Gets the flick scroll y velocity.float
float
float
float
Deprecated.UsegetActor()
.hit
(float x, float y, boolean touchable) If this method is overridden, the super method orWidgetGroup.validate()
should be called to ensure the widget group is laid out.boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
Returns true if the actor is larger than the scroll pane horizontally.boolean
Returns true if the actor is larger than the scroll pane vertically.boolean
void
layout()
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, callsLayout.invalidate()
on any each child whose width or height has changed, and callsLayout.validate()
on each child.boolean
removeActor
(Actor actor) Removes an actor from this group and unfocuses it.boolean
removeActor
(Actor actor, boolean unfocus) Removes an actor from this group.removeActorAt
(int index, boolean unfocus) 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
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.void
Sets theActor
embedded in this scroll pane.void
setCancelTouchFocus
(boolean cancelTouchFocus) When true (default) and flick scrolling begins,cancelTouchFocus()
is called.void
setClamp
(boolean clamp) For flick scroll, prevents scrolling out of the actor's bounds.void
setFadeScrollBars
(boolean fadeScrollBars) When true the scrollbars don't reduce the scrollable size and fade out after some time of not being used.void
setFlickScroll
(boolean flickScroll) void
setFlickScrollTapSquareSize
(float halfTapSquareSize) 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 actor 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.void
setScrollbarsOnTop
(boolean scrollbarsOnTop) When false (the default), the actor is clipped so it is not drawn under the scrollbars.void
setScrollbarsVisible
(boolean visible) Shows or hides the scrollbars for when usingsetFadeScrollBars(boolean)
.void
setScrollBarTouch
(boolean scrollBarTouch) When false, the scroll bars don't respond to touch or mouse events.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
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 actor's bounds in seconds.void
setVariableSizeKnobs
(boolean variableSizeKnobs) void
setVelocityX
(float velocityX) void
setVelocityY
(float velocityY) void
Deprecated.UsesetActor(Actor)
.void
Sets the visual scroll amount equal to the scroll amount.Methods inherited from class com.prineside.tdi2.scene2d.ui.WidgetGroup
getMaxHeight, getMaxHeightValue, getMaxWidth, getMaxWidthValue, getMinHeightValue, getMinWidthValue, getPrefHeightValue, getPrefWidthValue, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setPrefHeight, setPrefHeight, setPrefWidth, setPrefWidth, setWidth, validate
Methods inherited from class com.prineside.tdi2.scene2d.Group
clear, clear, clearChildren, clearChildren, debugAll, findActor, getChild, getChildren, getCullingArea, hasChildren, isTransform, localToDescendantCoordinates, setCullingArea, setDebug, setTransform, swapActor, swapActor, toString
Methods inherited from class com.prineside.tdi2.scene2d.Actor
addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, remove, removeAction, removeCaptureListener, removeListener, rotateBy, scaleBy, scaleBy, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront
-
Constructor Details
-
ScrollPane
- Parameters:
actor
- May be null.
-
ScrollPane
- Parameters:
actor
- May be null.
-
-
Method Details
-
setScrollbarsVisible
public void setScrollbarsVisible(boolean visible) Shows or hides the scrollbars for when usingsetFadeScrollBars(boolean)
. -
cancelTouchFocus
public void cancelTouchFocus()Cancels the stage's touch focus for all listeners except this scroll pane's flick scroll listener. This causes any actors inside the scrollpane that have received touchDown to receive touchUp.- See Also:
-
cancel
public void cancel()If currently scrolling by tracking a touch down, stop scrolling. -
setStyle
-
getStyle
Returns the scroll pane's style. Modifying the returned style may not have an effect untilsetStyle(ScrollPaneStyle)
is called. -
act
public void act(float delta) Description copied from class:Actor
Updates the actor based on time. Typically this is called each frame byStage.act(float)
.The default implementation calls
Action.act(float)
on each action and removes actions that are complete. -
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, callsLayout.invalidate()
on any each child whose width or height has changed, and callsLayout.validate()
on each child. This method should almost never be called directly, insteadLayout.validate()
should be used.- Specified by:
layout
in interfaceLayout
- Overrides:
layout
in classWidgetGroup
-
draw
Description copied from class:WidgetGroup
If this method is overridden, the super method orWidgetGroup.validate()
should be called to ensure the widget group is laid out.- Overrides:
draw
in classWidgetGroup
parentAlpha
- The parent alpha, to be multiplied with this actor's alpha, allowing the parent's alpha to affect all children.
-
fling
public void fling(float flingTime, float velocityX, float velocityY) Generate fling gesture.- Parameters:
flingTime
- Time in seconds for which you want to fling last.velocityX
- Velocity for horizontal direction.velocityY
- Velocity for vertical direction.
-
getPrefWidth
public float getPrefWidth()- Specified by:
getPrefWidth
in interfaceLayout
- Overrides:
getPrefWidth
in classWidgetGroup
-
getPrefHeight
public float getPrefHeight()- Specified by:
getPrefHeight
in interfaceLayout
- Overrides:
getPrefHeight
in classWidgetGroup
-
getMinWidth
public float getMinWidth()- Specified by:
getMinWidth
in interfaceLayout
- Overrides:
getMinWidth
in classWidgetGroup
-
getMinHeight
public float getMinHeight()- Specified by:
getMinHeight
in interfaceLayout
- Overrides:
getMinHeight
in classWidgetGroup
-
setActor
Sets theActor
embedded in this scroll pane.- Parameters:
actor
- May be null to remove any current actor.
-
getActor
Returns the actor embedded in this scroll pane, or null. -
setWidget
Deprecated.UsesetActor(Actor)
. -
getWidget
Deprecated.UsegetActor()
. -
addActor
Deprecated.ScrollPane may have only a single child.Description copied from class:Group
Adds an actor as a child of this group, removing it from its previous parent. If the actor is already a child of this group, no changes are made. -
addActorAt
Deprecated.ScrollPane may have only a single child.Description copied from class:Group
Adds an actor as a child of this group at a specific index, removing it from its previous parent. If the actor is already a child of this group, no changes are made.- Overrides:
addActorAt
in classGroup
- Parameters:
index
- May be greater than the number of children.- See Also:
-
addActorBefore
Deprecated.ScrollPane may have only a single child.Description copied from class:Group
Adds an actor as a child of this group immediately before another child actor, removing it from its previous parent. If the actor is already a child of this group, no changes are made.- Overrides:
addActorBefore
in classGroup
- See Also:
-
addActorAfter
Deprecated.ScrollPane may have only a single child.Description copied from class:Group
Adds an actor as a child of this group immediately after another child actor, removing it from its previous parent. If the actor is already a child of this group, no changes are made. IfactorAfter
is not in this group, the actor is added as the last child.- Overrides:
addActorAfter
in classGroup
- See Also:
-
removeActor
Description copied from class:Group
Removes an actor from this group and unfocuses it. CallsGroup.removeActor(Actor, boolean)
with true.- Overrides:
removeActor
in classGroup
-
removeActor
Description copied from class:Group
Removes an actor from this group. CallsGroup.removeActorAt(int, boolean)
with the actor's child index.- Overrides:
removeActor
in classGroup
-
removeActorAt
Description copied from class:Group
Removes an actor from this group. If the actor will not be used again and has actions, they should becleared
so the actions will be returned to theirpool
, if any. This is not done automatically.- Overrides:
removeActorAt
in classGroup
unfocus
- If true,Stage.unfocus(Actor)
is called.- Returns:
- the actor removed from this group.
-
hit
Description copied from class:WidgetGroup
If this method is overridden, the super method orWidgetGroup.validate()
should be called to ensure the widget group is laid out.- Overrides:
hit
in classWidgetGroup
touchable
- If true, hit detection will respect thetouchability
.- See Also:
-
setScrollX
public void setScrollX(float pixels) -
getScrollX
public float getScrollX()Returns the x scroll position in pixels, where 0 is the left of the scroll pane. -
setScrollY
public void setScrollY(float pixels) -
getScrollY
public float getScrollY()Returns the y scroll position in pixels, where 0 is the top of the scroll pane. -
updateVisualScroll
public void updateVisualScroll()Sets the visual scroll amount equal to the scroll amount. This can be used when setting the scroll amount without animating. -
getVisualScrollX
public float getVisualScrollX() -
getVisualScrollY
public float getVisualScrollY() -
getVisualScrollPercentX
public float getVisualScrollPercentX() -
getVisualScrollPercentY
public float getVisualScrollPercentY() -
getScrollPercentX
public float getScrollPercentX() -
setScrollPercentX
public void setScrollPercentX(float percentX) -
getScrollPercentY
public float getScrollPercentY() -
setScrollPercentY
public void setScrollPercentY(float percentY) -
setFlickScroll
public void setFlickScroll(boolean flickScroll) -
setFlickScrollTapSquareSize
public void setFlickScrollTapSquareSize(float halfTapSquareSize) -
scrollTo
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. Coordinates are in the scroll pane actor's coordinate system. -
scrollTo
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. Coordinates are in the scroll pane actor's coordinate system. -
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. -
getScrollBarHeight
public float getScrollBarHeight() -
getScrollBarWidth
public float getScrollBarWidth() -
getScrollWidth
public float getScrollWidth()Returns the width of the scrolled viewport. -
getScrollHeight
public float getScrollHeight()Returns the height of the scrolled viewport. -
isScrollX
public boolean isScrollX()Returns true if the actor is larger than the scroll pane horizontally. -
isScrollY
public boolean isScrollY()Returns true if the actor is larger than the scroll pane vertically. -
setScrollingDisabled
public void setScrollingDisabled(boolean x, boolean y) Disables scrolling in a direction. The actor will be sized to the FlickScrollPane in the disabled direction. -
isScrollingDisabledX
public boolean isScrollingDisabledX() -
isScrollingDisabledY
public boolean isScrollingDisabledY() -
isLeftEdge
public boolean isLeftEdge() -
isRightEdge
public boolean isRightEdge() -
isTopEdge
public boolean isTopEdge() -
isBottomEdge
public boolean isBottomEdge() -
isDragging
public boolean isDragging() -
isPanning
public boolean isPanning() -
isFlinging
public boolean isFlinging() -
setVelocityX
public void setVelocityX(float velocityX) -
getVelocityX
public float getVelocityX()Gets the flick scroll x velocity. -
setVelocityY
public void setVelocityY(float velocityY) -
getVelocityY
public float getVelocityY()Gets the flick scroll y velocity. -
setOverscroll
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. Default is true. -
setupOverscroll
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. Default is 50, 30, 200. -
getOverscrollDistance
public float getOverscrollDistance() -
setForceScroll
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. -
isForceScrollX
public boolean isForceScrollX() -
isForceScrollY
public boolean isForceScrollY() -
setFlingTime
public void setFlingTime(float flingTime) For flick scroll, sets the amount of time in seconds that a fling will continue to scroll. Default is 1. -
setClamp
public void setClamp(boolean clamp) For flick scroll, prevents scrolling out of the actor's bounds. Default is true. -
setScrollBarPositions
public void setScrollBarPositions(boolean bottom, boolean right) Set the position of the vertical and horizontal scroll bars. -
setFadeScrollBars
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. -
setupFadeScrollBars
public void setupFadeScrollBars(float fadeAlphaSeconds, float fadeDelaySeconds) -
getFadeScrollBars
public boolean getFadeScrollBars() -
setScrollBarTouch
public void setScrollBarTouch(boolean scrollBarTouch) When false, the scroll bars don't respond to touch or mouse events. Default is true. -
setSmoothScrolling
public void setSmoothScrolling(boolean smoothScrolling) -
setScrollbarsOnTop
public void setScrollbarsOnTop(boolean scrollbarsOnTop) When false (the default), the actor is clipped so it is not drawn under the scrollbars. When true, the actor is clipped to the entire scroll pane bounds and the scrollbars are drawn on top of the actor. IfsetFadeScrollBars(boolean)
is true, the scroll bars are always drawn on top. -
getVariableSizeKnobs
public boolean getVariableSizeKnobs() -
setVariableSizeKnobs
public void setVariableSizeKnobs(boolean variableSizeKnobs) If true, the scroll knobs are sized based ongetMaxX()
orgetMaxY()
. If false, the scroll knobs are sized based onDrawable.getMinWidth()
orDrawable.getMinHeight()
. Default is true. -
setCancelTouchFocus
public void setCancelTouchFocus(boolean cancelTouchFocus) When true (default) and flick scrolling begins,cancelTouchFocus()
is called. This causes any actors inside the scrollpane that have received touchDown to receive touchUp when flick scrolling begins. -
drawDebug
Description copied from class:Group
Draws this actor's debug lines ifActor.getDebug()
is true and, regardless ofActor.getDebug()
, callsActor.drawDebug(ShapeRenderer)
on each child.
-