Class HorizontalGroup

  • All Implemented Interfaces:
    Cullable, Layout

    public class HorizontalGroup
    extends WidgetGroup
    A group that lays out its children side by side horizontally, with optional wrapping. This can be easier than using Table when actors need to be inserted into or removed from the middle of the group. Group.getChildren() can be sorted to change the order of the actors (eg Actor.setZIndex(int)). invalidate() must be called after changing the children order.

    The preferred width is the sum of the children's preferred widths plus spacing. The preferred height is the largest preferred height of any child. The preferred size is slightly different when wrap is enabled. The min size is the preferred size and the max size is 0.

    Widgets are sized using their preferred width, so widgets which return 0 as their preferred width will be given a width of 0 (eg, a label with word wrap enabled).

    • Constructor Detail

      • HorizontalGroup

        public HorizontalGroup()
    • Method Detail

      • invalidate

        public void invalidate()
        Description copied from interface: Layout
        Invalidates this actor's layout, causing Layout.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).
        Specified by:
        invalidate in interface Layout
        Overrides:
        invalidate in class WidgetGroup
      • 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
      • getRows

        public int getRows()
        When wrapping is enabled, the number of rows may be > 1.
      • setRound

        public void setRound​(boolean round)
        If true (the default), positions and sizes are rounded to integers.
      • reverse

        public HorizontalGroup reverse()
        The children will be displayed last to first.
      • reverse

        public HorizontalGroup reverse​(boolean reverse)
        If true, the children will be displayed last to first.
      • getReverse

        public boolean getReverse()
      • wrapReverse

        public HorizontalGroup wrapReverse()
        Rows will wrap above the previous rows.
      • wrapReverse

        public HorizontalGroup wrapReverse​(boolean wrapReverse)
        If true, rows will wrap above the previous rows.
      • getWrapReverse

        public boolean getWrapReverse()
      • space

        public HorizontalGroup space​(float space)
        Sets the horizontal space between children.
      • getSpace

        public float getSpace()
      • wrapSpace

        public HorizontalGroup wrapSpace​(float wrapSpace)
        Sets the vertical space between rows when wrap is enabled.
      • getWrapSpace

        public float getWrapSpace()
      • pad

        public HorizontalGroup pad​(float pad)
        Sets the padTop, padLeft, padBottom, and padRight to the specified value.
      • pad

        public HorizontalGroup pad​(float top,
                                   float left,
                                   float bottom,
                                   float right)
      • getPadTop

        public float getPadTop()
      • getPadLeft

        public float getPadLeft()
      • getPadBottom

        public float getPadBottom()
      • getPadRight

        public float getPadRight()
      • center

        public HorizontalGroup center()
        Sets the alignment of all widgets within the horizontal group to Align.center. This clears any other alignment.
      • getAlign

        public int getAlign()
      • fill

        public HorizontalGroup fill​(float fill)
        Parameters:
        fill - 0 will use preferred width.
      • getFill

        public float getFill()
      • expand

        public HorizontalGroup expand​(boolean expand)
        When true and wrap is false, the rows will take up the entire horizontal group height.
      • getExpand

        public boolean getExpand()
      • wrap

        public HorizontalGroup wrap()
        If false, the widgets are arranged in a single row and the preferred width is the widget widths plus spacing.

        If true, the widgets will wrap using the width of the horizontal group. The preferred width of the group will be 0 as it is expected that something external will set the width of the group. Widgets are sized to their preferred width unless it is larger than the group's width, in which case they are sized to the group's width but not less than their minimum width. Default is false.

        When wrap is enabled, the group's preferred height depends on the width of the group. In some cases the parent of the group will need to layout twice: once to set the width of the group and a second time to adjust to the group's new preferred height.

      • getWrap

        public boolean getWrap()
      • rowCenter

        public HorizontalGroup rowCenter()
        Sets the alignment of widgets within each row to Align.center. This clears any other alignment.