Package com.prineside.tdi2.scene2d.ui
Class Table
java.lang.Object
com.prineside.tdi2.scene2d.Actor
com.prineside.tdi2.scene2d.Group
com.prineside.tdi2.scene2d.ui.WidgetGroup
com.prineside.tdi2.scene2d.ui.Table
- Direct Known Subclasses:
Button
,EffectTooltip
,LabelToggleButton
,SimulationScreen.RunningSimCell
,TableButton
,TextField.ContextMenu
,WebView
,Window
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
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic Value
Value that is the bottom padding of the table's background.static Value
Value that is the left padding of the table's background.static Value
Value that is the right padding of the table's background.static Value
Value that is the top padding of the table's background.static Color
static Color
static Color
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd()
Adds a cell without an actor.add
(T actor) Adds a new cell to the table with the specified actor.align
(int align) Alignment of the logical table within the table actor.background
(Drawable background) bottom()
AddsAlign.bottom
and clearsAlign.top
for the alignment of the logical table within the table actor.center()
Sets the alignment of the logical table within the table actor toAlign.center
.void
clearChildren
(boolean unfocus) Removes all actors and cells from the table.clip()
SetssetClip(boolean)
to true.clip
(boolean enabled) columnDefaults
(int column) Gets the cell values that will be used as the defaults for all cells in the specified column.debug()
CallsActor.setDebug(boolean)
withtrue
.debug
(Table.Debug debug) Turns debug lines on or off.Turns on actor debug lines.debugAll()
CallsGroup.setDebug(boolean, boolean)
withtrue, true
.Turns on cell debug lines.Turns on table debug lines.defaults()
The cell values that will be used as the defaults for all cells.void
If this method is overridden, the super method orWidgetGroup.validate()
should be called to ensure the widget group is laid out.void
drawDebug
(ShapeRenderer shapes) Draws this actor's debug lines ifActor.getDebug()
is true and, regardless ofActor.getDebug()
, callsActor.drawDebug(ShapeRenderer)
on each child.int
getAlign()
getCell
(T actor) Returns the cell for the specified actor in this table, or null.getCells()
Returns the cells for this table.boolean
getClip()
float
getColumnMinWidth
(int columnIndex) Returns the min width of the specified column.float
getColumnPrefWidth
(int columnIndex) Returns the pref width of the specified column.int
float
getColumnWidth
(int columnIndex) Returns the width of the specified column, or 0 if the table layout has not been validated.float
float
float
float
float
float
float
getPadX()
ReturnsgetPadLeft()
plusgetPadRight()
.float
getPadY()
ReturnsgetPadTop()
plusgetPadBottom()
.float
float
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()
hit
(float x, float y, boolean touchable) If this method is overridden, the super method orWidgetGroup.validate()
should be called to ensure the widget group is laid out.void
Invalidates this actor's layout, causingLayout.layout()
to happen the next timeLayout.validate()
is called.void
layout()
Positions and sizes children of the table using the cell associated with each child.left()
AddsAlign.left
and clearsAlign.right
for the alignment of the logical table within the table actor.pad
(float pad) Sets the padTop, padLeft, padBottom, and padRight around the table to the specified value.pad
(float top, float left, float bottom, float right) Sets the padTop, padLeft, padBottom, and padRight around the table to the specified value.padBottom
(float padBottom) Padding at the bottom edge of the table.Padding at the bottom edge of the table.padLeft
(float padLeft) Padding at the left edge of the table.Padding at the left edge of the table.padRight
(float padRight) Padding at the right edge of the table.Padding at the right edge of the table.padTop
(float padTop) Padding at the top edge of the table.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.removeActorAt
(int index, boolean unfocus) Removes an actor from this group.void
reset()
Removes all actors and cells from the table (same asGroup.clearChildren()
) and additionally resets all table properties and cell, column, and row defaults.right()
AddsAlign.right
and clearsAlign.left
for the alignment of the logical table within the table actor.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
setClip
(boolean enabled) Causes the contents to be clipped if they exceed the table'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 and ceiled to the nearest integer value.Adds a new cell to the table with the specified actors in aStack
.top()
AddsAlign.top
and clearsAlign.bottom
for the alignment of the logical table within the table actor.Methods inherited from class com.prineside.tdi2.scene2d.ui.WidgetGroup
getMaxHeight, getMaxHeightValue, getMaxWidth, getMaxWidthValue, getMinHeightValue, getMinWidthValue, getPrefHeightValue, getPrefWidthValue, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setPrefHeight, setPrefHeight, setPrefWidth, setPrefWidth, setWidth, validate
Methods inherited from class com.prineside.tdi2.scene2d.Group
act, addActor, addActorAfter, addActorAt, addActorBefore, clear, clear, clearChildren, findActor, getChild, getChildren, getCullingArea, hasChildren, isTransform, localToDescendantCoordinates, setCullingArea, setDebug, setTransform, swapActor, swapActor, toString
Methods inherited from class com.prineside.tdi2.scene2d.Actor
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, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront
-
Field Details
-
debugTableColor
-
debugCellColor
-
debugActorColor
-
backgroundTop
Value that is the top padding of the table's background. -
backgroundLeft
Value that is the left padding of the table's background. -
backgroundBottom
Value that is the bottom padding of the table's background. -
backgroundRight
Value that is the right padding of the table's background.
-
-
Constructor Details
-
Table
public Table()
-
-
Method Details
-
draw
Description copied from class:WidgetGroup
If this method is overridden, the super method orWidgetGroup.validate()
should be called to ensure the widget group is laid out.- Overrides:
draw
in classWidgetGroup
parentAlpha
- The parent alpha, to be multiplied with this actor's alpha, allowing the parent's alpha to affect all children.
-
setBackground
- Parameters:
background
- May be null to clear the background.
-
background
- See Also:
-
getBackground
-
hit
Description copied from class:WidgetGroup
If this method is overridden, the super method orWidgetGroup.validate()
should be called to ensure the widget group is laid out.- Overrides:
hit
in classWidgetGroup
touchable
- If true, hit detection will respect thetouchability
.- See Also:
-
clip
SetssetClip(boolean)
to true. -
clip
-
setClip
public void setClip(boolean enabled) Causes the contents to be clipped if they exceed the table's bounds. Enabling clipping setsGroup.setTransform(boolean)
to true. -
getClip
public boolean getClip() -
invalidate
public void invalidate()Description copied from interface:Layout
Invalidates this actor's layout, causingLayout.layout()
to happen the next timeLayout.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 interfaceLayout
- Overrides:
invalidate
in classWidgetGroup
-
add
Adds a new cell to the table with the specified actor. -
add
-
add
Adds a cell without an actor. -
stack
Adds a new cell to the table with the specified actors in aStack
.- Parameters:
actors
- May be null or empty to add a stack without any actors.
-
removeActor
Description copied from class:Group
Removes an actor from this group and unfocuses it. CallsGroup.removeActor(Actor, boolean)
with true.- Overrides:
removeActor
in classGroup
-
removeActor
Description copied from class:Group
Removes an actor from this group. CallsGroup.removeActorAt(int, boolean)
with the actor's child index.- Overrides:
removeActor
in classGroup
-
removeActorAt
Description copied from class:Group
Removes an actor from this group. If the actor will not be used again and has actions, they should becleared
so the actions will be returned to theirpool
, if any. This is not done automatically.- Overrides:
removeActorAt
in classGroup
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 classGroup
-
reset
public void reset()Removes all actors and cells from the table (same asGroup.clearChildren()
) and additionally resets all table properties and cell, column, and row defaults. -
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
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
Returns the cell for the specified actor in this table, or null. -
getCells
Returns the cells for this table. -
getPrefWidth
public float getPrefWidth()- Specified by:
getPrefWidth
in interfaceLayout
- Overrides:
getPrefWidth
in classWidgetGroup
-
getPrefHeight
public float getPrefHeight()- Specified by:
getPrefHeight
in interfaceLayout
- Overrides:
getPrefHeight
in classWidgetGroup
-
getMinWidth
public float getMinWidth()- Specified by:
getMinWidth
in interfaceLayout
- Overrides:
getMinWidth
in classWidgetGroup
-
getMinHeight
public float getMinHeight()- Specified by:
getMinHeight
in interfaceLayout
- Overrides:
getMinHeight
in classWidgetGroup
-
defaults
The cell values that will be used as the defaults for all cells. -
pad
Sets the padTop, padLeft, padBottom, and padRight around the table to the specified value. -
pad
-
padTop
Padding at the top edge of the table. -
padLeft
Padding at the left edge of the table. -
padBottom
Padding at the bottom edge of the table. -
padRight
Padding at the right edge of the table. -
pad
Sets the padTop, padLeft, padBottom, and padRight around the table to the specified value. -
pad
-
padTop
Padding at the top edge of the table. -
padLeft
Padding at the left edge of the table. -
padBottom
Padding at the bottom edge of the table. -
padRight
Padding at the right edge of the table. -
align
Alignment of the logical table within the table actor. Set toAlign.center
,Align.top
,Align.bottom
,Align.left
,Align.right
, or any combination of those. -
center
Sets the alignment of the logical table within the table actor toAlign.center
. This clears any other alignment. -
top
AddsAlign.top
and clearsAlign.bottom
for the alignment of the logical table within the table actor. -
left
AddsAlign.left
and clearsAlign.right
for the alignment of the logical table within the table actor. -
bottom
AddsAlign.bottom
and clearsAlign.top
for the alignment of the logical table within the table actor. -
right
AddsAlign.right
and clearsAlign.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. -
debug
Description copied from class:Actor
CallsActor.setDebug(boolean)
withtrue
. -
debugAll
Description copied from class:Group
CallsGroup.setDebug(boolean, boolean)
withtrue, true
. -
debugTable
Turns on table debug lines. -
debugCell
Turns on cell debug lines. -
debugActor
Turns on actor debug lines. -
debug
Turns debug lines on or off. -
getTableDebug
-
getPadTopValue
-
getPadTop
public float getPadTop() -
getPadLeftValue
-
getPadLeft
public float getPadLeft() -
getPadBottomValue
-
getPadBottom
public float getPadBottom() -
getPadRightValue
-
getPadRight
public float getPadRight() -
getPadX
public float getPadX()ReturnsgetPadLeft()
plusgetPadRight()
. -
getPadY
public float getPadY()ReturnsgetPadTop()
plusgetPadBottom()
. -
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 interfaceLayout
- Overrides:
layout
in classWidgetGroup
-
drawDebug
Description copied from class:Group
Draws this actor's debug lines ifActor.getDebug()
is true and, regardless ofActor.getDebug()
, callsActor.drawDebug(ShapeRenderer)
on each child.
-