1 #ifndef LXGUI_GUI_FONT_STRING_HPP
2 #define LXGUI_GUI_FONT_STRING_HPP
4 #include "lxgui/gui_layered_region.hpp"
5 #include "lxgui/gui_text.hpp"
6 #include "lxgui/lxgui.hpp"
7 #include "lxgui/utils.hpp"
61 std::string
serialize(
const std::string& tab)
const override;
64 void render()
const override;
153 void set_font(
const std::string& font_name,
float height);
238 const utils::ustring&
get_text()
const;
400 void set_text(
const utils::ustring& content);
429 void parse_attributes_(
const layout_node& node)
override;
432 const std::vector<std::string>& get_type_list_()
const override;
434 void create_text_object_();
435 bool is_vertex_cache_used_()
const;
437 void update_borders_()
override;
439 std::unique_ptr<text> text_;
441 utils::ustring content_;
442 std::string font_name_;
443 float height_ = 0.0f;
445 float spacing_ = 0.0f;
446 float line_spacing_ = 1.0f;
451 bool is_outlined_ =
false;
452 bool non_space_wrap_enabled_ =
false;
453 bool word_wrap_enabled_ =
true;
454 bool ellipsis_enabled_ =
true;
455 bool formatting_enabled_ =
true;
460 bool is_shadow_enabled_ =
false;
Holds a single color (float RGBA, 128 bits)
A layered_region that can draw text on the screen.
void enable_formatting()
Enables color formatting.
const color & get_text_color() const
Returns the text color.
void set_word_wrap_enabled(bool enabled)
Enables/disables word wrap.
void enable_word_ellipsis()
Show an ellipsis "..." if words don't fit in the text box.
void set_non_space_wrap_enabled(bool enabled)
Sets whether large text without whitespace is truncated or wrapped.
const std::string & get_font_name() const
Returns the name of the font file.
const vector2f & get_offset() const
Returns this font_string's offset.
void set_formatting_enabled(bool enabled)
Enables color formatting.
const color & get_shadow_color() const
Returns this font_string's shadow color.
float get_string_width() const
Returns the width of the string if no format or wrapping is applied.
bool is_word_ellipsis_enabled() const
Checks if word ellipsis is enabled.
void set_shadow_color(const color &shadow_color)
Sets this font_string's shadow color.
void copy_from(const region &obj) override
Copies a region's parameters into this font_string (inheritance).
bool is_non_space_wrap_enabled() const
Checks if large text is truncated or wrapped.
void enable_non_space_wrap()
Allows large text without whitespace to wrap.
float get_string_height() const
Returns the height of the string if no format or wrapping is applied.
const vector2f & get_shadow_offset() const
Returns this font_string's shadow offset.
void set_line_spacing(float line_spacing)
Sets the space between each line as a fraction of the font height.
std::string serialize(const std::string &tab) const override
Prints all relevant information about this region in a string.
void set_alignment_x(alignment_x align_x)
Sets this font_string's horizontal alignment behavior.
bool is_formatting_enabled() const
Checks if color formatting is enabled.
float get_font_height() const
Returns the height of the font.
void render() const override
Renders this region on the current render target.
void enable_shadow()
Makes this font_string draw a shadow under its text.
void set_vertex_cache_strategy(vertex_cache_strategy strategy)
Selects the strategy for using vertex caches.
void set_alignment_y(alignment_y align_y)
Sets this font_string's vertical alignment behavior.
void notify_scaling_factor_updated() override
Tells this region that the global interface scaling factor has changed.
void disable_word_wrap()
Disables word wrap.
text * get_text_object()
Returns the text used to render this font_string.
void set_offset(const vector2f &offset)
Sets this font_string's offset.
void set_outlined(bool outlined)
Adds or remove the outline around the text.
void set_shadow_offset(const vector2f &shadow_offset)
Sets this font_string's shadow offset.
static constexpr const char * class_name
bool is_outlined() const
Check if this font_string is outlined.
void set_text(const utils::ustring &content)
Sets the rendered text.
static void register_on_lua(sol::state &lua)
Registers this region class to the provided Lua state.
void disable_word_ellipsis()
Do not show an ellipsis "..." if words don't fit in the text box.
void parse_layout(const layout_node &node) override
Parses data from a layout_node.
float get_line_spacing() const
Returns the space between each line as a fraction of the font height.
bool is_word_wrap_enabled() const
Checks if word wrap is enabled.
void disable_formatting()
Disables color formatting.
font_string(utils::control_block &block, manager &mgr, const region_core_attributes &attr)
Constructor.
void set_text_color(const color &text_color)
Sets the text color.
alignment_y get_alignment_y() const
Returns the vertical alignment behavior.
void set_shadow_enabled(bool enabled)
Sets whether this font_string should draw a shadow under its text.
vertex_cache_strategy get_vertex_cache_strategy() const
Gets the strategy for using vertex caches.
bool is_shadow_enabled() const
Checks if this font_string draws a shadow under its text.
void set_word_ellipsis_enabled(bool enabled)
Sets whether to show an ellipsis "..." if words don't fit in the text box.
float get_spacing() const
Returns the space between each letter.
void set_font(const std::string &font_name, float height)
Sets this font_string's font (file and size).
const utils::ustring & get_text() const
Returns the rendered text (with format tags).
void set_spacing(float spacing)
Sets the space between each letter.
void enable_word_wrap()
Enables word wrap.
alignment_x get_alignment_x() const
Returns the horizontal alignment behavior.
void disable_non_space_wrap()
Does not allow large text without whitespace to wrap.
void disable_shadow()
Makes this font_string draw a shadow under its text.
A region that can be rendered in a layer.
layered_region(utils::control_block &block, manager &mgr, const region_core_attributes &attr)
Constructor.
An node in a layout file.
Manages the user interface.
The base class of all elements in the GUI.
Used to draw some text on the screen.
vertex_cache_strategy
Strategy for using a vertex cache.
@ prefer_enabled
Use vertex cache if renderer supports and allows.
@ automatic
Choose automatically to maximize performance on common case.
@ always_disabled
Never use vertex cache.
@ always_enabled
Use vertex cache if renderer supports, even if not allowed.
Struct holding all the core information about a region necessary for its creation.
static const vector2 zero