Package heronarts.glx.ui
Class UIObject
java.lang.Object
heronarts.glx.ui.UIEventHandler
heronarts.glx.ui.UIObject
- All Implemented Interfaces:
LXLoopTask
- Direct Known Subclasses:
UI2dComponent
,UI3dComponent
,UI3dContext
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddListener
(LXListenableParameter parameter, LXParameterListener listener) Adds a parameter listener which will automatically be unregistered when this UIObject is disposedaddListener
(LXListenableParameter parameter, LXParameterListener listener, boolean fire) Adds a parameter listener which will automatically be unregistered when this UIObject is disposedaddLoopTask
(LXLoopTask loopTask) Add a task to be performed on every loop of the UI engine.blur()
Blur this object.Brings this object to the front of its container.protected boolean
contains
(float x, float y) Whether the given point is contained by this objectvoid
dispose()
Focuses on this object, giving focus to everything above and whatever was previously focused below.Objects are encouraged to override this method providing a helpful String displayed to the user explaining the function of this UI component.Gets which immediate child of this object is focused, may be null.abstract float
protected GLX
getLX()
protected UIObject
Subclasses may access the object that is containing this oneprotected UI
getUI()
abstract float
getWidth()
float
getX()
float
getY()
boolean
Whether this object has direct focus, meaning that no child element is focusedboolean
hasFocus()
Whether this object has focusboolean
Whether this object is visible.final void
loop
(double deltaMs) Processes all the loop tasks in this objectprotected void
onBlur()
Subclasses override when element loses focusprotected void
Subclasses override when element is focusedprotected void
onUIResize
(UI ui) Subclasses may override this method to handle resize events on the global UI.removeLoopTask
(LXLoopTask loopTask) Remove a task from the UI engineprotected void
setConsumeMousePress
(boolean consumeMousePress) Toggles whether this object always consumes mouse press events it receivessetDebugId
(String debugId) setDescription
(String description) setVisible
(boolean visible) Set whether this object is visibleToggle visible state of this componenttoString()
Methods inherited from class heronarts.glx.ui.UIEventHandler
onKeyPressed, onKeyReleased, onMouseDragged, onMouseMoved, onMouseOut, onMouseOver, onMousePressed, onMouseReleased, onMouseScroll
-
Field Details
-
visible
-
children
-
hasFocus
protected boolean hasFocus
-
-
Constructor Details
-
UIObject
protected UIObject()
-
-
Method Details
-
setDebugId
-
toString
-
addListener
Adds a parameter listener which will automatically be unregistered when this UIObject is disposed- Parameters:
parameter
- Parameter to listen tolistener
- 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 tolistener
- Parameter listenerfire
- Whether to fire listener immediately upon registration- Returns:
- this
-
dispose
public void dispose() -
getUI
-
getLX
-
requireUIThread
protected void requireUIThread() -
addLoopTask
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
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 interfaceLXLoopTask
-
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-coordinatey
- 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
-
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
Toggle visible state of this component- Returns:
- this
-
setVisible
Set whether this object is visible- Parameters:
visible
- Whether the object is visible- Returns:
- this
-
setConsumeMousePress
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
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
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
Blur this object. Blurs its children from the bottom of the tree up.- Returns:
- this
-
bringToFront
Brings this object to the front of its container.- Returns:
- this
-
onUIResize
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
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
-