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 Classes Modifier and Type Class Description static class
ScrollPaneSnapAction.AlignSlot
a Slot determined by anAlign
static interface
ScrollPaneSnapAction.Indicator
Indicates the position of thesnapped
slot.static class
ScrollPaneSnapAction.Slot
An actor with a slot added to its listeners can be snapped to.static class
ScrollPaneSnapAction.SnapEvent
Fired when the ScrollPane snaps into or out of a slot.static class
ScrollPaneSnapAction.ValueSlot
a Slot determined byValues
-
Field Summary
Fields inherited from class com.badlogic.gdx.scenes.scene2d.Action
actor, target
-
Constructor Summary
Constructors Constructor Description ScrollPaneSnapAction()
usespercentWidth(.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 Type Method Description boolean
act(float delta)
void
dirtyIndicator()
forces theindicator
to be notified next timeact
is calledboolean
findClosestSlot(com.badlogic.gdx.math.Vector2 slot)
com.badlogic.gdx.scenes.scene2d.ui.Value
getAnchorX()
com.badlogic.gdx.scenes.scene2d.ui.Value
getAnchorY()
ScrollPaneSnapAction.Indicator
getIndicator()
com.badlogic.gdx.utils.FloatArray
getSlots()
float
getSnappedSlotX()
float
getSnappedSlotY()
boolean
isIndicateVertical()
boolean
isSnapped()
void
reportSlot(float x, float y)
void
reset()
void
setAnchor(com.badlogic.gdx.scenes.scene2d.ui.Value anchorX, com.badlogic.gdx.scenes.scene2d.ui.Value anchorY)
void
setAnchorX(com.badlogic.gdx.scenes.scene2d.ui.Value anchorX)
void
setAnchorY(com.badlogic.gdx.scenes.scene2d.ui.Value anchorY)
void
setIndicateVertical(boolean indicateVertical)
void
setIndicator(ScrollPaneSnapAction.Indicator indicator)
void
setTarget(com.badlogic.gdx.scenes.scene2d.Actor target)
void
snap(float slotX, float slotY)
void
snap(com.badlogic.gdx.math.Vector2 slot)
void
snap(ScrollPaneSnapAction.Slot slot, com.badlogic.gdx.scenes.scene2d.Actor actor)
Snaps to the slot on the given actor.void
updateSlots()
clears and fillsslots
with slots on the given ScrollPaneMethods inherited from class com.badlogic.gdx.scenes.scene2d.Action
getActor, getPool, getTarget, restart, setActor, setPool, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
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
- theanchorX
anchorY
- theanchorY
-
-
Method Details
-
act
public boolean act(float delta)- Specified by:
act
in classcom.badlogic.gdx.scenes.scene2d.Action
-
setTarget
public void setTarget(com.badlogic.gdx.scenes.scene2d.Actor target)- Overrides:
setTarget
in classcom.badlogic.gdx.scenes.scene2d.Action
-
reset
public void reset()- Specified by:
reset
in interfacecom.badlogic.gdx.utils.Pool.Poolable
- Overrides:
reset
in classcom.badlogic.gdx.scenes.scene2d.Action
-
updateSlots
public void updateSlots()clears and fillsslots
with 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(float, float)
-
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 theindicator
to be notified next timeact
is 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
- theanchorX
to 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
- theanchorY
to set
-
setAnchor
public void setAnchor(com.badlogic.gdx.scenes.scene2d.ui.Value anchorX, com.badlogic.gdx.scenes.scene2d.ui.Value anchorY)- Parameters:
anchorX
- theanchorX
to setanchorY
- theanchorY
to set
-
getIndicator
- Returns:
- the
indicator
-
setIndicator
- Parameters:
indicator
- theindicator
to set
-
isIndicateVertical
public boolean isIndicateVertical()- Returns:
- the
indicateVertical
-
setIndicateVertical
public void setIndicateVertical(boolean indicateVertical)- Parameters:
indicateVertical
- theindicateVertical
to set
-
getSlots
public com.badlogic.gdx.utils.FloatArray getSlots()- Returns:
- the
slots
-
isSnapped
public boolean isSnapped()- Returns:
- the
snapped
-