The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
font::floating_label Class Reference

#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 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.
 
void move (double xmove, double ymove)
 Change the floating label's position.
 
void update (const clock::time_point &time)
 Finalize draw position and alpha, and queue redrawing if changed.
 
void draw ()
 Draw the label to the screen.
 
bool create_texture ()
 Ensure a texture for this floating label exists, creating one if needed.
 
void clear_texture ()
 
point get_draw_size () const
 Return the size of the label in drawing coordinates.
 
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

clock::duration get_time_alive (const clock::time_point &current_time) const
 
int xpos (std::size_t width) const
 
point get_pos (const clock::time_point &time) const
 
uint8_t get_alpha (const clock::time_point &time) const
 
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_
 
utils::optional< int > width_
 
utils::optional< int > height_
 
rect clip_rect_
 
bool visible_
 
font::ALIGN align_
 
int border_
 
LABEL_SCROLL_MODE scroll_
 
bool use_markup_
 

Detailed Description

Definition at line 43 of file floating_label.hpp.

Member Typedef Documentation

◆ clock

using font::floating_label::clock = std::chrono::steady_clock
private

Definition at line 45 of file floating_label.hpp.

Constructor & Destructor Documentation

◆ floating_label()

font::floating_label::floating_label ( const std::string &  text)

Definition at line 53 of file floating_label.cpp.

Member Function Documentation

◆ clear_texture()

void font::floating_label::clear_texture ( )

Definition at line 100 of file floating_label.cpp.

References texture::reset(), and tex_.

◆ create_texture()

bool font::floating_label::create_texture ( )

◆ draw()

void font::floating_label::draw ( )

◆ expired()

bool font::floating_label::expired ( const clock::time_point &  time) const
inline

Definition at line 101 of file floating_label.hpp.

References fadeout_, get_time_alive(), and lifetime_.

◆ get_alpha()

uint8_t font::floating_label::get_alpha ( const clock::time_point &  time) const
private

◆ get_bg_rect()

rect font::floating_label::get_bg_rect ( const rect &  text_rect) const
private

Definition at line 95 of file floating_label.cpp.

References border_, and rect::padded_by().

Referenced by draw(), get_draw_size(), undraw(), and update().

◆ get_draw_size()

point font::floating_label::get_draw_size ( ) const
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(), tex_, and texture::w().

◆ get_fade_time()

auto font::floating_label::get_fade_time ( ) const
inline

Definition at line 111 of file floating_label.hpp.

References fadeout_.

◆ get_pos()

point font::floating_label::get_pos ( const clock::time_point &  time) const
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().

◆ get_time_alive()

auto font::floating_label::get_time_alive ( const clock::time_point &  current_time) const
private

Definition at line 230 of file floating_label.cpp.

Referenced by expired(), get_alpha(), and get_pos().

◆ move()

void font::floating_label::move ( double  xmove,
double  ymove 
)

Change the floating label's position.

Definition at line 77 of file floating_label.cpp.

References xpos_, and ypos_.

◆ scroll()

LABEL_SCROLL_MODE font::floating_label::scroll ( ) const
inline

Definition at line 108 of file floating_label.hpp.

References scroll_.

Referenced by set_scroll_mode().

◆ set_alignment()

void font::floating_label::set_alignment ( ALIGN  align)
inline

◆ set_bg_color()

void font::floating_label::set_bg_color ( const color_t &  bg_color)
inline

◆ set_border_size()

void font::floating_label::set_border_size ( int  border)
inline

◆ set_clip_rect()

void font::floating_label::set_clip_rect ( const rect &  r)
inline

◆ set_color()

void font::floating_label::set_color ( const color_t &  color)
inline

◆ set_font_size()

void font::floating_label::set_font_size ( int  font_size)
inline

◆ set_height()

void font::floating_label::set_height ( int  h)
inline

Definition at line 71 of file floating_label.hpp.

References h, and height_.

Referenced by terrain_label::recalculate().

◆ set_lifetime()

void font::floating_label::set_lifetime ( const std::chrono::milliseconds &  lifetime,
const std::chrono::milliseconds &  fadeout = std::chrono::milliseconds{100} 
)

◆ set_move()

void font::floating_label::set_move ( double  xmove,
double  ymove 
)
inline

Definition at line 58 of file floating_label.hpp.

References xmove_, and ymove_.

Referenced by game_display::float_label().

◆ set_position()

void font::floating_label::set_position ( double  xpos,
double  ypos 
)
inline

◆ set_scroll_mode()

void font::floating_label::set_scroll_mode ( LABEL_SCROLL_MODE  scroll)
inline

Definition at line 74 of file floating_label.hpp.

References scroll(), and scroll_.

Referenced by game_display::float_label(), and terrain_label::recalculate().

◆ set_width()

void font::floating_label::set_width ( int  w)
inline

Definition at line 70 of file floating_label.hpp.

References w, and width_.

