public class WidgetGroup extends Group implements Layout
Group that participates in layout and provides a minimum, preferred, and maximum size.
The default preferred size of a widget group is 0 and this is almost always overridden by a subclass. The default minimum size returns the preferred size, so a subclass may choose to return 0 for minimum size if it wants to allow itself to be sized smaller than the preferred size. The default maximum size is 0, which means no maximum size.
See Layout for details on how a widget group should participate in layout. A widget group's mutator methods should call
invalidate() or invalidateHierarchy() as needed. By default, invalidateHierarchy is called when child widgets
are added and removed.
| Constructor and Description |
|---|
WidgetGroup() |
WidgetGroup(Actor... actors)
Creates a new widget group containing the specified actors.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
childrenChanged()
Called when actors are added to or removed from the group.
|
void |
draw(Batch batch,
float parentAlpha)
If this method is overridden, the super method or
validate() should be called to ensure the widget group is laid
out. |
float |
getMaxHeight()
Zero indicates no max height.
|
float |
getMaxWidth()
Zero indicates no max width.
|
float |
getMinHeight() |
float |
getMinWidth() |
float |
getPrefHeight() |
float |
getPrefWidth() |
void |
invalidate()
Invalidates this actor's layout, causing
Layout.layout() to happen the next time Layout.validate() is called. |
void |
invalidateHierarchy()
Invalidates this actor and all its ancestors, calling
Layout.invalidate() on each. |
void |
layout()
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child,
calls
Layout.invalidate() on any each child whose width or height has changed, and calls Layout.validate() on each
child. |
boolean |
needsLayout()
Returns true if the widget's layout has been
invalidated. |
void |
pack()
Sizes this actor to its preferred width and height, then calls
Layout.validate(). |
void |
setFillParent(boolean fillParent)
If true, this actor will be sized to the parent in
Layout.validate(). |
void |
setLayoutEnabled(boolean enabled)
Enables or disables the layout for this actor and all child actors, recursively.
|
protected void |
sizeChanged()
Called when the actor's size has been changed.
|
void |
validate()
Ensures the actor has been laid out.
|
act, addActor, addActorAfter, addActorAt, addActorBefore, applyTransform, applyTransform, clear, clearChildren, computeTransform, debugAll, drawChildren, drawDebug, drawDebugChildren, findActor, getChildren, getCullingArea, hasChildren, hit, isTransform, localToDescendantCoordinates, removeActor, removeActor, resetTransform, resetTransform, setCullingArea, setDebug, setStage, setTransform, swapActor, swapActor, toStringaddAction, addCaptureListener, addListener, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebugBounds, 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, hasParent, isAscendantOf, isDescendantOf, isTouchable, isVisible, localToAscendantCoordinates, localToParentCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setWidth, setX, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFrontpublic WidgetGroup()
public WidgetGroup(Actor... actors)
public float getMinWidth()
getMinWidth in interface Layoutpublic float getMinHeight()
getMinHeight in interface Layoutpublic float getPrefWidth()
getPrefWidth in interface Layoutpublic float getPrefHeight()
getPrefHeight in interface Layoutpublic float getMaxWidth()
LayoutgetMaxWidth in interface Layoutpublic float getMaxHeight()
LayoutgetMaxHeight in interface Layoutpublic void setLayoutEnabled(boolean enabled)
LayoutLayout.validate() will not
cause a layout to occur. This can be useful when an actor will be manipulated externally, such as with actions. Default is
true.setLayoutEnabled in interface Layoutpublic void validate()
LayoutLayout.layout() if Layout.invalidate() has been called since the last time
Layout.validate() was called, or if the actor otherwise needs to be laid out. This method is usually called in
Actor.draw(Batch, float) by the actor itself before drawing is performed.public boolean needsLayout()
invalidated.public void invalidate()
LayoutLayout.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).invalidate in interface Layoutpublic void invalidateHierarchy()
LayoutLayout.invalidate() on each. This method should be called when
state changes in the actor that affects the minimum, preferred, maximum, or actual size of the actor (meaning it potentially
affects the parent actor's layout).invalidateHierarchy in interface Layoutprotected void childrenChanged()
GroupchildrenChanged in class Groupprotected void sizeChanged()
ActorsizeChanged in class Actorpublic void pack()
LayoutLayout.validate().
Generally this method should not be called in an actor's constructor because it calls Layout.layout(), which means a
subclass would have layout() called before the subclass' constructor. Instead, in constructors simply set the actor's size
to Layout.getPrefWidth() and Layout.getPrefHeight(). This allows the actor to have a size at construction time for more
convenient use with groups that do not layout their children.
public void setFillParent(boolean fillParent)
LayoutLayout.validate(). If the parent is the stage, the actor will be sized
to the stage. This method is for convenience only when the widget's parent does not set the size of its children (such as
the stage).setFillParent in interface Layoutpublic void layout()
LayoutLayout.invalidate() on any each child whose width or height has changed, and calls Layout.validate() on each
child. This method should almost never be called directly, instead Layout.validate() should be used.public void draw(Batch batch, float parentAlpha)
validate() should be called to ensure the widget group is laid
out.