T
- public class LinesPanel<T extends com.badlogic.gdx.graphics.Color> extends com.badlogic.gdx.scenes.scene2d.Actor
IColoredString
s. It is lines-oriented:
putting a line may erase a line put before. It is designed to write text with
a serif font (as opposed to SquidPanel
). It performs line wrapping by
default. It can write from top to bottom or from bottom to top (the default).
This
tweet
shows an example. The panel at the top of the screenshot is implemented using
this class (with drawBottomUp
being true
).
Contrary to SquidMessageBox
, this panel doesn't support scrolling
(for now). So it's suited when it is fine forgetting old messages (as in
brogue's messages area).
An alternative, doing similar lines-drawing business,
but being backed up by {@link SquidPanel}.
Modifier and Type | Field and Description |
---|---|
int |
align
The alignment used when typesetting
|
com.badlogic.gdx.graphics.Color |
clearingColor
The color to use to clear the screen before drawing.
|
protected LinkedList<squidpony.panel.IColoredString<T>> |
content
What to display.
|
boolean |
drawBottomUp
If
true , draws: |
protected com.badlogic.gdx.graphics.g2d.BitmapFont |
font
The font used to draw
content . |
protected squidpony.panel.IMarkup<T> |
markup
The markup used to typeset
content . |
protected int |
maxLines
The maximal size of
content |
protected com.badlogic.gdx.graphics.glutils.ShapeRenderer |
renderer
The renderer used by
clearArea(Batch) . |
boolean |
wrap
Whether to wrap text
|
float |
xOffset
The horizontal offset to use when writing.
|
float |
yOffset
The vertical offset to use when writing.
|
Constructor and Description |
---|
LinesPanel(squidpony.panel.IMarkup<T> markup,
com.badlogic.gdx.graphics.g2d.BitmapFont font,
int maxLines) |
Modifier and Type | Method and Description |
---|---|
void |
addFirst(squidpony.panel.IColoredString<T> ics)
|
void |
addLast(squidpony.panel.IColoredString<T> ics)
|
protected String |
applyMarkup(squidpony.panel.IColoredString<T> ics) |
protected boolean |
atMax() |
protected void |
clearArea(com.badlogic.gdx.graphics.g2d.Batch batch)
Paints this panel with
clearingColor |
static int |
computeMaxLines(com.badlogic.gdx.graphics.g2d.BitmapFont font,
float height) |
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
float parentAlpha) |
protected com.badlogic.gdx.graphics.glutils.ShapeRenderer |
getRenderer() |
protected String |
toDraw(squidpony.panel.IColoredString<T> ics,
int ydx) |
protected squidpony.panel.IColoredString<T> |
transform(squidpony.panel.IColoredString<T> ics,
int ydx)
If you want to grey out "older" messages, you would do it in this method,
when
ydx > 0 (using an IColorCenter maybe ?). |
act, addAction, addCaptureListener, addListener, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, drawDebugBounds, fire, 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, hasParent, hit, isAscendantOf, isDescendantOf, isTouchable, isVisible, localToAscendantCoordinates, localToParentCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setStage, setTouchable, setUserObject, setVisible, setWidth, setX, setY, setZIndex, sizeBy, sizeBy, sizeChanged, stageToLocalCoordinates, toBack, toFront, toString
protected final squidpony.panel.IMarkup<T extends com.badlogic.gdx.graphics.Color> markup
content
.protected final LinkedList<squidpony.panel.IColoredString<T extends com.badlogic.gdx.graphics.Color>> content
null
entries.protected com.badlogic.gdx.graphics.glutils.ShapeRenderer renderer
clearArea(Batch)
. Do not access directly:
use getRenderer()
instead.public float xOffset
0
.public float yOffset
0
.public boolean drawBottomUp
true
, draws:
... content[1] content[0]If
false
, draws:
content[0] content[1] ...
public com.badlogic.gdx.graphics.Color clearingColor
null
if you clean on your own.public boolean wrap
public int align
public LinesPanel(squidpony.panel.IMarkup<T> markup, com.badlogic.gdx.graphics.g2d.BitmapFont font, int maxLines)
markup
- The markup to use, or null
if none. You likely want to
give GDXMarkup
. If non-null
, markup will be
enabled in font
.font
- The font to use.maxLines
- The maximum number of lines that this panel should display.
Must be >= 0
.IllegalStateException
- If maxLines < 0
public static int computeMaxLines(com.badlogic.gdx.graphics.g2d.BitmapFont font, float height)
font
- height
- #WrappingLinesPanel(IMarkup, BitmapFont, int)
when the
desired pixel height is height
public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha)
draw
in class com.badlogic.gdx.scenes.scene2d.Actor
protected void clearArea(com.badlogic.gdx.graphics.g2d.Batch batch)
clearingColor
protected boolean atMax()
protected String applyMarkup(squidpony.panel.IColoredString<T> ics)
protected squidpony.panel.IColoredString<T> transform(squidpony.panel.IColoredString<T> ics, int ydx)
ydx > 0
(using an IColorCenter
maybe ?).ics
- ydx
- The index of #ics
within content
.ics
, or ics
itself.protected com.badlogic.gdx.graphics.glutils.ShapeRenderer getRenderer()
Copyright © 2012–2016. All rights reserved.