Class TextraLabel

java.lang.Object
com.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.ui.Widget
com.github.tommyettinger.textra.TextraLabel
All Implemented Interfaces:
com.badlogic.gdx.scenes.scene2d.utils.Layout
Direct Known Subclasses:
TypingLabel

public class TextraLabel extends com.badlogic.gdx.scenes.scene2d.ui.Widget
A scene2d.ui Widget that displays text using a Font rather than a libGDX BitmapFont. This supports being laid out in a Table just like the typical Label.
...Maybe not quite ready for prime-time yet. This could use some more features for ease-of-use.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
     
     
     
     
    boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    TextraLabel​(String text, com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle style)
     
    TextraLabel​(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin)
     
    TextraLabel​(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName)
     
    TextraLabel​(String text, Font font)
     
    TextraLabel​(String text, Font font, com.badlogic.gdx.graphics.Color color)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    draw​(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha)
     
    int
    Gets the alignment for the text in this TextraLabel.
    float
     
    float
     
    boolean
     
    void
     
    void
    setAlignment​(int alignment)
    Sets the alignment for the text in this TextraLabel.
    void
    setSize​(float width, float height)
     
    void
    setText​(String markupText)
    Changes the text in this TextraLabel to the given String, parsing any markup in it.
    void
    setWrap​(boolean wrap)
     

    Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget

    getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validate

    Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor

    act, addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, drawDebugBounds, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, hit, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, scaleChanged, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setStage, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • layout

      public Layout layout
    • font

      public Font font
    • align

      public int align
    • wrap

      public boolean wrap
    • storedText

      public String storedText
  • Constructor Details

    • TextraLabel

      public TextraLabel()
    • TextraLabel

      public TextraLabel(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin)
    • TextraLabel

      public TextraLabel(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName)
    • TextraLabel

      public TextraLabel(String text, com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle style)
    • TextraLabel

      public TextraLabel(String text, Font font)
    • TextraLabel

      public TextraLabel(String text, Font font, com.badlogic.gdx.graphics.Color color)
  • Method Details

    • draw

      public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha)
      Overrides:
      draw in class com.badlogic.gdx.scenes.scene2d.ui.Widget
    • getPrefWidth

      public float getPrefWidth()
      Specified by:
      getPrefWidth in interface com.badlogic.gdx.scenes.scene2d.utils.Layout
      Overrides:
      getPrefWidth in class com.badlogic.gdx.scenes.scene2d.ui.Widget
    • getPrefHeight

      public float getPrefHeight()
      Specified by:
      getPrefHeight in interface com.badlogic.gdx.scenes.scene2d.utils.Layout
      Overrides:
      getPrefHeight in class com.badlogic.gdx.scenes.scene2d.ui.Widget
    • isWrap

      public boolean isWrap()
    • setWrap

      public void setWrap(boolean wrap)
    • setSize

      public void setSize(float width, float height)
      Overrides:
      setSize in class com.badlogic.gdx.scenes.scene2d.Actor
    • layout

      public void layout()
      Specified by:
      layout in interface com.badlogic.gdx.scenes.scene2d.utils.Layout
      Overrides:
      layout in class com.badlogic.gdx.scenes.scene2d.ui.Widget
    • getAlignment

      public int getAlignment()
      Gets the alignment for the text in this TextraLabel. This is a constant in Align.
      Returns:
      the alignment used by this TextraLabel, as a constant from Align
      See Also:
      Align
    • setAlignment

      public void setAlignment(int alignment)
      Sets the alignment for the text in this TextraLabel.
      Parameters:
      alignment - a constant from Align
      See Also:
      Align
    • setText

      public void setText(String markupText)
      Changes the text in this TextraLabel to the given String, parsing any markup in it.
      Parameters:
      markupText - a String that can contain Font markup