lxgui
|
Used to draw some text on the screen. More...
#include <gui_text.hpp>
Public Member Functions | |
text (renderer &rdr, std::shared_ptr< const font > fnt, std::shared_ptr< const font > outline_fnt=nullptr) | |
Constructor. | |
text (const text &)=delete | |
text (text &&)=delete | |
text & | operator= (const text &)=delete |
text & | operator= (text &&)=delete |
float | get_line_height () const |
Returns the height of one line (constant). | |
void | set_scaling_factor (float scaling_factor) |
Set the scaling factor to use when rendering glyphs. | |
float | get_scaling_factor () const |
Returns the scaling factor used when rendering glyphs. | |
void | set_text (const utils::ustring &content) |
Sets the text to render (unicode character set). | |
const utils::ustring & | get_text () const |
Returns the text that will be rendered (unicode character set). | |
void | set_color (const color &c, bool force_color=false) |
Sets this text's default color. | |
const color & | get_color () const |
Returns this text's default color. | |
void | set_alpha (float alpha) |
Sets this text's transparency (alpha). | |
float | get_alpha () const |
Returns this text's transparency (alpha). | |
void | set_box_dimensions (float box_width, float box_height) |
Sets the dimensions of the text box. | |
void | set_box_width (float box_width) |
Sets the width of the text box. | |
void | set_box_height (float box_height) |
Sets the height of the text box. | |
float | get_width () const |
Returns the width of the rendered text. | |
float | get_height () const |
Returns the height of the rendered text. | |
float | get_box_width () const |
Returns the width of the text box. | |
float | get_box_height () const |
Returns the height of the text box. | |
float | get_text_width () const |
Returns the length of the text. | |
std::size_t | get_line_count () const |
Returns the number of text lines. | |
float | get_string_width (const std::string &content) const |
Returns the length of a provided string. | |
float | get_string_width (const utils::ustring &content) const |
Returns the length of a provided string. | |
float | get_character_width (char32_t c) const |
Returns the length of a single character. | |
float | get_character_kerning (char32_t c1, char32_t c2) const |
Returns the kerning between two characters. | |
float | get_text_height () const |
Returns the height of the text. | |
void | set_alignment_x (alignment_x align_x) |
Sets text horizontal alignment. | |
void | set_alignment_y (alignment_y align_y) |
Sets text vertical alignment. | |
alignment_x | get_alignment_x () const |
Returns the text horizontal alignment. | |
alignment_y | get_alignment_y () const |
Returns the text vertical alignment. | |
void | set_tracking (float tracking) |
Sets this text's tracking. | |
float | get_tracking () const |
Returns this text's tracking. | |
void | set_line_spacing (float line_spacing) |
Sets this text's line spacing. | |
float | get_line_spacing () const |
Returns this text's line spacing. | |
void | set_remove_starting_spaces (bool remove_starting_spaces) |
Allows removal of a line's starting spaces. | |
bool | get_remove_starting_spaces () const |
Checks if starting spaces removing is active. | |
void | set_word_wrap_enabled (bool wrap) |
Allows/disallows word wrap when the line is too long for the text box. | |
void | enable_word_wrap () |
Allows word wrap when the line is too long for the text box. | |
void | disable_word_wrap () |
Disallow word wrap when the line is too long for the text box. | |
bool | is_word_wrap_enabled () const |
Checks if word wrap is enabled. | |
void | set_word_ellipsis_enabled (bool add_ellipsis) |
Sets whether to show an ellipsis "..." if words don't fit in the text box. | |
void | enable_word_ellipsis () |
Show an ellipsis "..." if words don't fit in the text box. | |
void | disable_word_ellipsis () |
Do not show an ellipsis "..." if words don't fit in the text box. | |
bool | is_word_ellipsis_enabled () const |
Checks if word ellipsis is enabled. | |
void | set_formatting_enabled (bool formatting) |
Enables color formatting. | |
void | enable_formatting () |
Enables color formatting. | |
void | disable_formatting () |
Disables color formatting. | |
void | render (const matrix4f &transform=matrix4f::identity) const |
Renders this text at the given position. | |
std::size_t | get_letter_count () const |
Returns the number of letters currently displayed. | |
const std::array< vertex, 4 > & | get_letter_quad (std::size_t index) const |
Returns the quad for the letter at the provided index (position, texture coords, color). | |
quad | create_letter_quad (char32_t c) const |
Creates a quad that contains the provided character. | |
void | set_use_vertex_cache (bool use_vertex_cache) |
Sets whether this text object should use vertex caches or not. | |
bool | get_use_vertex_cache () const |
Checks if this text object is using vertex cache or not. | |
const renderer & | get_renderer () const |
Returns the renderer used to render this text. | |
renderer & | get_renderer () |
Returns the renderer used to render this text. | |
Used to draw some text on the screen.
Definition at line 29 of file gui_text.hpp.
|
explicit |
Constructor.
rdr | The renderer instance to use |
fnt | The font to use for rendering |
outline_fnt | The font to use for outlines |
Definition at line 283 of file gui_text.cpp.
|
delete |
|
delete |
quad lxgui::gui::text::create_letter_quad | ( | char32_t | c | ) | const |
Creates a quad that contains the provided character.
c | The character to draw |
Definition at line 1045 of file gui_text.cpp.
|
inline |
Disables color formatting.
Definition at line 355 of file gui_text.hpp.
|
inline |
Do not show an ellipsis "..." if words don't fit in the text box.
Definition at line 326 of file gui_text.hpp.
|
inline |
Disallow word wrap when the line is too long for the text box.
Definition at line 299 of file gui_text.hpp.
|
inline |
Enables color formatting.
Definition at line 347 of file gui_text.hpp.
|
inline |
Show an ellipsis "..." if words don't fit in the text box.
Definition at line 319 of file gui_text.hpp.
|
inline |
Allows word wrap when the line is too long for the text box.
Definition at line 292 of file gui_text.hpp.
alignment_x lxgui::gui::text::get_alignment_x | ( | ) | const |
Returns the text horizontal alignment.
Definition at line 454 of file gui_text.cpp.
alignment_y lxgui::gui::text::get_alignment_y | ( | ) | const |
Returns the text vertical alignment.
Definition at line 458 of file gui_text.cpp.
float lxgui::gui::text::get_alpha | ( | ) | const |
Returns this text's transparency (alpha).
Definition at line 342 of file gui_text.cpp.
float lxgui::gui::text::get_box_height | ( | ) | const |
Returns the height of the text box.
Definition at line 388 of file gui_text.cpp.
float lxgui::gui::text::get_box_width | ( | ) | const |
Returns the width of the text box.
Definition at line 384 of file gui_text.cpp.
float lxgui::gui::text::get_character_kerning | ( | char32_t | c1, |
char32_t | c2 | ||
) | const |
Returns the kerning between two characters.
c1 | The first character |
c2 | The second character |
Definition at line 432 of file gui_text.cpp.
float lxgui::gui::text::get_character_width | ( | char32_t | c | ) | const |
Returns the length of a single character.
c | The character to measure |
Definition at line 423 of file gui_text.cpp.
const color & lxgui::gui::text::get_color | ( | ) | const |
Returns this text's default color.
Definition at line 329 of file gui_text.cpp.
float lxgui::gui::text::get_height | ( | ) | const |
Returns the height of the rendered text.
Definition at line 379 of file gui_text.cpp.
std::size_t lxgui::gui::text::get_letter_count | ( | ) | const |
Returns the number of letters currently displayed.
Definition at line 1053 of file gui_text.cpp.
const std::array< vertex, 4 > & lxgui::gui::text::get_letter_quad | ( | std::size_t | index | ) | const |
Returns the quad for the letter at the provided index (position, texture coords, color).
index | The index of the letter (0: first letter); must be less than get_letter_count(). |
Definition at line 1058 of file gui_text.cpp.
std::size_t lxgui::gui::text::get_line_count | ( | ) | const |
Returns the number of text lines.
Definition at line 406 of file gui_text.cpp.
float lxgui::gui::text::get_line_height | ( | ) | const |
Returns the height of one line (constant).
Definition at line 287 of file gui_text.cpp.
float lxgui::gui::text::get_line_spacing | ( | ) | const |
Returns this text's line spacing.
Definition at line 484 of file gui_text.cpp.
bool lxgui::gui::text::get_remove_starting_spaces | ( | ) | const |
Checks if starting spaces removing is active.
Definition at line 497 of file gui_text.cpp.
|
inline |
Returns the renderer used to render this text.
Definition at line 420 of file gui_text.hpp.
|
inline |
Returns the renderer used to render this text.
Definition at line 412 of file gui_text.hpp.
float lxgui::gui::text::get_scaling_factor | ( | ) | const |
Returns the scaling factor used when rendering glyphs.
Definition at line 302 of file gui_text.cpp.
float lxgui::gui::text::get_string_width | ( | const std::string & | content | ) | const |
Returns the length of a provided string.
content | The string to measure |
Definition at line 411 of file gui_text.cpp.
float lxgui::gui::text::get_string_width | ( | const utils::ustring & | content | ) | const |
Returns the length of a provided string.
content | The string to measure |
Definition at line 415 of file gui_text.cpp.
const utils::ustring & lxgui::gui::text::get_text | ( | ) | const |
Returns the text that will be rendered (unicode character set).
Definition at line 315 of file gui_text.cpp.
float lxgui::gui::text::get_text_height | ( | ) | const |
Returns the height of the text.
Definition at line 396 of file gui_text.cpp.
float lxgui::gui::text::get_text_width | ( | ) | const |
Returns the length of the text.
Definition at line 392 of file gui_text.cpp.
float lxgui::gui::text::get_tracking | ( | ) | const |
Returns this text's tracking.
Definition at line 471 of file gui_text.cpp.
bool lxgui::gui::text::get_use_vertex_cache | ( | ) | const |
Checks if this text object is using vertex cache or not.
Definition at line 540 of file gui_text.cpp.
float lxgui::gui::text::get_width | ( | ) | const |
Returns the width of the rendered text.
Definition at line 374 of file gui_text.cpp.
bool lxgui::gui::text::is_word_ellipsis_enabled | ( | ) | const |
Checks if word ellipsis is enabled.
Definition at line 523 of file gui_text.cpp.
bool lxgui::gui::text::is_word_wrap_enabled | ( | ) | const |
Checks if word wrap is enabled.
Definition at line 510 of file gui_text.cpp.
void lxgui::gui::text::render | ( | const matrix4f & | transform = matrix4f::identity | ) | const |
Renders this text at the given position.
transform | The transform to apply to the text |
Definition at line 548 of file gui_text.cpp.
void lxgui::gui::text::set_alignment_x | ( | alignment_x | align_x | ) |
Sets text horizontal alignment.
align_x | The new horizontal alignment |
Definition at line 436 of file gui_text.cpp.
void lxgui::gui::text::set_alignment_y | ( | alignment_y | align_y | ) |
Sets text vertical alignment.
align_y | The new vertical alignment |
Definition at line 445 of file gui_text.cpp.
void lxgui::gui::text::set_alpha | ( | float | alpha | ) |
Sets this text's transparency (alpha).
alpha | The new alpha value |
Definition at line 333 of file gui_text.cpp.
void lxgui::gui::text::set_box_dimensions | ( | float | box_width, |
float | box_height | ||
) |
Sets the dimensions of the text box.
box_width | The new width |
box_height | The new height |
Definition at line 346 of file gui_text.cpp.
void lxgui::gui::text::set_box_height | ( | float | box_height | ) |
Sets the height of the text box.
box_height | The new height |
Definition at line 365 of file gui_text.cpp.
void lxgui::gui::text::set_box_width | ( | float | box_width | ) |
Sets the width of the text box.
box_width | The new width |
Definition at line 356 of file gui_text.cpp.
void lxgui::gui::text::set_color | ( | const color & | c, |
bool | force_color = false |
||
) |
Sets this text's default color.
c | The default color |
force_color | 'true' to ignore color tags |
Definition at line 319 of file gui_text.cpp.
void lxgui::gui::text::set_formatting_enabled | ( | bool | formatting | ) |
Enables color formatting.
formatting | 'true' to enable color formatting |
Definition at line 527 of file gui_text.cpp.
void lxgui::gui::text::set_line_spacing | ( | float | line_spacing | ) |
Sets this text's line spacing.
line_spacing | The new line spacing |
Definition at line 475 of file gui_text.cpp.
void lxgui::gui::text::set_remove_starting_spaces | ( | bool | remove_starting_spaces | ) |
Allows removal of a line's starting spaces.
remove_starting_spaces | 'true' to remove them |
Definition at line 488 of file gui_text.cpp.
void lxgui::gui::text::set_scaling_factor | ( | float | scaling_factor | ) |
Set the scaling factor to use when rendering glyphs.
scaling_factor | The scaling factor |
Definition at line 294 of file gui_text.cpp.
void lxgui::gui::text::set_text | ( | const utils::ustring & | content | ) |
Sets the text to render (unicode character set).
content | The text to render |
Definition at line 306 of file gui_text.cpp.
void lxgui::gui::text::set_tracking | ( | float | tracking | ) |
Sets this text's tracking.
tracking | The new tracking |
Definition at line 462 of file gui_text.cpp.
void lxgui::gui::text::set_use_vertex_cache | ( | bool | use_vertex_cache | ) |
Sets whether this text object should use vertex caches or not.
Definition at line 536 of file gui_text.cpp.
void lxgui::gui::text::set_word_ellipsis_enabled | ( | bool | add_ellipsis | ) |
Sets whether to show an ellipsis "..." if words don't fit in the text box.
add_ellipsis | 'true' to put "..." at the end of a truncated line |
Definition at line 514 of file gui_text.cpp.
void lxgui::gui::text::set_word_wrap_enabled | ( | bool | wrap | ) |
Allows/disallows word wrap when the line is too long for the text box.
wrap | 'true' to enable word wrap |
Definition at line 501 of file gui_text.cpp.