public class ImageButton extends Button implements NodeStateListener
Modifier and Type | Field and Description |
---|---|
protected Image |
actionImage |
protected Image |
disabledImage |
protected Image |
hoverImage |
protected Image |
normalImage |
asyncRemoveAll, children, renderNode
deferredLayout, deferredRender, deferredUpdate, effects, height, styleId, visibility, width, x, y, zIndex
Constructor and Description |
---|
ImageButton()
Constructor.
|
ImageButton(float x,
float y,
float width,
float height)
Constructor
|
ImageButton(java.lang.String id)
Constructor
|
ImageButton(java.lang.String id,
float x,
float y,
float width,
float height)
Constructor
|
Modifier and Type | Method and Description |
---|---|
Image |
getActionImage()
Returns the backing
Image for the button in its action state |
java.lang.String |
getActionTexturePath()
Returns the texture path when button is in action state
|
java.lang.String |
getAtlas()
Returns the atlas (if any) to look up the texture in
|
Image |
getDisabledImage()
Returns the backing
Image for the button in its disabled state |
java.lang.String |
getDisabledTexturePath()
Returns the texture path when button is in disabled state
|
Image |
getHoverImage()
Returns the backing
Image for the button in its hover state |
java.lang.String |
getHoverTexturePath()
Returns the texture path when button is in hover state
|
Image |
getNormalImage()
Returns the backing
Image for the button in its default state |
java.lang.String |
getNormalTexturePath()
Returns the texture path when button is in normal state
|
TextureRegion |
getTextureRegion(AssetManager assetManager)
Returns the current
TextureRegion for this ImageButton |
boolean |
isResponsive()
Returns if the image should scale to the size of the
ImageButton |
void |
onNodeStateChanged(UiElement element,
NodeState nodeState) |
void |
setActionTexture(Texture texture)
Sets the
Texture used by this ImageButton when in its action state |
void |
setActionTexturePath(java.lang.String texturePath)
Sets the texture path to use in action state.
|
void |
setActionTextureRegion(TextureRegion textureRegion)
Sets the
TextureRegion used by this ImageButton when in its action state |
void |
setAtlas(java.lang.String atlas)
Sets the atlas to look up the texture in
|
void |
setDisabledTexture(Texture texture)
Sets the
Texture used by this ImageButton when in its disabled state |
void |
setDisabledTexturePath(java.lang.String texturePath)
Sets the texture path to use in disabled state.
|
void |
setDisabledTextureRegion(TextureRegion textureRegion)
Sets the
TextureRegion used by this ImageButton when in its disabled state |
void |
setHoverTexture(Texture texture)
Sets the
Texture used by this ImageButton when in its hover state |
void |
setHoverTexturePath(java.lang.String texturePath)
Sets the texture path to use in hover state.
|
void |
setHoverTextureRegion(TextureRegion textureRegion)
Sets the
TextureRegion used by this ImageButton when in its hover state |
void |
setNormalTexture(Texture texture)
Sets the
Texture used by this ImageButton when in its normal state |
void |
setNormalTexturePath(java.lang.String texturePath)
Sets the texture path to use in normal state.
|
void |
setNormalTextureRegion(TextureRegion textureRegion)
Sets the
TextureRegion used by this ImageButton when in its normal state |
void |
setResponsive(boolean responsive)
Sets if the image should scale to the size of the
ImageButton |
addActionListener, createRenderNode, getStyleRule, isEnabled, notifyActionListenersOfBeginEvent, notifyActionListenersOfEndEvent, removeActionListener, setEnabled
add, add, attach, detach, 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, setStyleId, setVisibility, setWidthFlex, setXFlex, setXYFlex, setYFlex, setZIndex, shrinkToContents, shrinkToContents, syncWithUpdate
addEffectListener, addHoverListener, addNodeStateListener, alignAbove, alignBelow, alignEdgeToEdge, alignLeftOf, alignRightOf, applyEffect, deferUntilLayout, deferUntilLayout, deferUntilRender, deferUntilRender, deferUntilUpdate, deferUntilUpdate, deferUntilUpdate, deferUntilUpdate, equals, getContentHeight, getContentWidth, getHeight, getId, getMarginBottom, getMarginLeft, getMarginRight, getMarginTop, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getStyleId, getVisibility, getWidth, 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
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
addHoverListener, getId, invokeBeginHover, invokeEndHover, notifyHoverListenersOnBeginHover, notifyHoverListenersOnEndHover, removeHoverListener
protected Image normalImage
protected Image hoverImage
protected Image actionImage
protected Image disabledImage
public ImageButton()
ImageButton
public ImageButton(java.lang.String id)
id
- The unique ID for this ImageButton
public ImageButton(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 ImageButton(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 TextureRegion getTextureRegion(AssetManager assetManager)
TextureRegion
for this ImageButton
assetManager
- The game's AssetManager
TextureRegion
has been setpublic void setNormalTextureRegion(TextureRegion textureRegion)
TextureRegion
used by this ImageButton
when in its normal statetextureRegion
- The TextureRegion
to usepublic void setNormalTexture(Texture texture)
Texture
used by this ImageButton
when in its normal statetexture
- The Texture
to usepublic java.lang.String getNormalTexturePath()
public void setNormalTexturePath(java.lang.String texturePath)
TextureRegion
by loading it via the AssetManager
texturePath
- The path to the texturepublic void setHoverTextureRegion(TextureRegion textureRegion)
TextureRegion
used by this ImageButton
when in its hover statetextureRegion
- The TextureRegion
to usepublic void setHoverTexture(Texture texture)
Texture
used by this ImageButton
when in its hover statetexture
- The Texture
to usepublic java.lang.String getHoverTexturePath()
public void setHoverTexturePath(java.lang.String texturePath)
TextureRegion
by loading it via the AssetManager
texturePath
- The path to the texturepublic void setActionTextureRegion(TextureRegion textureRegion)
TextureRegion
used by this ImageButton
when in its action statetextureRegion
- The TextureRegion
to usepublic void setActionTexture(Texture texture)
Texture
used by this ImageButton
when in its action statetexture
- The Texture
to usepublic java.lang.String getActionTexturePath()
public void setActionTexturePath(java.lang.String texturePath)
TextureRegion
by loading it via the AssetManager
texturePath
- The path to the texturepublic void setDisabledTextureRegion(TextureRegion textureRegion)
TextureRegion
used by this ImageButton
when in its disabled statetextureRegion
- The TextureRegion
to usepublic void setDisabledTexture(Texture texture)
Texture
used by this ImageButton
when in its disabled statetexture
- The Texture
to usepublic java.lang.String getDisabledTexturePath()
public void setDisabledTexturePath(java.lang.String texturePath)
TextureRegion
by loading it via the AssetManager
texturePath
- The path to the texturepublic java.lang.String getAtlas()
public void setAtlas(java.lang.String atlas)
atlas
- Null if the texture should not be looked up via an atlaspublic boolean isResponsive()
ImageButton
public void setResponsive(boolean responsive)
ImageButton
responsive
- public Image getNormalImage()
Image
for the button in its default statepublic Image getHoverImage()
Image
for the button in its hover statepublic Image getActionImage()
Image
for the button in its action statepublic Image getDisabledImage()
Image
for the button in its disabled statepublic void onNodeStateChanged(UiElement element, NodeState nodeState)
onNodeStateChanged
in interface NodeStateListener