Package com.prineside.tdi2.scene2d.ui
Class Container<T extends Actor>
java.lang.Object
com.prineside.tdi2.scene2d.Actor
com.prineside.tdi2.scene2d.Group
com.prineside.tdi2.scene2d.ui.WidgetGroup
com.prineside.tdi2.scene2d.ui.Container<T>
A group with a single child that sizes and positions the child using constraints. This provides layout similar to a
Table
with a single cell but is more lightweight.- Author:
- Nathan Sweet
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated.Container may have only a single child.void
addActorAfter
(Actor actorAfter, Actor actor) Deprecated.Container may have only a single child.void
addActorAt
(int index, Actor actor) Deprecated.Container may have only a single child.void
addActorBefore
(Actor actorBefore, Actor actor) Deprecated.Container may have only a single child.align
(int align) Sets the alignment of the actor within the container.background
(Drawable background) bottom()
SetsAlign.bottom
and clearsAlign.top
for the alignment of the actor within the container.center()
Sets the alignment of the actor within the container toAlign.center
.clip()
Sets clip to true.clip
(boolean enabled) 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.fill()
Sets fillX and fillY to 1.fill
(boolean fill) Sets fillX and fillY to 1 if true, 0 if false.fill
(boolean x, boolean y) Sets fillX and fillY to 1 if true, 0 if false.fill
(float x, float y) fillX()
Sets fillX to 1.fillY()
Sets fillY to 1.getActor()
int
getAlign()
boolean
getClip()
float
getFillX()
float
getFillY()
float
Zero indicates no max height.float
Zero indicates no max width.float
float
float
float
float
float
float
getPadX()
ReturnsgetPadLeft()
plusgetPadRight()
.float
getPadY()
ReturnsgetPadTop()
plusgetPadBottom()
.float
float
height
(float height) Sets the minHeight, prefHeight, and maxHeight to the specified value.Sets the minHeight, prefHeight, and maxHeight to the specified value.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
layout()
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, callsLayout.invalidate()
on any each child whose width or height has changed, and callsLayout.validate()
on each child.left()
SetsAlign.left
and clearsAlign.right
for the alignment of the actor within the container.maxHeight
(float maxHeight) maxSize
(float size) Sets the maxWidth and maxHeight to the specified value.maxSize
(float width, float height) Sets the maxWidth and maxHeight to the specified values.Sets the maxWidth and maxHeight to the specified value.Sets the maxWidth and maxHeight to the specified values.maxWidth
(float maxWidth) minHeight
(float minHeight) minSize
(float size) Sets the minWidth and minHeight to the specified value.minSize
(float width, float height) Sets the minWidth and minHeight to the specified values.Sets the minWidth and minHeight to the specified value.Sets the minWidth and minHeight to the specified values.minWidth
(float minWidth) pad
(float pad) Sets the padTop, padLeft, padBottom, and padRight to the specified value.pad
(float top, float left, float bottom, float right) Sets the padTop, padLeft, padBottom, and padRight to the specified value.padBottom
(float padBottom) padLeft
(float padLeft) padRight
(float padRight) padTop
(float padTop) prefHeight
(float prefHeight) prefHeight
(Value prefHeight) prefSize
(float size) Sets the prefWidth and prefHeight to the specified values.prefSize
(float width, float height) Sets the prefWidth and prefHeight to the specified value.Sets the prefWidth and prefHeight to the specified value.Sets the prefWidth and prefHeight to the specified values.prefWidth
(float prefWidth) 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.right()
SetsAlign.right
and clearsAlign.left
for the alignment of the actor within the container.void
void
setBackground
(Drawable background) Sets the background drawable and adjusts the container's padding to match the background.void
setBackground
(Drawable background, boolean adjustPadding) Sets the background drawable and, if adjustPadding is true, sets the container's padding toDrawable.getBottomHeight()
,Drawable.getTopHeight()
,Drawable.getLeftWidth()
, andDrawable.getRightWidth()
.void
setClip
(boolean enabled) Causes the contents to be clipped if they exceed the container bounds.void
setCullingArea
(Rectangle cullingArea) Children completely outside of this rectangle will not be drawn.void
setRound
(boolean round) If true (the default), positions and sizes are rounded to integers.size
(float size) Sets the minWidth, prefWidth, maxWidth, minHeight, prefHeight, and maxHeight to the specified value.size
(float width, float height) Sets the minWidth, prefWidth, maxWidth, minHeight, prefHeight, and maxHeight to the specified values.Sets the minWidth, prefWidth, maxWidth, minHeight, prefHeight, and maxHeight to the specified value.Sets the minWidth, prefWidth, maxWidth, minHeight, prefHeight, and maxHeight to the specified values.top()
SetsAlign.top
and clearsAlign.bottom
for the alignment of the actor within the container.width
(float width) Sets the minWidth, prefWidth, and maxWidth to the specified value.Sets the minWidth, prefWidth, and maxWidth to the specified value.Methods inherited from class com.prineside.tdi2.scene2d.ui.WidgetGroup
getMinWidthValue, invalidate, 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, clear, clear, clearChildren, clearChildren, debugAll, findActor, getChild, getChildren, getCullingArea, hasChildren, isTransform, localToDescendantCoordinates, setDebug, setTransform, swapActor, swapActor, toString
Methods inherited from class com.prineside.tdi2.scene2d.Actor
addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, 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, setDebug, 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
-
Constructor Details
-
Container
public Container()Creates a container with no actor. -
Container
-
-
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
Sets the background drawable and adjusts the container's padding to match the background.- See Also:
-
setBackground
Sets the background drawable and, if adjustPadding is true, sets the container's padding toDrawable.getBottomHeight()
,Drawable.getTopHeight()
,Drawable.getLeftWidth()
, andDrawable.getRightWidth()
.- Parameters:
background
- If null, the background will be cleared and padding removed.
-
background
- See Also:
-
getBackground
-
layout
public void layout()Description copied from interface:Layout
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, callsLayout.invalidate()
on any each child whose width or height has changed, and callsLayout.validate()
on each child. This method should almost never be called directly, insteadLayout.validate()
should be used.- Specified by:
layout
in interfaceLayout
- Overrides:
layout
in classWidgetGroup
-
setCullingArea
Description copied from class:Group
Children completely outside of this rectangle will not be drawn. This is only valid for use with unrotated and unscaled actors.- Specified by:
setCullingArea
in interfaceCullable
- Overrides:
setCullingArea
in classGroup
- Parameters:
cullingArea
- May be null.
-
setActor
- Parameters:
actor
- May be null.
-
getActor
- Returns:
- May be null.
-
addActor
Deprecated.Container may have only a single child.Description copied from class:Group
Adds an actor as a child of this group, removing it from its previous parent. If the actor is already a child of this group, no changes are made. -
addActorAt
Deprecated.Container may have only a single child.Description copied from class:Group
Adds an actor as a child of this group at a specific index, removing it from its previous parent. If the actor is already a child of this group, no changes are made.- Overrides:
addActorAt
in classGroup
- Parameters:
index
- May be greater than the number of children.- See Also:
-
addActorBefore
Deprecated.Container may have only a single child.Description copied from class:Group
Adds an actor as a child of this group immediately before another child actor, removing it from its previous parent. If the actor is already a child of this group, no changes are made.- Overrides:
addActorBefore
in classGroup
- See Also:
-
addActorAfter
Deprecated.Container may have only a single child.Description copied from class:Group
Adds an actor as a child of this group immediately after another child actor, removing it from its previous parent. If the actor is already a child of this group, no changes are made. IfactorAfter
is not in this group, the actor is added as the last child.- Overrides:
addActorAfter
in classGroup
- See Also:
-
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.
-
size
Sets the minWidth, prefWidth, maxWidth, minHeight, prefHeight, and maxHeight to the specified value. -
size
Sets the minWidth, prefWidth, maxWidth, minHeight, prefHeight, and maxHeight to the specified values. -
size
Sets the minWidth, prefWidth, maxWidth, minHeight, prefHeight, and maxHeight to the specified value. -
size
Sets the minWidth, prefWidth, maxWidth, minHeight, prefHeight, and maxHeight to the specified values. -
width
Sets the minWidth, prefWidth, and maxWidth to the specified value. -
width
Sets the minWidth, prefWidth, and maxWidth to the specified value. -
height
Sets the minHeight, prefHeight, and maxHeight to the specified value. -
height
Sets the minHeight, prefHeight, and maxHeight to the specified value. -
minSize
Sets the minWidth and minHeight to the specified value. -
minSize
Sets the minWidth and minHeight to the specified values. -
minWidth
-
minHeight
-
minSize
Sets the minWidth and minHeight to the specified value. -
minSize
Sets the minWidth and minHeight to the specified values. -
minWidth
-
minHeight
-
prefSize
Sets the prefWidth and prefHeight to the specified value. -
prefSize
Sets the prefWidth and prefHeight to the specified values. -
prefWidth
-
prefHeight
-
prefSize
Sets the prefWidth and prefHeight to the specified value. -
prefSize
Sets the prefWidth and prefHeight to the specified values. -
prefWidth
-
prefHeight
-
maxSize
Sets the maxWidth and maxHeight to the specified value. -
maxSize
Sets the maxWidth and maxHeight to the specified values. -
maxWidth
-
maxHeight
-
maxSize
Sets the maxWidth and maxHeight to the specified value. -
maxSize
Sets the maxWidth and maxHeight to the specified values. -
maxWidth
-
maxHeight
-
pad
Sets the padTop, padLeft, padBottom, and padRight to the specified value. -
pad
-
padTop
-
padLeft
-
padBottom
-
padRight
-
pad
Sets the padTop, padLeft, padBottom, and padRight to the specified value. -
pad
-
padTop
-
padLeft
-
padBottom
-
padRight
-
fill
Sets fillX and fillY to 1. -
fillX
Sets fillX to 1. -
fillY
Sets fillY to 1. -
fill
-
fill
Sets fillX and fillY to 1 if true, 0 if false. -
fill
Sets fillX and fillY to 1 if true, 0 if false. -
align
Sets the alignment of the actor within the container. Set toAlign.center
,Align.top
,Align.bottom
,Align.left
,Align.right
, or any combination of those. -
center
Sets the alignment of the actor within the container toAlign.center
. This clears any other alignment. -
top
SetsAlign.top
and clearsAlign.bottom
for the alignment of the actor within the container. -
left
SetsAlign.left
and clearsAlign.right
for the alignment of the actor within the container. -
bottom
SetsAlign.bottom
and clearsAlign.top
for the alignment of the actor within the container. -
right
SetsAlign.right
and clearsAlign.left
for the alignment of the actor within the container. -
getMinWidth
public float getMinWidth()- Specified by:
getMinWidth
in interfaceLayout
- Overrides:
getMinWidth
in classWidgetGroup
-
getMinHeightValue
- Overrides:
getMinHeightValue
in classWidgetGroup
-
getMinHeight
public float getMinHeight()- Specified by:
getMinHeight
in interfaceLayout
- Overrides:
getMinHeight
in classWidgetGroup
-
getPrefWidthValue
- Overrides:
getPrefWidthValue
in classWidgetGroup
-
getPrefWidth
public float getPrefWidth()- Specified by:
getPrefWidth
in interfaceLayout
- Overrides:
getPrefWidth
in classWidgetGroup
-
getPrefHeightValue
- Overrides:
getPrefHeightValue
in classWidgetGroup
-
getPrefHeight
public float getPrefHeight()- Specified by:
getPrefHeight
in interfaceLayout
- Overrides:
getPrefHeight
in classWidgetGroup
-
getMaxWidthValue
- Overrides:
getMaxWidthValue
in classWidgetGroup
-
getMaxWidth
public float getMaxWidth()Description copied from interface:Layout
Zero indicates no max width.- Specified by:
getMaxWidth
in interfaceLayout
- Overrides:
getMaxWidth
in classWidgetGroup
-
getMaxHeightValue
- Overrides:
getMaxHeightValue
in classWidgetGroup
-
getMaxHeight
public float getMaxHeight()Description copied from interface:Layout
Zero indicates no max height.- Specified by:
getMaxHeight
in interfaceLayout
- Overrides:
getMaxHeight
in classWidgetGroup
-
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()
. -
getFillX
public float getFillX() -
getFillY
public float getFillY() -
getAlign
public int getAlign() -
setRound
public void setRound(boolean round) If true (the default), positions and sizes are rounded to integers. -
clip
Sets clip to true. -
clip
-
setClip
public void setClip(boolean enabled) Causes the contents to be clipped if they exceed the container bounds. Enabling clipping will setGroup.setTransform(boolean)
to true. -
getClip
public boolean getClip() -
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:
-
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.
-