Class SplitPane
- java.lang.Object
-
- com.badlogic.gdx.scenes.scene2d.Actor
-
- com.badlogic.gdx.scenes.scene2d.Group
-
- com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
-
- com.badlogic.gdx.scenes.scene2d.ui.SplitPane
-
public class SplitPane extends WidgetGroup
A container that contains two widgets and is divided either horizontally or vertically. The user may resize the widgets. The child widgets are always sized to fill their side of the SplitPane.Minimum and maximum split amounts can be set to limit the motion of the resizing handle. The handle position is also prevented from shrinking the children below their minimum sizes. If these limits over-constrain the handle, it will be locked and placed at an averaged location, resulting in cropped children. The minimum child size can be ignored (allowing dynamic cropping) by wrapping the child in a Container with a minimum size of 0 and fill() set, or by overriding
clampSplitAmount()
.The preferred size of a SplitPane is that of the child widgets and the size of the
SplitPane.SplitPaneStyle.handle
. The widgets are sized depending on the SplitPane size and thesplit position
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SplitPane.SplitPaneStyle
The style for a splitpane, seeSplitPane
.
-
Constructor Summary
Constructors Constructor Description SplitPane(Actor firstWidget, Actor secondWidget, boolean vertical, Skin skin)
SplitPane(Actor firstWidget, Actor secondWidget, boolean vertical, Skin skin, java.lang.String styleName)
SplitPane(Actor firstWidget, Actor secondWidget, boolean vertical, SplitPane.SplitPaneStyle style)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addActor(Actor actor)
Adds an actor as a child of this group, removing it from its previous parent.void
addActorAt(int index, Actor actor)
Adds an actor as a child of this group at a specific index, removing it from its previous parent.void
addActorBefore(Actor actorBefore, Actor actor)
Adds an actor as a child of this group immediately before another child actor, removing it from its previous parent.protected void
clampSplitAmount()
Called during layout to clamp thesplitAmount
within the set limits.void
draw(Batch batch, float parentAlpha)
If this method is overridden, the super method orWidgetGroup.validate()
should be called to ensure the widget group is laid out.float
getMaxSplitAmount()
float
getMinHeight()
float
getMinSplitAmount()
float
getMinWidth()
float
getPrefHeight()
float
getPrefWidth()
float
getSplitAmount()
SplitPane.SplitPaneStyle
getStyle()
Returns the split pane's style.boolean
isCursorOverHandle()
boolean
isVertical()
void
layout()
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, callsLayout.invalidate()
on any each child whose width or height has changed, and callsLayout.validate()
on each child.boolean
removeActor(Actor actor)
Removes an actor from this group and unfocuses it.boolean
removeActor(Actor actor, boolean unfocus)
Removes an actor from this group.Actor
removeActorAt(int index, boolean unfocus)
Removes an actor from this group.void
setFirstWidget(Actor widget)
void
setMaxSplitAmount(float maxAmount)
void
setMinSplitAmount(float minAmount)
void
setSecondWidget(Actor widget)
void
setSplitAmount(float splitAmount)
void
setStyle(SplitPane.SplitPaneStyle style)
void
setVertical(boolean vertical)
-
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
childrenChanged, getMaxHeight, getMaxWidth, hit, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validate
-
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Group
act, addActorAfter, applyTransform, applyTransform, clear, clear, clearChildren, clearChildren, computeTransform, debugAll, drawChildren, drawDebug, drawDebugChildren, findActor, getChild, getChildren, getCullingArea, hasChildren, isTransform, localToDescendantCoordinates, resetTransform, resetTransform, setCullingArea, setDebug, setStage, setTransform, swapActor, swapActor, toString
-
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebugBounds, fire, firstAscendant, 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, hasKeyboardFocus, hasParent, hasScrollFocus, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, scaleChanged, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront
-
-
-
-
Constructor Detail
-
SplitPane
public SplitPane(@Null Actor firstWidget, @Null Actor secondWidget, boolean vertical, Skin skin)
- Parameters:
firstWidget
- May be null.secondWidget
- May be null.
-
SplitPane
public SplitPane(@Null Actor firstWidget, @Null Actor secondWidget, boolean vertical, Skin skin, java.lang.String styleName)
- Parameters:
firstWidget
- May be null.secondWidget
- May be null.
-
SplitPane
public SplitPane(@Null Actor firstWidget, @Null Actor secondWidget, boolean vertical, SplitPane.SplitPaneStyle style)
- Parameters:
firstWidget
- May be null.secondWidget
- May be null.
-
-
Method Detail
-
setStyle
public void setStyle(SplitPane.SplitPaneStyle style)
-
getStyle
public SplitPane.SplitPaneStyle getStyle()
Returns the split pane's style. Modifying the returned style may not have an effect untilsetStyle(SplitPaneStyle)
is called.
-
layout
public void layout()
Description copied from interface:Layout
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, callsLayout.invalidate()
on any each child whose width or height has changed, and callsLayout.validate()
on each child. This method should almost never be called directly, insteadLayout.validate()
should be used.- Specified by:
layout
in interfaceLayout
- Overrides:
layout
in classWidgetGroup
-
getPrefWidth
public float getPrefWidth()
- Specified by:
getPrefWidth
in interfaceLayout
- Overrides:
getPrefWidth
in classWidgetGroup
-
getPrefHeight
public float getPrefHeight()
- Specified by:
getPrefHeight
in interfaceLayout
- Overrides:
getPrefHeight
in classWidgetGroup
-
getMinWidth
public float getMinWidth()
- Specified by:
getMinWidth
in interfaceLayout
- Overrides:
getMinWidth
in classWidgetGroup
-
getMinHeight
public float getMinHeight()
- Specified by:
getMinHeight
in interfaceLayout
- Overrides:
getMinHeight
in classWidgetGroup
-
setVertical
public void setVertical(boolean vertical)
-
isVertical
public boolean isVertical()
-
draw
public void draw(Batch batch, float parentAlpha)
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
parentAlpha
- The parent alpha, to be multiplied with this actor's alpha, allowing the parent's alpha to affect all children.
-
setSplitAmount
public void setSplitAmount(float splitAmount)
- Parameters:
splitAmount
- The split amount between the min and max amount. This parameter is clamped during layout. SeeclampSplitAmount()
.
-
getSplitAmount
public float getSplitAmount()
-
clampSplitAmount
protected void clampSplitAmount()
Called during layout to clamp thesplitAmount
within the set limits. By default it imposes the limits of the min amount, max amount, and min sizes of the children. This method is internally called in response to layout, so it should not callWidgetGroup.invalidate()
.
-
getMinSplitAmount
public float getMinSplitAmount()
-
setMinSplitAmount
public void setMinSplitAmount(float minAmount)
-
getMaxSplitAmount
public float getMaxSplitAmount()
-
setMaxSplitAmount
public void setMaxSplitAmount(float maxAmount)
-
addActor
public void addActor(Actor actor)
Description copied from class:Group
Adds an actor as a child of this group, removing it from its previous parent. If the actor is already a child of this group, no changes are made.
-
addActorAt
public void addActorAt(int index, Actor actor)
Description copied from class:Group
Adds an actor as a child of this group at a specific index, removing it from its previous parent. If the actor is already a child of this group, no changes are made.- Overrides:
addActorAt
in classGroup
- Parameters:
index
- May be greater than the number of children.
-
addActorBefore
public void addActorBefore(Actor actorBefore, Actor actor)
Description copied from class:Group
Adds an actor as a child of this group immediately before another child actor, removing it from its previous parent. If the actor is already a child of this group, no changes are made.- Overrides:
addActorBefore
in classGroup
-
removeActor
public boolean removeActor(Actor actor)
Description copied from class:Group
Removes an actor from this group and unfocuses it. CallsGroup.removeActor(Actor, boolean)
with true.- Overrides:
removeActor
in classGroup
-
removeActor
public boolean removeActor(Actor actor, boolean unfocus)
Description copied from class:Group
Removes an actor from this group. CallsGroup.removeActorAt(int, boolean)
with the actor's child index.- Overrides:
removeActor
in classGroup
-
removeActorAt
public Actor removeActorAt(int index, boolean unfocus)
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:
removeActorAt
in classGroup
unfocus
- If true,Stage.unfocus(Actor)
is called.- Returns:
- the actor removed from this group.
-
isCursorOverHandle
public boolean isCursorOverHandle()
-
-