Builder-style API for configuring and constructing Text_sprites.
The idea is that a Text_sprite::Builder allows configuring a Text_sprite in detail before actually constructing it. For example:
Definition at line 238 of file ge211_sprites.h.
Public Member Functions | |
Constructor and builder | |
Builder (Font const &) | |
Constructs a new Text_sprite::Builder with the given Font. | |
Text_sprite | build () const |
Builds the configured Text_sprite. | |
Builder-style setters | |
template<class T > | |
Builder & | add_message (T const &value) |
Adds to the builder's message. More... | |
template<class T > | |
Builder & | operator<< (T const &value) |
Adds to the builder's message. More... | |
Builder & | message (std::string const &) |
Replaces the configured message with the given message. More... | |
Builder & | font (Font const &) |
Sets font to use. More... | |
Builder & | color (Color) |
Sets the color to use. More... | |
Builder & | antialias (bool) |
Sets whether to use anti-aliasing. More... | |
Builder & | word_wrap (int) |
Sets the pixel width for wrapping the text. More... | |
Getters | |
std::string | message () const |
Gets the configured message. | |
Font const & | font () const |
Gets the font that will be used. | |
Color | color () const |
Gets the color that will be used. | |
bool | antialias () const |
Gets whether anti-aliasing will be used. | |
int | word_wrap () const |
Gets the wrapping width that will be used. | |
|
inline |
Adds to the builder's message.
This takes any printable type and prints it à la operator<<
. Returns the builder, for call chaining.
Definition at line 259 of file ge211_sprites.h.
Text_sprite::Builder & antialias | ( | bool | antialias | ) |
Sets whether to use anti-aliasing.
Anti-aliasing, on by default, makes text smoother but can make it take longer to render. Returns a reference to the Builder for call chaining.
Definition at line 271 of file ge211_sprites.cpp.
Text_sprite::Builder & color | ( | Color | color | ) |
Sets the color to use.
Returns a reference to the Builder for call chaining.
Definition at line 265 of file ge211_sprites.cpp.
Text_sprite::Builder & font | ( | Font const & | font | ) |
Sets font to use.
Returns a reference to the Builder for call chaining.
Definition at line 259 of file ge211_sprites.cpp.
Text_sprite::Builder & message | ( | std::string const & | message | ) |
Replaces the configured message with the given message.
Returns a reference to the Builder for call chaining.
Definition at line 253 of file ge211_sprites.cpp.
|
inline |
Adds to the builder's message.
This is an alias for add_message(const T&).
For example:
Definition at line 279 of file ge211_sprites.h.
Text_sprite::Builder & word_wrap | ( | int | word_wrap | ) |
Sets the pixel width for wrapping the text.
If set to 0, the text does not wrap at all. Newlines in the text will produces newlines in the output only if wrapping is on (non-zero). Returns a reference to the Builder for call chaining.
Definition at line 277 of file ge211_sprites.cpp.