public abstract class UiElement extends java.lang.Object implements Hoverable
| Modifier and Type | Field and Description |
|---|---|
protected com.badlogic.gdx.utils.Array<DeferredRunnable> |
deferredLayout |
protected com.badlogic.gdx.utils.Array<DeferredRunnable> |
deferredRender |
protected com.badlogic.gdx.utils.Array<DeferredRunnable> |
deferredUpdate |
protected com.badlogic.gdx.utils.Queue<UiEffect> |
effects |
protected float |
height |
protected java.lang.String |
styleId |
protected Visibility |
visibility |
protected float |
width |
protected float |
x |
protected float |
y |
protected int |
zIndex |
| Constructor and Description |
|---|
UiElement()
Constructor.
|
UiElement(float x,
float y,
float width,
float height)
Constructor
|
UiElement(java.lang.String id)
Constructor
|
UiElement(java.lang.String id,
float x,
float y,
float width,
float height)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
addEffectListener(UiEffectListener listener)
Adds a
UiEffectListener to this UiElement |
void |
addHoverListener(HoverListener listener)
Adds a
HoverListener to listen for hover events |
void |
addNodeStateListener(NodeStateListener listener) |
void |
alignAbove(UiElement alignToElement,
HorizontalAlignment horizontalAlignment)
Aligns the bottom edge of this element to the top of another element
|
void |
alignBelow(UiElement alignToElement,
HorizontalAlignment horizontalAlignment)
Aligns the top edge of this element to the bottom of another element
|
void |
alignEdgeToEdge(UiElement alignToElement,
HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment)
Aligns the edges of this
UiElement to the edges of another element. |
void |
alignLeftOf(UiElement alignToElement,
VerticalAlignment verticalAlignment)
Aligns the right edge of this element to the left edge of another element
|
void |
alignRightOf(UiElement alignToElement,
VerticalAlignment verticalAlignment)
Aligns the left edge of this element to the right edge of another element
|
void |
applyEffect(UiEffect effect)
Applies a
UiEffect to this element |
abstract void |
attach(ParentRenderNode<?,?> parentRenderNode)
Attaches a
RenderNode for this element to a parent
RenderNode |
DeferredRunnable |
deferUntilLayout(java.lang.Runnable runnable)
Defers the execution of a
Runnable instance until the next UI re-layout completes |
DeferredRunnable |
deferUntilLayout(java.lang.Runnable runnable,
boolean skipQueue)
Defers the execution of a
Runnable instance until the next UI re-layout completes |
DeferredRunnable |
deferUntilRender(java.lang.Runnable runnable)
Defers the execution of a
Runnable instance until the UI render completes |
DeferredRunnable |
deferUntilRender(java.lang.Runnable runnable,
boolean skipQueue)
Defers the execution of a
Runnable instance until the UI render completes |
DeferredRunnable |
deferUntilUpdate(java.lang.Runnable runnable)
Defers the execution of a
Runnable instance until the next frame update |
DeferredRunnable |
deferUntilUpdate(java.lang.Runnable runnable,
boolean skipQueue)
Defers the execution of a
Runnable instance for a period of time |
DeferredRunnable |
deferUntilUpdate(java.lang.Runnable runnable,
float duration)
Defers the execution of a
Runnable instance for a period of time |
DeferredRunnable |
deferUntilUpdate(java.lang.Runnable runnable,
float duration,
boolean skipQueue)
Defers the execution of a
Runnable instance for a period of time |
abstract void |
detach(ParentRenderNode<?,?> parentRenderNode)
Detaches this element's
RenderNode from a parent
RenderNode |
boolean |
equals(java.lang.Object obj) |
float |
getContentHeight()
Returns the height of this element minus its margin and padding
|
float |
getContentWidth()
Returns the width of this element minus its margin and padding
|
UiElement |
getElementById(java.lang.String id)
Searches the UI for a
UiElement with a given id. |
float |
getHeight() |
java.lang.String |
getId()
Returns the unique id
|
int |
getMarginBottom() |
int |
getMarginLeft() |
int |
getMarginRight() |
int |
getMarginTop() |
int |
getPaddingBottom() |
int |
getPaddingLeft() |
int |
getPaddingRight() |
int |
getPaddingTop() |
abstract int |
getRenderHeight()
Returns the height this element is currently rendering at
|
abstract int |
getRenderWidth()
Returns the width this element is currently rendering at
|
abstract int |
getRenderX()
Returns X coordinate of where this element is currently rendering
|
abstract int |
getRenderY()
Returns Y coordinate of where this element is currently rendering
|
java.lang.String |
getStyleId()
Returns the current style id of this
UiElement |
abstract StyleRule |
getStyleRule() |
Visibility |
getVisibility()
Returns the current
Visibility of this UiElement |
float |
getWidth() |
float |
getX() |
float |
getY() |
int |
getZIndex()
Returns the Z index of this
UiElement |
int |
hashCode() |
boolean |
isDebugEnabled() |
boolean |
isFlexLayout()
Returns if this
UiElement is using a flex layout |
boolean |
isInitialised()
Returns if the
UiElement has been initialised within the render tree |
abstract boolean |
isInitialLayoutOccurred() |
abstract boolean |
isInitialUpdateOccurred() |
abstract boolean |
isRenderNodeDirty() |
void |
notifyEffectListenersOnFinished(UiEffect effect)
Notifies all
UiEffectListeners of the finished event |
void |
notifyHoverListenersOnBeginHover()
Notifies all
HoverListeners of the begin hover event |
void |
notifyHoverListenersOnEndHover()
Notifies all
HoverListeners of the end hover event |
void |
notifyNodeStateListeners(NodeState nodeState) |
void |
removeEffectListener(UiEffectListener listener)
Removes a
UiEffectListener from this UiElement |
void |
removeHoverListener(HoverListener listener)
Removes a
HoverListener from this Hoverable |
void |
removeNodeStateListener(NodeStateListener listener) |
boolean |
set(float x,
float y,
float width,
float height)
Sets the x, y, width and height of this element
|
boolean |
setContentHeight(float contentHeight)
Sets the content height.
|
boolean |
setContentWidth(float contentWidth)
Sets the content width.
|
void |
setDebugEnabled(boolean debugEnabled) |
boolean |
setHeight(float height)
Sets the height of this element
|
void |
setHeightToContentHeightOf(UiElement otherElement)
Sets the height of this element to match the content height of another
UiElement. |
void |
setHeightToHeightOf(UiElement otherElement)
Sets the height of this element to match the height of another
UiElement |
abstract void |
setRenderNodeDirty() |
abstract void |
setStyleId(java.lang.String styleId)
Sets the style if for this
UiElement |
abstract void |
setVisibility(Visibility visibility)
Sets the current
Visibility of this UiElement |
boolean |
setWidth(float width)
Sets the width of this element
|
void |
setWidthToContentWidthOf(UiElement otherElement)
Sets the width of this element to match the content width of another
UiElement. |
void |
setWidthToWidthOf(UiElement otherElement)
Sets the width of this element to match the width of another
UiElement |
boolean |
setX(float x)
Sets the x coordinate of this element.
|
boolean |
setXY(float x,
float y)
Sets the x and y coordinates of this element
|
boolean |
setY(float y)
Sets the y coordinate of this element
|
abstract void |
setZIndex(int zIndex)
Sets the Z index of this
UiElement. |
void |
snapTo(UiElement snapToElement)
|
void |
snapTo(UiElement snapToElement,
HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment)
Snaps this
UiElement to the same area of another element. |
void |
syncWithLayout(UiContainerRenderTree rootNode)
Syncs data between the
UiElement and RenderNode during UI layout |
void |
syncWithRender(UiContainerRenderTree rootNode)
Syncs data between the
UiElement and RenderNode during UI render |
void |
syncWithUpdate(UiContainerRenderTree rootNode)
Syncs data between the
UiElement and RenderNode during update |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitinvokeBeginHover, invokeEndHoverprotected final com.badlogic.gdx.utils.Queue<UiEffect> effects
protected final com.badlogic.gdx.utils.Array<DeferredRunnable> deferredLayout
protected final com.badlogic.gdx.utils.Array<DeferredRunnable> deferredUpdate
protected final com.badlogic.gdx.utils.Array<DeferredRunnable> deferredRender
protected Visibility visibility
protected java.lang.String styleId
protected int zIndex
protected float x
protected float y
protected float width
protected float height
public UiElement()
public UiElement(java.lang.String id)
id - The unique ID for this element (if null an ID will be generated)public UiElement(float x,
float y,
float width,
float height)
x - The x coordinate of this element relative to its parenty - The y coordinate of this element relative to its parentwidth - The width of this elementheight - The height of this elementpublic UiElement(java.lang.String id,
float x,
float y,
float width,
float height)
id - The unique ID for this element (if null an ID will be generated)x - The x coordinate of this element relative to its parenty - The y coordinate of this element relative to its parentwidth - The width of this elementheight - The height of this elementpublic abstract boolean isInitialLayoutOccurred()
public abstract boolean isInitialUpdateOccurred()
public boolean isInitialised()
UiElement has been initialised within the render treepublic abstract boolean isRenderNodeDirty()
public abstract void setRenderNodeDirty()
public void syncWithLayout(UiContainerRenderTree rootNode)
UiElement and RenderNode during UI layoutpublic void syncWithUpdate(UiContainerRenderTree rootNode)
UiElement and RenderNode during updatepublic void syncWithRender(UiContainerRenderTree rootNode)
UiElement and RenderNode during UI renderpublic void alignEdgeToEdge(UiElement alignToElement, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)
UiElement to the edges of another element.alignToElement - The UiElement to align with. Note: This can also be the UiContainerhorizontalAlignment - HorizontalAlignment.LEFT aligns the right-side of this element to the left side of the align element.
HorizontalAlignment.CENTER aligns the center of this element to the center of the align element.
HorizontalAlignment.RIGHT aligns the left-side of this element to the right-side of the align element.verticalAlignment - VerticalAlignment.TOP aligns the bottom-side of this element to the top-side of the align element.
VerticalAlignment.MIDDLE aligns the middle of this element to the middle of the align element.
VerticalAlignment.BOTTOM aligns the top-side of this element to the bottom-side of the align element.public void alignLeftOf(UiElement alignToElement, VerticalAlignment verticalAlignment)
alignToElement - The UiElement to align with. Note: This can also be the UiContainerverticalAlignment - VerticalAlignment.TOP aligns the top-side of this element to the top-side of the align element.
* VerticalAlignment.MIDDLE aligns the middle of this element to the middle of the align element.
* VerticalAlignment.BOTTOM aligns the bottom-side of this element to the bottom-side of the align element.public void alignRightOf(UiElement alignToElement, VerticalAlignment verticalAlignment)
alignToElement - The UiElement to align with. Note: This can also be the UiContainerverticalAlignment - VerticalAlignment.TOP aligns the top-side of this element to the top-side of the align element.
* VerticalAlignment.MIDDLE aligns the middle of this element to the middle of the align element.
* VerticalAlignment.BOTTOM aligns the bottom-side of this element to the bottom-side of the align element.public void alignBelow(UiElement alignToElement, HorizontalAlignment horizontalAlignment)
alignToElement - The UiElement to align with. Note: This can also be the UiContainerhorizontalAlignment - HorizontalAlignment.LEFT aligns the left-side of this element to the left side of the align element.
HorizontalAlignment.CENTER aligns the center of this element to the center of the align element.
HorizontalAlignment.RIGHT aligns the right-side of this element to the right-side of the align element.public void alignAbove(UiElement alignToElement, HorizontalAlignment horizontalAlignment)
alignToElement - The UiElement to align with. Note: This can also be the UiContainerhorizontalAlignment - HorizontalAlignment.LEFT aligns the left-side of this element to the left side of the align element.
* HorizontalAlignment.CENTER aligns the center of this element to the center of the align element.
* HorizontalAlignment.RIGHT aligns the right-side of this element to the right-side of the align element.public void snapTo(UiElement snapToElement)
snapToElement - The UiElement to snap to. Note: This can also be the UiContainerpublic void snapTo(UiElement snapToElement, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)
UiElement to the same area of another element.snapToElement - The UiElement to snap to. Note: This can also be the UiContainerhorizontalAlignment - The HorizontalAlignment of this element within the area of the align elementverticalAlignment - The VerticalAlignment of this element within the area of the align elementpublic void setWidthToWidthOf(UiElement otherElement)
UiElementotherElement - The UiElement to get the width ofpublic void setWidthToContentWidthOf(UiElement otherElement)
UiElement. See getContentWidth()otherElement - The UiElement to get the content width ofpublic void setHeightToHeightOf(UiElement otherElement)
UiElementotherElement - The UiElement to get the height ofpublic void setHeightToContentHeightOf(UiElement otherElement)
UiElement. See getContentHeight()otherElement - The UiElement to get the content height ofpublic abstract void attach(ParentRenderNode<?,?> parentRenderNode)
RenderNode for this element to a parent
RenderNodeparentRenderNode - The parent RenderNode to attach topublic abstract void detach(ParentRenderNode<?,?> parentRenderNode)
RenderNode from a parent
RenderNodeparentRenderNode - The parent RenderNode to detach frompublic void applyEffect(UiEffect effect)
UiEffect to this elementeffect - The UiEffect to be appliedpublic DeferredRunnable deferUntilUpdate(java.lang.Runnable runnable)
Runnable instance until the next frame updaterunnable - The Runnable to executeDeferredRunnable that can be cancelledpublic DeferredRunnable deferUntilUpdate(java.lang.Runnable runnable, float duration)
Runnable instance for a period of timerunnable - The Runnable to executeduration - The time to wait (in seconds) until executing the RunnableDeferredRunnable that can be cancelledpublic DeferredRunnable deferUntilUpdate(java.lang.Runnable runnable, boolean skipQueue)
Runnable instance for a period of timerunnable - The Runnable to executeskipQueue - True if the task should skip to the front of the deferred queueDeferredRunnable that can be cancelledpublic DeferredRunnable deferUntilUpdate(java.lang.Runnable runnable, float duration, boolean skipQueue)
Runnable instance for a period of timerunnable - The Runnable to executeduration - The time to wait (in seconds) until executing the RunnableskipQueue - True if the task should skip to the front of the deferred queueDeferredRunnable that can be cancelledpublic DeferredRunnable deferUntilLayout(java.lang.Runnable runnable)
Runnable instance until the next UI re-layout completesrunnable - The Runnable to executeDeferredRunnable that can be cancelledpublic DeferredRunnable deferUntilLayout(java.lang.Runnable runnable, boolean skipQueue)
Runnable instance until the next UI re-layout completesrunnable - The Runnable to executeskipQueue - True if the task should skip to the front of the deferred queueDeferredRunnable that can be cancelledpublic DeferredRunnable deferUntilRender(java.lang.Runnable runnable)
Runnable instance until the UI render completesrunnable - The Runnable to executeDeferredRunnable that can be cancelledpublic DeferredRunnable deferUntilRender(java.lang.Runnable runnable, boolean skipQueue)
Runnable instance until the UI render completesrunnable - The Runnable to executeskipQueue - True if the task should skip to the front of the deferred queueDeferredRunnable that can be cancelledpublic java.lang.String getId()
Hoverablepublic Visibility getVisibility()
Visibility of this UiElementpublic abstract void setVisibility(Visibility visibility)
Visibility of this UiElementvisibility - The Visibility to setpublic java.lang.String getStyleId()
UiElementUiTheme.DEFAULT_STYLE_ID by defaultpublic abstract void setStyleId(java.lang.String styleId)
UiElementstyleId - The style id to setpublic int getZIndex()
UiElementpublic abstract void setZIndex(int zIndex)
UiElement. Elements will be rendered on
different Z layers in ascending Z order (negatives values first, positive values last)zIndex - The Z indexpublic void addHoverListener(HoverListener listener)
HoverableHoverListener to listen for hover eventsaddHoverListener in interface Hoverablelistener - The HoverListener to addpublic void removeHoverListener(HoverListener listener)
HoverableHoverListener from this HoverableremoveHoverListener in interface Hoverablelistener - The HoverListener to removepublic void notifyHoverListenersOnBeginHover()
HoverListeners of the begin hover eventnotifyHoverListenersOnBeginHover in interface Hoverablepublic void addEffectListener(UiEffectListener listener)
UiEffectListener to this UiElementlistener - The UiEffectListener to addpublic void removeEffectListener(UiEffectListener listener)
UiEffectListener from this UiElementlistener - The UiEffectListener to removepublic void notifyHoverListenersOnEndHover()
HoverListeners of the end hover eventnotifyHoverListenersOnEndHover in interface Hoverablepublic void notifyEffectListenersOnFinished(UiEffect effect)
UiEffectListeners of the finished eventeffect - The UiEffect that finishedpublic void addNodeStateListener(NodeStateListener listener)
public void removeNodeStateListener(NodeStateListener listener)
public void notifyNodeStateListeners(NodeState nodeState)
public UiElement getElementById(java.lang.String id)
UiElement with a given id. Warning: This
can be an expensive operation for complex UIs. It is recommended you
cache results.public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic boolean isDebugEnabled()
public void setDebugEnabled(boolean debugEnabled)
public float getX()
public float getY()
public float getWidth()
public float getHeight()
public boolean set(float x,
float y,
float width,
float height)
x - The x coordinate (in pixels) relative to its parenty - The y coordinate (in pixels) relative to its parentwidth - The width in pixelsheight - The height in pixelspublic boolean setXY(float x,
float y)
x - The x coordinate (in pixels) relative to its parenty - The y coordinate (in pixels) relative to its parentpublic boolean setX(float x)
x - The x coordinate (in pixels) relative to its parentpublic boolean setY(float y)
y - The y coordinate (in pixels) relative to its parentpublic boolean setWidth(float width)
width - The width in pixelspublic boolean setHeight(float height)
height - The height in pixelspublic float getContentWidth()
public float getContentHeight()
public boolean setContentWidth(float contentWidth)
getContentWidth()contentWidth - public boolean setContentHeight(float contentHeight)
getContentHeight()contentHeight - public abstract StyleRule getStyleRule()
public int getMarginTop()
public int getMarginBottom()
public int getMarginLeft()
public int getMarginRight()
public int getPaddingTop()
public int getPaddingBottom()
public int getPaddingLeft()
public int getPaddingRight()
public abstract int getRenderX()
Integer.MIN_VALUE if not renderingpublic abstract int getRenderY()
Integer.MIN_VALUE if not renderingpublic abstract int getRenderWidth()
public abstract int getRenderHeight()
public boolean isFlexLayout()
UiElement is using a flex layout