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
  • Constructor Details

    • ScrollPaneSnapAction

      public ScrollPaneSnapAction()
      uses percentWidth(.5f) and percentHeight(.5f) as anchor
    • ScrollPaneSnapAction

      public ScrollPaneSnapAction​(com.badlogic.gdx.scenes.scene2d.ui.Value anchorX, com.badlogic.gdx.scenes.scene2d.ui.Value anchorY)
      Parameters:
      anchorX - the anchorX
      anchorY - the anchorY
  • Method Details

    • act

      public boolean act​(float delta)
      Specified by:
      act in class com.badlogic.gdx.scenes.scene2d.Action
    • setTarget

      public void setTarget​(com.badlogic.gdx.scenes.scene2d.Actor target)
      Overrides:
      setTarget in class com.badlogic.gdx.scenes.scene2d.Action
    • reset

      public void reset()
      Specified by:
      reset in interface com.badlogic.gdx.utils.Pool.Poolable
      Overrides:
      reset in class com.badlogic.gdx.scenes.scene2d.Action
    • updateSlots

      public void updateSlots()
      clears and fills slots with slots on the given ScrollPane
    • reportSlot

      public void reportSlot​(float x, float y)
      Parameters:
      x - the x coordinate of the Slot in the widget's coordinates
      y - the y coordinate of the Slot in the widget'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

      public void snap​(ScrollPaneSnapAction.Slot slot, com.badlogic.gdx.scenes.scene2d.Actor actor)
      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 to
      slotY - the y coordinate of the slot to snap to
    • dirtyIndicator

      public void dirtyIndicator()
      forces the indicator to be notified next time act 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 - the anchorX 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 - the anchorY to set
    • setAnchor

      public void setAnchor​(com.badlogic.gdx.scenes.scene2d.ui.Value anchorX, com.badlogic.gdx.scenes.scene2d.ui.Value anchorY)
      Parameters:
      anchorX - the anchorX to set
      anchorY - the anchorY to set
    • getIndicator

      public ScrollPaneSnapAction.Indicator getIndicator()
      Returns:
      the indicator
    • setIndicator

      public void setIndicator​(ScrollPaneSnapAction.Indicator indicator)
      Parameters:
      indicator - the indicator to set
    • isIndicateVertical

      public boolean isIndicateVertical()
      Returns:
      the indicateVertical
    • setIndicateVertical

      public void setIndicateVertical​(boolean indicateVertical)
      Parameters:
      indicateVertical - the indicateVertical to set
    • getSlots

      public com.badlogic.gdx.utils.FloatArray getSlots()
      Returns:
      the slots
    • isSnapped

      public boolean isSnapped()
      Returns:
      the snapped