45 using clock = std::chrono::steady_clock;
63 void set_lifetime(
const std::chrono::milliseconds& lifetime,
const std::chrono::milliseconds& fadeout = std::chrono::milliseconds{100});
80 void move(
double xmove,
double ymove);
82 void update(
const clock::time_point& time);
101 bool expired(
const clock::time_point& time)
const
115 std::chrono::milliseconds
get_time_alive(
const clock::time_point& current_time)
const;
116 int xpos(std::size_t width)
const;
118 uint8_t
get_alpha(
const clock::time_point& time);
SDL_Point get_draw_size() const
Return the size of the label in drawing coordinates.
std::chrono::milliseconds lifetime_
void show(const bool value)
void set_move(double xmove, double ymove)
rect get_bg_rect(const rect &text_rect) const
LABEL_SCROLL_MODE scroll_
LABEL_SCROLL_MODE scroll() const
auto get_fade_time() const
clock::time_point time_start_
bool create_texture()
Ensure a texture for this floating label exists, creating one if needed.
void set_position(double xpos, double ypos)
point get_pos(const clock::time_point &time)
floating_label(const std::string &text)
std::chrono::milliseconds get_time_alive(const clock::time_point ¤t_time) const
void set_alignment(ALIGN align)
int xpos(std::size_t width) const
void update(const clock::time_point &time)
Finalize draw position and alpha, and queue redrawing if changed.
void set_lifetime(const std::chrono::milliseconds &lifetime, const std::chrono::milliseconds &fadeout=std::chrono::milliseconds{100})
std::chrono::milliseconds fadeout_
void set_color(const color_t &color)
void set_border_size(int border)
uint8_t get_alpha(const clock::time_point &time)
void move(double xmove, double ymove)
Change the floating label's position.
void set_clip_rect(const SDL_Rect &r)
void set_bg_color(const color_t &bg_color)
void set_scroll_mode(LABEL_SCROLL_MODE scroll)
bool expired(const clock::time_point &time) const
std::chrono::steady_clock clock
void draw()
Draw the label to the screen.
void undraw()
Mark the last drawn location as requiring redraw.
void set_font_size(int font_size)
Wrapper class to encapsulate creation and management of an SDL_Texture.
int w() const
The draw-space width of the texture, in pixels.
int h() const
The draw-space height of the texture, in pixels.
@ border
The border of the map.
int add_floating_label(const floating_label &flabel)
add a label floating on the screen above everything else.
void show_floating_label(int handle, bool value)
hides or shows a floating label
void scroll_floating_labels(double xmove, double ymove)
moves all floating labels that have 'scroll_mode' set to ANCHOR_LABEL_MAP
SDL_Rect get_floating_label_rect(int handle)
void remove_floating_label(int handle, const std::chrono::milliseconds &fadeout)
removes the floating label given by 'handle' from the screen
void update_floating_labels()
void move_floating_label(int handle, double xmove, double ymove)
moves the floating label given by 'handle' by (xmove,ymove)
void draw_floating_labels()
void show(const std::string &window_id, const t_string &message, const point &mouse, const SDL_Rect &source_rect)
Shows a tip.
std::shared_ptr< halo_record > handle
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
Contains the SDL_Rect helper code.
The basic class for representing 8-bit RGB or RGBA colour values.
structure which will hide all current floating labels, and cause floating labels instantiated after i...
~floating_label_context()
An abstract description of a rectangle with integer coordinates.