#include <floating_label.hpp>
Public Member Functions | |
floating_label (const std::string &text) | |
void | set_font_size (int font_size) |
void | set_position (double xpos, double ypos) |
void | set_move (double xmove, double ymove) |
void | set_lifetime (const std::chrono::milliseconds &lifetime, const std::chrono::milliseconds &fadeout=std::chrono::milliseconds{100}) |
void | set_color (const color_t &color) |
void | set_bg_color (const color_t &bg_color) |
void | set_border_size (int border) |
void | set_width (int w) |
void | set_height (int h) |
void | set_clip_rect (const SDL_Rect &r) |
void | set_alignment (ALIGN align) |
void | set_scroll_mode (LABEL_SCROLL_MODE scroll) |
void | use_markup (bool b) |
void | undraw () |
Mark the last drawn location as requiring redraw. More... | |
void | move (double xmove, double ymove) |
Change the floating label's position. More... | |
void | update (const clock::time_point &time) |
Finalize draw position and alpha, and queue redrawing if changed. More... | |
void | draw () |
Draw the label to the screen. More... | |
bool | create_texture () |
Ensure a texture for this floating label exists, creating one if needed. More... | |
void | clear_texture () |
SDL_Point | get_draw_size () const |
Return the size of the label in drawing coordinates. More... | |
bool | expired (const clock::time_point &time) const |
void | show (const bool value) |
LABEL_SCROLL_MODE | scroll () const |
auto | get_fade_time () const |
Private Types | |
using | clock = std::chrono::steady_clock |
Private Member Functions | |
std::chrono::milliseconds | get_time_alive (const clock::time_point ¤t_time) const |
int | xpos (std::size_t width) const |
point | get_pos (const clock::time_point &time) |
uint8_t | get_alpha (const clock::time_point &time) |
rect | get_bg_rect (const rect &text_rect) const |
Private Attributes | |
texture | tex_ |
rect | screen_loc_ |
uint8_t | alpha_ |
std::chrono::milliseconds | fadeout_ |
clock::time_point | time_start_ |
std::string | text_ |
int | font_size_ |
color_t | color_ |
color_t | bgcolor_ |
double | xpos_ |
double | ypos_ |
double | xmove_ |
double | ymove_ |
std::chrono::milliseconds | lifetime_ |
int | width_ |
int | height_ |
SDL_Rect | clip_rect_ |
bool | visible_ |
font::ALIGN | align_ |
int | border_ |
LABEL_SCROLL_MODE | scroll_ |
bool | use_markup_ |
Definition at line 43 of file floating_label.hpp.
|
private |
Definition at line 45 of file floating_label.hpp.
font::floating_label::floating_label | ( | const std::string & | text | ) |
Definition at line 52 of file floating_label.cpp.
void font::floating_label::clear_texture | ( | ) |
Definition at line 101 of file floating_label.cpp.
References texture::reset(), and tex_.
bool font::floating_label::create_texture | ( | ) |
Ensure a texture for this floating label exists, creating one if needed.
Definition at line 106 of file floating_label.cpp.
References bgcolor_, clip_rect_, color_, DBG_FT, ERR_FT, font::FONT_SANS_SERIF, font_size_, font::get_text_renderer(), video::headless(), height_, font::pango_text::render_and_get_texture(), font::pango_text::set_add_outline(), font::pango_text::set_alignment(), font::pango_text::set_characters_per_line(), font::pango_text::set_ellipse_mode(), font::pango_text::set_family_class(), font::pango_text::set_font_size(), font::pango_text::set_font_style(), font::pango_text::set_foreground_color(), font::pango_text::set_link_aware(), font::pango_text::set_maximum_height(), font::pango_text::set_maximum_width(), font::pango_text::set_text(), font::pango_text::STYLE_NORMAL, tex_, text_, use_markup_, and width_.
Referenced by update().
void font::floating_label::draw | ( | ) |
Draw the label to the screen.
Definition at line 188 of file floating_label.cpp.
References alpha_, bgcolor_, draw::blit(), clip_rect_, DBG_FT, rect::empty(), ERR_DP, draw::fill(), get_bg_rect(), draw::get_clip(), rect::intersect(), rect::overlaps(), draw::reduce_clip(), screen_loc_, texture::set_alpha_mod(), tex_, and visible_.
|
inline |
Definition at line 101 of file floating_label.hpp.
References fadeout_, get_time_alive(), and lifetime_.
|
private |
Definition at line 244 of file floating_label.cpp.
References fadeout_, get_time_alive(), lifetime_, and tex_.
Referenced by update().
Definition at line 96 of file floating_label.cpp.
References border_, and rect::padded_by().
Referenced by draw(), get_draw_size(), undraw(), and update().
|
inline |
Return the size of the label in drawing coordinates.
Definition at line 96 of file floating_label.hpp.
References get_bg_rect(), texture::h(), utf8::size(), tex_, and texture::w().
|
inline |
Definition at line 111 of file floating_label.hpp.
References fadeout_.
|
private |
Definition at line 235 of file floating_label.cpp.
References get_time_alive(), tex_, texture::w(), xmove_, xpos(), ymove_, and ypos_.
Referenced by update().
|
private |
Definition at line 230 of file floating_label.cpp.
References time_start_.
Referenced by expired(), get_alpha(), and get_pos().
void font::floating_label::move | ( | double | xmove, |
double | ymove | ||
) |
Change the floating label's position.
Definition at line 78 of file floating_label.cpp.
|
inline |
Definition at line 108 of file floating_label.hpp.
References scroll_.
Referenced by set_scroll_mode().
|
inline |
Definition at line 73 of file floating_label.hpp.
References align_.
Referenced by display_chat_manager::add_chat_message(), game_lua_kernel::intf_set_floating_label(), display::update_fps_label(), and gui::floating_textbox::update_location().
|
inline |
Definition at line 65 of file floating_label.hpp.
References bgcolor_.
Referenced by display_chat_manager::add_chat_message(), game_lua_kernel::intf_set_floating_label(), editor::editor_display::set_help_string(), editor::editor_display::set_status(), and display::update_fps_label().
|
inline |
Definition at line 68 of file floating_label.hpp.
References border, and border_.
Referenced by display_chat_manager::add_chat_message(), editor::editor_display::set_help_string(), editor::editor_display::set_status(), and display::update_fps_label().
|
inline |
Definition at line 72 of file floating_label.hpp.
References clip_rect_.
Referenced by display_chat_manager::add_chat_message(), display::announce(), game_lua_kernel::intf_set_floating_label(), terrain_label::recalculate(), display::set_diagnostic(), and gui::floating_textbox::update_location().
|
inline |
Definition at line 64 of file floating_label.hpp.
References color_.
Referenced by display_chat_manager::add_chat_message(), display::announce(), game_display::float_label(), game_lua_kernel::intf_set_floating_label(), terrain_label::recalculate(), display::set_diagnostic(), display::update_fps_label(), and gui::floating_textbox::update_location().
|
inline |
Definition at line 50 of file floating_label.hpp.
References font_size_.
Referenced by display_chat_manager::add_chat_message(), display::announce(), game_display::float_label(), game_lua_kernel::intf_set_floating_label(), terrain_label::recalculate(), display::set_diagnostic(), editor::editor_display::set_help_string(), editor::editor_display::set_status(), and display::update_fps_label().
|
inline |
Definition at line 71 of file floating_label.hpp.
Referenced by terrain_label::recalculate().
void font::floating_label::set_lifetime | ( | const std::chrono::milliseconds & | lifetime, |
const std::chrono::milliseconds & | fadeout = std::chrono::milliseconds{100} |
||
) |
Definition at line 223 of file floating_label.cpp.
References fadeout_, lifetime_, and time_start_.
Referenced by display::announce(), game_display::float_label(), game_lua_kernel::intf_set_floating_label(), and editor::editor_display::set_status().
|
inline |
Definition at line 58 of file floating_label.hpp.
References xmove_, and ymove_.
Referenced by game_display::float_label().
|
inline |
Definition at line 53 of file floating_label.hpp.
References xpos(), xpos_, and ypos_.
Referenced by display_chat_manager::add_chat_message(), display::announce(), game_display::float_label(), game_lua_kernel::intf_set_floating_label(), terrain_label::recalculate(), display::set_diagnostic(), editor::editor_display::set_help_string(), editor::editor_display::set_status(), display::update_fps_label(), and gui::floating_textbox::update_location().
|
inline |
Definition at line 74 of file floating_label.hpp.
References scroll(), and scroll_.
Referenced by game_display::float_label(), and terrain_label::recalculate().
|
inline |
Definition at line 70 of file floating_label.hpp.
Referenced by terrain_label::recalculate().
|
inline |
Definition at line 106 of file floating_label.hpp.
References visible_.
void font::floating_label::undraw | ( | ) |
Mark the last drawn location as requiring redraw.
Definition at line 153 of file floating_label.cpp.
References DBG_FT, get_bg_rect(), draw_manager::invalidate_region(), and screen_loc_.
void font::floating_label::update | ( | const clock::time_point & | time | ) |
Finalize draw position and alpha, and queue redrawing if changed.
Definition at line 160 of file floating_label.cpp.
References alpha_, create_texture(), DBG_FT, ERR_FT, get_alpha(), get_bg_rect(), get_pos(), texture::h(), video::headless(), draw_manager::invalidate_region(), screen_loc_, tex_, text_, and texture::w().
|
inline |
Definition at line 75 of file floating_label.hpp.
References b, and use_markup_.
Referenced by display_chat_manager::add_chat_message(), terrain_label::recalculate(), and editor::editor_display::set_status().
|
private |
Definition at line 84 of file floating_label.cpp.
References align_, font::CENTER_ALIGN, font::RIGHT_ALIGN, and xpos_.
Referenced by get_pos(), and set_position().
|
private |
Definition at line 133 of file floating_label.hpp.
Referenced by set_alignment(), and xpos().
|
private |
Definition at line 122 of file floating_label.hpp.
|
private |
Definition at line 127 of file floating_label.hpp.
Referenced by create_texture(), draw(), and set_bg_color().
|
private |
Definition at line 134 of file floating_label.hpp.
Referenced by get_bg_rect(), and set_border_size().
|
private |
Definition at line 131 of file floating_label.hpp.
Referenced by create_texture(), draw(), and set_clip_rect().
|
private |
Definition at line 127 of file floating_label.hpp.
Referenced by create_texture(), and set_color().
|
private |
Definition at line 123 of file floating_label.hpp.
Referenced by expired(), get_alpha(), get_fade_time(), and set_lifetime().
|
private |
Definition at line 126 of file floating_label.hpp.
Referenced by create_texture(), and set_font_size().
|
private |
Definition at line 130 of file floating_label.hpp.
Referenced by create_texture(), and set_height().
|
private |
Definition at line 129 of file floating_label.hpp.
Referenced by expired(), get_alpha(), and set_lifetime().
|
private |
Definition at line 121 of file floating_label.hpp.
|
private |
Definition at line 135 of file floating_label.hpp.
Referenced by scroll(), and set_scroll_mode().
|
private |
Definition at line 120 of file floating_label.hpp.
Referenced by clear_texture(), create_texture(), draw(), get_alpha(), get_draw_size(), get_pos(), and update().
|
private |
Definition at line 125 of file floating_label.hpp.
Referenced by create_texture(), and update().
|
private |
Definition at line 124 of file floating_label.hpp.
Referenced by get_time_alive(), and set_lifetime().
|
private |
Definition at line 136 of file floating_label.hpp.
Referenced by create_texture(), and use_markup().
|
private |
Definition at line 132 of file floating_label.hpp.
|
private |
Definition at line 130 of file floating_label.hpp.
Referenced by create_texture(), and set_width().
|
private |
Definition at line 128 of file floating_label.hpp.
Referenced by get_pos(), and set_move().
|
private |
Definition at line 128 of file floating_label.hpp.
Referenced by move(), set_position(), and xpos().
|
private |
Definition at line 128 of file floating_label.hpp.
Referenced by get_pos(), and set_move().
|
private |
Definition at line 128 of file floating_label.hpp.
Referenced by get_pos(), move(), and set_position().