Class ScrollPane
- All Implemented Interfaces:
Cullable
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
-
Field Summary
Fields inherited from class arc.scene.Group
children, cullingArea, transform
Fields inherited from class arc.scene.Element
color, cullable, fillParent, height, name, originX, originY, parent, parentAlpha, rotation, scaleX, scaleY, touchable, touchablility, translation, userObject, visibility, visible, width, x, y
-
Constructor Summary
ConstructorDescriptionScrollPane
(Element widget) ScrollPane
(Element widget, ScrollPane.ScrollPaneStyle style) -
Method Summary
Modifier and TypeMethodDescriptionvoid
act
(float delta) Updates the actor based on time.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
draw()
If this method is overridden, the super method orWidgetGroup.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
float
protected float
Returns the amount to scroll horizontally when the mouse wheel is scrolled.protected float
Returns the amount to scroll vertically when the mouse wheel is scrolled.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
Returns the actor embedded in this scroll pane, or null.hit
(float x, float y, boolean touchable) Returns the deepest actor that contains the specified point and istouchable
andvisible
, or null if no actor was hit.boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
Returns true if the widget is larger than the scroll pane horizontally.boolean
Returns true if the widget 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, callsElement.invalidate()
on any each child whose width or height has changed, and callsElement.validate()
on each child.boolean
removeChild
(Element actor) Removes an actor from this group and unfocuses it.boolean
removeChild
(Element actor, 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.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) and flick scrolling begins,cancelTouchFocus()
is called.void
setClamp
(boolean clamp) For flick scroll, prevents scrolling out of the widget's bounds.void
setClip
(boolean clip) 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 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.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
setScrollingDisabledX
(boolean x) void
setScrollingDisabledY
(boolean y) void
setScrollPercentX
(float percentX) void
setScrollPercentY
(float percentY) void
setScrollX
(float pixels) void
setScrollXForce
(float pixels) void
setScrollY
(float pixels) void
setScrollYForce
(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 widget's bounds in seconds.void
setVariableSizeKnobs
(boolean variableSizeKnobs) void
setVelocityX
(float velocityX) void
setVelocityY
(float velocityY) void
Sets theElement
embedded in this scroll pane.void
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.Methods inherited from class arc.scene.ui.layout.WidgetGroup
childrenChanged, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validate
Methods inherited from class arc.scene.Group
addChild, addChildAfter, addChildAt, addChildBefore, applyTransform, clear, clearChildren, computeTransform, drawChildren, fill, fill, fill, find, find, findVisible, forEach, getChildren, getCullingArea, hasChildren, isTransform, localToDescendantCoordinates, resetTransform, setCullingArea, setScene, setTransform, swapActor, swapActor, toString
Methods inherited from class arc.scene.Element
actions, addAction, addCaptureListener, addListener, change, changed, clearActions, clearListeners, clicked, clicked, clicked, clicked, clipBegin, clipBegin, clipEnd, dragged, exited, fire, fireClick, getActions, getCaptureListeners, getHeight, getListeners, getMaxHeight, getMaxWidth, getRight, getRotation, getScene, getTop, getWidth, getX, getY, getZIndex, hasActions, hasKeyboard, hasMouse, hasParent, hasScroll, hovered, isAscendantOf, isDescendantOf, isDescendantOf, isTouchable, keepInStage, keyDown, keyDown, localToAscendantCoordinates, localToParentCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, released, remove, removeAction, removeCaptureListener, removeListener, requestKeyboard, requestScroll, rotateBy, rotationChanged, scaleBy, scaleBy, screenToLocalCoordinates, scrolled, setBounds, setColor, setColor, setHeight, setOrigin, setOrigin, setPosition, setPosition, setRotation, setRotationOrigin, setScale, setScale, setSize, setSize, setTranslation, setWidth, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, tapped, toBack, toFront, touchable, update, updateVisibility, visible
-
Field Details
-
disableX
protected boolean disableX -
disableY
protected boolean disableY
-
-
Constructor Details
-
ScrollPane
- Parameters:
widget
- May be null.
-
ScrollPane
- Parameters:
widget
- May be null.
-
-
Method Details
-
cancelTouchFocus
public void cancelTouchFocus()Cancels the stage's touch focus for all listeners except this scroll pane's flick scroll listener. This causes any widgets 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. -
getStyle
Returns the scroll pane's style. Modifying the returned style may not have an effect untilsetStyle(ScrollPaneStyle)
is called. -
setStyle
-
act
public void act(float delta) Description copied from class:Element
Updates the actor based on time. Typically this is called each frame byScene.act(float)
.The default implementation calls
Action.act(float)
on each action and removes actions that are complete. -
setClip
public void setClip(boolean clip) -
layout
public void layout()Description copied from class:Element
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, callsElement.invalidate()
on any each child whose width or height has changed, and callsElement.validate()
on each child. This method should almost never be called directly, insteadElement.validate()
should be used.- Overrides:
layout
in classWidgetGroup
-
draw
public void 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
-
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()- Overrides:
getPrefWidth
in classWidgetGroup
-
getPrefHeight
public float getPrefHeight()- Overrides:
getPrefHeight
in classWidgetGroup
-
getMinWidth
public float getMinWidth()- Overrides:
getMinWidth
in classWidgetGroup
-
getMinHeight
public float getMinHeight()- Overrides:
getMinHeight
in classWidgetGroup
-
getWidget
Returns the actor embedded in this scroll pane, or null. -
setWidget
Sets theElement
embedded in this scroll pane.- Parameters:
widget
- May be null to remove any current actor.
-
removeChild
Description copied from class:Group
Removes an actor from this group and unfocuses it. CallsGroup.removeChild(Element, boolean)
with true.- Overrides:
removeChild
in classGroup
-
removeChild
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:
removeChild
in classGroup
unfocus
- If true,Scene.unfocus(Element)
is called.- Returns:
- true if the actor was removed from this group.
-
hit
Description copied from class:Element
Returns the deepest actor that contains the specified point and istouchable
andvisible
, 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.
-
scrollX
protected void scrollX(float pixelsX) Called whenever the x scroll amount is changed. -
scrollY
protected void scrollY(float pixelsY) Called whenever the y scroll amount is changed. -
visualScrollX
protected void visualScrollX(float pixelsX) Called whenever the visual x scroll amount is changed. -
visualScrollY
protected void visualScrollY(float pixelsY) Called whenever the visual y scroll amount is changed. -
getMouseWheelX
protected float getMouseWheelX()Returns the amount to scroll horizontally when the mouse wheel is scrolled. -
getMouseWheelY
protected float getMouseWheelY()Returns the amount to scroll vertically when the mouse wheel is scrolled. -
setScrollXForce
public void setScrollXForce(float pixels) -
getScrollX
public float getScrollX()Returns the x scroll position in pixels, where 0 is the left of the scroll pane. -
setScrollYForce
public void setScrollYForce(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 widget'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 widget'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 widget is larger than the scroll pane horizontally. -
setScrollX
public void setScrollX(float pixels) -
isScrollY
public boolean isScrollY()Returns true if the widget is larger than the scroll pane vertically. -
setScrollY
public void setScrollY(float pixels) -
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. -
setScrollingDisabledX
public void setScrollingDisabledX(boolean x) -
setScrollingDisabledY
public void setScrollingDisabledY(boolean y) -
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() -
getVelocityX
public float getVelocityX()Gets the flick scroll x velocity. -
setVelocityX
public void setVelocityX(float velocityX) -
getVelocityY
public float getVelocityY()Gets the flick scroll y velocity. -
setVelocityY
public void setVelocityY(float velocityY) -
setOverscroll
public 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. 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 widget's bounds in seconds. Default is 50, 30, 200. -
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 widget'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) -
setSmoothScrolling
public void setSmoothScrolling(boolean smoothScrolling) -
setScrollbarsOnTop
public void setScrollbarsOnTop(boolean scrollbarsOnTop) When false (the default), the widget is clipped so it is not drawn under the scrollbars. When true, the widget is clipped to the entire scroll pane bounds and the scrollbars are drawn on top of the widget. 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 widgets inside the scrollpane that have received touchDown to receive touchUp when flick scrolling begins.
-