Class UIContainer

All Implemented Interfaces:
UIKeyHandler, Hintable, Savable
Direct Known Subclasses:
UIFrame, UIPanel, UIPopupMenu, UISlider, UISliderKnob, UITooltip

public abstract class UIContainer extends UIComponent
Defines a component that can hold and manage other components or containers, using a layout manager to position and potentially resize them.
  • Field Details

    • STANDIN_TEXTURE_SIZE

      public static int STANDIN_TEXTURE_SIZE
    • _textureRenderer

      protected static TextureRenderer _textureRenderer
      A texture renderer to use for cache operations.
  • Constructor Details

    • UIContainer

      public UIContainer()
  • Method Details

    • contains

      public boolean contains(UIComponent component)
      Checks to see if a given UIComponent is in this container.
      Parameters:
      component - the component to look for
      Returns:
      true if the given component is in this container.
    • contains

      public boolean contains(UIComponent component, boolean recurse)
      Checks to see if a given UIComponent is in this container or (if instructed) its subcontainers.
      Parameters:
      component - the component to look for
      recurse - if true, recursively check any sub-containers for the given component.
      Returns:
      if the given component is found
    • add

      public void add(UIComponent component)
      Add a component to this container.
      Parameters:
      component - the component to add
    • remove

      public void remove(UIComponent component)
      Remove a component from this container.
      Parameters:
      component - the component to remove
    • removeAllComponents

      public void removeAllComponents()
      Removes all UI components from this container. If other types of Spatials are attached to this container, they are ignored.
    • detachAllChildren

      public void detachAllChildren()
      Description copied from class: Node
      detachAllChildren removes all children attached to this node.
      Overrides:
      detachAllChildren in class Node
    • setLayout

      public void setLayout(UILayout layout)
      Parameters:
      layout - the new layout to use with this container. If null, no layout is done by this container.
    • getLayout

      public UILayout getLayout()
      Returns:
      the layout currently used by this container or null if no layout is used.
    • layout

      public void layout()
      Description copied from class: UIComponent
      Override this to perform actual layout.
      Overrides:
      layout in class UIComponent
    • updateMinimumSizeFromContents

      public void updateMinimumSizeFromContents()
      Description copied from class: UIComponent
      Ask this component to update its minimum allowed size, based on its contents.
      Overrides:
      updateMinimumSizeFromContents in class UIComponent
    • attachedToHud

      public void attachedToHud()
      Description copied from class: UIComponent
      Override to provide an action to take when this component or its top level component are attached to a UIHud.
      Overrides:
      attachedToHud in class UIComponent
    • detachedFromHud

      public void detachedFromHud()
      Description copied from class: UIComponent
      Override to provide an action to take just before this component or its top level component are removed from a UIHud.
      Overrides:
      detachedFromHud in class UIComponent
    • getUIComponent

      public UIComponent getUIComponent(int hudX, int hudY)
      Overrides:
      getUIComponent in class UIComponent
      Parameters:
      hudX - the x screen coordinate
      hudY - the y screen coordinate
      Returns:
      this component (or an appropriate child coordinate in the case of a container) if the given screen coordinates fall inside the margin area of this component.
    • drawComponent

      protected void drawComponent(Renderer renderer)
      Description copied from class: UIComponent
      Draw this component's contents using the given renderer.
      Overrides:
      drawComponent in class UIComponent
      Parameters:
      renderer - the renderer
    • draw

      public void draw(Renderer renderer)
      Description copied from class: Node
      draw calls the onDraw method for each child maintained by this node.
      Overrides:
      draw in class UIComponent
      Parameters:
      renderer - the renderer to draw to.
      See Also:
    • isDirty

      public boolean isDirty()
      Returns:
      true if this container has had recent content changes that would require a repaint.
    • setDirty

      public void setDirty(boolean dirty)
      Parameters:
      dirty - true if this container has had recent content changes that would require a repaint.
    • fireComponentDirty

      public void fireComponentDirty()
      Set ourselves dirty.
      Overrides:
      fireComponentDirty in class UIComponent
    • fireStyleChanged

      public void fireStyleChanged()
      Description copied from class: UIComponent
      Let subcomponents know that style has been changed.
      Overrides:
      fireStyleChanged in class UIComponent
    • clearStandin

      public void clearStandin()
      Release our standin and cached texture for gc. If needed again, they will be created from scratch.
    • setDoClip

      public void setDoClip(boolean doClip)
      Parameters:
      doClip - true (default) if we want this container to clip the drawing of its contents to the dimensions of its content area.
    • isDoClip

      public boolean isDoClip()
    • setUseStandin

      public void setUseStandin(boolean use)
      Parameters:
      use - if true, we will draw the container's contents to a cached texture and use that to display this container (on a simple quad) instead of drawing all of its components each time. When the container is marked as dirty, we will update the contents of the texture.
    • isUseStandin

      public boolean isUseStandin()
      Returns:
      true if we should use a cached texture copy to draw this container.
      See Also:
    • isDrawingStandin

      public static boolean isDrawingStandin()
      Returns:
      true if we are currently rendering a container to texture.
    • setMinificationFilter

      public void setMinificationFilter(Texture.MinificationFilter filter)
      Set the minification filter for the standin.
      Parameters:
      filter - the minification filter to set
    • getMinificationFilter

      public Texture.MinificationFilter getMinificationFilter()
      Returns:
      the minification filter used for standin.