APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.scenes.scene2d.ui

public Class HorizontalGroup

extends WidgetGroup
Class Inheritance
Imports
com.badlogic.gdx.graphics.glutils.ShapeRenderer, .ShapeRenderer.ShapeType, com.badlogic.gdx.scenes.scene2d.Actor, .Touchable, com.badlogic.gdx.scenes.scene2d.utils.Layout, com.badlogic.gdx.utils.Align, .FloatArray, .SnapshotArray

A group that lays out its children side by side horizontally, with optional wrapping. This can be easier than using Table when actors need to be inserted into or removed from the middle of the group. getChildren() can be sorted to change the order of the actors (eg Actor#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 with word wrap enabled).

Author
Nathan Sweet

Field Summary

Modifier and TypeField and Description
private int
private boolean
private float
private float
private float
private float
private float
private float
private float
private float
private boolean
private boolean
private int
private FloatArray
private boolean
private float
private boolean
private boolean
private float

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public HorizontalGroup
align(int align)

Sets the alignment of all widgets within the horizontal group.

public HorizontalGroup
bottom()

Sets Align#bottom and clears Align#top for the alignment of all widgets within the horizontal group.

public HorizontalGroup
center()

Sets the alignment of all widgets within the horizontal group to Align#center.

private void
protected void
drawDebugBounds(ShapeRenderer shapes)

Overrides com.badlogic.gdx.scenes.scene2d.Actor.drawDebugBounds.

Draws a rectangle for the bounds of this actor if getDebug() is true.

public HorizontalGroup
public HorizontalGroup
expand(boolean expand)

When true and wrap is false, the rows will take up the entire horizontal group height.

public HorizontalGroup
fill()

public HorizontalGroup
fill(float
0 will use preferred height.
fill
)

public int
public boolean
public float
public float
public float
public float
public float
public float
public float
public boolean
public int
getRows()

When wrapping is enabled, the number of rows may be > 1.

public float
public boolean
public boolean
public float
public HorizontalGroup
grow()

Sets fill to 1 and expand to true.

public void
invalidate()

Overrides com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup.invalidate.

Implements com.badlogic.gdx.scenes.scene2d.utils.Layout.invalidate.

Invalidates this actor's layout, causing layout() to happen the next time validate() is called.

public void
layout()

Overrides com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup.layout.

Implements com.badlogic.gdx.scenes.scene2d.utils.Layout.layout.

Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, calls invalidate() on any each child whose width or height has changed, and calls validate() on each child.

private void
public HorizontalGroup
left()

Adds Align#left and clears Align#right for the alignment of all widgets within the horizontal group.

public HorizontalGroup
pad(float pad)

Sets the padTop, padLeft, padBottom, and padRight to the specified value.

public HorizontalGroup
pad(float top, float left, float bottom, float right)

public HorizontalGroup
padBottom(float padBottom)

public HorizontalGroup
padLeft(float padLeft)

public HorizontalGroup
padRight(float padRight)

public HorizontalGroup
padTop(float padTop)

public HorizontalGroup
reverse()

The children will be displayed last to first.

public HorizontalGroup
reverse(boolean reverse)

If true, the children will be displayed last to first.

public HorizontalGroup
right()

Adds Align#right and clears Align#left for the alignment of all widgets within the horizontal group.

public HorizontalGroup
rowAlign(int rowAlign)

Sets the horizontal alignment of each row of widgets when wrapping is enabled and sets the vertical alignment of widgets within each row.

public HorizontalGroup
rowBottom()

Sets Align#bottom and clears Align#top for the alignment of widgets within each row.

public HorizontalGroup
rowCenter()

Sets the alignment of widgets within each row to Align#center.

public HorizontalGroup
rowLeft()

Adds Align#left and clears Align#right for the alignment of each row of widgets when wrapping is enabled.

public HorizontalGroup
rowRight()

Adds Align#right and clears Align#left for the alignment of each row of widgets when wrapping is enabled.

public HorizontalGroup
rowTop()

Sets Align#top and clears Align#bottom for the alignment of widgets within each row.

public void
setRound(boolean round)

If true (the default), positions and sizes are rounded to integers.

public HorizontalGroup
space(float space)

Sets the horizontal space between children.

public HorizontalGroup
top()

Sets Align#top and clears Align#bottom for the alignment of all widgets within the horizontal group.

public HorizontalGroup
wrap()

If false, the widgets are arranged in a single row and the preferred width is the widget widths plus spacing.

public HorizontalGroup
wrap(boolean wrap)

public HorizontalGroup
wrapReverse()

Rows will wrap above the previous rows.

public HorizontalGroup
wrapReverse(boolean wrapReverse)

If true, rows will wrap above the previous rows.

public HorizontalGroup
wrapSpace(float wrapSpace)

Sets the vertical space between rows when wrap is enabled.

Inherited from com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup:
childrenChangeddrawgetMaxHeightgetMaxWidthgetMinHeightgetMinWidthhitinvalidateHierarchyneedsLayoutpacksetFillParentsetLayoutEnabledsizeChangedvalidate

Field Detail

alignback to summary
private int align
expandback to summary
private boolean expand
fillback to summary
private float fill
lastPrefHeightback to summary
private float lastPrefHeight
padBottomback to summary
private float padBottom
padLeftback to summary
private float padLeft
padRightback to summary
private float padRight
padTopback to summary
private float padTop
prefHeightback to summary
private float prefHeight
prefWidthback to summary
private float prefWidth
reverseback to summary
private boolean reverse
roundback to summary
private boolean round
rowAlignback to summary
private int rowAlign
rowSizesback to summary
private FloatArray rowSizes
sizeInvalidback to summary
private boolean sizeInvalid
spaceback to summary
private float space
wrapback to summary
private boolean wrap
wrapReverseback to summary
private boolean wrapReverse
wrapSpaceback to summary
private float wrapSpace

Constructor Detail

HorizontalGroupback to summary
public HorizontalGroup()

Method Detail

alignback to summary
public HorizontalGroup align(int align)

Sets the alignment of all widgets within the horizontal group. Set to Align#center, Align#top, Align#bottom, Align#left, Align#right, or any combination of those.

bottomback to summary
public HorizontalGroup bottom()

Sets Align#bottom and clears Align#top for the alignment of all widgets within the horizontal group.

centerback to summary
public HorizontalGroup center()

Sets the alignment of all widgets within the horizontal group to Align#center. This clears any other alignment.

computeSizeback to summary
private void computeSize()
drawDebugBoundsback to summary
protected void drawDebugBounds(ShapeRenderer shapes)

Overrides com.badlogic.gdx.scenes.scene2d.Actor.drawDebugBounds.

Doc from com.badlogic.gdx.scenes.scene2d.Actor.drawDebugBounds.

Draws a rectangle for the bounds of this actor if getDebug() is true.

expandback to summary
public HorizontalGroup expand()
expandback to summary
public HorizontalGroup expand(boolean expand)

When true and wrap is false, the rows will take up the entire horizontal group height.

fillback to summary
public HorizontalGroup fill()
fillback to summary
public HorizontalGroup fill(float fill)
Parameters
fill:float

0 will use preferred height.

getAlignback to summary
public int getAlign()
getExpandback to summary
public boolean getExpand()
getFillback to summary
public float getFill()
getPadBottomback to summary
public float getPadBottom()
getPadLeftback to summary
public float getPadLeft()
getPadRightback to summary
public float getPadRight()
getPadTopback to summary
public float getPadTop()
getPrefHeightback to summary
public float getPrefHeight()

Overrides com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup.getPrefHeight.

Implements com.badlogic.gdx.scenes.scene2d.utils.Layout.getPrefHeight.

getPrefWidthback to summary
public float getPrefWidth()

Overrides com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup.getPrefWidth.

Implements com.badlogic.gdx.scenes.scene2d.utils.Layout.getPrefWidth.

getReverseback to summary
public boolean getReverse()
getRowsback to summary
public int getRows()

When wrapping is enabled, the number of rows may be > 1.

getSpaceback to summary
public float getSpace()
getWrapback to summary
public boolean getWrap()
getWrapReverseback to summary
public boolean getWrapReverse()
getWrapSpaceback to summary
public float getWrapSpace()
growback to summary
public HorizontalGroup grow()

Sets fill to 1 and expand to true.

invalidateback to summary
public void invalidate()

Overrides com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup.invalidate.

Implements com.badlogic.gdx.scenes.scene2d.utils.Layout.invalidate.

Doc from com.badlogic.gdx.scenes.scene2d.utils.Layout.invalidate.

Invalidates this actor's layout, causing layout() to happen the next time 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).

layoutback to summary
public void layout()

Overrides com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup.layout.

Implements com.badlogic.gdx.scenes.scene2d.utils.Layout.layout.

Doc from com.badlogic.gdx.scenes.scene2d.utils.Layout.layout.

Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, calls invalidate() on any each child whose width or height has changed, and calls validate() on each child. This method should almost never be called directly, instead validate() should be used.

layoutWrappedback to summary
private void layoutWrapped()
leftback to summary
public HorizontalGroup left()

Adds Align#left and clears Align#right for the alignment of all widgets within the horizontal group.

padback to summary
public HorizontalGroup pad(float pad)

Sets the padTop, padLeft, padBottom, and padRight to the specified value.

padback to summary
public HorizontalGroup pad(float top, float left, float bottom, float right)
padBottomback to summary
public HorizontalGroup padBottom(float padBottom)
padLeftback to summary
public HorizontalGroup padLeft(float padLeft)
padRightback to summary
public HorizontalGroup padRight(float padRight)
padTopback to summary
public HorizontalGroup padTop(float padTop)
reverseback to summary
public HorizontalGroup reverse()

The children will be displayed last to first.

reverseback to summary
public HorizontalGroup reverse(boolean reverse)

If true, the children will be displayed last to first.

rightback to summary
public HorizontalGroup right()

Adds Align#right and clears Align#left for the alignment of all widgets within the horizontal group.

rowAlignback to summary
public HorizontalGroup rowAlign(int rowAlign)

Sets the horizontal alignment of each row of widgets when wrapping is enabled and sets the vertical alignment of widgets within each row. Set to Align#center, Align#top, Align#bottom, Align#left, Align#right, or any combination of those.

rowBottomback to summary
public HorizontalGroup rowBottom()

Sets Align#bottom and clears Align#top for the alignment of widgets within each row.

rowCenterback to summary
public HorizontalGroup rowCenter()

Sets the alignment of widgets within each row to Align#center. This clears any other alignment.

rowLeftback to summary
public HorizontalGroup rowLeft()

Adds Align#left and clears Align#right for the alignment of each row of widgets when wrapping is enabled.

rowRightback to summary
public HorizontalGroup rowRight()

Adds Align#right and clears Align#left for the alignment of each row of widgets when wrapping is enabled.

rowTopback to summary
public HorizontalGroup rowTop()

Sets Align#top and clears Align#bottom for the alignment of widgets within each row.

setRoundback to summary
public void setRound(boolean round)

If true (the default), positions and sizes are rounded to integers.

spaceback to summary
public HorizontalGroup space(float space)

Sets the horizontal space between children.

topback to summary
public HorizontalGroup top()

Sets Align#top and clears Align#bottom for the alignment of all widgets within the horizontal group.

wrapback to summary
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.

wrapback to summary
public HorizontalGroup wrap(boolean wrap)
wrapReverseback to summary
public HorizontalGroup wrapReverse()

Rows will wrap above the previous rows.

wrapReverseback to summary
public HorizontalGroup wrapReverse(boolean wrapReverse)

If true, rows will wrap above the previous rows.

wrapSpaceback to summary
public HorizontalGroup wrapSpace(float wrapSpace)

Sets the vertical space between rows when wrap is enabled.