Class VerticalGroup

All Implemented Interfaces:
Cullable, Layout

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

The preferred width is the largest preferred width of any child. The preferred height is the sum of the children's preferred heights plus spacing. 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 height, so widgets which return 0 as their preferred height will be given a height of 0.

Author:
Nathan Sweet
  • Constructor Details

    • VerticalGroup

      public VerticalGroup()
  • Method Details

    • 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
    • getPrefWidth

      public float getPrefWidth()
      Specified by:
      getPrefWidth in interface Layout
      Overrides:
      getPrefWidth in class WidgetGroup
    • getPrefHeight

      public float getPrefHeight()
      Specified by:
      getPrefHeight in interface Layout
      Overrides:
      getPrefHeight in class WidgetGroup
    • getColumns

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

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

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

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

      public boolean getReverse()
    • space

      public VerticalGroup space(float space)
      Sets the vertical space between children.
    • getSpace

      public float getSpace()
    • wrapSpace

      public VerticalGroup wrapSpace(float wrapSpace)
      Sets the horizontal space between columns when wrap is enabled.
    • getWrapSpace

      public float getWrapSpace()
    • pad

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

      public VerticalGroup pad(float top, float left, float bottom, float right)
    • padTop

      public VerticalGroup padTop(float padTop)
    • padLeft

      public VerticalGroup padLeft(float padLeft)
    • padBottom

      public VerticalGroup padBottom(float padBottom)
    • padRight

      public VerticalGroup padRight(float padRight)
    • getPadTop

      public float getPadTop()
    • getPadLeft

      public float getPadLeft()
    • getPadBottom

      public float getPadBottom()
    • getPadRight

      public float getPadRight()
    • align

      public VerticalGroup align(int align)
      Sets the alignment of all widgets within the vertical group. Set to Align.center, Align.top, Align.bottom, Align.left, Align.right, or any combination of those.
    • center

      public VerticalGroup center()
      Sets the alignment of all widgets within the vertical group to Align.center. This clears any other alignment.
    • top

      public VerticalGroup top()
      Sets Align.top and clears Align.bottom for the alignment of all widgets within the vertical group.
    • left

      public VerticalGroup left()
      Adds Align.left and clears Align.right for the alignment of all widgets within the vertical group.
    • bottom

      public VerticalGroup bottom()
      Sets Align.bottom and clears Align.top for the alignment of all widgets within the vertical group.
    • right

      public VerticalGroup right()
      Adds Align.right and clears Align.left for the alignment of all widgets within the vertical group.
    • getAlign

      public int getAlign()
    • fill

      public VerticalGroup fill()
    • fill

      public VerticalGroup fill(float fill)
      Parameters:
      fill - 0 will use preferred height.
    • getFill

      public float getFill()
    • expand

      public VerticalGroup expand()
    • expand

      public VerticalGroup expand(boolean expand)
      When true and wrap is false, the columns will take up the entire vertical group width.
    • getExpand

      public boolean getExpand()
    • grow

      public VerticalGroup grow()
      Sets fill to 1 and expand to true.
    • wrap

      public VerticalGroup wrap()
      If false, the widgets are arranged in a single column and the preferred height is the widget heights plus spacing.

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

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

    • wrap

      public VerticalGroup wrap(boolean wrap)
    • getWrap

      public boolean getWrap()
    • columnAlign

      public VerticalGroup columnAlign(int columnAlign)
      Sets the vertical alignment of each column of widgets when wrapping is enabled and sets the horizontal alignment of widgets within each column. Set to Align.center, Align.top, Align.bottom, Align.left, Align.right, or any combination of those.
    • columnCenter

      public VerticalGroup columnCenter()
      Sets the alignment of widgets within each column to Align.center. This clears any other alignment.
    • columnTop

      public VerticalGroup columnTop()
      Adds Align.top and clears Align.bottom for the alignment of each column of widgets when wrapping is enabled.
    • columnLeft

      public VerticalGroup columnLeft()
      Adds Align.left and clears Align.right for the alignment of widgets within each column.
    • columnBottom

      public VerticalGroup columnBottom()
      Adds Align.bottom and clears Align.top for the alignment of each column of widgets when wrapping is enabled.
    • columnRight

      public VerticalGroup columnRight()
      Adds Align.right and clears Align.left for the alignment of widgets within each column.