Class WidgetGroup

java.lang.Object
arc.scene.Element
arc.scene.Group
arc.scene.ui.layout.WidgetGroup
All Implemented Interfaces:
Cullable
Direct Known Subclasses:
Collapser, FxWidgetGroup, LCanvas.DragLayout, MapObjectivesCanvas, MapObjectivesCanvas.ObjectiveTilemap, ScrollPane, Stack, Table, TreeElement

public class WidgetGroup extends Group
A 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 Details

    • WidgetGroup

      public WidgetGroup()
    • WidgetGroup

      public WidgetGroup(Element... actors)
      Creates a new widget group containing the specified actors.
  • Method Details

    • getMinWidth

      public float getMinWidth()
      Overrides:
      getMinWidth in class Element
    • getMinHeight

      public float getMinHeight()
      Overrides:
      getMinHeight in class Element
    • getPrefWidth

      public float getPrefWidth()
      Overrides:
      getPrefWidth in class Element
    • getPrefHeight

      public float getPrefHeight()
      Overrides:
      getPrefHeight in class Element
    • setLayoutEnabled

      public void setLayoutEnabled(boolean enabled)
      Overrides:
      setLayoutEnabled in class Element
    • validate

      public void validate()
      Description copied from class: Element
      Ensures the actor has been laid out. Calls Element.layout() if Element.invalidate() has been called since the last time Element.validate() was called, or if the actor otherwise needs to be laid out. This method is usually called in Element.draw() by the actor itself before drawing is performed.
      Overrides:
      validate in class Element
    • needsLayout

      public boolean needsLayout()
      Returns true if the widget's layout has been invalidated.
      Overrides:
      needsLayout in class Element
    • invalidate

      public void invalidate()
      Description copied from class: Element
      Invalidates this actor's layout, causing Element.layout() to happen the next time Element.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).
      Overrides:
      invalidate in class Element
    • invalidateHierarchy

      public void invalidateHierarchy()
      Description copied from class: Element
      Invalidates this actor and its ascendants, calling Element.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).
      Overrides:
      invalidateHierarchy in class Element
    • childrenChanged

      protected void childrenChanged()
      Description copied from class: Group
      Called when actors are added to or removed from the group.
      Overrides:
      childrenChanged in class Group
    • sizeChanged

      protected void sizeChanged()
      Description copied from class: Element
      Called when the actor's size has been changed.
      Overrides:
      sizeChanged in class Element
    • pack

      public void pack()
      Description copied from class: Element
      Sizes this actor to its preferred width and height, then calls Element.validate().

      Generally this method should not be called in an actor's constructor because it calls Element.layout(), which means a subclass would have layout() called before the subclass' constructor. Instead, in constructors simply set the actor's size to Element.getPrefWidth() and Element.getPrefHeight(). This allows the actor to have a size at construction time for more convenient use with groups that do not layout their children.

      Overrides:
      pack in class Element
    • setFillParent

      public void setFillParent(boolean fillParent)
      Description copied from class: Element
      If true, this actor will be sized to the parent in Element.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).
      Overrides:
      setFillParent in class Element
    • layout

      public void layout()
      Description copied from class: Element
      Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, calls Element.invalidate() on any each child whose width or height has changed, and calls Element.validate() on each child. This method should almost never be called directly, instead Element.validate() should be used.
      Overrides:
      layout in class Element
    • draw

      public void draw()
      If this method is overridden, the super method or validate() should be called to ensure the widget group is laid out.
      Overrides:
      draw in class Group