|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.Group
com.badlogic.gdx.scenes.scene2d.ui.tablelayout.Table
com.badlogic.gdx.scenes.scene2d.ui.Container
public class Container
Group
capable of layouting inserted Actor
instances in a table layout. See
http://code.google.com/p/table-layout/
row()
method.
To insert an Actor into the current row call the add(Actor)
method. Actors are added from left to right to
the current row. Do not use the Group.addActor(Actor)
, Group.addActorAfter(Actor, Actor)
,
Group.addActorAt(int, Actor)
, Group.addActorBefore(Actor, Actor)
methods!
Container.CellProperties
defining the layout of that Actor within
the cell as well as the layout of the cell within the table.
To specify how an Actor should be layouted within the cell, one can manipulate the Container.CellProperties
instance
returned by the add(Actor)
method. It allows to define the alignment, padding, minimum and maximum size
of the Actor within the cell. By default an Actor's width and height are taken. If the Actor is a Widget
its
preferred width and height are taken (see Widget.getPrefWidth()
and Widget.getPrefWidth()
. To let an Actor
fill the entire cell on either or both the x- and y-axis one can use the Container.CellProperties.fill(boolean, boolean)
method.
The layouting process may resize the Actor according to the Container.CellProperties
as well as the available space
of the cell within the table.
To specify how a cell should be layouted within the table the Container.CellProperties
class offers the methods
Container.CellProperties.expand(boolean, boolean)
, Container.CellProperties.spacing(int, int, int, int)
and
Container.CellProperties.colspan(int)
method.
The Container.CellProperties.expand(boolean, boolean)
method will make the cell take up
any remaining space in the layout. If multiple cells are configured to expand, the sizes of each cell determined
by its contained Actor are used as weightings. Additionally one can use the Container.CellProperties.expand(int, int)
method to directly specify a weight.
The Container.CellProperties.spacing(int, int, int, int)
method allows to define how much space should be left empty
between adjacent cells.
The Container.CellProperties.colspan(int)
method allows to define how many columns a cell should span in the table.
Note that a table does not necessarily have to have the same amount of columns in every row.
To set the Container.CellProperties
for all cells in an entire row, one can manipulate the Container.CellProperties
instance
returned by the row()
method.
setPrefSize(float, float)
method.
Table.layout()
or
Table.draw(com.badlogic.gdx.graphics.g2d.SpriteBatch, float)
. Consequently, if a Container is
nested inside another Container, the parent Container also has to be invalidated.
To perform the invalidation of a Container call the invalidate()
method. To also invalidate a Container's
parent Container call the invalidateHierarchically()
method, which will invalidate the Container and
all its parents.
An Actor added to a container can also change its (preferred) size. In this case the Container has to be informed of this circumstance by a
explicitely calling either invalidate()
or invalidateHierarchically()
.
Action
to an Actor contained in a Container will not work. It is advised to not change
the size of contained Actors during runtime, as layouting every frame might be a costly operation.
Actors should also not be scaled or rotated when contained inside a Container. The layouting algorithm will simply ignore these properties!
Window
and Pane
for styled
Containers.
Nested Class Summary | |
---|---|
static class |
Container.CellProperties
Class specifying the layout of an Actor within a cell as well as the behaviour of th cell within the entire layout. |
Field Summary |
---|
Fields inherited from class com.badlogic.gdx.scenes.scene2d.ui.tablelayout.Table |
---|
layout |
Fields inherited from class com.badlogic.gdx.scenes.scene2d.Group |
---|
children, debug, debugTexture, focusedActor, groups, immutableChildren, immutableGroups, keyboardFocusedActor, lastTouchedChild, namesToActors, oldBatchTransform, scenetransform, scrollFocusedActor, tmp4, transform |
Fields inherited from class com.badlogic.gdx.scenes.scene2d.Actor |
---|
actions, color, height, name, originX, originY, parent, rotation, scaleX, scaleY, touchable, width, x, y |
Constructor Summary | |
---|---|
Container(java.lang.String name,
int prefWidth,
int prefHeight)
Creates a new container with the given name and (preferred) width. |
Method Summary | |
---|---|
Container.CellProperties |
add(Actor actor)
Adds a new Actor to this Container. |
Container |
align(int align)
Sets the alignment of this container's content within the container. |
void |
invalidate()
Invalidates this layout. |
void |
invalidateHierarchically()
Invalidates this layout and all parents that implement the Layout interface. |
Container |
padding(int top,
int left,
int bottom,
int right)
Sets the padding of this container. |
Container.CellProperties |
row()
Adds a new row to the table layout of this Container. |
void |
setPrefSize(float width,
float height)
Sets the (preferred) size of this Container. |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.tablelayout.Table |
---|
applyLayout, draw, drawDebug, getPrefHeight, getPrefWidth, layout |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Group |
---|
act, addActor, addActorAfter, addActorAt, addActorBefore, clear, disableDebugging, drawChild, drawChildren, enableDebugging, findActor, focus, getActors, getGroups, hit, keyboardFocus, keyDown, keyTyped, keyUp, removeActor, removeActorRecursive, resetTransform, scrolled, scrollFocus, setupTransform, sortChildren, swapActor, swapActor, toChildCoordinates, touchDown, touchDragged, touchMoved, touchUp, unfocusAll, unfocusAll, updateTransform |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor |
---|
action, clearActions, isMarkedToRemove, markToRemove, remove, toLocalCoordinates, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Container(java.lang.String name, int prefWidth, int prefHeight)
Container
).
name
- the name of the container.prefWidth
- the (preferred) widthprefHeight
- the (preferred) heightMethod Detail |
---|
public Container.CellProperties add(Actor actor)
Actor
to this Container. See the class documentation for
more information (Container
).
actor
- the Actor
Container.CellProperties
of the cell containing the Actor.public Container.CellProperties row()
add(Actor)
will add the Actors to this row. See the class documentation for more information (Container
).
Container.CellProperties
for all cells within this row.public Container padding(int top, int left, int bottom, int right)
top
- the top paddingleft
- the left paddingbottom
- the bottom paddingright
- the right padding
public Container align(int align)
align
- combination of TableLayout.TOP, TableLayout.LEFT, etc.
public void invalidateHierarchically()
Layout
interface.
See the class documentation for more information (Container
).
public void invalidate()
Container
)
invalidate
in interface Layout
invalidate
in class Table
public void setPrefSize(float width, float height)
invalidateHierarchically()
implicitely.
width
- the widthheight
- the height
|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |