Rose
|
Encapsulation of code for rendering Text. More...
#include <Text.h>
Public Types | |
enum | RenderStyle { Blended, Shaded, Solid } |
enum | Status { OK, TextEmpty, FontError, SurfaceError, TextureError } |
Public Member Functions | |
Text (const Text &)=delete | |
Text (Text &&)=delete | |
Text & | operator= (const Text &)=delete |
Text & | operator= (Text &&)=delete |
Status | createTextureBlended (gm::Context &context) |
Create a Blended Texture from text. More... | |
void | setPointSize (int pointSize) |
Set the font point size. | |
void | setFontName (const std::string &fontName) |
Set the font name. | |
bool | setText (const std::string &text) |
Set the text displayed. More... | |
bool | textUpdated () |
void | setSuffix (const std::string &suffix) |
void | setTextMaxSize (int maxSize, char em='\0') |
void | setTextValidationPattern (const std::string ®ex) |
Protected Member Functions | |
void | setEditingMode (bool editing, int carret) |
Set the editing mode. | |
Protected Attributes | |
std::string | mText {} |
The UTF8 or ASCII text to render. | |
std::string | mSuffix {} |
The UTF8 or ASCII suffix. | |
color::RGBA | mTextFgColor |
The foreground color to use. | |
color::RGBA | mTextBgColor |
The background color to use if rendering Shaded. | |
color::RGBA | mCaretColor {} |
The color of the caret when editing. | |
color::RGBA | mRegexFail {} |
The text colour for regex validation failure. | |
color::RGBA | mDataSaved {} |
The text colour when the data has been saved to settings. | |
float | mCaretAlpha {0.f} |
The alpha value of the caret during animation. | |
RenderStyle | mRenderStyle {Blended} |
The style of rendering Solid, Shaded, or Blended. | |
std::string | mFontName |
The name of the True Type Font to use. | |
std::shared_ptr< _TTF_Font > | mFont {} |
The cached font used. | |
int | mPointSize |
The point (pixel) size of the font. | |
gm::Texture | mTexture {} |
The generated Texture. | |
Size | mTextSize {} |
The size of the Texture in pixels. | |
Status | mStatus {OK} |
The Status of the last operation. | |
int | mCaretLocation {0} |
The location of the caret. | |
bool | mEditingActive {false} |
True when the text is being edited. | |
bool | mEditable {false} |
The label text is editable. | |
bool | mTextValidated {true} |
Ture when the content validates by mValidationPatter. | |
bool | mSaveToSettings {false} |
Set to true when modifications have been saved. | |
int | mMaxSize {0} |
The maximum number of characters to be held, 0 indicates variable. | |
char | eM {'N'} |
The character used to compute the maximum screen rectangle width. | |
std::unique_ptr< std::regex > | mValidationPattern {} |
Regular expression to validate content. | |
Encapsulation of code for rendering Text.
enum rose::Text::Status |
Text::Status rose::Text::createTextureBlended | ( | gm::Context & | context | ) |
Create a Blended Texture from text.
Fetches the Font corresponding to mFontName and mPointSize, then renders the text in mText as UTF8 to mTexture. The foreground color is set to mTextFgColor. If mRenderStyle is set to Shaded the background color is set to mTextBgColor. The size of the Texture is placed in mTextSize.
If the requested font is not found, or mText is empty any mTexture is reset and mTextSize is set to Zero.
context | The graphics Context. |
|
inline |
Set the text displayed.
text | The new text. |