public class Table extends WidgetGroup
Actor.getTouchable() is
Touchable.childrenOnly.
The preferred and minimum sizes are that of the children when laid out in columns and rows.
| Modifier and Type | Class and Description |
|---|---|
static class |
Table.Debug |
static class |
Table.DebugRect |
| Modifier and Type | Field and Description |
|---|---|
static Value |
backgroundBottom
Value that is the bottom padding of the table's background.
|
static Value |
backgroundLeft
Value that is the left padding of the table's background.
|
static Value |
backgroundRight
Value that is the right padding of the table's background.
|
static Value |
backgroundTop
Value that is the top padding of the table's background.
|
static Color |
debugActorColor |
static Color |
debugCellColor |
static Color |
debugTableColor |
| Constructor and Description |
|---|
Table() |
Table(Skin skin)
Creates a table with a skin, which enables the
add(CharSequence) and add(CharSequence, String) methods to
be used. |
| Modifier and Type | Method and Description |
|---|---|
Cell |
add()
Adds a cell without an actor.
|
void |
add(Actor... actors) |
Cell<Label> |
add(java.lang.CharSequence text)
Adds a new cell with a label.
|
Cell<Label> |
add(java.lang.CharSequence text,
java.lang.String labelStyleName)
Adds a new cell with a label.
|
Cell<Label> |
add(java.lang.CharSequence text,
java.lang.String fontName,
Color color)
Adds a new cell with a label.
|
Cell<Label> |
add(java.lang.CharSequence text,
java.lang.String fontName,
java.lang.String colorName)
Adds a new cell with a label.
|
<T extends Actor> |
add(T actor)
Adds a new cell to the table with the specified actor.
|
Table |
align(int align)
Alignment of the logical table within the table actor.
|
Table |
background(Drawable background) |
Table |
background(java.lang.String drawableName) |
Table |
bottom()
Adds
Align.bottom and clears Align.top for the alignment of the logical table within the table actor. |
Table |
center()
Sets the alignment of the logical table within the table actor to
Align.center. |
void |
clearChildren()
Removes all actors and cells from the table.
|
Cell |
columnDefaults(int column)
Gets the cell values that will be used as the defaults for all cells in the specified column.
|
Table |
debug()
Calls
Actor.setDebug(boolean) with true. |
Table |
debug(Table.Debug debug)
Turns debug lines on or off.
|
Table |
debugActor()
Turns on actor debug lines.
|
Table |
debugAll()
Calls
Group.setDebug(boolean, boolean) with true, true. |
Table |
debugCell()
Turns on cell debug lines.
|
Table |
debugTable()
Turns on table debug lines.
|
Cell |
defaults()
The cell values that will be used as the defaults for all cells.
|
void |
draw(Batch batch,
float parentAlpha)
If this method is overridden, the super method or
WidgetGroup.validate() should be called to ensure the widget group is laid
out. |
protected void |
drawBackground(Batch batch,
float parentAlpha,
float x,
float y)
Called to draw the background, before clipping is applied (if enabled).
|
void |
drawDebug(ShapeRenderer shapes)
Draws this actor's debug lines if
Actor.getDebug() is true and, regardless of Actor.getDebug(), calls
Actor.drawDebug(ShapeRenderer) on each child. |
protected void |
drawDebugBounds(ShapeRenderer shapes)
Draws a rectange for the bounds of this actor if
Actor.getDebug() is true. |
int |
getAlign() |
Drawable |
getBackground() |
<T extends Actor> |
getCell(T actor)
Returns the cell for the specified actor in this table, or null.
|
Array<Cell> |
getCells()
Returns the cells for this table.
|
boolean |
getClip() |
float |
getColumnMinWidth(int columnIndex)
Returns the min height of the specified column.
|
float |
getColumnPrefWidth(int columnIndex)
Returns the pref height of the specified column.
|
int |
getColumns() |
float |
getColumnWidth(int columnIndex)
Returns the width of the specified column, or 0 if the table layout has not been validated.
|
float |
getMinHeight() |
float |
getMinWidth() |
float |
getPadBottom() |
Value |
getPadBottomValue() |
float |
getPadLeft() |
Value |
getPadLeftValue() |
float |
getPadRight() |
Value |
getPadRightValue() |
float |
getPadTop() |
Value |
getPadTopValue() |
float |
getPadX()
Returns
getPadLeft() plus getPadRight(). |
float |
getPadY()
Returns
getPadTop() plus getPadBottom(). |
float |
getPrefHeight() |
float |
getPrefWidth() |
int |
getRow(float y)
Returns the row index for the y coordinate, or -1 if there are no cells.
|
float |
getRowHeight(int rowIndex)
Returns the height of the specified row, or 0 if the table layout has not been validated.
|
float |
getRowMinHeight(int rowIndex)
Returns the min height of the specified row.
|
float |
getRowPrefHeight(int rowIndex)
Returns the pref height of the specified row.
|
int |
getRows() |
Skin |
getSkin() |
Table.Debug |
getTableDebug() |
Actor |
hit(float x,
float y,
boolean touchable)
|
void |
invalidate()
Invalidates this actor's layout, causing
Layout.layout() to happen the next time Layout.validate() is called. |
void |
layout()
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child,
calls
Layout.invalidate() on any each child whose width or height has changed, and calls Layout.validate() on each
child. |
Table |
left()
Adds
Align.left and clears Align.right for the alignment of the logical table within the table actor. |
Table |
pad(float pad)
Sets the padTop, padLeft, padBottom, and padRight around the table to the specified value.
|
Table |
pad(float top,
float left,
float bottom,
float right) |
Table |
pad(Value pad)
Sets the padTop, padLeft, padBottom, and padRight around the table to the specified value.
|
Table |
pad(Value top,
Value left,
Value bottom,
Value right) |
Table |
padBottom(float padBottom)
Padding at the bottom edge of the table.
|
Table |
padBottom(Value padBottom)
Padding at the bottom edge of the table.
|
Table |
padLeft(float padLeft)
Padding at the left edge of the table.
|
Table |
padLeft(Value padLeft)
Padding at the left edge of the table.
|
Table |
padRight(float padRight)
Padding at the right edge of the table.
|
Table |
padRight(Value padRight)
Padding at the right edge of the table.
|
Table |
padTop(float padTop)
Padding at the top edge of the table.
|
Table |
padTop(Value padTop)
Padding at the top edge of the table.
|
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.
|
void |
reset()
Removes all actors and cells from the table (same as
clearChildren()) and additionally resets all table properties
and cell, column, and row defaults. |
Table |
right()
Adds
Align.right and clears Align.left for the alignment of the logical table within the table actor. |
Cell |
row()
Indicates that subsequent cells should be added to a new row and returns the cell values that will be used as the defaults
for all cells in the new row.
|
void |
setBackground(Drawable background) |
void |
setBackground(java.lang.String drawableName)
Sets the background drawable from the skin and adjusts the table's padding to match the background.
|
void |
setClip(boolean enabled)
Causes the contents to be clipped if they exceed the table actor's bounds.
|
void |
setDebug(boolean enabled)
If true,
Actor.drawDebug(ShapeRenderer) will be called for this actor. |
void |
setRound(boolean round)
If true (the default), positions and sizes are rounded to integers.
|
void |
setSkin(Skin skin) |
Cell<Stack> |
stack(Actor... actors)
Adds a new cell to the table with the specified actors in a
Stack. |
Table |
top()
Adds
Align.top and clears Align.bottom for the alignment of the logical table within the table actor. |
childrenChanged, getMaxHeight, getMaxWidth, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validateact, addActor, addActorAfter, addActorAt, addActorBefore, applyTransform, applyTransform, clear, computeTransform, drawChildren, drawDebugChildren, findActor, getChildren, getCullingArea, hasChildren, isTransform, localToDescendantCoordinates, resetTransform, resetTransform, setCullingArea, setDebug, setStage, setTransform, swapActor, swapActor, toStringaddAction, addCaptureListener, addListener, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, 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, hasParent, isAscendantOf, isDescendantOf, isTouchable, isVisible, localToAscendantCoordinates, localToParentCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, screenToLocalCoordinates, setBounds, setColor, setColor, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setWidth, setX, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFrontpublic static Color debugTableColor
public static Color debugCellColor
public static Color debugActorColor
public static Value backgroundTop
public static Value backgroundLeft
public static Value backgroundBottom
public static Value backgroundRight
public Table()
public Table(Skin skin)
add(CharSequence) and add(CharSequence, String) methods to
be used.public void draw(Batch batch, float parentAlpha)
WidgetGroupWidgetGroup.validate() should be called to ensure the widget group is laid
out.draw in class WidgetGroupparentAlpha - Should be multiplied with the actor's alpha, allowing a parent's alpha to affect all children.protected void drawBackground(Batch batch, float parentAlpha, float x, float y)
public void setBackground(java.lang.String drawableName)
Table(Skin) or setSkin(Skin) was used.setBackground(Drawable)public void setBackground(Drawable background)
background - May be null to clear the background.public Table background(Drawable background)
setBackground(Drawable)public Table background(java.lang.String drawableName)
setBackground(String)public Drawable getBackground()
public Actor hit(float x, float y, boolean touchable)
Actortouchable and
visible, or null if no actor was hit. The point is specified in the actor's local coordinate system
(0,0 is the bottom left of the actor and width,height is the upper right).
This method is used to delegate touchDown, mouse, and enter/exit events. If this method returns null, those events will not occur on this Actor.
The default implementation returns this actor if the point is within this actor's bounds.
hit in class Grouptouchable - If true, the hit detection will respect the touchability.Touchablepublic void setClip(boolean enabled)
Group.setTransform(boolean) to true.public boolean getClip()
public void invalidate()
LayoutLayout.layout() to happen the next time Layout.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).invalidate in interface Layoutinvalidate in class WidgetGrouppublic <T extends Actor> Cell<T> add(T actor)
public void add(Actor... actors)
public Cell<Label> add(java.lang.CharSequence text)
Table(Skin) or setSkin(Skin) was used.public Cell<Label> add(java.lang.CharSequence text, java.lang.String labelStyleName)
Table(Skin) or setSkin(Skin) was used.public Cell<Label> add(java.lang.CharSequence text, java.lang.String fontName, Color color)
Table(Skin) or setSkin(Skin) was used.public Cell<Label> add(java.lang.CharSequence text, java.lang.String fontName, java.lang.String colorName)
Table(Skin) or setSkin(Skin) was used.public Cell add()
public Cell<Stack> stack(Actor... actors)
Stack.actors - May be null to add a stack without any actors.public boolean removeActor(Actor actor)
GroupGroup.removeActor(Actor, boolean) with true.removeActor in class Grouppublic boolean removeActor(Actor actor, boolean unfocus)
Groupcleared so the actions will be returned to their
pool, if any. This is not done automatically.removeActor in class Groupunfocus - If true, Stage.unfocus(Actor) is called.public void clearChildren()
clearChildren in class Grouppublic void reset()
clearChildren()) and additionally resets all table properties
and cell, column, and row defaults.public Cell row()
public Cell columnDefaults(int column)
public <T extends Actor> Cell<T> getCell(T actor)
public float getPrefWidth()
getPrefWidth in interface LayoutgetPrefWidth in class WidgetGrouppublic float getPrefHeight()
getPrefHeight in interface LayoutgetPrefHeight in class WidgetGrouppublic float getMinWidth()
getMinWidth in interface LayoutgetMinWidth in class WidgetGrouppublic float getMinHeight()
getMinHeight in interface LayoutgetMinHeight in class WidgetGrouppublic Cell defaults()
public Table pad(Value pad)
public Table pad(float pad)
public Table pad(float top, float left, float bottom, float right)
public Table padTop(float padTop)
public Table padLeft(float padLeft)
public Table padBottom(float padBottom)
public Table padRight(float padRight)
public Table align(int align)
Align.center, Align.top, Align.bottom
, Align.left, Align.right, or any combination of those.public Table center()
Align.center. This clears any other alignment.public Table top()
Align.top and clears Align.bottom for the alignment of the logical table within the table actor.public Table left()
Align.left and clears Align.right for the alignment of the logical table within the table actor.public Table bottom()
Align.bottom and clears Align.top for the alignment of the logical table within the table actor.public Table right()
Align.right and clears Align.left for the alignment of the logical table within the table actor.public void setDebug(boolean enabled)
ActorActor.drawDebug(ShapeRenderer) will be called for this actor.public Table debug()
ActorActor.setDebug(boolean) with true.public Table debugAll()
GroupGroup.setDebug(boolean, boolean) with true, true.public Table debugTable()
public Table debugCell()
public Table debugActor()
public Table debug(Table.Debug debug)
public Table.Debug getTableDebug()
public Value getPadTopValue()
public float getPadTop()
public Value getPadLeftValue()
public float getPadLeft()
public Value getPadBottomValue()
public float getPadBottom()
public Value getPadRightValue()
public float getPadRight()
public float getPadX()
getPadLeft() plus getPadRight().public float getPadY()
getPadTop() plus getPadBottom().public int getAlign()
public int getRow(float y)
y - The y coordinate, where 0 is the top of the table.public void setSkin(Skin skin)
public void setRound(boolean round)
public int getRows()
public int getColumns()
public float getRowHeight(int rowIndex)
public float getRowMinHeight(int rowIndex)
public float getRowPrefHeight(int rowIndex)
public float getColumnWidth(int columnIndex)
public float getColumnMinWidth(int columnIndex)
public float getColumnPrefWidth(int columnIndex)
public void layout()
LayoutLayout.invalidate() on any each child whose width or height has changed, and calls Layout.validate() on each
child. This method should almost never be called directly, instead Layout.validate() should be used.layout in interface Layoutlayout in class WidgetGrouppublic void drawDebug(ShapeRenderer shapes)
GroupActor.getDebug() is true and, regardless of Actor.getDebug(), calls
Actor.drawDebug(ShapeRenderer) on each child.protected void drawDebugBounds(ShapeRenderer shapes)
ActorActor.getDebug() is true.drawDebugBounds in class Actorpublic Skin getSkin()