public class UiContainer extends ParentUiElement implements org.mini2Dx.gdx.InputProcessor
update(float)
and
render(Graphics)
must be called by your GameContainer
asyncRemoveAll, children, renderNode
deferredLayout, deferredRender, deferredUpdate, effects, height, styleId, visibility, width, x, y, zIndex
Constructor and Description |
---|
UiContainer(GameContainer gc,
AssetManager assetManager)
Constructor
|
UiContainer(int width,
int height,
AssetManager assetManager) |
Modifier and Type | Method and Description |
---|---|
void |
addActionKey(int keycode)
Add the key used for triggering actions (i.e.
|
void |
addGamePadInput(GamePadUiInput<?> input)
Adds a
GamePadUiInput instance to this UiContainer |
void |
addInputSourceListener(UiInputSourceListener listener)
Adds a
UiInputSourceListener to this UiContainer |
void |
addScreenSizeListener(ScreenSizeListener listener)
Adds a
ScreenSizeListener to listen for ScreenSize change |
void |
addUiContainerListener(UiContainerListener listener)
Adds a
UiContainerListener to this UiContainer |
void |
attach(ParentRenderNode<?,?> parentRenderNode)
Attaches a
RenderNode for this element to a parent
RenderNode |
boolean |
buttonDown(GamePadUiInput<?> controllerUiInput,
GamePadButton button) |
boolean |
buttonUp(GamePadUiInput<?> controllerUiInput,
GamePadButton button) |
void |
clearActionKeys()
Clears the keys used for triggering actions (i.e.
|
void |
clearActiveAction() |
void |
clearActiveNavigation()
Clears the current
Navigatable being navigated |
protected ParentRenderNode<?,?> |
createRenderNode(ParentRenderNode<?,?> parent)
Creates the
ParentRenderNode for this UiElement |
void |
detach(ParentRenderNode<?,?> parentRenderNode)
Detaches this element's
RenderNode from a parent
RenderNode |
void |
dispose() |
ActionableRenderNode |
getActiveAction()
Returns the currently hovered
ActionableRenderNode |
Navigatable |
getActiveNavigation()
Returns the currently active
Navigatable |
static Visibility |
getDefaultVisibility()
Returns the default
Visibility for newly created
UiElement objects |
float |
getHeight()
Returns the height of the
UiContainer |
GamePadType |
getLastGamePadType()
Returns the last
GamePadType used on the UiContainer |
InputSource |
getLastInputSource()
Returns the last
InputSource used on the UiContainer |
float |
getScaleX()
Returns the configured
Graphics scaling during rendering |
float |
getScaleY()
Returns the configured
Graphics scaling during rendering |
ScreenSizeScaleMode |
getScreenSizeScaleMode()
Returns the scaling mode used for
ScreenSize values |
static UiContainerState |
getState()
Returns the current
UiContainerState |
StyleRule |
getStyleRule() |
static UiTheme |
getTheme()
Returns the
UiTheme currently applied to this UiContainer |
float |
getWidth()
Returns the width of the
UiContainer |
static boolean |
isThemeApplied()
Returns if a
UiTheme has been applied to thi UiContainer |
boolean |
keyDown(int keycode) |
boolean |
keyNavigationAllowed()
Returns if this
UiContainer can be navigated by keyboard/gamepad |
boolean |
keyTyped(char character) |
boolean |
keyUp(int keycode) |
boolean |
mouseMoved(int screenX,
int screenY) |
boolean |
pointerNavigationAllowed()
Returns if this
UiContainer can be navigated by touch/mouse |
static void |
relayoutAllUiContainers() |
void |
removeActionKey(int keycode)
Removes a key used for triggering actions (i.e.
|
void |
removeGamePadInput(GamePadUiInput<?> input)
Removes a
GamePadUiInput instance from this
UiContainer |
void |
removeScreenSizeListener(ScreenSizeListener listener)
Removes a
ScreenSizeListener from this UiContainer |
void |
removeUiContainerListener(UiContainerListener listener)
Removes a
UiContainerListener from this UiContainer |
void |
removeUiContainerListener(UiInputSourceListener listener)
Removes a
UiInputSourceListener from this UiContainer |
void |
render(Graphics g)
Renders all visible
UiElement s |
boolean |
scrolled(int amount) |
void |
set(int width,
int height)
Sets the width and height of the
UiContainer |
void |
setActiveAction(ActionableRenderNode actionable) |
void |
setActiveNavigation(Navigatable activeNavigation)
Sets the current
Navigatable for UI navigation |
static void |
setDefaultVisibility(Visibility defaultVisibility)
Sets the default
Visibility for newly created UiElement
objects |
void |
setLastGamePadType(GamePadType lastGamePadType)
Sets the last
GamePadType used on the UiContainer |
void |
setLastInputSource(InputSource lastInputSource)
Sets the last
InputSource used on the UiContainer |
void |
setNavigationMode(NavigationMode navigationMode)
Sets the
NavigationMode on this UiContainer |
void |
setPassThroughMouseMovement(boolean passThroughMouseMovement)
Set to true if mouseMoved() events to should pass through this input handler regardless
|
void |
setScale(float scaleX,
float scaleY)
Sets the
Graphics scaling during rendering. |
void |
setScreenSizeScaleMode(ScreenSizeScaleMode screenSizeScaleMode)
Sets the scaling mode used for
ScreenSize values |
void |
setStyleId(java.lang.String styleId)
Sets the style if for this
UiElement |
static void |
setTheme(UiTheme theme)
Sets the current
UiTheme for this UiContainer |
void |
setVisibility(Visibility visibility)
Sets the current
Visibility of this UiElement |
void |
setZIndex(int zIndex)
Sets the Z index of this
UiElement . |
boolean |
touchDown(int screenX,
int screenY,
int pointer,
int button) |
boolean |
touchDragged(int screenX,
int screenY,
int pointer) |
boolean |
touchUp(int screenX,
int screenY,
int pointer,
int button) |
void |
update(float delta)
Updates all
UiElement s |
add, add, get, getChild, getElementById, getFlexLayout, getRenderHeight, getRenderWidth, getRenderX, getRenderY, getTotalChildren, invokeBeginHover, invokeEndHover, isFlexLayout, isInitialLayoutOccurred, isInitialUpdateOccurred, isOverflowClipped, isRenderNodeDirty, remove, remove, removeAll, removeAllAsync, setFlex, setFlexLayout, setHeightFlex, setOverflowClipped, setRenderNodeDirty, setWidthFlex, setXFlex, setXYFlex, setYFlex, shrinkToContents, shrinkToContents, syncWithUpdate
addEffectListener, addHoverListener, addNodeStateListener, alignAbove, alignBelow, alignEdgeToEdge, alignLeftOf, alignRightOf, applyEffect, deferUntilLayout, deferUntilLayout, deferUntilRender, deferUntilRender, deferUntilUpdate, deferUntilUpdate, deferUntilUpdate, deferUntilUpdate, equals, getContentHeight, getContentWidth, getId, getMarginBottom, getMarginLeft, getMarginRight, getMarginTop, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getStyleId, getVisibility, getX, getY, getZIndex, hashCode, isDebugEnabled, isInitialised, notifyEffectListenersOnFinished, notifyHoverListenersOnBeginHover, notifyHoverListenersOnEndHover, notifyNodeStateListeners, removeEffectListener, removeHoverListener, removeNodeStateListener, set, setContentHeight, setContentWidth, setDebugEnabled, setHeight, setHeightToContentHeightOf, setHeightToHeightOf, setWidth, setWidthToContentWidthOf, setWidthToWidthOf, setX, setXY, setY, snapTo, snapTo, syncWithLayout, syncWithRender
public UiContainer(GameContainer gc, AssetManager assetManager)
gc
- Your game's GameContainer
assetManager
- The AssetManager
for the gamepublic UiContainer(int width, int height, AssetManager assetManager)
public static void relayoutAllUiContainers()
public void dispose()
protected ParentRenderNode<?,?> createRenderNode(ParentRenderNode<?,?> parent)
ParentUiElement
ParentRenderNode
for this UiElement
createRenderNode
in class ParentUiElement
parent
- The parent of this nodeParentRenderNode
public void update(float delta)
UiElement
sdelta
- The time since the last frame (in seconds)public void render(Graphics g)
UiElement
sg
- The Graphics
contextpublic void attach(ParentRenderNode<?,?> parentRenderNode)
UiElement
RenderNode
for this element to a parent
RenderNode
attach
in class ParentUiElement
parentRenderNode
- The parent RenderNode
to attach topublic void detach(ParentRenderNode<?,?> parentRenderNode)
UiElement
RenderNode
from a parent
RenderNode
detach
in class ParentUiElement
parentRenderNode
- The parent RenderNode
to detach frompublic void setVisibility(Visibility visibility)
UiElement
Visibility
of this UiElement
setVisibility
in class ParentUiElement
visibility
- The Visibility
to setpublic void addScreenSizeListener(ScreenSizeListener listener)
ScreenSizeListener
to listen for ScreenSize
changelistener
- The ScreenSizeListener
to addpublic void removeScreenSizeListener(ScreenSizeListener listener)
ScreenSizeListener
from this UiContainer
listener
- The ScreenSizeListener
to removepublic static boolean isThemeApplied()
UiTheme
has been applied to thi UiContainer
UiTheme
has been appliedpublic static UiTheme getTheme()
UiTheme
currently applied to this UiContainer
UiTheme
has been appliedpublic static void setTheme(UiTheme theme)
UiTheme
for this UiContainer
theme
- The UiTheme
to applypublic static UiContainerState getState()
UiContainerState
public void setStyleId(java.lang.String styleId)
UiElement
UiElement
setStyleId
in class ParentUiElement
styleId
- The style id to setpublic boolean touchDown(int screenX, int screenY, int pointer, int button)
touchDown
in interface org.mini2Dx.gdx.InputProcessor
public boolean touchUp(int screenX, int screenY, int pointer, int button)
touchUp
in interface org.mini2Dx.gdx.InputProcessor
public boolean touchDragged(int screenX, int screenY, int pointer)
touchDragged
in interface org.mini2Dx.gdx.InputProcessor
public boolean mouseMoved(int screenX, int screenY)
mouseMoved
in interface org.mini2Dx.gdx.InputProcessor
public boolean scrolled(int amount)
scrolled
in interface org.mini2Dx.gdx.InputProcessor
public boolean keyTyped(char character)
keyTyped
in interface org.mini2Dx.gdx.InputProcessor
public boolean keyDown(int keycode)
keyDown
in interface org.mini2Dx.gdx.InputProcessor
public boolean keyUp(int keycode)
keyUp
in interface org.mini2Dx.gdx.InputProcessor
public boolean buttonDown(GamePadUiInput<?> controllerUiInput, GamePadButton button)
public boolean buttonUp(GamePadUiInput<?> controllerUiInput, GamePadButton button)
public void setActiveAction(ActionableRenderNode actionable)
public void setActiveNavigation(Navigatable activeNavigation)
Navigatable
for UI navigationactiveNavigation
- The current Navigatable
being navigatedpublic void clearActiveAction()
public void clearActiveNavigation()
Navigatable
being navigatedpublic Navigatable getActiveNavigation()
Navigatable
public ActionableRenderNode getActiveAction()
ActionableRenderNode
public float getWidth()
UiContainer
public float getHeight()
UiContainer
public StyleRule getStyleRule()
getStyleRule
in class UiElement
public void set(int width, int height)
UiContainer
width
- The width in pixelsheight
- The height in pixelspublic float getScaleX()
Graphics
scaling during renderingpublic float getScaleY()
Graphics
scaling during renderingpublic void setScale(float scaleX, float scaleY)
Graphics
scaling during rendering. Mouse/touch
coordinates will be scaled accordingly.scaleX
- Scaling along the X axisscaleY
- Scaling along the Y axispublic InputSource getLastInputSource()
InputSource
used on the UiContainer
public void setLastInputSource(InputSource lastInputSource)
InputSource
used on the UiContainer
lastInputSource
- The InputSource
last usedpublic GamePadType getLastGamePadType()
GamePadType
used on the UiContainer
public void setLastGamePadType(GamePadType lastGamePadType)
GamePadType
used on the UiContainer
lastGamePadType
- The GamePadType
last usedpublic void addGamePadInput(GamePadUiInput<?> input)
GamePadUiInput
instance to this UiContainer
input
- The instance to addpublic void removeGamePadInput(GamePadUiInput<?> input)
GamePadUiInput
instance from this
UiContainer
input
- The instance to removepublic void setZIndex(int zIndex)
UiElement
UiElement
. Elements will be rendered on
different Z layers in ascending Z order (negatives values first, positive values last)setZIndex
in class ParentUiElement
zIndex
- The Z indexpublic void addActionKey(int keycode)
keycode
- The Input.Keys
valuepublic void removeActionKey(int keycode)
keycode
- The Input.Keys
valuepublic void clearActionKeys()
public void setPassThroughMouseMovement(boolean passThroughMouseMovement)
passThroughMouseMovement
- public boolean keyNavigationAllowed()
UiContainer
can be navigated by keyboard/gamepadpublic boolean pointerNavigationAllowed()
UiContainer
can be navigated by touch/mousepublic void setNavigationMode(NavigationMode navigationMode)
NavigationMode
on this UiContainer
navigationMode
- The NavigationMode
public ScreenSizeScaleMode getScreenSizeScaleMode()
ScreenSize
valuesScreenSizeScaleMode.NO_SCALING
by defaultpublic void setScreenSizeScaleMode(ScreenSizeScaleMode screenSizeScaleMode)
ScreenSize
valuesscreenSizeScaleMode
- The ScreenSizeScaleMode
to setpublic void addUiContainerListener(UiContainerListener listener)
UiContainerListener
to this UiContainer
listener
- The UiContainerListener
to be notified of eventspublic void removeUiContainerListener(UiContainerListener listener)
UiContainerListener
from this UiContainer
listener
- The UiContainerListener
to stop receiving eventspublic void addInputSourceListener(UiInputSourceListener listener)
UiInputSourceListener
to this UiContainer
listener
- The UiInputSourceListener
to be notified of eventspublic void removeUiContainerListener(UiInputSourceListener listener)
UiInputSourceListener
from this UiContainer
listener
- The UiInputSourceListener
to stop receiving eventspublic static Visibility getDefaultVisibility()
Visibility
for newly created
UiElement
objectsVisibility
value. Visibility.HIDDEN
by
defaultpublic static void setDefaultVisibility(Visibility defaultVisibility)
Visibility
for newly created UiElement
objectsdefaultVisibility
- The Visibility
to set as default