The Battle for Wesnoth  1.17.10+dev
Public Member Functions | 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, const surface &surface=nullptr)
 
void set_font_size (int font_size)
 
void set_position (double xpos, double ypos)
 
void set_move (double xmove, double ymove)
 
void set_lifetime (int lifetime, int fadeout=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 (int 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...
 
SDL_Point get_draw_size () const
 Return the size of the label in drawing coordinates. More...
 
bool expired (int time) const
 
void show (const bool value)
 
LABEL_SCROLL_MODE scroll () const
 
int get_fade_time () const
 

Private Member Functions

int get_time_alive (int current_time) const
 
int xpos (std::size_t width) const
 
point get_pos (int time)
 
uint8_t get_alpha (int time)
 
rect get_bg_rect (const rect &text_rect) const
 

Private Attributes

texture tex_
 
rect screen_loc_
 
uint8_t alpha_
 
int fadeout_
 
int time_start_
 
std::string text_
 
int font_size_
 
color_t color_
 
color_t bgcolor_
 
double xpos_
 
double ypos_
 
double xmove_
 
double ymove_
 
int lifetime_
 
int width_
 
int height_
 
SDL_Rect clip_rect_
 
bool visible_
 
font::ALIGN align_
 
int border_
 
LABEL_SCROLL_MODE scroll_
 
bool use_markup_
 

Detailed Description

Definition at line 41 of file floating_label.hpp.

Constructor & Destructor Documentation

◆ floating_label()

font::floating_label::floating_label ( const std::string &  text,
const surface surface = nullptr 
)

Definition at line 54 of file floating_label.cpp.

References surface::get(), and tex_.

Member Function Documentation

◆ create_texture()

bool font::floating_label::create_texture ( )

◆ draw()

void font::floating_label::draw ( )

◆ expired()

bool font::floating_label::expired ( int  time) const
inline

Definition at line 92 of file floating_label.hpp.

◆ get_alpha()

uint8_t font::floating_label::get_alpha ( int  time)
private

Definition at line 251 of file floating_label.cpp.

References fadeout_, get_time_alive(), lifetime_, and tex_.

Referenced by update().

◆ get_bg_rect()

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

Definition at line 101 of file floating_label.cpp.

References border_, display::get_singleton(), and display::get_zoom_factor().

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

◆ get_draw_size()

SDL_Point font::floating_label::get_draw_size ( ) const
inline

Return the size of the label in drawing coordinates.

Definition at line 90 of file floating_label.hpp.

◆ get_fade_time()

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

Definition at line 99 of file floating_label.hpp.

◆ get_pos()

point font::floating_label::get_pos ( int  time)
private

Definition at line 242 of file floating_label.cpp.

References get_time_alive(), tex_, texture::w(), xmove_, xpos(), ymove_, and ypos_.

Referenced by update().

◆ get_time_alive()

int font::floating_label::get_time_alive ( int  current_time) const
inlineprivate

Definition at line 103 of file floating_label.hpp.

Referenced by get_alpha(), and get_pos().

◆ move()

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

Change the floating label's position.

Definition at line 83 of file floating_label.cpp.

References xpos_, and ypos_.

◆ scroll()

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

Definition at line 96 of file floating_label.hpp.

◆ 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

Definition at line 64 of file floating_label.hpp.

Referenced by font::set_help_string().

◆ set_clip_rect()

void font::floating_label::set_clip_rect ( const SDL_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 67 of file floating_label.hpp.

References h.

◆ set_lifetime()

void font::floating_label::set_lifetime ( int  lifetime,
int  fadeout = 100 
)

◆ set_move()

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

Definition at line 54 of file floating_label.hpp.

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 70 of file floating_label.hpp.

Referenced by game_display::float_label().

◆ set_width()

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

Definition at line 66 of file floating_label.hpp.

References w.

◆ show()

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

Definition at line 94 of file floating_label.hpp.

◆ undraw()

void font::floating_label::undraw ( )

Mark the last drawn location as requiring redraw.

Definition at line 159 of file floating_label.cpp.

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

◆ update()

void font::floating_label::update ( int  time)

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

Definition at line 166 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().

◆ use_markup()

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

Definition at line 71 of file floating_label.hpp.

References b, and draw_manager::update().

◆ xpos()

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

Definition at line 89 of file floating_label.cpp.

References align_, font::CENTER_ALIGN, font::RIGHT_ALIGN, and xpos_.

Referenced by get_pos().

Member Data Documentation

◆ align_

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

Definition at line 121 of file floating_label.hpp.

Referenced by xpos().

◆ alpha_

uint8_t font::floating_label::alpha_
private

Definition at line 110 of file floating_label.hpp.

Referenced by draw(), and update().

◆ bgcolor_

color_t font::floating_label::bgcolor_
private

Definition at line 115 of file floating_label.hpp.

Referenced by create_texture(), and draw().

◆ border_

int font::floating_label::border_
private

Definition at line 122 of file floating_label.hpp.

Referenced by get_bg_rect().

◆ clip_rect_

SDL_Rect font::floating_label::clip_rect_
private

Definition at line 119 of file floating_label.hpp.

Referenced by create_texture(), and draw().

◆ color_

color_t font::floating_label::color_
private

Definition at line 115 of file floating_label.hpp.

Referenced by create_texture().

◆ fadeout_

int font::floating_label::fadeout_
private

Definition at line 111 of file floating_label.hpp.

Referenced by get_alpha(), and set_lifetime().

◆ font_size_

int font::floating_label::font_size_
private

Definition at line 114 of file floating_label.hpp.

Referenced by create_texture().

◆ height_

int font::floating_label::height_
private

Definition at line 118 of file floating_label.hpp.

Referenced by create_texture().

◆ lifetime_

int font::floating_label::lifetime_
private

Definition at line 117 of file floating_label.hpp.

Referenced by get_alpha(), and set_lifetime().

◆ screen_loc_

rect font::floating_label::screen_loc_
private

Definition at line 109 of file floating_label.hpp.

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

◆ scroll_

LABEL_SCROLL_MODE font::floating_label::scroll_
private

Definition at line 123 of file floating_label.hpp.

◆ tex_

texture font::floating_label::tex_
private

Definition at line 108 of file floating_label.hpp.

Referenced by create_texture(), draw(), floating_label(), get_alpha(), get_pos(), and update().

◆ text_

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

Definition at line 113 of file floating_label.hpp.

Referenced by create_texture(), and update().

◆ time_start_

int font::floating_label::time_start_
private

Definition at line 112 of file floating_label.hpp.

Referenced by set_lifetime().

◆ use_markup_

bool font::floating_label::use_markup_
private

Definition at line 124 of file floating_label.hpp.

Referenced by create_texture().

◆ visible_

bool font::floating_label::visible_
private

Definition at line 120 of file floating_label.hpp.

Referenced by draw().

◆ width_

int font::floating_label::width_
private

Definition at line 118 of file floating_label.hpp.

Referenced by create_texture().

◆ xmove_

double font::floating_label::xmove_
private

Definition at line 116 of file floating_label.hpp.

Referenced by get_pos().

◆ xpos_

double font::floating_label::xpos_
private

Definition at line 116 of file floating_label.hpp.

Referenced by move(), and xpos().

◆ ymove_

double font::floating_label::ymove_
private

Definition at line 116 of file floating_label.hpp.

Referenced by get_pos().

◆ ypos_

double font::floating_label::ypos_
private

Definition at line 116 of file floating_label.hpp.

Referenced by get_pos(), and move().


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