lxgui
Loading...
Searching...
No Matches
gui_animated_texture.hpp
1#ifndef LXGUI_GUI_ANIMATED_TEXTURE_HPP
2#define LXGUI_GUI_ANIMATED_TEXTURE_HPP
3
4#include "lxgui/gui_layered_region.hpp"
5#include "lxgui/gui_quad.hpp"
6#include "lxgui/lxgui.hpp"
7#include "lxgui/utils.hpp"
8
9namespace lxgui::gui {
10
11class renderer;
12
18public:
20
22 explicit animated_texture(
23 utils::control_block& block, manager& mgr, const region_core_attributes& attr);
24
30 std::string serialize(const std::string& tab) const override;
31
33 void render() const override;
34
39 void update(float delta) override;
40
45 void copy_from(const region& obj) override;
46
51 float get_speed() const;
52
57 float get_state() const;
58
63 float is_paused() const;
64
69 const std::string& get_texture_file() const;
70
78 color get_vertex_color(std::size_t index) const;
79
84 void set_speed(float speed);
85
90 void set_state(float state);
91
96 void set_paused(bool is_paused);
97
102 void play() {
103 set_paused(false);
104 }
105
110 void pause() {
111 set_paused(true);
112 }
113
117 void stop() {
118 set_paused(true);
119 set_state(0.0f);
120 }
121
129 void set_texture(const std::string& file_name);
130
139 void
140 set_vertex_color(const color& c, std::size_t index = std::numeric_limits<std::size_t>::max());
141
146 void parse_layout(const layout_node& node) override;
147
149 static void register_on_lua(sol::state& lua);
150
151 static constexpr const char* class_name = "AnimatedTexture";
152
153private:
154 void parse_attributes_(const layout_node& node) override;
155 void parse_tex_coords_node_(const layout_node& node);
156 void parse_gradient_node_(const layout_node& node);
157
158 void update_tex_coords_();
159 void update_borders_() override;
160
161 const std::vector<std::string>& get_type_list_() const override;
162
163 std::string file_;
164
165 float speed_ = 1.0f;
166 float state_ = 0.0f;
167 bool is_paused_ = false;
168
169 renderer& renderer_;
170 quad quad_;
171};
172
173} // namespace lxgui::gui
174
175#endif
A layered_region that can draw animated sequences.
void parse_layout(const layout_node &node) override
Parses data from a layout_node.
const std::string & get_texture_file() const
Returns this texture's texture file.
float get_state() const
Returns this animated_texture's state (0: begin, 1: end).
static void register_on_lua(sol::state &lua)
Registers this region class to the provided Lua state.
void play()
Play this animated_texture.
std::string serialize(const std::string &tab) const override
Prints all relevant information about this region in a string.
void set_vertex_color(const color &c, std::size_t index=std::numeric_limits< std::size_t >::max())
Sets this texture's vertex color.
void stop()
Stop this animated_texture (stop playing and reset to start).
void update(float delta) override
Updates this region's logic.
color get_vertex_color(std::size_t index) const
Returns this texture's vertex color.
void set_state(float state)
Returns this animated_texture's state (0: begin, 1: end).
void pause()
Pause this animated_texture.
void set_texture(const std::string &file_name)
Sets this texture's texture file.
static constexpr const char * class_name
float get_speed() const
Returns this animated_texture's animation speed (frame per second).
void set_speed(float speed)
Set this animated_texture's animation speed (frame per second).
void set_paused(bool is_paused)
Play or pause this animated_texture.
void copy_from(const region &obj) override
Copies a region's parameters into this texture (inheritance).
float is_paused() const
Check if this animated_texture is paused.
void render() const override
Renders this region on the current render target.
Holds a single color (float RGBA, 128 bits)
Definition gui_color.hpp:13
A region that can be rendered in a layer.
An node in a layout file.
Manages the user interface.
The base class of all elements in the GUI.
Abstract type for implementation specific management.
Simple structure holding four vertices and a material.
Definition gui_quad.hpp:18
Struct holding all the core information about a region necessary for its creation.