Class ScrollPaneSnapAction
java.lang.Object
com.badlogic.gdx.scenes.scene2d.Action
net.dermetfan.gdx.scenes.scene2d.ui.ScrollPaneSnapAction
- All Implemented Interfaces:
com.badlogic.gdx.utils.Pool.Poolable
public class ScrollPaneSnapAction
extends com.badlogic.gdx.scenes.scene2d.Action
Lets a
ScrollPane snap to certain slots.
Does nothing when added to other Actors. Stays until it is manually removed.- Since:
- 0.10.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classa Slot determined by anAlignstatic interfaceIndicates the position of thesnappedslot.static classAn actor with a slot added to its listeners can be snapped to.static classFired when the ScrollPane snaps into or out of a slot.static classa Slot determined byValues -
Field Summary
Fields inherited from class com.badlogic.gdx.scenes.scene2d.Action
actor, target -
Constructor Summary
ConstructorsConstructorDescriptionusespercentWidth(.5f)andpercentHeight(.5f)as anchorScrollPaneSnapAction(com.badlogic.gdx.scenes.scene2d.ui.Value anchorX, com.badlogic.gdx.scenes.scene2d.ui.Value anchorY) -
Method Summary
Modifier and TypeMethodDescriptionbooleanact(float delta) voidforces theindicatorto be notified next timeactis calledbooleanfindClosestSlot(com.badlogic.gdx.math.Vector2 slot) com.badlogic.gdx.scenes.scene2d.ui.Valuecom.badlogic.gdx.scenes.scene2d.ui.Valuecom.badlogic.gdx.utils.FloatArraygetSlots()floatfloatbooleanbooleanvoidreportSlot(float x, float y) voidreset()voidsetAnchor(com.badlogic.gdx.scenes.scene2d.ui.Value anchorX, com.badlogic.gdx.scenes.scene2d.ui.Value anchorY) voidsetAnchorX(com.badlogic.gdx.scenes.scene2d.ui.Value anchorX) voidsetAnchorY(com.badlogic.gdx.scenes.scene2d.ui.Value anchorY) voidsetIndicateVertical(boolean indicateVertical) voidsetIndicator(ScrollPaneSnapAction.Indicator indicator) voidsetTarget(com.badlogic.gdx.scenes.scene2d.Actor target) voidsnap(float slotX, float slotY) voidsnap(com.badlogic.gdx.math.Vector2 slot) voidsnap(ScrollPaneSnapAction.Slot slot, com.badlogic.gdx.scenes.scene2d.Actor actor) Snaps to the slot on the given actor.voidclears and fillsslotswith slots on the given ScrollPaneMethods inherited from class com.badlogic.gdx.scenes.scene2d.Action
getActor, getPool, getTarget, restart, setActor, setPool, toString
-
Constructor Details
-
ScrollPaneSnapAction
public ScrollPaneSnapAction()usespercentWidth(.5f)andpercentHeight(.5f)as anchor -
ScrollPaneSnapAction
public ScrollPaneSnapAction(com.badlogic.gdx.scenes.scene2d.ui.Value anchorX, com.badlogic.gdx.scenes.scene2d.ui.Value anchorY) - Parameters:
anchorX- theanchorXanchorY- theanchorY
-
-
Method Details
-
act
public boolean act(float delta) - Specified by:
actin classcom.badlogic.gdx.scenes.scene2d.Action
-
setTarget
public void setTarget(com.badlogic.gdx.scenes.scene2d.Actor target) - Overrides:
setTargetin classcom.badlogic.gdx.scenes.scene2d.Action
-
reset
public void reset()- Specified by:
resetin interfacecom.badlogic.gdx.utils.Pool.Poolable- Overrides:
resetin classcom.badlogic.gdx.scenes.scene2d.Action
-
updateSlots
public void updateSlots()clears and fillsslotswith slots on the given ScrollPane -
reportSlot
public void reportSlot(float x, float y) - Parameters:
x- the x coordinate of the Slot in thewidget's coordinatesy- the y coordinate of the Slot in thewidget's coordinates
-
findClosestSlot
public boolean findClosestSlot(com.badlogic.gdx.math.Vector2 slot) - Parameters:
slot- is set to the Slot closest to the anchor with the visual scroll amount- Returns:
- true if a slot was found
-
snap
Snaps to the slot on the given actor. -
snap
public void snap(com.badlogic.gdx.math.Vector2 slot) - See Also:
-
snap
public void snap(float slotX, float slotY) - Parameters:
slotX- the x coordinate of the slot to snap toslotY- the y coordinate of the slot to snap to
-
dirtyIndicator
public void dirtyIndicator()forces theindicatorto be notified next timeactis called -
getSnappedSlotX
public float getSnappedSlotX()- Returns:
- the slot x the given pane is currently snapped to (assuming it is)
-
getSnappedSlotY
public float getSnappedSlotY()- Returns:
- the slot y the given pane is currently snapped to (assuming it is)
-
getAnchorX
public com.badlogic.gdx.scenes.scene2d.ui.Value getAnchorX()- Returns:
- the
anchorX
-
setAnchorX
public void setAnchorX(com.badlogic.gdx.scenes.scene2d.ui.Value anchorX) - Parameters:
anchorX- theanchorXto set
-
getAnchorY
public com.badlogic.gdx.scenes.scene2d.ui.Value getAnchorY()- Returns:
- the
anchorY
-
setAnchorY
public void setAnchorY(com.badlogic.gdx.scenes.scene2d.ui.Value anchorY) - Parameters:
anchorY- theanchorYto set
-
setAnchor
public void setAnchor(com.badlogic.gdx.scenes.scene2d.ui.Value anchorX, com.badlogic.gdx.scenes.scene2d.ui.Value anchorY) - Parameters:
anchorX- theanchorXto setanchorY- theanchorYto set
-
getIndicator
- Returns:
- the
indicator
-
setIndicator
- Parameters:
indicator- theindicatorto set
-
isIndicateVertical
public boolean isIndicateVertical()- Returns:
- the
indicateVertical
-
setIndicateVertical
public void setIndicateVertical(boolean indicateVertical) - Parameters:
indicateVertical- theindicateVerticalto set
-
getSlots
public com.badlogic.gdx.utils.FloatArray getSlots()- Returns:
- the
slots
-
isSnapped
public boolean isSnapped()- Returns:
- the
snapped
-