The Battle for Wesnoth  1.19.0-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 50 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 95 of file floating_label.hpp.

References fadeout_, get_time_alive(), and lifetime_.

◆ get_alpha()

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

Definition at line 241 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 97 of file floating_label.cpp.

References border_.

Referenced by draw(), get_draw_size(), 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.

References get_bg_rect(), texture::h(), utf8::size(), tex_, and texture::w().

◆ get_fade_time()

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

Definition at line 102 of file floating_label.hpp.

References fadeout_.

◆ get_pos()

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

Definition at line 232 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 106 of file floating_label.hpp.

References time_start_.

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 79 of file floating_label.cpp.

References xpos_, and ypos_.

◆ scroll()

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

Definition at line 99 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 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, and height_.

Referenced by terrain_label::recalculate().

◆ 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.

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

References w, and width_.

Referenced by terrain_label::recalculate().

◆ show()

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

Definition at line 97 of file floating_label.hpp.

References visible_.

◆ undraw()

void font::floating_label::undraw ( )

Mark the last drawn location as requiring redraw.

Definition at line 154 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 161 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 use_markup_.

Referenced by display_chat_manager::add_chat_message(), and terrain_label::recalculate().

◆ xpos()

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

Definition at line 85 of file floating_label.cpp.

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

Referenced by get_pos(), and set_position().

Member Data Documentation

◆ align_

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

Definition at line 124 of file floating_label.hpp.

Referenced by set_alignment(), and xpos().

◆ alpha_

uint8_t font::floating_label::alpha_
private

Definition at line 113 of file floating_label.hpp.

Referenced by draw(), and update().

◆ bgcolor_

color_t font::floating_label::bgcolor_
private

Definition at line 118 of file floating_label.hpp.

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

◆ border_

int font::floating_label::border_
private

Definition at line 125 of file floating_label.hpp.

Referenced by get_bg_rect(), and set_border_size().

◆ clip_rect_

SDL_Rect font::floating_label::clip_rect_
private

Definition at line 122 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 118 of file floating_label.hpp.

Referenced by create_texture(), and set_color().

◆ fadeout_

int font::floating_label::fadeout_
private

Definition at line 114 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 117 of file floating_label.hpp.

Referenced by create_texture(), and set_font_size().

◆ height_

int font::floating_label::height_
private

Definition at line 121 of file floating_label.hpp.

Referenced by create_texture(), and set_height().

◆ lifetime_

int font::floating_label::lifetime_
private

Definition at line 120 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 112 of file floating_label.hpp.

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

◆ scroll_

LABEL_SCROLL_MODE font::floating_label::scroll_
private

Definition at line 126 of file floating_label.hpp.

Referenced by scroll(), and set_scroll_mode().

◆ tex_

texture font::floating_label::tex_
private

◆ text_

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

Definition at line 116 of file floating_label.hpp.

Referenced by create_texture(), and update().

◆ time_start_

int font::floating_label::time_start_
private

Definition at line 115 of file floating_label.hpp.

Referenced by get_time_alive(), and set_lifetime().

◆ use_markup_

bool font::floating_label::use_markup_
private

Definition at line 127 of file floating_label.hpp.

Referenced by create_texture(), and use_markup().

◆ visible_

bool font::floating_label::visible_
private

Definition at line 123 of file floating_label.hpp.

Referenced by draw(), and show().

◆ width_

int font::floating_label::width_
private

Definition at line 121 of file floating_label.hpp.

Referenced by create_texture(), and set_width().

◆ xmove_

double font::floating_label::xmove_
private

Definition at line 119 of file floating_label.hpp.

Referenced by get_pos(), and set_move().

◆ xpos_

double font::floating_label::xpos_
private

Definition at line 119 of file floating_label.hpp.

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

◆ ymove_

double font::floating_label::ymove_
private

Definition at line 119 of file floating_label.hpp.

Referenced by get_pos(), and set_move().

◆ ypos_

double font::floating_label::ypos_
private

Definition at line 119 of file floating_label.hpp.

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


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