libgdx API

com.badlogic.gdx.scenes.scene2d.ui.tablelayout
Class Table

java.lang.Object
  extended by com.badlogic.gdx.scenes.scene2d.Actor
      extended by com.badlogic.gdx.scenes.scene2d.Group
          extended by com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
              extended by com.badlogic.gdx.scenes.scene2d.ui.tablelayout.Table
All Implemented Interfaces:
Cullable, Layout
Direct Known Subclasses:
Button, Window

public class Table
extends WidgetGroup

Author:
Nathan Sweet

Field Summary
 boolean clip
           
 boolean isPressed
           
 
Fields inherited from class com.badlogic.gdx.scenes.scene2d.Group
batchTransform, children, cullingArea, debug, debugTexture, groups, immutableChildren, immutableGroups, lastTouchedChild, localTransform, namesToActors, oldBatchTransform, point, transform, worldTransform
 
Fields inherited from class com.badlogic.gdx.scenes.scene2d.Actor
actions, color, height, name, originX, originY, parent, rotation, scaleX, scaleY, stage, touchable, visible, width, x, y
 
Constructor Summary
Table()
           
Table(Skin skin)
           
Table(Skin skin, TableLayout layout, java.lang.String name)
           
Table(java.lang.String name)
           
 
Method Summary
 Cell add()
          Adds a cell with a placeholder actor.
 Cell add(Actor actor)
          Adds a new cell to the table with the specified actor.
 Cell add(java.lang.String text)
           
 Table align(int align)
          Alignment of the table within the actor being laid out.
 Table align(java.lang.String value)
          Alignment of the table within the actor being laid out.
 Table bottom()
          Sets the alignment of the table within the actor being laid out to Align.BOTTOM.
 Table center()
          Sets the alignment of the table within the actor being laid out to Align.CENTER.
 void clear()
          Removes all actors and cells from the table.
 void click(float x, float y)
           
 Cell columnDefaults(int column)
          Gets the cell values that will be used as the defaults for all cells in the specified column.
 Table debug()
          Turns on all debug lines.
 Table debug(int debug)
          Turns on debug lines.
 Table debug(java.lang.String value)
          Turns on debug lines.
 Cell defaults()
          The cell values that will be used as the defaults for all cells.
 void draw(SpriteBatch 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(SpriteBatch batch, float parentAlpha)
          Called to draw the background, before clipping is applied (if enabled).
static void drawDebug(Stage stage)
          Draws the debug lines for all TableLayouts in the stage.
 int getAlign()
           
 java.util.List<Cell> getAllCells()
          Returns all cells, anywhere in the table hierarchy.
 java.util.List<Cell> getAllCells(java.lang.String namePrefix)
          Returns all cells with the specified name prefix, anywhere in the table hierarchy.
 NinePatch getBackgroundPatch()
           
 Cell getCell(Actor actor)
          Returns the cell for the specified actor, anywhere in the table hierarchy.
 Cell getCell(java.lang.String name)
          Returns the cell with the specified name, anywhere in the table hierarchy.
 java.util.List<Cell> getCells()
          Returns the cells for this table.
 ClickListener getClickListener()
           
 int getDebug()
           
 java.lang.String getHeight()
           
 float getMinHeight()
           
 float getMinWidth()
           
 java.lang.String getPadBottom()
           
 java.lang.String getPadLeft()
           
 java.lang.String getPadRight()
           
 java.lang.String getPadTop()
           
 float getPrefHeight()
           
 float getPrefWidth()
           
 int getRow(float y)
          Returns the row index for the y coordinate.
 TableLayout getTableLayout()
           
 Actor getWidget(java.lang.String name)
          Returns the widget with the specified name, anywhere in the table hierarchy.
 java.util.List<Actor> getWidgets()
          Returns all named widgets, anywhere in the table hierarchy.
 java.util.List<Actor> getWidgets(java.lang.String namePrefix)
          Returns all widgets with the specified name prefix, anywhere in the table hierarchy.
 Table height(int height)
          The fixed height of the table.
 Table height(java.lang.String height)
          The fixed height of the table, or null.
 void invalidate()
          Invalidates this actor's layout, causing Layout.layout() to be called the next time Layout.validate() is called.
 void layout()
          Positions and sizes children of the actor being laid out using the cell associated with each child.
 Table left()
          Sets the alignment of the table within the actor being laid out to Align.LEFT.
 Table newTable()
          Creates a new table with the same Skin and AssetManager as this table.
 Table pad(int pad)
          Padding around the table.
 Table pad(int top, int left, int bottom, int right)
          Padding around the table.
 Table pad(java.lang.String pad)
          Padding around the table.
 Table pad(java.lang.String top, java.lang.String left, java.lang.String bottom, java.lang.String right)
          Padding around the table.
 Table padBottom(int padBottom)
          Padding at the bottom of the table.
 Table padBottom(java.lang.String padBottom)
          Padding at the bottom of the table.
 Table padLeft(int padLeft)
          Padding at the left of the table.
 Table padLeft(java.lang.String padLeft)
          Padding at the left of the table.
 Table padRight(int padRight)
          Padding at the right of the table.
 Table padRight(java.lang.String padRight)
          Padding at the right of the table.
 Table padTop(int padTop)
          Padding at the top of the table.
 Table padTop(java.lang.String padTop)
          Padding at the top of the table.
 void parse(FileHandle tableDescriptionFile)
           
 void parse(java.lang.String tableDescription)
          Parses a table description and adds the actors and cells to the table.
 Actor register(java.lang.String name, Actor widget)
           
 void reset()
          Removes all actors and cells from the table (same as clear()) and additionally resets all table properties and cell, column, and row defaults.
 Table right()
          Sets the alignment of the table within the actor being laid out to Align.RIGHT.
 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 setAssetManager(AssetManager assetManager)
           
 void setBackground(NinePatch background)
          Sets the background ninepatch and sets the table's padding to NinePatch.getTopHeight() , NinePatch.getBottomHeight(), NinePatch.getLeftWidth(), and NinePatch.getRightWidth().
 void setClickListener(ClickListener listener)
           
 void setClip(boolean enabled)
          Causes the contents to be clipped if they exceed the table bounds.
 void setSkin(Skin skin)
           
 void setWidget(java.lang.String name, Actor actor)
          Sets the actor in the cell with the specified name.
 Table size(int width, int height)
          The fixed size of the table.
 Table size(java.lang.String width, java.lang.String height)
          The fixed size of the table.
 Cell stack(Actor... actor)
          Adds a new cell to the table with the specified actors in a Stack.
 Table top()
          Sets the alignment of the table within the actor being laid out to Align.TOP.
 boolean touchDown(float x, float y, int pointer)
           
 void touchUp(float x, float y, int pointer)
           
 Table width(int width)
          The fixed width of the table.
 Table width(java.lang.String width)
          The fixed width of the table, or null.
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
childrenChanged, getMaxHeight, getMaxWidth, invalidateHierarchy, needsLayout, pack, setFillParent, validate
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Group
act, addActor, addActorAfter, addActorAt, addActorBefore, applyTransform, disableDebugging, drawChild, drawChildren, enableDebugging, findActor, getActors, getGroups, hit, isDescendant, removeActor, removeActorRecursive, resetTransform, setCullingArea, sortChildren, swapActor, swapActor, toChildCoordinates, toLocalCoordinates, touchMoved, updateTransform
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
action, clearActions, getStage, isMarkedToRemove, keyDown, keyTyped, keyUp, markToRemove, remove, scrolled, toLocalCoordinates, toString, touchDragged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

clip

public boolean clip

isPressed

public boolean isPressed
Constructor Detail

Table

public Table()

Table

public Table(java.lang.String name)

Table

public Table(Skin skin)

Table

public Table(Skin skin,
             TableLayout layout,
             java.lang.String name)
Method Detail

draw

public void draw(SpriteBatch batch,
                 float parentAlpha)
Description copied from class: WidgetGroup
If this method is overridden, the super method or WidgetGroup.validate() should be called to ensure the widget group is laid out.

Overrides:
draw in class WidgetGroup
Parameters:
batch - the spritebatch to render with
parentAlpha - the parent's alpha value.

drawBackground

protected void drawBackground(SpriteBatch batch,
                              float parentAlpha)
Called to draw the background, before clipping is applied (if enabled). Default implementation draws the background nine patch.


invalidate

public void invalidate()
Description copied from interface: Layout
Invalidates this actor's layout, causing Layout.layout() to be called the next time Layout.validate() is called. This should be done 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 interface Layout
Overrides:
invalidate in class WidgetGroup

getPrefWidth

public float getPrefWidth()

getPrefHeight

public float getPrefHeight()

getMinWidth

public float getMinWidth()
Specified by:
getMinWidth in interface Layout
Overrides:
getMinWidth in class WidgetGroup

getMinHeight

public float getMinHeight()
Specified by:
getMinHeight in interface Layout
Overrides:
getMinHeight in class WidgetGroup

setBackground

public void setBackground(NinePatch background)
Sets the background ninepatch and sets the table's padding to NinePatch.getTopHeight() , NinePatch.getBottomHeight(), NinePatch.getLeftWidth(), and NinePatch.getRightWidth().

Parameters:
background - If null, no background will be set and all padding is removed.

getBackgroundPatch

public NinePatch getBackgroundPatch()

setClip

public void setClip(boolean enabled)
Causes the contents to be clipped if they exceed the table bounds. Enabling clipping will set Group.transform to true.


setClickListener

public void setClickListener(ClickListener listener)

getClickListener

public ClickListener getClickListener()

touchDown

public boolean touchDown(float x,
                         float y,
                         int pointer)
Overrides:
touchDown in class Group

touchUp

public void touchUp(float x,
                    float y,
                    int pointer)
Overrides:
touchUp in class Actor

click

public void click(float x,
                  float y)

getRow

public int getRow(float y)
Returns the row index for the y coordinate.


getTableLayout

public TableLayout getTableLayout()

clear

public void clear()
Removes all actors and cells from the table.

Overrides:
clear in class Group

register

public Actor register(java.lang.String name,
                      Actor widget)

add

public Cell add(java.lang.String text)

add

public Cell add()
Adds a cell with a placeholder actor.


add

public Cell add(Actor actor)
Adds a new cell to the table with the specified actor.

Parameters:
actor - May be null to add a cell without an actor.
See Also:
TableLayout#add(Actor)

stack

public Cell stack(Actor... actor)
Adds a new cell to the table with the specified actors in a Stack.

Parameters:
actor - May be null to add a cell without an actor.
See Also:
TableLayout#stack(Actor...)

newTable

public Table newTable()
Creates a new table with the same Skin and AssetManager as this table.


row

public 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.

See Also:
TableLayout#row()

parse

public void parse(FileHandle tableDescriptionFile)

parse

public void parse(java.lang.String tableDescription)
Parses a table description and adds the actors and cells to the table.

See Also:
TableLayout#parse(String)

columnDefaults

public Cell columnDefaults(int column)
Gets the cell values that will be used as the defaults for all cells in the specified column.

See Also:
TableLayout#columnDefaults(int)

defaults

public Cell defaults()
The cell values that will be used as the defaults for all cells.

See Also:
TableLayout#defaults()

layout

public void layout()
Positions and sizes children of the actor being laid out using the cell associated with each child.

Specified by:
layout in interface Layout
Overrides:
layout in class WidgetGroup
See Also:
TableLayout.layout()

reset

public void reset()
Removes all actors and cells from the table (same as clear()) and additionally resets all table properties and cell, column, and row defaults.

See Also:
TableLayout#reset()

getWidget

public Actor getWidget(java.lang.String name)
Returns the widget with the specified name, anywhere in the table hierarchy.


getWidgets

public java.util.List<Actor> getWidgets()
Returns all named widgets, anywhere in the table hierarchy.


getWidgets

public java.util.List<Actor> getWidgets(java.lang.String namePrefix)
Returns all widgets with the specified name prefix, anywhere in the table hierarchy.


getCell

public Cell getCell(Actor actor)
Returns the cell for the specified actor, anywhere in the table hierarchy.

See Also:
TableLayout#getCell(Actor)

getCell

public Cell getCell(java.lang.String name)
Returns the cell with the specified name, anywhere in the table hierarchy.

See Also:
TableLayout#getCell(String)

getAllCells

public java.util.List<Cell> getAllCells()
Returns all cells, anywhere in the table hierarchy.

See Also:
TableLayout#getAllCells()

getAllCells

public java.util.List<Cell> getAllCells(java.lang.String namePrefix)
Returns all cells with the specified name prefix, anywhere in the table hierarchy.

See Also:
TableLayout#getAllCells(String)

getCells

public java.util.List<Cell> getCells()
Returns the cells for this table.

See Also:
TableLayout#getCells()

setWidget

public void setWidget(java.lang.String name,
                      Actor actor)
Sets the actor in the cell with the specified name.

See Also:
TableLayout#setWidget(String, Actor)

size

public Table size(java.lang.String width,
                  java.lang.String height)
The fixed size of the table.

See Also:
TableLayout#size(String, String)

width

public Table width(java.lang.String width)
The fixed width of the table, or null.

See Also:
TableLayout#width(String)

height

public Table height(java.lang.String height)
The fixed height of the table, or null.

See Also:
TableLayout#height(String)

size

public Table size(int width,
                  int height)
The fixed size of the table.

See Also:
TableLayout#size(int, int)

width

public Table width(int width)
The fixed width of the table.

See Also:
TableLayout#width(int)

height

public Table height(int height)
The fixed height of the table.

See Also:
TableLayout#height(int)

pad

public Table pad(java.lang.String pad)
Padding around the table.

See Also:
TableLayout#pad(String)

pad

public Table pad(java.lang.String top,
                 java.lang.String left,
                 java.lang.String bottom,
                 java.lang.String right)
Padding around the table.

See Also:
TableLayout#pad(String, String, String, String)

padTop

public Table padTop(java.lang.String padTop)
Padding at the top of the table.

See Also:
TableLayout#padTop(String)

padLeft

public Table padLeft(java.lang.String padLeft)
Padding at the left of the table.

See Also:
TableLayout#padLeft(String)

padBottom

public Table padBottom(java.lang.String padBottom)
Padding at the bottom of the table.

See Also:
TableLayout#padBottom(String)

padRight

public Table padRight(java.lang.String padRight)
Padding at the right of the table.

See Also:
TableLayout#padRight(String)

pad

public Table pad(int pad)
Padding around the table.

See Also:
TableLayout#pad(int)

pad

public Table pad(int top,
                 int left,
                 int bottom,
                 int right)
Padding around the table.

See Also:
TableLayout#pad(int, int, int, int)

padTop

public Table padTop(int padTop)
Padding at the top of the table.

See Also:
TableLayout#padTop(int)

padLeft

public Table padLeft(int padLeft)
Padding at the left of the table.

See Also:
TableLayout#padLeft(int)

padBottom

public Table padBottom(int padBottom)
Padding at the bottom of the table.

See Also:
TableLayout#padBottom(int)

padRight

public Table padRight(int padRight)
Padding at the right of the table.

See Also:
TableLayout#padRight(int)

align

public Table align(int align)
Alignment of the table within the actor being laid out. Set to Align.CENTER, Align.TOP, Align.BOTTOM , Align.LEFT , Align.RIGHT, or any combination of those.

See Also:
TableLayout#align(int)

align

public Table align(java.lang.String value)
Alignment of the table within the actor being laid out. Set to "center", "top", "bottom", "left", "right", or a string containing any combination of those.

See Also:
TableLayout#align(String)

center

public Table center()
Sets the alignment of the table within the actor being laid out to Align.CENTER.

See Also:
TableLayout#center()

top

public Table top()
Sets the alignment of the table within the actor being laid out to Align.TOP.

See Also:
TableLayout#top()

left

public Table left()
Sets the alignment of the table within the actor being laid out to Align.LEFT.

See Also:
TableLayout#left()

bottom

public Table bottom()
Sets the alignment of the table within the actor being laid out to Align.BOTTOM.

See Also:
TableLayout#bottom()

right

public Table right()
Sets the alignment of the table within the actor being laid out to Align.RIGHT.

See Also:
TableLayout#right()

debug

public Table debug()
Turns on all debug lines.

See Also:
TableLayout#debug()

debug

public Table debug(int debug)
Turns on debug lines. Set to , , , , or any combination of those. Set to to disable.

See Also:
TableLayout#debug()

debug

public Table debug(java.lang.String value)
Turns on debug lines. Set to "all", "table", "cell", "widget", or a string containing any combination of those. Set to null to disable.

See Also:
TableLayout#debug(String)

getDebug

public int getDebug()

getHeight

public java.lang.String getHeight()

getPadTop

public java.lang.String getPadTop()

getPadLeft

public java.lang.String getPadLeft()

getPadBottom

public java.lang.String getPadBottom()

getPadRight

public java.lang.String getPadRight()

getAlign

public int getAlign()

setSkin

public void setSkin(Skin skin)

setAssetManager

public void setAssetManager(AssetManager assetManager)

drawDebug

public static void drawDebug(Stage stage)
Draws the debug lines for all TableLayouts in the stage. If this method is not called each frame, no debug lines will be drawn. If debug is never turned on for any table in the application, calling this method will have no effect. If a table has ever had debug set, calling this method causes an expensive traversal of all actors in the stage.


libgdx API

Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)