Class Container<T extends Actor>

  • All Implemented Interfaces:
    Cullable, Layout

    public class Container<T extends Actor>
    extends WidgetGroup
    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.
    • Constructor Detail

      • Container

        public Container()
        Creates a container with no actor.
      • Container

        public Container​(@Null
                         T actor)
    • Method Detail

      • 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.
      • drawBackground

        protected void drawBackground​(Batch batch,
                                      float parentAlpha,
                                      float x,
                                      float y)
        Called to draw the background, before clipping is applied (if enabled). Default implementation draws the background drawable.
      • 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, calls Layout.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.
        Specified by:
        layout in interface Layout
        Overrides:
        layout in class WidgetGroup
      • setCullingArea

        public void setCullingArea​(Rectangle cullingArea)
        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 interface Cullable
        Overrides:
        setCullingArea in class Group
        Parameters:
        cullingArea - May be null.
      • setActor

        public void setActor​(@Null
                             T actor)
        Parameters:
        actor - May be null.
      • getActor

        @Null
        public T getActor()
        Returns:
        May be null.
      • addActor

        @Deprecated
        public void addActor​(Actor actor)
        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.
        Overrides:
        addActor in class Group
        See Also:
        setActor(Actor)
      • addActorAt

        @Deprecated
        public void addActorAt​(int index,
                               Actor actor)
        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 class Group
        Parameters:
        index - May be greater than the number of children.
        See Also:
        setActor(Actor)
      • addActorBefore

        @Deprecated
        public void addActorBefore​(Actor actorBefore,
                                   Actor actor)
        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 class Group
        See Also:
        setActor(Actor)
      • addActorAfter

        @Deprecated
        public void addActorAfter​(Actor actorAfter,
                                  Actor actor)
        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. If actorAfter is not in this group, the actor is added as the last child.
        Overrides:
        addActorAfter in class Group
        See Also:
        setActor(Actor)
      • 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.
      • size

        public Container<T> size​(Value size)
        Sets the minWidth, prefWidth, maxWidth, minHeight, prefHeight, and maxHeight to the specified value.
      • size

        public Container<T> size​(Value width,
                                 Value height)
        Sets the minWidth, prefWidth, maxWidth, minHeight, prefHeight, and maxHeight to the specified values.
      • size

        public Container<T> size​(float size)
        Sets the minWidth, prefWidth, maxWidth, minHeight, prefHeight, and maxHeight to the specified value.
      • size

        public Container<T> size​(float width,
                                 float height)
        Sets the minWidth, prefWidth, maxWidth, minHeight, prefHeight, and maxHeight to the specified values.
      • width

        public Container<T> width​(Value width)
        Sets the minWidth, prefWidth, and maxWidth to the specified value.
      • width

        public Container<T> width​(float width)
        Sets the minWidth, prefWidth, and maxWidth to the specified value.
      • height

        public Container<T> height​(Value height)
        Sets the minHeight, prefHeight, and maxHeight to the specified value.
      • height

        public Container<T> height​(float height)
        Sets the minHeight, prefHeight, and maxHeight to the specified value.
      • minSize

        public Container<T> minSize​(Value size)
        Sets the minWidth and minHeight to the specified value.
      • minSize

        public Container<T> minSize​(Value width,
                                    Value height)
        Sets the minWidth and minHeight to the specified values.
      • minSize

        public Container<T> minSize​(float size)
        Sets the minWidth and minHeight to the specified value.
      • minSize

        public Container<T> minSize​(float width,
                                    float height)
        Sets the minWidth and minHeight to the specified values.
      • minWidth

        public Container<T> minWidth​(float minWidth)
      • minHeight

        public Container<T> minHeight​(float minHeight)
      • prefSize

        public Container<T> prefSize​(Value size)
        Sets the prefWidth and prefHeight to the specified value.
      • prefSize

        public Container<T> prefSize​(Value width,
                                     Value height)
        Sets the prefWidth and prefHeight to the specified values.
      • prefSize

        public Container<T> prefSize​(float width,
                                     float height)
        Sets the prefWidth and prefHeight to the specified value.
      • prefSize

        public Container<T> prefSize​(float size)
        Sets the prefWidth and prefHeight to the specified values.
      • prefWidth

        public Container<T> prefWidth​(float prefWidth)
      • prefHeight

        public Container<T> prefHeight​(float prefHeight)
      • maxSize

        public Container<T> maxSize​(Value size)
        Sets the maxWidth and maxHeight to the specified value.
      • maxSize

        public Container<T> maxSize​(Value width,
                                    Value height)
        Sets the maxWidth and maxHeight to the specified values.
      • maxSize

        public Container<T> maxSize​(float size)
        Sets the maxWidth and maxHeight to the specified value.
      • maxSize

        public Container<T> maxSize​(float width,
                                    float height)
        Sets the maxWidth and maxHeight to the specified values.
      • maxWidth

        public Container<T> maxWidth​(float maxWidth)
      • maxHeight

        public Container<T> maxHeight​(float maxHeight)
      • pad

        public Container<T> pad​(Value pad)
        Sets the padTop, padLeft, padBottom, and padRight to the specified value.
      • pad

        public Container<T> pad​(float pad)
        Sets the padTop, padLeft, padBottom, and padRight to the specified value.
      • pad

        public Container<T> pad​(float top,
                                float left,
                                float bottom,
                                float right)
      • padTop

        public Container<T> padTop​(float padTop)
      • padLeft

        public Container<T> padLeft​(float padLeft)
      • padBottom

        public Container<T> padBottom​(float padBottom)
      • padRight

        public Container<T> padRight​(float padRight)
      • fill

        public Container<T> fill()
        Sets fillX and fillY to 1.
      • fillX

        public Container<T> fillX()
        Sets fillX to 1.
      • fillY

        public Container<T> fillY()
        Sets fillY to 1.
      • fill

        public Container<T> fill​(float x,
                                 float y)
      • fill

        public Container<T> fill​(boolean x,
                                 boolean y)
        Sets fillX and fillY to 1 if true, 0 if false.
      • fill

        public Container<T> fill​(boolean fill)
        Sets fillX and fillY to 1 if true, 0 if false.
      • center

        public Container<T> center()
        Sets the alignment of the actor within the container to Align.center. This clears any other alignment.
      • getMinHeightValue

        public Value getMinHeightValue()
      • getPrefWidthValue

        public Value getPrefWidthValue()
      • getPrefHeightValue

        public Value getPrefHeightValue()
      • getMaxWidthValue

        public Value getMaxWidthValue()
      • getMaxHeightValue

        public Value getMaxHeightValue()
      • 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()
      • 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

        public Container<T> clip()
        Sets clip to true.
      • clip

        public Container<T> clip​(boolean enabled)
      • setClip

        public void setClip​(boolean enabled)
        Causes the contents to be clipped if they exceed the container bounds. Enabling clipping will set Group.setTransform(boolean) to true.
      • getClip

        public boolean getClip()