HoverRace
2.0
|
A fragment of text rendered on an SDL surface. More...
#include <SdlSurfaceText.h>
Public Member Functions | |
SdlSurfaceText (SdlDisplay &display) | |
Constructor. More... | |
SdlSurfaceText (SdlDisplay &display, const UiFont &font, const Color color=COLOR_WHITE) | |
Constructor with initial font and color. More... | |
~SdlSurfaceText () | |
int | GetHeight () const |
int | GetWidth () const |
int | MeasureLineHeight () |
Calculate the line-height of text using the current font. More... | |
SdlSurfaceText & | operator= (const SdlSurfaceText &)=delete |
SDL_Surface * | RenderToNewSurface (const std::string &s) |
Create a new SDL surface and render text onto it. More... | |
SDL_Surface * | RenderToSurface (SDL_Surface *dest, int x, int y, const std::string &s) |
Render text onto an existing surface. More... | |
void | SetColor (const Color color) |
void | SetFixedScale (bool fixedScale) |
void | SetFont (const UiFont &font) |
void | SetWrapWidth (int wrapWidth) |
Private Attributes | |
Color | color |
SdlDisplay & | display |
bool | fixedScale |
UiFont | font |
int | height |
int | width |
int | wrapWidth |
A fragment of text rendered on an SDL surface.
This class does not manage the SDL surface itself, since the surface may be shared amongst multiple instances (e.g. to only use one texture for multiple text fragments). Instead, this class handles rendering the text onto a surface and keeps track of the properties needed for a display renderer or post-processor to use the rendered text.
Note that since this class deals directly with surfaces, no UI scaling is taken into account; users of this class must pre-scale all values that are passed in (if necessary).
HoverRace::Display::SDL::SdlSurfaceText::SdlSurfaceText | ( | SdlDisplay & | display | ) |
Constructor.
display | The current display. |
HoverRace::Display::SDL::SdlSurfaceText::SdlSurfaceText | ( | SdlDisplay & | display, |
const UiFont & | font, | ||
const Color | color = COLOR_WHITE |
||
) |
Constructor with initial font and color.
display | The current display. |
font | The font to render with. |
color | The text foreground color. |
|
inline |
|
inline |
|
inline |
int HoverRace::Display::SDL::SdlSurfaceText::MeasureLineHeight | ( | ) |
Calculate the line-height of text using the current font.
This is useful when needing to treat an empty string as if it were being rendered, since normally an empty string would be a zero-by-zero size.
This will set the height to the line-height and the width to 1.
|
delete |
SDL_Surface * HoverRace::Display::SDL::SdlSurfaceText::RenderToNewSurface | ( | const std::string & | s | ) |
SDL_Surface * HoverRace::Display::SDL::SdlSurfaceText::RenderToSurface | ( | SDL_Surface * | dest, |
int | x, | ||
int | y, | ||
const std::string & | s | ||
) |
Render text onto an existing surface.
dest | The destination surface (may not be nullptr ). |
x | The horizontal offset. |
y | The vertical offset. |
s | The text to render (may not be blank). |
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |