Package com.ardor3d.extension.ui
Class StateBasedUIComponent
java.lang.Object
com.ardor3d.scenegraph.Spatial
com.ardor3d.scenegraph.Node
com.ardor3d.extension.ui.UIComponent
com.ardor3d.extension.ui.StateBasedUIComponent
- All Implemented Interfaces:
UIKeyHandler
,Hintable
,Savable
- Direct Known Subclasses:
AbstractLabelUIComponent
,AbstractUITextEntryComponent
StateBasedUIComponent describes a component that acts as a state machine, containing multiple states, one of which is
currently active. Each of these states may override the current appearance and behavior of the component, making this
class an ideal base for components such as "mouse over" buttons, components that can be visibly "disabled",
toggleable components, etc.
-
Field Summary
Fields inherited from class com.ardor3d.extension.ui.UIComponent
_tooltipPopTime, _tooltipText, DEFAULT_FOREGROUND_COLOR
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
Called by the hud when a component is given focus.abstract UIState
abstract UIState
boolean
keyHeld
(Key key, InputState state) Called when this component has focus and a key is held down over more than 1 input cycle.boolean
keyPressed
(Key key, InputState state) Called when this component has focus and a key is pressed.boolean
keyReleased
(Key key, InputState state) Called when this component has focus and a key is released.void
Called by the hud when a component loses focus.void
mouseDeparted
(int mouseX, int mouseY, InputState state) Called when a mouse cursor leaves this component.void
mouseEntered
(int mouseX, int mouseY, InputState state) Called when a mouse cursor enters this component.boolean
mouseMoved
(int mouseX, int mouseY, InputState state) Called when a mouse is moved while the cursor is over this component.boolean
mousePressed
(MouseButton button, InputState state) Called when a mouse button is pressed while the cursor is over this component.boolean
mouseReleased
(MouseButton button, InputState state) Called when a mouse button is released while the cursor is over this component.boolean
mouseWheel
(int wheelDx, InputState state) Called when the mouse wheel is moved while the cursor is over this component.void
Re-apply the current state.void
setEnabled
(boolean enabled) void
setForegroundColor
(ReadOnlyColorRGBA color, boolean allStates) Sets the text color on this component and (optionally) all contained states.final void
switchState
(UIState nextState) Set our current active state.Methods inherited from class com.ardor3d.extension.ui.UIComponent
addFontStyle, applySkin, attachedToHud, cancelTooltipTimer, centerOn, centerOn, clearFontStyle, clearMaximumContentSize, clearMinimumContentSize, compact, detachedFromHud, draw, drawComponent, fireComponentDirty, fireStyleChanged, fitComponentIn, getBackdrop, getBorder, getCombinedOpacity, getContentHeight, getContentWidth, getCurrentOpacity, getDefaultFontFamily, getDefaultFontSize, getDefaultFontStyles, getFontStyles, getForegroundColor, getHud, getHudX, getHudY, getKeyFocusTarget, getLayoutData, getLocalComponentHeight, getLocalComponentWidth, getLocalFontStyles, getLocalForegroundColor, getLocalOpacity, getLocalX, getLocalY, getMargin, getMaximumContentHeight, getMaximumContentWidth, getMaximumLocalComponentHeight, getMaximumLocalComponentWidth, getMinimumContentHeight, getMinimumContentWidth, getMinimumLocalComponentHeight, getMinimumLocalComponentWidth, getPadding, getRelativeComponentBounds, getRelativeMaxComponentBounds, getRelativeMinComponentBounds, getTooltipPopTime, getTooltipText, getTopLevelComponent, getTotalBottom, getTotalLeft, getTotalRight, getTotalTop, getUIComponent, hasVirginContentArea, insideMargin, isAttachedToHUD, isConsumeKeyEvents, isConsumeMouseEvents, isEnabled, isUseTransparency, isVisible, layout, mouseClicked, pack, postdrawComponent, predrawComponent, requestFocus, setBackdrop, setBorder, setConsumeKeyEvents, setConsumeMouseEvents, setContentHeight, setContentSize, setContentWidth, setDefaultFontFamily, setDefaultFontSize, setDefaultFontStyles, setFontStyles, setForegroundColor, setHudX, setHudXY, setHudY, setKeyFocusTarget, setLayoutData, setLayoutMinimumContentSize, setLocalComponentHeight, setLocalComponentSize, setLocalComponentWidth, setLocalX, setLocalXY, setLocalY, setMargin, setMaximumContentHeight, setMaximumContentSize, setMaximumContentWidth, setMinimumContentHeight, setMinimumContentSize, setMinimumContentWidth, setOpacity, setPadding, setTooltipPopTime, setTooltipText, setUseTransparency, setVirginContentArea, setVisible, updateMinimumSizeFromContents, updateWorldTransform, updateWorldTransform, validateContentSize
Methods inherited from class com.ardor3d.scenegraph.Node
acceptVisitor, attachChild, attachChildAt, detachAllChildren, detachChild, detachChildAt, detachChildNamed, getChild, getChild, getChildIndex, getChildren, getClassTag, getNumberOfChildren, hasChild, makeCopy, makeInstanced, propagateDirtyDown, read, sortLights, swapChildren, updateChildren, updateWorldBound, updateWorldRenderStates, 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, updateGeometricState, updateWorldRenderStates, worldToLocal
-
Constructor Details
-
StateBasedUIComponent
public StateBasedUIComponent()
-
-
Method Details
-
getDefaultState
- Returns:
- the state that represents the default appearance and behavior for this component.
-
getDisabledState
- Returns:
- the state that represents the disabled appearance and behavior for this component.
-
getCurrentState
- Returns:
- this component's currently active state
-
setEnabled
public void setEnabled(boolean enabled) - Overrides:
setEnabled
in classUIComponent
- Parameters:
enabled
- if true, sets the defaultState to active, otherwise sets the disabledState to active.
-
switchState
Set our current active state.- Parameters:
nextState
- the state to set as active for this component. If null, this is a no-op.
-
refreshState
public void refreshState()Re-apply the current state. -
setForegroundColor
Sets the text color on this component and (optionally) all contained states.- Parameters:
color
- the new foreground colorallStates
- if true, set across all contained states as well as self.
-
mouseDeparted
Description copied from class:UIComponent
Called when a mouse cursor leaves this component.- Overrides:
mouseDeparted
in classUIComponent
- Parameters:
mouseX
- mouse x coordinate.mouseY
- mouse y coordinate.state
- the current tracked state of the input system.
-
mouseEntered
Description copied from class:UIComponent
Called when a mouse cursor enters this component.- Overrides:
mouseEntered
in classUIComponent
- Parameters:
mouseX
- mouse x coordinate.mouseY
- mouse y coordinate.state
- the current tracked state of the input system.
-
mouseMoved
Description copied from class:UIComponent
Called when a mouse is moved while the cursor is over this component.- Overrides:
mouseMoved
in classUIComponent
- Parameters:
mouseX
- mouse x coordinate.mouseY
- mouse y coordinate.state
- the current tracked state of the input system.- Returns:
- true if we want to consider the event "consumed" by the UI system.
-
mousePressed
Description copied from class:UIComponent
Called when a mouse button is pressed while the cursor is over this component.- Overrides:
mousePressed
in classUIComponent
- Parameters:
button
- the button that was pressedstate
- the current tracked state of the input system.- Returns:
- true if we want to consider the event "consumed" by the UI system.
-
mouseReleased
Description copied from class:UIComponent
Called when a mouse button is released while the cursor is over this component.- Overrides:
mouseReleased
in classUIComponent
- Parameters:
button
- the button that was releasedstate
- the current tracked state of the input system.- Returns:
- true if we want to consider the event "consumed" by the UI system.
-
mouseWheel
Description copied from class:UIComponent
Called when the mouse wheel is moved while the cursor is over this component.- Overrides:
mouseWheel
in classUIComponent
- Parameters:
wheelDx
- the last change of the wheelstate
- the current tracked state of the input system.- Returns:
- true if we want to consider the event "consumed" by the UI system.
-
keyPressed
Description copied from class:UIComponent
Called when this component has focus and a key is pressed.- Specified by:
keyPressed
in interfaceUIKeyHandler
- Overrides:
keyPressed
in classUIComponent
- Parameters:
key
- the key pressed.state
- the current tracked state of the input system.- Returns:
- true if we want to consider the event "consumed" by the UI system.
-
keyReleased
Description copied from class:UIComponent
Called when this component has focus and a key is released.- Specified by:
keyReleased
in interfaceUIKeyHandler
- Overrides:
keyReleased
in classUIComponent
- Parameters:
key
- the key released.state
- the current tracked state of the input system.- Returns:
- true if we want to consider the event "consumed" by the UI system.
-
keyHeld
Description copied from class:UIComponent
Called when this component has focus and a key is held down over more than 1 input cycle.- Specified by:
keyHeld
in interfaceUIKeyHandler
- Overrides:
keyHeld
in classUIComponent
- Parameters:
key
- the key held.state
- the current tracked state of the input system.- Returns:
- true if we want to consider the event "consumed" by the UI system.
-
gainedFocus
public void gainedFocus()Description copied from class:UIComponent
Called by the hud when a component is given focus.- Overrides:
gainedFocus
in classUIComponent
-
lostFocus
public void lostFocus()Description copied from class:UIComponent
Called by the hud when a component loses focus.- Overrides:
lostFocus
in classUIComponent
-
getStates
- Returns:
- an ImmutableSet of possible states for this component.
-