Class UIObject

All Implemented Interfaces:
LXLoopTask
Direct Known Subclasses:
UI2dComponent, UI3dComponent, UI3dContext

public abstract class UIObject extends UIEventHandler implements LXLoopTask
  • Field Details

  • Constructor Details

    • UIObject

      protected UIObject()
  • Method Details

    • setDebugId

      public UIObject setDebugId(String debugId)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • addListener

      public UIObject addListener(LXListenableParameter parameter, LXParameterListener listener)
      Adds a parameter listener which will automatically be unregistered when this UIObject is disposed
      Parameters:
      parameter - Parameter to listen to
      listener - Parameter listener
      Returns:
      this
    • addListener

      public UIObject addListener(LXListenableParameter parameter, LXParameterListener listener, boolean fire)
      Adds a parameter listener which will automatically be unregistered when this UIObject is disposed
      Parameters:
      parameter - Parameter to listen to
      listener - Parameter listener
      fire - Whether to fire listener immediately upon registration
      Returns:
      this
    • dispose

      public void dispose()
    • getUI

      protected UI getUI()
    • getLX

      protected GLX getLX()
    • requireUIThread

      protected void requireUIThread()
    • addLoopTask

      public UIObject addLoopTask(LXLoopTask loopTask)
      Add a task to be performed on every loop of the UI engine.
      Parameters:
      loopTask - Task to be performed on every UI frame
      Returns:
      this
    • removeLoopTask

      public UIObject removeLoopTask(LXLoopTask loopTask)
      Remove a task from the UI engine
      Parameters:
      loopTask - Task to be removed from work list
      Returns:
      this
    • loop

      public final void loop(double deltaMs)
      Processes all the loop tasks in this object
      Specified by:
      loop in interface LXLoopTask
    • getParent

      protected UIObject getParent()
      Subclasses may access the object that is containing this one
      Returns:
      Parent object
    • contains

      protected boolean contains(float x, float y)
      Whether the given point is contained by this object
      Parameters:
      x - x-coordinate
      y - y-coordinate
      Returns:
      True if the object contains this point
    • getX

      public float getX()
    • getY

      public float getY()
    • getWidth

      public abstract float getWidth()
    • getHeight

      public abstract float getHeight()
    • setDescription

      public UIObject setDescription(String description)
    • getDescription

      public String getDescription()
      Objects are encouraged to override this method providing a helpful String displayed to the user explaining the function of this UI component. If no help is available, return null rather than an empty String.
      Returns:
      Helpful contextual string explaining function of this element
    • isVisible

      public boolean isVisible()
      Whether this object is visible.
      Returns:
      True if this object is being displayed
    • toggleVisible

      public UIObject toggleVisible()
      Toggle visible state of this component
      Returns:
      this
    • setVisible

      public UIObject setVisible(boolean visible)
      Set whether this object is visible
      Parameters:
      visible - Whether the object is visible
      Returns:
      this
    • setConsumeMousePress

      public UIObject setConsumeMousePress(boolean consumeMousePress)
      Toggles whether this object always consumes mouse press events it receives
      Parameters:
      consumeMousePress - Whether to always consume mouse press events by default
      Returns:
      this
    • hasFocus

      public boolean hasFocus()
      Whether this object has focus
      Returns:
      true or false
    • hasDirectFocus

      public boolean hasDirectFocus()
      Whether this object has direct focus, meaning that no child element is focused
      Returns:
      true or false
    • getFocusedChild

      public UIObject getFocusedChild()
      Gets which immediate child of this object is focused, may be null. Child may also have focused children.
      Returns:
      immediate child of this object which has focus
    • focus

      public UIObject focus(Event event)
      Focuses on this object, giving focus to everything above and whatever was previously focused below.
      Parameters:
      event - Event that caused the focus
      Returns:
      this
    • blur

      public UIObject blur()
      Blur this object. Blurs its children from the bottom of the tree up.
      Returns:
      this
    • bringToFront

      public UIObject bringToFront()
      Brings this object to the front of its container.
      Returns:
      this
    • onUIResize

      protected void onUIResize(UI ui)
      Subclasses may override this method to handle resize events on the global UI. Called on the UI thread, only happens if ui.setResizable(true) has been called.
      Parameters:
      ui - The UI object
    • onFocus

      protected void onFocus(Event event)
      Subclasses override when element is focused
      Parameters:
      event - Event that caused the focus to occur
    • onBlur

      protected void onBlur()
      Subclasses override when element loses focus