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.
|
Table |
add(Actor... actors) |
Cell<Label> |
add(CharSequence text)
Adds a new cell with a label.
|
Cell<Label> |
add(CharSequence text,
String labelStyleName)
Adds a new cell with a label.
|
Cell<Label> |
add(CharSequence text,
String fontName,
Color color)
Adds a new cell with a label.
|
Cell<Label> |
add(CharSequence text,
String fontName,
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(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. |
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. |
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 not over a row.
|
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.
|
Actor |
removeActorAt(int index,
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(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 of child actors 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. |
getMaxHeight, getMaxWidth, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, validate
act, addActor, addActorAfter, addActorAt, addActorBefore, clear, findActor, getChild, getChildren, getCullingArea, hasChildren, isTransform, localToDescendantCoordinates, setCullingArea, setDebug, setTransform, swapActor, swapActor, toString
addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, 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, hasKeyboardFocus, hasParent, hasScrollFocus, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, remove, removeAction, removeCaptureListener, removeListener, rotateBy, scaleBy, scaleBy, screenToLocalCoordinates, setBounds, setColor, setColor, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront
public 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(@Null Skin skin)
add(CharSequence)
and add(CharSequence, String)
methods to
be used.public void draw(Batch batch, float parentAlpha)
WidgetGroup
WidgetGroup.validate()
should be called to ensure the widget group is laid
out.draw
in class WidgetGroup
parentAlpha
- The parent alpha, to be multiplied with this actor's alpha, allowing the parent's alpha to affect all
children.public void setBackground(String drawableName)
Table(Skin)
or setSkin(Skin)
was used.setBackground(Drawable)
public void setBackground(@Null Drawable background)
background
- May be null to clear the background.public Table background(@Null Drawable background)
setBackground(Drawable)
public Table background(String drawableName)
setBackground(String)
@Null public Actor hit(float x, float y, boolean touchable)
Actor
visible
(and optionally, touchable
) actor that contains
the specified point, 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 and this actor is visible.
hit
in class Group
touchable
- If true, hit detection will respect the touchability
.Touchable
public void setClip(boolean enabled)
Group.setTransform(boolean)
to true.public boolean getClip()
public void invalidate()
Layout
Layout.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 Layout
invalidate
in class WidgetGroup
public <T extends Actor> Cell<T> add(@Null T actor)
public Cell<Label> add(@Null CharSequence text)
Table(Skin)
or setSkin(Skin)
was used.public Cell<Label> add(@Null CharSequence text, String labelStyleName)
Table(Skin)
or setSkin(Skin)
was used.public Cell<Label> add(@Null CharSequence text, String fontName, @Null Color color)
Table(Skin)
or setSkin(Skin)
was used.public Cell<Label> add(@Null CharSequence text, String fontName, 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)
Group
Group.removeActor(Actor, boolean)
with true.removeActor
in class Group
public boolean removeActor(Actor actor, boolean unfocus)
Group
Group.removeActorAt(int, boolean)
with the actor's child index.removeActor
in class Group
public Actor removeActorAt(int index, boolean unfocus)
Group
cleared
so the actions will be returned to their
pool
, if any. This is not done automatically.removeActorAt
in class Group
unfocus
- If true, Stage.unfocus(Actor)
is called.public void clearChildren()
clearChildren
in class Group
public void reset()
clearChildren()
) and additionally resets all table properties
and cell, column, and row defaults.public Cell row()
public Cell columnDefaults(int column)
@Null public <T extends Actor> Cell<T> getCell(T actor)
public float getPrefWidth()
getPrefWidth
in interface Layout
getPrefWidth
in class WidgetGroup
public float getPrefHeight()
getPrefHeight
in interface Layout
getPrefHeight
in class WidgetGroup
public float getMinWidth()
getMinWidth
in interface Layout
getMinWidth
in class WidgetGroup
public float getMinHeight()
getMinHeight
in interface Layout
getMinHeight
in class WidgetGroup
public 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)
Actor
Actor.drawDebug(ShapeRenderer)
will be called for this actor.public Table debug()
Actor
Actor.setDebug(boolean)
with true
.public Table debugAll()
Group
Group.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 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()
Layout
Layout.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 Layout
layout
in class WidgetGroup
public void drawDebug(ShapeRenderer shapes)
Group
Actor.getDebug()
is true and, regardless of Actor.getDebug()
, calls
Actor.drawDebug(ShapeRenderer)
on each child.Copyright © 2020. All rights reserved.