Symphony Of Empires
UI::Text Class Reference

Multiline textbox that allows more descriptive paragraphs than the Label widget. More...

#include <text.hpp>

Inheritance diagram for UI::Text:
Collaboration diagram for UI::Text:

Public Member Functions

 Text (int x, int y, unsigned w, unsigned h, UI::Widget *parent)
 
 Text (int x, int y, const std::string &text, UI::Widget *parent)
 Create a new text object from a text string. More...
 
virtual ~Text ()
 
virtual void on_render (Context &ctx, Eng3D::Rect viewport)
 
virtual void set_text (const std::string &text)
 Generates text for the widget and overrides the current text texture. More...
 
- Public Member Functions inherited from UI::Widget
 Widget ()=default
 
 Widget (Widget *parent, int x, int y, unsigned w, unsigned h, WidgetType type)
 
 Widget (Widget *parent, int x, int y, unsigned w, unsigned h, WidgetType type, std::shared_ptr< Eng3D::Texture > tex)
 
 Widget (const Widget &)=default
 
 Widget (Widget &&) noexcept=default
 
Widgetoperator= (Widget &) noexcept=default
 
Widgetoperator= (const Widget &)=default
 
virtual ~Widget ()
 
constexpr void move_by (const glm::ivec2 offset)
 Moves a widget by x and y. More...
 
void add_child (UI::Widget &child)
 Adds a children to the widget. More...
 
template<typename T , typename ... Targs>
T & make_widget (Targs &&...args)
 
virtual void set_tooltip (UI::Tooltip *tooltip)
 Set the tooltip to be shown when this widget is hovered, overrides the previous tooltip. More...
 
virtual void set_tooltip (const std::string &text)
 Set the tooltip to be shown when this widget is hovered, but generate it from a string instead of taking an already existing widget. More...
 
virtual void set_tooltip (std::function< std::string()> tooltip_text_creator)
 Set the tooltip to be shown when this widget is hovered, but generate when used needed. It is created from a string instead of taking an already existing widget. More...
 
glm::ivec2 get_y_bounds () const
 Obtains the height of the top and bottom overflow in widget That is the space that the children of this widget take up but cannot be seen. More...
 
void scroll (int y)
 Scrolls all the children of this widget by a factor of y. More...
 
constexpr void set_y (int _y)
 
constexpr void above_of (const UI::Widget &rhs)
 
constexpr void below_of (const UI::Widget &rhs)
 
constexpr void left_side_of (const UI::Widget &rhs)
 
constexpr void right_side_of (const UI::Widget &rhs)
 
virtual void set_on_click (std::function< void(UI::Widget &)> _on_click)
 Sets the on_click function of this widget. More...
 
virtual void set_on_each_tick (std::function< void(UI::Widget &)> _on_each_tick)
 Sets the on_each_tick function of this widget. More...
 
virtual void set_on_drag (std::function< void(glm::ivec2, glm::ivec2)> _on_drag)
 
template<typename F >
void sort_children (F &&comp)
 Sort the children of this widget. More...
 
void kill ()
 Kills the current widget, setting it up for deletion when dead widgets are cleared by the UI context. More...
 
void kill_children ()
 
size_t max_height () const
 

Public Attributes

int min_height = 0
 
bool auto_adjust = true
 Whetever to auto adjust the widget depending on the text. More...
 
- Public Attributes inherited from UI::Widget
bool is_pinned = false
 
bool is_render = true
 
bool is_scroll = false
 
uint32_t is_hover = 0
 
bool is_float = false
 
bool is_fullscreen = false
 
bool is_transparent = false
 
bool managed = true
 
UI::Widgetparent = nullptr
 
std::vector< std::unique_ptr< UI::Widget > > children
 
bool have_shadow = false
 
UI::Origin origin = UI::Origin::UPPER_LEFT
 
UI::WidgetType type
 
int x = 0
 
int y = 0
 
glm::ivec2 padding { 0 }
 
size_t width = 0
 
size_t height = 0
 
std::shared_ptr< Eng3D::Texturecurrent_texture
 
