Class HorizontalGroup
- 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.HorizontalGroup
-
public class HorizontalGroup extends WidgetGroup
A group that lays out its children side by side horizontally, with optional wrapping. This can be easier than usingTable
when actors need to be inserted into or removed from the middle of the group.Group.getChildren()
can be sorted to change the order of the actors (egActor.setZIndex(int)
).invalidate()
must be called after changing the children order.The preferred width is the sum of the children's preferred widths plus spacing. The preferred height is the largest preferred height of any child. The preferred size is slightly different when
wrap
is enabled. The min size is the preferred size and the max size is 0.Widgets are sized using their
preferred width
, so widgets which return 0 as their preferred width will be given a width of 0 (eg, a label withword wrap
enabled).
-
-
Constructor Summary
Constructors Constructor Description HorizontalGroup()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HorizontalGroup
align(int align)
Sets the alignment of all widgets within the horizontal group.HorizontalGroup
bottom()
SetsAlign.bottom
and clearsAlign.top
for the alignment of all widgets within the horizontal group.HorizontalGroup
center()
Sets the alignment of all widgets within the horizontal group toAlign.center
.protected void
drawDebugBounds(ShapeRenderer shapes)
Draws a rectangle for the bounds of this actor ifActor.getDebug()
is true.HorizontalGroup
expand()
HorizontalGroup
expand(boolean expand)
When true and wrap is false, the rows will take up the entire horizontal group height.HorizontalGroup
fill()
HorizontalGroup
fill(float fill)
int
getAlign()
boolean
getExpand()
float
getFill()
float
getPadBottom()
float
getPadLeft()
float
getPadRight()
float
getPadTop()
float
getPrefHeight()
float
getPrefWidth()
boolean
getReverse()
int
getRows()
When wrapping is enabled, the number of rows may be > 1.float
getSpace()
boolean
getWrap()
boolean
getWrapReverse()
float
getWrapSpace()
HorizontalGroup
grow()
Sets fill to 1 and expand to true.void
invalidate()
Invalidates this actor's layout, causingLayout.layout()
to happen the next timeLayout.validate()
is called.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.HorizontalGroup
left()
AddsAlign.left
and clearsAlign.right
for the alignment of all widgets within the horizontal group.HorizontalGroup
pad(float pad)
Sets the padTop, padLeft, padBottom, and padRight to the specified value.HorizontalGroup
pad(float top, float left, float bottom, float right)
HorizontalGroup
padBottom(float padBottom)
HorizontalGroup
padLeft(float padLeft)
HorizontalGroup
padRight(float padRight)
HorizontalGroup
padTop(float padTop)
HorizontalGroup
reverse()
The children will be displayed last to first.HorizontalGroup
reverse(boolean reverse)
If true, the children will be displayed last to first.HorizontalGroup
right()
AddsAlign.right
and clearsAlign.left
for the alignment of all widgets within the horizontal group.HorizontalGroup
rowAlign(int rowAlign)
Sets the horizontal alignment of each row of widgets whenwrapping
is enabled and sets the vertical alignment of widgets within each row.HorizontalGroup
rowBottom()
SetsAlign.bottom
and clearsAlign.top
for the alignment of widgets within each row.HorizontalGroup
rowCenter()
Sets the alignment of widgets within each row toAlign.center
.HorizontalGroup
rowLeft()
AddsAlign.left
and clearsAlign.right
for the alignment of each row of widgets whenwrapping
is enabled.HorizontalGroup
rowRight()
AddsAlign.right
and clearsAlign.left
for the alignment of each row of widgets whenwrapping
is enabled.HorizontalGroup
rowTop()
SetsAlign.top
and clearsAlign.bottom
for the alignment of widgets within each row.void
setRound(boolean round)
If true (the default), positions and sizes are rounded to integers.HorizontalGroup
space(float space)
Sets the horizontal space between children.HorizontalGroup
top()
SetsAlign.top
and clearsAlign.bottom
for the alignment of all widgets within the horizontal group.HorizontalGroup
wrap()
If false, the widgets are arranged in a single row and the preferred width is the widget widths plus spacing.HorizontalGroup
wrap(boolean wrap)
HorizontalGroup
wrapReverse()
Rows will wrap above the previous rows.HorizontalGroup
wrapReverse(boolean wrapReverse)
If true, rows will wrap above the previous rows.HorizontalGroup
wrapSpace(float wrapSpace)
Sets the vertical space between rows when wrap is enabled.-
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
childrenChanged, draw, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, hit, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validate
-
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Group
act, addActor, addActorAfter, addActorAt, addActorBefore, applyTransform, applyTransform, clear, clear, clearChildren, clearChildren, computeTransform, debugAll, drawChildren, drawDebug, drawDebugChildren, findActor, getChild, getChildren, getCullingArea, hasChildren, isTransform, localToDescendantCoordinates, removeActor, removeActor, removeActorAt, 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, 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
-
-
-
-
Method Detail
-
invalidate
public void invalidate()
Description copied from interface:Layout
Invalidates this actor's layout, causingLayout.layout()
to happen the next timeLayout.validate()
is called. This method should be called when state changes in the actor that requires a layout but does not change the minimum, preferred, maximum, or actual size of the actor (meaning it does not affect the parent actor's layout).- Specified by:
invalidate
in interfaceLayout
- Overrides:
invalidate
in classWidgetGroup
-
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
-
getRows
public int getRows()
When wrapping is enabled, the number of rows may be > 1.
-
setRound
public void setRound(boolean round)
If true (the default), positions and sizes are rounded to integers.
-
reverse
public HorizontalGroup reverse()
The children will be displayed last to first.
-
reverse
public HorizontalGroup reverse(boolean reverse)
If true, the children will be displayed last to first.
-
getReverse
public boolean getReverse()
-
wrapReverse
public HorizontalGroup wrapReverse()
Rows will wrap above the previous rows.
-
wrapReverse
public HorizontalGroup wrapReverse(boolean wrapReverse)
If true, rows will wrap above the previous rows.
-
getWrapReverse
public boolean getWrapReverse()
-
space
public HorizontalGroup space(float space)
Sets the horizontal space between children.
-
getSpace
public float getSpace()
-
wrapSpace
public HorizontalGroup wrapSpace(float wrapSpace)
Sets the vertical space between rows when wrap is enabled.
-
getWrapSpace
public float getWrapSpace()
-
pad
public HorizontalGroup pad(float pad)
Sets the padTop, padLeft, padBottom, and padRight to the specified value.
-
pad
public HorizontalGroup pad(float top, float left, float bottom, float right)
-
padTop
public HorizontalGroup padTop(float padTop)
-
padLeft
public HorizontalGroup padLeft(float padLeft)
-
padBottom
public HorizontalGroup padBottom(float padBottom)
-
padRight
public HorizontalGroup padRight(float padRight)
-
getPadTop
public float getPadTop()
-
getPadLeft
public float getPadLeft()
-
getPadBottom
public float getPadBottom()
-
getPadRight
public float getPadRight()
-
align
public HorizontalGroup align(int align)
Sets the alignment of all widgets within the horizontal group. Set toAlign.center
,Align.top
,Align.bottom
,Align.left
,Align.right
, or any combination of those.
-
center
public HorizontalGroup center()
Sets the alignment of all widgets within the horizontal group toAlign.center
. This clears any other alignment.
-
top
public HorizontalGroup top()
SetsAlign.top
and clearsAlign.bottom
for the alignment of all widgets within the horizontal group.
-
left
public HorizontalGroup left()
AddsAlign.left
and clearsAlign.right
for the alignment of all widgets within the horizontal group.
-
bottom
public HorizontalGroup bottom()
SetsAlign.bottom
and clearsAlign.top
for the alignment of all widgets within the horizontal group.
-
right
public HorizontalGroup right()
AddsAlign.right
and clearsAlign.left
for the alignment of all widgets within the horizontal group.
-
getAlign
public int getAlign()
-
fill
public HorizontalGroup fill()
-
fill
public HorizontalGroup fill(float fill)
- Parameters:
fill
- 0 will use preferred width.
-
getFill
public float getFill()
-
expand
public HorizontalGroup expand()
-
expand
public HorizontalGroup expand(boolean expand)
When true and wrap is false, the rows will take up the entire horizontal group height.
-
getExpand
public boolean getExpand()
-
grow
public HorizontalGroup grow()
Sets fill to 1 and expand to true.
-
wrap
public HorizontalGroup wrap()
If false, the widgets are arranged in a single row and the preferred width is the widget widths plus spacing.If true, the widgets will wrap using the width of the horizontal group. The preferred width of the group will be 0 as it is expected that something external will set the width of the group. Widgets are sized to their preferred width unless it is larger than the group's width, in which case they are sized to the group's width but not less than their minimum width. Default is false.
When wrap is enabled, the group's preferred height depends on the width of the group. In some cases the parent of the group will need to layout twice: once to set the width of the group and a second time to adjust to the group's new preferred height.
-
wrap
public HorizontalGroup wrap(boolean wrap)
-
getWrap
public boolean getWrap()
-
rowAlign
public HorizontalGroup rowAlign(int rowAlign)
Sets the horizontal alignment of each row of widgets whenwrapping
is enabled and sets the vertical alignment of widgets within each row. Set toAlign.center
,Align.top
,Align.bottom
,Align.left
,Align.right
, or any combination of those.
-
rowCenter
public HorizontalGroup rowCenter()
Sets the alignment of widgets within each row toAlign.center
. This clears any other alignment.
-
rowTop
public HorizontalGroup rowTop()
SetsAlign.top
and clearsAlign.bottom
for the alignment of widgets within each row.
-
rowLeft
public HorizontalGroup rowLeft()
AddsAlign.left
and clearsAlign.right
for the alignment of each row of widgets whenwrapping
is enabled.
-
rowBottom
public HorizontalGroup rowBottom()
SetsAlign.bottom
and clearsAlign.top
for the alignment of widgets within each row.
-
rowRight
public HorizontalGroup rowRight()
AddsAlign.right
and clearsAlign.left
for the alignment of each row of widgets whenwrapping
is enabled.
-
drawDebugBounds
protected void drawDebugBounds(ShapeRenderer shapes)
Description copied from class:Actor
Draws a rectangle for the bounds of this actor ifActor.getDebug()
is true.- Overrides:
drawDebugBounds
in classActor
-
-