public class DragPane
extends com.badlogic.gdx.scenes.scene2d.ui.Container<com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup>
WidgetGroup
. Allows actors with specialized Draggable
listener attached
to be dropped and added into its group's content.
Note that unless Draggable
with appropriate listener (preferably DragPane.DefaultDragListener
) is attached to dragged
actors, this widget will act like a regular group with no extra functionalities. It's usually a good idea to use
setDraggable(Draggable)
method, as it will attach the listener to all its children, making them all draggable. If you
want to filter widgets accepted by this pane, use setListener(DragPaneListener)
method.
setDraggable(Draggable)
,
setListener(DragPaneListener)
Modifier and Type | Class and Description |
---|---|
static class |
DragPane.DefaultDragListener
Default
Draggable.DragListener implementation. |
static interface |
DragPane.DragPaneListener
Allows to select children added to the group.
|
Constructor and Description |
---|
DragPane()
Creates a new horizontal drag pane.
|
DragPane(boolean vertical) |
DragPane(com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup group) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
accept(com.badlogic.gdx.scenes.scene2d.Actor actor) |
void |
addActor(com.badlogic.gdx.scenes.scene2d.Actor actor) |
void |
addActorAfter(com.badlogic.gdx.scenes.scene2d.Actor actorAfter,
com.badlogic.gdx.scenes.scene2d.Actor actor) |
void |
addActorAt(int index,
com.badlogic.gdx.scenes.scene2d.Actor actor) |
void |
addActorBefore(com.badlogic.gdx.scenes.scene2d.Actor actorBefore,
com.badlogic.gdx.scenes.scene2d.Actor actor) |
void |
clear() |
boolean |
contains(com.badlogic.gdx.scenes.scene2d.Actor actor) |
protected void |
doOnAdd(com.badlogic.gdx.scenes.scene2d.Actor actor) |
<T extends com.badlogic.gdx.scenes.scene2d.Actor> |
findActor(String name) |
com.badlogic.gdx.utils.SnapshotArray<com.badlogic.gdx.scenes.scene2d.Actor> |
getChildren() |
Draggable |
getDraggable() |
GridGroup |
getGridGroup() |
com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup |
getGroup() |
com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup |
getHorizontalGroup() |
com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup |
getVerticalGroup() |
void |
invalidate() |
boolean |
isGrid() |
boolean |
isHorizontal() |
boolean |
isVertical() |
boolean |
removeActor(com.badlogic.gdx.scenes.scene2d.Actor actor)
Removes an actor from this group.
|
boolean |
removeActor(com.badlogic.gdx.scenes.scene2d.Actor actor,
boolean unfocus)
Removes an actor from this group.
|
void |
setActor(com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup group) |
void |
setBounds(float x,
float y,
float width,
float height) |
void |
setDraggable(Draggable draggable) |
void |
setGroup(com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup group) |
void |
setHeight(float height) |
void |
setListener(DragPane.DragPaneListener listener) |
void |
setWidth(float width) |
void |
validate() |
align, background, bottom, center, draw, drawBackground, drawDebug, fill, fill, fill, fill, fillX, fillY, getActor, getAlign, getBackground, getClip, getFillX, getFillY, getMaxHeight, getMaxHeightValue, getMaxWidth, getMaxWidthValue, getMinHeight, getMinHeightValue, getMinWidth, getPadBottom, getPadBottomValue, getPadLeft, getPadLeftValue, getPadRight, getPadRightValue, getPadTop, getPadTopValue, getPadX, getPadY, getPrefHeight, getPrefHeightValue, getPrefWidth, getPrefWidthValue, height, height, hit, layout, left, maxHeight, maxHeight, maxSize, maxSize, maxSize, maxSize, maxWidth, maxWidth, minHeight, minHeight, minSize, minSize, minSize, minSize, minWidth, minWidth, pad, pad, pad, pad, padBottom, padBottom, padLeft, padLeft, padRight, padRight, padTop, padTop, prefHeight, prefHeight, prefSize, prefSize, prefSize, prefSize, prefWidth, prefWidth, right, setBackground, setBackground, setClip, setRound, size, size, size, size, top, width, width
childrenChanged, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged
act, applyTransform, applyTransform, clearChildren, computeTransform, debugAll, drawChildren, drawDebugChildren, getCullingArea, hasChildren, isTransform, localToDescendantCoordinates, resetTransform, resetTransform, setCullingArea, setDebug, setStage, setTransform, swapActor, swapActor, toString
addAction, addCaptureListener, addListener, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebugBounds, fire, 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, hasParent, isAscendantOf, isDescendantOf, isTouchable, isVisible, localToAscendantCoordinates, localToParentCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, scaleBy, scaleBy, screenToLocalCoordinates, setColor, setColor, setDebug, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setX, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront
public DragPane()
public DragPane(boolean vertical)
vertical
- if true, actors will be stored vertically, if false - horizontally.public DragPane(com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup group)
group
- must append its actors through standard Group.addActor(Actor)
method. Must support
Group.addActorAfter(Actor, Actor)
and Group.addActorBefore(Actor, Actor)
methods. Note
that Table
does not meet these requirements.VerticalGroup
,
HorizontalGroup
,
GridGroup
public boolean isVertical()
VerticalGroup
.getVerticalGroup()
public boolean isHorizontal()
HorizontalGroup
.getHorizontalGroup()
public boolean isGrid()
GridGroup
.getGridGroup()
public com.badlogic.gdx.utils.SnapshotArray<com.badlogic.gdx.scenes.scene2d.Actor> getChildren()
getChildren
in class com.badlogic.gdx.scenes.scene2d.Group
public com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup getGroup()
public void setGroup(com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup group)
group
- will replace the internally managed group. All current children will be moved to this group.public void setActor(com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup group)
setActor
in class com.badlogic.gdx.scenes.scene2d.ui.Container<com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup>
group
- will replace the internally managed group. All current children will be moved to this group.public com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup getHorizontalGroup()
ClassCastException
- if drag pane is not horizontal.isHorizontal()
public com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup getVerticalGroup()
ClassCastException
- if drag pane is not vertical.isVertical()
public GridGroup getGridGroup()
ClassCastException
- if drag pane is not a grid.isGrid()
public Draggable getDraggable()
public void setDraggable(Draggable draggable)
draggable
- will be automatically added to all children.public void setBounds(float x, float y, float width, float height)
setBounds
in class com.badlogic.gdx.scenes.scene2d.Actor
public void setWidth(float width)
setWidth
in class com.badlogic.gdx.scenes.scene2d.Actor
public void setHeight(float height)
setHeight
in class com.badlogic.gdx.scenes.scene2d.Actor
public boolean contains(com.badlogic.gdx.scenes.scene2d.Actor actor)
actor
- might be in the drag pane.public boolean removeActor(com.badlogic.gdx.scenes.scene2d.Actor actor)
cleared
so the actions will be returned to their
pool
, if any. This is not done automatically.
Note that the direct parent of DragPane
's children is the internal pane's group accessible through
getGroup()
- and since this removal method is overridden and extended, pane's children should be deleted with
dragPane.removeActor(child)
rather than Actor.remove()
method.
removeActor
in class com.badlogic.gdx.scenes.scene2d.ui.Container<com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup>
actor
- will be removed, if present in the internal WidgetGroup
.public boolean removeActor(com.badlogic.gdx.scenes.scene2d.Actor actor, boolean unfocus)
cleared
so the actions will be returned to their
pool
, if any. This is not done automatically.
Note that the direct parent of DragPane
's children is the internal pane's group accessible through
getGroup()
- and since this removal method is overridden and extended, pane's children should be deleted with
dragPane.removeActor(child, true)
rather than Actor.remove()
method.
removeActor
in class com.badlogic.gdx.scenes.scene2d.Group
unfocus
- if true, Stage.unfocus(Actor)
is called.actor
- will be removed, if present in the internal WidgetGroup
.public void clear()
clear
in class com.badlogic.gdx.scenes.scene2d.Group
public void addActor(com.badlogic.gdx.scenes.scene2d.Actor actor)
addActor
in class com.badlogic.gdx.scenes.scene2d.ui.Container<com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup>
public void addActorAfter(com.badlogic.gdx.scenes.scene2d.Actor actorAfter, com.badlogic.gdx.scenes.scene2d.Actor actor)
addActorAfter
in class com.badlogic.gdx.scenes.scene2d.ui.Container<com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup>
public void addActorAt(int index, com.badlogic.gdx.scenes.scene2d.Actor actor)
addActorAt
in class com.badlogic.gdx.scenes.scene2d.ui.Container<com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup>
public void addActorBefore(com.badlogic.gdx.scenes.scene2d.Actor actorBefore, com.badlogic.gdx.scenes.scene2d.Actor actor)
addActorBefore
in class com.badlogic.gdx.scenes.scene2d.ui.Container<com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup>
protected void doOnAdd(com.badlogic.gdx.scenes.scene2d.Actor actor)
actor
- was just added to the group.public <T extends com.badlogic.gdx.scenes.scene2d.Actor> T findActor(String name)
findActor
in class com.badlogic.gdx.scenes.scene2d.Group
public void invalidate()
invalidate
in interface com.badlogic.gdx.scenes.scene2d.utils.Layout
invalidate
in class com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
public void validate()
validate
in interface com.badlogic.gdx.scenes.scene2d.utils.Layout
validate
in class com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
public void setListener(DragPane.DragPaneListener listener)
listener
- manages children appended to the drag pane.protected boolean accept(com.badlogic.gdx.scenes.scene2d.Actor actor)
actor
- is dragged over the pane.Copyright © 2015. All rights reserved.