std::shared_ptr< Eng3D::Texturetext_texture
 
int text_offset_x = 4
 
int text_offset_y = 4
 
UI::Align text_align_y = UI::Align::START
 
UI::Align text_align_x = UI::Align::START
 
Eng3D::Color text_color = Eng3D::Color(0.f, 0.f, 0.f)
 
std::shared_ptr< Eng3D::TrueType::Fontfont
 
UI::Border border
 
Eng3D::Color background_color = Eng3D::Color(1.f, 1.f, 1.f, 0.f)
 
UI::Flex flex = UI::Flex::NONE
 
UI::FlexJustify flex_justify = UI::FlexJustify::START
 
UI::Align flex_align = UI::Align::START
 
UI::Overflow overflow = UI::Overflow::CLAMP
 
size_t flex_gap = 0
 
UI::Tooltiptooltip = nullptr
 
std::function< UI::Tooltip *()> tooltip_creator
 
void * user_data = nullptr
 
std::function< void(glm::ivec2 mouse_pos, glm::ivec2 mouse_delta)> on_drag
 
std::function< void(UI::Widget &)> on_update
 
std::function< void(UI::Widget &)> on_click
 
std::function< void(UI::Widget &)> on_click_outside
 
std::function< void(UI::Widget &)> on_each_tick
 
std::function< void(UI::Widget &, int i)> on_pos_recalc
 
std::function< void(UI::Widget &, glm::ivec2 mouse_pos, glm::ivec2 widget_pos)> on_hover
 
int lua_on_update = 0
 
int lua_on_click = 0
 
int lua_on_click_outside = 0
 
int lua_on_each_tick = 0
 
int dpad_index = 0
 Index for select_dpad_ui_widget, 0 means index=Auto (first to last) More...
 
int scrolled_y = 0
 Total amount of scroll. More...
 

Additional Inherited Members

- Protected Member Functions inherited from UI::Widget
void draw_rectangle (int x, int y, unsigned w, unsigned h, Eng3D::Rect viewport, const Eng3D::Texture *tex)
 
void draw_rect (const Eng3D::Texture *tex, Eng3D::Rect rect_pos, Eng3D::Rect rect_tex, Eng3D::Rect viewport)
 
- Protected Attributes inherited from UI::Widget
bool clickable_effect = true
 

Detailed Description

Multiline textbox that allows more descriptive paragraphs than the Label widget.

Todo:
Markdown support?

Definition at line 41 of file text.hpp.

Constructor & Destructor Documentation

◆ Text() [1/2]

UI::Text::Text ( int  x,
int  y,
unsigned  w,
unsigned  h,
UI::Widget parent 
)

Definition at line 30 of file text.cpp.

◆ Text() [2/2]

UI::Text::Text ( int  _x,
int  _y,
const std::string &  _text,
UI::Widget _parent 
)

Create a new text object from a text string.

Parameters
_xX coordinate
_yY coordinate
_textText to generate from
_parentParent of the object (required to properly auto adjust)

Definition at line 42 of file text.cpp.

Here is the call graph for this function:

◆ ~Text()

virtual UI::Text::~Text ( )
inlinevirtual

Definition at line 45 of file text.hpp.

Member Function Documentation

◆ on_render()

void UI::Text::on_render ( Context ctx,
Eng3D::Rect  viewport 
)
virtual

Reimplemented from UI::Widget.

Definition at line 52 of file text.cpp.

◆ set_text()

void UI::Text::set_text ( const std::string &  _text)
virtual

Generates text for the widget and overrides the current text texture.

Parameters
_text
Todo:
only works for monospace fonts width width 12, fix it for all fonts

Reimplemented from UI::Widget.

Definition at line 56 of file text.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ auto_adjust

bool UI::Text::auto_adjust = true

Whetever to auto adjust the widget depending on the text.

Definition at line 51 of file text.hpp.

◆ min_height

int UI::Text::min_height = 0

Definition at line 49 of file text.hpp.


The documentation for this class was generated from the following files: