Package com.ardor3d.extension.ui
Class UIHud
java.lang.Object
com.ardor3d.scenegraph.Spatial
com.ardor3d.scenegraph.Node
com.ardor3d.extension.ui.UIHud
UIHud represents a "Heads Up Display" or the base of a game UI scenegraph. Various UI Input, dragging, events, etc.
are handled through this class.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected final LogicalLayer
The logical layer used by this UI to receive input events.protected boolean
Internal flag indicating whether the last input event was consumed by the UI.static int
Fields inherited from class com.ardor3d.scenegraph.Spatial
_controllers, _delegateMap, _dirtyMark, _frustumIntersects, _listener, _localTransform, _name, _parent, _queueDistance, _renderStateList, _sceneHints, _userData, _worldBound, _worldTransform, ON_DIRTY_ATTACHED, ON_DIRTY_BOUNDING, ON_DIRTY_RENDERSTATE, ON_DIRTY_TRANSFORM, ON_DIRTY_TRANSFORM_ONLY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(UIComponent component) Add the given component to this hud.void
addDragListener
(DragListener listener) Add the given drag listener to this hud.void
addHudListener
(HudListener listener) Add the given hud listener to this hud.void
bringToFront
(UIComponent component) Reorder the components so that the given component is drawn last and is therefore "on top" of any others.void
void
closePopupMenusAfter
(Object parent) void
Overridden to force component detachments to go throughremove(UIComponent)
void
Override to force setting ortho before drawing and to specifically handle draw order of components and tool tip.boolean
fireKeyHeldEvent
(Key key, InputState currentIS) Handle key held (pressed down over more than one input update cycle.)boolean
fireKeyPressedEvent
(Key key, InputState currentIS) Handle key presses.boolean
fireKeyReleasedEvent
(Key key, InputState currentIS) Handle key releases.boolean
fireMouseButtonPressed
(MouseButton button, InputState currentIS) Handle mouse presses.boolean
fireMouseButtonReleased
(MouseButton button, InputState currentIS) Handle mouse releases.boolean
fireMouseMoved
(int mouseX, int mouseY, InputState currentIS) Handle movement events.boolean
fireMouseWheelMoved
(int wheelDx, InputState currentIS) Handle wheel events.int
int
int
getUIComponent
(int x, int y) Look for a UIComponent at the given screen coordinates.int
getWidth()
boolean
protected boolean
offerKeyInputToUI
(TwoInputStates inputStates) protected boolean
offerMouseInputToUI
(TwoInputStates inputStates) Parse a given set of input states for UI events and pass these events to the UI components contained in this hud.void
remove
(UIComponent component) Remove the given component from the hudboolean
removeDragListener
(DragListener listener) Remove any matching drag listener from this hud.boolean
removeHudListener
(HudListener listener) Remove any matching hud listener from this hud.void
setDragButton
(MouseButton dragButton) void
setFocusedComponent
(UIComponent compomponent) void
setIgnoreMouseInputOnGrabbed
(boolean mouseInputOnGrabbed) void
setMouseManager
(MouseManager manager) void
setPostKeyboardHook
(UIHud.UIInputPostHook postKeyboardHook) void
setPostMouseHook
(UIHud.UIInputPostHook postMouseHook) void
setupInput
(PhysicalLayer physicalLayer, LogicalLayer forwardTo) Convenience method for setting up the UI's connection to the Ardor3D input system, along with a forwarding address for input events that the UI does not care about.protected void
Set up our logical layer with a trigger that hands input to the UI and saves whether it was "consumed".void
showPopOver
(IPopOver pop) void
showSubPopupMenu
(IPopOver pop) void
updateGeometricState
(double time, boolean initiator) updateGeometricState
updates all the geometry information for the node.Methods inherited from class com.ardor3d.scenegraph.Node
acceptVisitor, attachChild, attachChildAt, detachChild, detachChildAt, detachChildNamed, getChild, getChild, getChildIndex, getChildren, getClassTag, getNumberOfChildren, hasChild, makeCopy, makeInstanced, propagateDirtyDown, read, sortLights, swapChildren, updateChildren, updateWorldBound, updateWorldRenderStates, updateWorldTransform, write
Methods inherited from class com.ardor3d.scenegraph.Spatial
addController, addTranslation, addTranslation, applyWorldRenderStates, clearControllers, clearDirty, clearDirty, clearRenderState, getController, getControllerCount, getControllers, getCurrentRenderDelegate, getLastFrustumIntersection, getListener, getLocalLastFrustumIntersection, getLocalRenderState, getLocalRenderStates, getName, getParent, getParentHintable, getRenderDelegate, getRotation, getScale, getSceneHints, getTransform, getTranslation, getUserData, getWorldBound, getWorldRotation, getWorldScale, getWorldTransform, getWorldTranslation, hasAncestor, isDirty, localToWorld, markDirty, markDirty, onDraw, propagateBoundToRoot, propagateDirtyUp, propagateStatesFromRoot, propageEventUp, removeController, removeController, removeFromParent, setLastFrustumIntersection, setListener, setName, setParent, setRenderDelegate, setRenderState, setRotation, setRotation, setScale, setScale, setScale, setTransform, setTranslation, setTranslation, setUserData, setWorldRotation, setWorldRotation, setWorldScale, setWorldScale, setWorldScale, setWorldTransform, setWorldTranslation, setWorldTranslation, toString, updateControllers, updateGeometricState, updateWorldRenderStates, worldToLocal
-
Field Details
-
MOUSE_CLICK_SENSITIVITY
public static int MOUSE_CLICK_SENSITIVITY -
_logicalLayer
The logical layer used by this UI to receive input events. -
_mouseInputConsumed
protected boolean _mouseInputConsumedInternal flag indicating whether the last input event was consumed by the UI. This is used to decide if we will forward the event to the next LogicalLayer. -
_keyInputConsumed
protected boolean _keyInputConsumed
-
-
Constructor Details
-
UIHud
Construct a new UIHud for a given canvas- Parameters:
canvas
- the canvas
-
-
Method Details
-
getLastMouseX
public int getLastMouseX()- Returns:
- the last detected x position of the mouse.
-
getLastMouseY
public int getLastMouseY()- Returns:
- the last detected y position of the mouse.
-
getTooltip
- Returns:
- this hud's associated tooltip object.
-
add
Add the given component to this hud.- Parameters:
component
- the component to add
-
remove
Remove the given component from the hud- Parameters:
component
- the component to remove
-
detachAllChildren
public void detachAllChildren()Overridden to force component detachments to go throughremove(UIComponent)
- Overrides:
detachAllChildren
in classNode
-
bringToFront
Reorder the components so that the given component is drawn last and is therefore "on top" of any others.- Parameters:
component
- the component to bring to front
-
getUIComponent
Look for a UIComponent at the given screen coordinates. If no pickable component is at that location, null is returned.- Parameters:
x
- the x screen coordinatey
- the y screen coordinate- Returns:
- the picked component or null if nothing pickable was found at the given coordinates.
-
getFocusedComponent
- Returns:
- the component that currently has key focus or null if none.
-
setFocusedComponent
- Parameters:
compomponent
- the component that should now have key focus. If this component has a focus target, that will be used instead.
-
getDragButton
- Returns:
- the MouseButton that triggers drag operations
-
setDragButton
- Parameters:
dragButton
- set the MouseButton that triggers drag operations
-
draw
Override to force setting ortho before drawing and to specifically handle draw order of components and tool tip. -
updateGeometricState
public void updateGeometricState(double time, boolean initiator) Description copied from class:Spatial
updateGeometricState
updates all the geometry information for the node.- Overrides:
updateGeometricState
in classSpatial
- Parameters:
time
- The time in seconds between the last two consecutive frames (time per frame). SeeReadOnlyTimer.getTimePerFrame()
initiator
- true if this node started the update process.
-
addDragListener
Add the given drag listener to this hud. Expired WeakReferences are also cleaned.- Parameters:
listener
- the listener to add
-
removeDragListener
Remove any matching drag listener from this hud. Expired WeakReferences are also cleaned.- Parameters:
listener
- the listener to remove- Returns:
- true if at least one "equal" DragListener was found in the pool of listeners and removed.
-
addHudListener
Add the given hud listener to this hud.- Parameters:
listener
- the listener to add
-
removeHudListener
Remove any matching hud listener from this hud.- Parameters:
listener
- the listener to remove- Returns:
- true if at least one "equal" HudListener was found in the pool of listeners and removed.
-
getLogicalLayer
- Returns:
- the logical layer associated with this hud. When chaining UI logic to game logic, this LogicalLayer is the one to call checkTriggers on.
-
isIgnoreMouseInputOnGrabbed
public boolean isIgnoreMouseInputOnGrabbed()- Returns:
- true if we should ignore (only forward) mouse input when the mouse is set to grabbed. If true, requires mouse manager to be set or this param is ignored.
-
setIgnoreMouseInputOnGrabbed
public void setIgnoreMouseInputOnGrabbed(boolean mouseInputOnGrabbed) - Parameters:
mouseInputOnGrabbed
- true if we should ignore (only forward) mouse input when the mouse is set to grabbed. If true, requires mouse manager to be set or this param is ignored.- See Also:
-
getMouseManager
- Returns:
- a MouseManager used to test if mouse is grabbed, or null if none was set.
-
setMouseManager
- Parameters:
manager
- a MouseManager used to test if mouse is grabbed.
-
setupInput
Convenience method for setting up the UI's connection to the Ardor3D input system, along with a forwarding address for input events that the UI does not care about.- Parameters:
physicalLayer
- the physical layer to register withforwardTo
- a LogicalLayer to send unconsumed (by the UI) input events to.
-
setupLogicalLayer
protected void setupLogicalLayer()Set up our logical layer with a trigger that hands input to the UI and saves whether it was "consumed". -
offerKeyInputToUI
-
offerMouseInputToUI
Parse a given set of input states for UI events and pass these events to the UI components contained in this hud.- Parameters:
inputStates
- our two InputState objects, detailing a before and after snapshot of the input system.- Returns:
- true if a UI element consumed the event described by inputStates.
-
fireMouseButtonPressed
Handle mouse presses.- Parameters:
button
- the button that was pressed.currentIS
- the current input state.- Returns:
- true if this event is consumed.
-
fireMouseButtonReleased
Handle mouse releases.- Parameters:
button
- the button that was release.currentIS
- the current input state.- Returns:
- true if this event is consumed.
-
fireMouseMoved
Handle movement events.- Parameters:
mouseX
- the new x position of the mousemouseY
- the new y position of the mousecurrentIS
- the current input state.- Returns:
- if this event is consumed.
-
fireMouseWheelMoved
Handle wheel events.- Parameters:
wheelDx
- the change in wheel position.currentIS
- the current input state.- Returns:
- if this event is consumed.
-
fireKeyPressedEvent
Handle key presses.- Parameters:
key
- the pressed keycurrentIS
- the current input state.- Returns:
- if this event is consumed.
-
fireKeyHeldEvent
Handle key held (pressed down over more than one input update cycle.)- Parameters:
key
- the held keycurrentIS
- the current input state.- Returns:
- if this event is consumed.
-
fireKeyReleasedEvent
Handle key releases.- Parameters:
key
- the released keycurrentIS
- the current input state.- Returns:
- if this event is consumed.
-
getWidth
public int getWidth() -
getHeight
public int getHeight() -
closePopupMenus
public void closePopupMenus() -
closePopupMenusAfter
-
showPopOver
-
showSubPopupMenu
-
getPostKeyboardHook
-
setPostKeyboardHook
-
getPostMouseHook
-
setPostMouseHook
-
getCanvas
-