Referenced by terrain_label::recalculate(), and gui::floating_textbox::update_location().

◆ show()

void font::floating_label::show ( const bool  value)
inline

Definition at line 106 of file floating_label.hpp.

References value, and visible_.

◆ undraw()

void font::floating_label::undraw ( )

Mark the last drawn location as requiring redraw.

Definition at line 147 of file floating_label.cpp.

References DBG_FT, get_bg_rect(), draw_manager::invalidate_region(), and screen_loc_.

◆ update()

void font::floating_label::update ( const clock::time_point &  time)

Finalize draw position and alpha, and queue redrawing if changed.

Definition at line 154 of file floating_label.cpp.

References alpha_, border_, create_texture(), DBG_FT, texture::draw_size(), ERR_FT, get_alpha(), get_bg_rect(), get_pos(), video::headless(), draw_manager::invalidate_region(), screen_loc_, tex_, and text_.

◆ use_markup()

void font::floating_label::use_markup ( bool  b)
inline

◆ xpos()

int font::floating_label::xpos ( std::size_t  width) const
private

Definition at line 83 of file floating_label.cpp.

References align_, font::CENTER_ALIGN, font::RIGHT_ALIGN, xpos(), and xpos_.

Referenced by get_pos(), set_position(), and xpos().

Member Data Documentation

◆ align_

font::ALIGN font::floating_label::align_
private

Definition at line 133 of file floating_label.hpp.

Referenced by set_alignment(), and xpos().

◆ alpha_

uint8_t font::floating_label::alpha_
private

Definition at line 122 of file floating_label.hpp.

Referenced by draw(), and update().

◆ bgcolor_

color_t font::floating_label::bgcolor_
private

Definition at line 127 of file floating_label.hpp.

Referenced by create_texture(), draw(), and set_bg_color().

◆ border_

int font::floating_label::border_
private

Definition at line 134 of file floating_label.hpp.

Referenced by get_bg_rect(), set_border_size(), and update().

◆ clip_rect_

rect font::floating_label::clip_rect_
private

Definition at line 131 of file floating_label.hpp.

Referenced by create_texture(), draw(), and set_clip_rect().

◆ color_

color_t font::floating_label::color_
private

Definition at line 127 of file floating_label.hpp.

Referenced by create_texture(), and set_color().

◆ fadeout_

std::chrono::milliseconds font::floating_label::fadeout_
private

Definition at line 123 of file floating_label.hpp.

Referenced by expired(), get_alpha(), get_fade_time(), and set_lifetime().

◆ font_size_

int font::floating_label::font_size_
private

Definition at line 126 of file floating_label.hpp.

Referenced by create_texture(), and set_font_size().

◆ height_

utils::optional<int> font::floating_label::height_
private

Definition at line 130 of file floating_label.hpp.

Referenced by create_texture(), and set_height().

◆ lifetime_

std::chrono::milliseconds font::floating_label::lifetime_
private

Definition at line 129 of file floating_label.hpp.

Referenced by expired(), get_alpha(), and set_lifetime().

◆ screen_loc_

rect font::floating_label::screen_loc_
private

Definition at line 121 of file floating_label.hpp.

Referenced by draw(), undraw(), and update().

◆ scroll_

LABEL_SCROLL_MODE font::floating_label::scroll_
private

Definition at line 135 of file floating_label.hpp.

Referenced by scroll(), and set_scroll_mode().

◆ tex_

texture font::floating_label::tex_
private

Definition at line 120 of file floating_label.hpp.

Referenced by clear_texture(), create_texture(), draw(), get_draw_size(), get_pos(), and update().

◆ text_

std::string font::floating_label::text_
private

Definition at line 125 of file floating_label.hpp.

Referenced by create_texture(), and update().

◆ time_start_

clock::time_point font::floating_label::time_start_
private

Definition at line 124 of file floating_label.hpp.

Referenced by set_lifetime().

◆ use_markup_

bool font::floating_label::use_markup_
private

Definition at line 136 of file floating_label.hpp.

Referenced by create_texture(), and use_markup().

◆ visible_

bool font::floating_label::visible_
private

Definition at line 132 of file floating_label.hpp.

Referenced by draw(), and show().

◆ width_

utils::optional<int> font::floating_label::width_
private

Definition at line 130 of file floating_label.hpp.

Referenced by create_texture(), and set_width().

◆ xmove_

double font::floating_label::xmove_
private

Definition at line 128 of file floating_label.hpp.

Referenced by get_pos(), and set_move().

◆ xpos_

double font::floating_label::xpos_
private

Definition at line 128 of file floating_label.hpp.

Referenced by move(), set_position(), and xpos().

◆ ymove_

double font::floating_label::ymove_
private

Definition at line 128 of file floating_label.hpp.

Referenced by get_pos(), and set_move().

◆ ypos_

double font::floating_label::ypos_
private

Definition at line 128 of file floating_label.hpp.

Referenced by get_pos(), move(), and set_position().


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