Class Table

All Implemented Interfaces:
Cullable, Layout
Direct Known Subclasses:
Button, EffectTooltip, LabelToggleButton, SimulationScreen.RunningSimCell, TableButton, TextField.ContextMenu, WebView, Window

public class Table extends WidgetGroup
A group that sizes and positions children using table constraints.

Children added with add(Actor...) (and similar methods returning a Cell) are laid out in rows and columns. Other children may be added with Group.addActor(Actor) (and similar methods) but are not laid out automatically and don't affect the preferred or minimum sizes.

By default, Actor.getTouchable() is Touchable.childrenOnly.

The preferred and minimum sizes are that of the children laid out in columns and rows.

Author:
Nathan Sweet
  • Field Details

    • debugTableColor

      public static Color debugTableColor
    • debugCellColor

      public static Color debugCellColor
    • debugActorColor

      public static Color debugActorColor
    • backgroundTop

      public static Value backgroundTop
      Value that is the top padding of the table's background.
    • backgroundLeft

      public static Value backgroundLeft
      Value that is the left padding of the table's background.
    • backgroundBottom

      public static Value backgroundBottom
      Value that is the bottom padding of the table's background.
    • backgroundRight

      public static Value backgroundRight
      Value that is the right padding of the table's background.
  • Constructor Details

    • Table

      public Table()
  • Method Details

    • draw

      public void draw(Batch 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
      parentAlpha - The parent alpha, to be multiplied with this actor's alpha, allowing the parent's alpha to affect all children.
    • setBackground

      public void setBackground(@Null Drawable background)
      Parameters:
      background - May be null to clear the background.
    • background

      public Table background(@Null Drawable background)
      See Also:
    • getBackground

      @Null public Drawable getBackground()
    • hit

      @Null public Actor hit(float x, float y, boolean touchable)
      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:
      hit in class WidgetGroup
      touchable - If true, hit detection will respect the touchability.
      See Also:
    • clip

      public Table clip()
      Sets setClip(boolean) to true.
    • clip

      public Table clip(boolean enabled)
    • setClip

      public void setClip(boolean enabled)
      Causes the contents to be clipped if they exceed the table's bounds. Enabling clipping sets Group.setTransform(boolean) to true.
    • getClip

      public boolean getClip()
    • invalidate

      public void invalidate()
      Description copied from interface: Layout
      Invalidates this actor's layout, causing 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).
      Specified by:
      invalidate in interface Layout
      Overrides:
      invalidate in class WidgetGroup
    • add

      public <T extends Actor> Cell<T> add(@Null T actor)
      Adds a new cell to the table with the specified actor.
    • add

      public Table add(Actor... actors)
    • add

      public Cell add()
      Adds a cell without an actor.
    • stack

      public Cell<Stack> stack(@Null Actor... actors)
      Adds a new cell to the table with the specified actors in a Stack.
      Parameters:
      actors - May be null or empty to add a stack without any actors.
    • removeActor

      public boolean removeActor(Actor actor)
      Description copied from class: Group
      Removes an actor from this group and unfocuses it. Calls Group.removeActor(Actor, boolean) with true.
      Overrides:
      removeActor in class Group
    • removeActor

      public boolean removeActor(Actor actor, boolean unfocus)
      Description copied from class: Group
      Removes an actor from this group. Calls Group.removeActorAt(int, boolean) with the actor's child index.
      Overrides:
      removeActor in class Group
    • removeActorAt

      public Actor removeActorAt(int index, boolean unfocus)
      Description copied from class: Group
      Removes an actor from this group. If the actor will not be used again and has actions, they should be cleared so the actions will be returned to their pool, if any. This is not done automatically.
      Overrides:
      removeActorAt in class Group
      unfocus - If true, Stage.unfocus(Actor) is called.
      Returns:
      the actor removed from this group.
    • clearChildren

      public void clearChildren(boolean unfocus)
      Removes all actors and cells from the table.
      Overrides:
      clearChildren in class Group
    • reset

      public void reset()
      Removes all actors and cells from the table (same as Group.clearChildren()) and additionally resets all table properties and cell, column, and row defaults.
    • 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.
    • columnDefaults

      public Cell columnDefaults(int column)
      Gets the cell values that will be used as the defaults for all cells in the specified column. Columns are indexed starting at 0.
    • getCell

      @Null public <T extends Actor> Cell<T> getCell(T actor)
      Returns the cell for the specified actor in this table, or null.
    • getCells

      public Array<Cell> getCells()
      Returns the cells for this table.
    • getPrefWidth

      public float getPrefWidth()
      Specified by:
      getPrefWidth in interface Layout
      Overrides:
      getPrefWidth in class WidgetGroup
    • getPrefHeight

      public float getPrefHeight()
      Specified by:
      getPrefHeight in interface Layout
      Overrides:
      getPrefHeight in class WidgetGroup
    • 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
    • defaults

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

      public Table pad(Value pad)
      Sets the padTop, padLeft, padBottom, and padRight around the table to the specified value.
    • pad

      public Table pad(Value top, Value left, Value bottom, Value right)
    • padTop

      public Table padTop(Value padTop)
      Padding at the top edge of the table.
    • padLeft

      public Table padLeft(Value padLeft)
      Padding at the left edge of the table.
    • padBottom

      public Table padBottom(Value padBottom)
      Padding at the bottom edge of the table.
    • padRight

      public Table padRight(Value padRight)
      Padding at the right edge of the table.
    • pad

      public Table pad(float pad)
      Sets the padTop, padLeft, padBottom, and padRight around the table to the specified value.
    • pad

      public Table pad(float top, float left, float bottom, float right)
    • padTop

      public Table padTop(float padTop)
      Padding at the top edge of the table.
    • padLeft

      public Table padLeft(float padLeft)
      Padding at the left edge of the table.
    • padBottom

      public Table padBottom(float padBottom)
      Padding at the bottom edge of the table.
    • padRight

      public Table padRight(float padRight)
      Padding at the right edge of the table.
    • align

      public Table align(int align)
      Alignment of the logical table within the table actor. Set to Align.center, Align.top, Align.bottom , Align.left, Align.right, or any combination of those.
    • center

      public Table center()
      Sets the alignment of the logical table within the table actor to Align.center. This clears any other alignment.
    • top

      public Table top()
      Adds Align.top and clears Align.bottom for the alignment of the logical table within the table actor.
    • left

      public Table left()
      Adds Align.left and clears Align.right for the alignment of the logical table within the table actor.
    • bottom

      public Table bottom()
      Adds Align.bottom and clears Align.top for the alignment of the logical table within the table actor.
    • right

      public Table right()
      Adds Align.right and clears Align.left for the alignment of the logical table within the table actor.
    • setDebug

      public void setDebug(boolean enabled)
      Description copied from class: Actor
      If true, Actor.drawDebug(ShapeRenderer) will be called for this actor.
      Overrides:
      setDebug in class Actor
    • debug

      public Table debug()
      Description copied from class: Actor
      Calls Actor.setDebug(boolean) with true.
      Overrides:
      debug in class Actor
    • debugAll

      public Table debugAll()
      Description copied from class: Group
      Calls Group.setDebug(boolean, boolean) with true, true.
      Overrides:
      debugAll in class Group
    • debugTable

      public Table debugTable()
      Turns on table debug lines.
    • debugCell

      public Table debugCell()
      Turns on cell debug lines.
    • debugActor

      public Table debugActor()
      Turns on actor debug lines.
    • debug

      public Table debug(Table.Debug debug)
      Turns debug lines on or off.
    • getTableDebug

      public Table.Debug getTableDebug()
    • getPadTopValue

      public Value getPadTopValue()
    • getPadTop

      public float getPadTop()
    • getPadLeftValue

      public Value getPadLeftValue()
    • getPadLeft

      public float getPadLeft()
    • getPadBottomValue

      public Value getPadBottomValue()
    • getPadBottom

      public float getPadBottom()
    • getPadRightValue

      public Value getPadRightValue()
    • getPadRight

      public float getPadRight()
    • getPadX

      public float getPadX()
    • getPadY

      public float getPadY()
    • getAlign

      public int getAlign()
    • getRow

      public int getRow(float y)
      Returns the row index for the y coordinate, or -1 if not over a row.
      Parameters:
      y - The y coordinate, where 0 is the top of the table.
    • setRound

      public void setRound(boolean round)
      If true (the default), positions and sizes of child actors are rounded and ceiled to the nearest integer value.
    • getRows

      public int getRows()
    • getColumns

      public int getColumns()
    • getRowHeight

      public float getRowHeight(int rowIndex)
      Returns the height of the specified row, or 0 if the table layout has not been validated.
    • getRowMinHeight

      public float getRowMinHeight(int rowIndex)
      Returns the min height of the specified row.
    • getRowPrefHeight

      public float getRowPrefHeight(int rowIndex)
      Returns the pref height of the specified row.
    • getColumnWidth

      public float getColumnWidth(int columnIndex)
      Returns the width of the specified column, or 0 if the table layout has not been validated.
    • getColumnMinWidth

      public float getColumnMinWidth(int columnIndex)
      Returns the min width of the specified column.
    • getColumnPrefWidth

      public float getColumnPrefWidth(int columnIndex)
      Returns the pref width of the specified column.
    • layout

      public void layout()
      Positions and sizes children of the table using the cell associated with each child. The values given are the position within the parent and size of the table.
      Specified by:
      layout in interface Layout
      Overrides:
      layout in class WidgetGroup
    • drawDebug

      public void drawDebug(ShapeRenderer shapes)
      Description copied from class: Group
      Draws this actor's debug lines if Actor.getDebug() is true and, regardless of Actor.getDebug(), calls Actor.drawDebug(ShapeRenderer) on each child.
      Overrides:
      drawDebug in class Group