|
JNGL
Easy to use cross-platform 2D game library
|
Rectangle shaped text block. More...
#include <jngl/text.hpp>
Public Member Functions | |
| Text (const std::string &text="") | |
Constructor, text may contain \n newlines. | |
| void | setText (const std::string &, double maxWidth=std::numeric_limits< double >::max()) |
The text to display (may contain \n newlines) | |
| void | setFont (Font &) |
| Font family. | |
| void | setFont (const std::shared_ptr< FontInterface > &) |
| void | setAlign (Alignment) |
| Alignment of this text block. | |
| void | step () override |
| Does nothing. | |
| void | draw () const override |
| Simply draws the Text object. | |
| void | draw (Mat3 modelview) const |
Public Member Functions inherited from Drawable | |
| Drawable (const Drawable &)=default | |
| Drawable & | operator= (const Drawable &)=default |
| Drawable (Drawable &&)=default | |
| Drawable & | operator= (Drawable &&)=default |
| Vec2 | getPos () const |
| Returns position (not center) | |
| virtual void | setPos (double x, double y) |
| Sets the position of the top-left of the Drawable. | |
| template<class Vect > | |
| void | setPos (Vect p) |
| Sets the position of the top-left of the Drawable. | |
| jngl::Vec2 | getCenter () const |
| Returns the position of the center of the Drawable. | |
| virtual void | setCenter (double x, double y) |
| Centers the Sprite at (x, y) | |
| template<class Vect > | |
| void | setCenter (Vect c) |
| Centers the Sprite at c (e.g. jngl::Vec2) | |
| double | getLeft () const |
| Returns the distance from the left side of the screen. | |
| void | setLeft (double x) |
| double | getTop () const |
| Returns the distance from the top of the screen. | |
| void | setTop (double y) |
| double | getRight () const |
| Returns the distance from the right side of the screen. | |
| void | setRight (double x) |
| double | getBottom () const |
| Returns the distance from the bottom of the screen. | |
| void | setBottom (double y) |
| double | getX () const |
| void | setX (double) |
| double | getY () const |
| void | setY (double) |
| Vec2 | getSize () const |
| Returns {width, height} in screen coordinates. | |
| float | getWidth () const |
| Returns the width in screen coordinates. | |
| float | getHeight () const |
| Returns the height in screen coordinates. | |
| void | drawBoundingBox () const |
| Draws a red box around the Drawable. | |
| bool | contains (jngl::Vec2 point) const |
| Returns whether point is inside the bounding box. | |
Additional Inherited Members | |
Protected Member Functions inherited from Drawable | |
| void | setWidth (float) |
| Override width (in screen coordinates) | |
| void | setHeight (float) |
| Override height (in screen coordinates) | |
Rectangle shaped text block.
This class represents a drawable text block that supports multi-line text with automatic word wrapping. Text can contain newline characters (\n) for manual line breaks, or use automatic word wrapping based on a maximum width.
Example usage:
| void setText | ( | const std::string & | , |
| double | maxWidth = std::numeric_limits< double >::max() ) |
The text to display (may contain \n newlines)
| maxWidth | Maximum width of the text block in pixels. If the text exceeds this width, it will be wrapped at word boundaries to fit within the specified width. Defaults to no limit (std::numeric_limits<double>::max()). |
|
overridevirtual |
Does nothing.
Implements Drawable.