lxgui
Loading...
Searching...
No Matches
gui_status_bar.hpp
1#ifndef LXGUI_GUI_STATUS_BAR_HPP
2#define LXGUI_GUI_STATUS_BAR_HPP
3
4#include "lxgui/gui_color.hpp"
5#include "lxgui/gui_frame.hpp"
6#include "lxgui/gui_orientation.hpp"
7#include "lxgui/lxgui.hpp"
8#include "lxgui/utils.hpp"
9
10namespace lxgui::gui {
11
12class texture;
13
32class status_bar : public frame {
33public:
34 using base = frame;
35
37 explicit status_bar(
38 utils::control_block& block, manager& mgr, const frame_core_attributes& attr);
39
45 std::string serialize(const std::string& tab) const override;
46
52 bool can_use_script(const std::string& script_name) const override;
53
58 void copy_from(const region& obj) override;
59
64 void set_min_value(float min_value);
65
70 void set_max_value(float max_value);
71
77 void set_min_max_values(float min_value, float max_value);
78
83 void set_value(float value);
84
89 void set_bar_draw_layer(layer bar_layer);
90
95 void set_bar_texture(utils::observer_ptr<texture> bar_texture);
96
101 void set_bar_color(const color& bar_color);
102
107 void set_orientation(orientation orient);
108
117 void set_reversed(bool reversed);
118
123 float get_min_value() const;
124
129 float get_max_value() const;
130
135 float get_value() const;
136
142
147 const utils::observer_ptr<texture>& get_bar_texture() {
148 return bar_texture_;
149 }
150
155 utils::observer_ptr<const texture> get_bar_texture() const {
156 return bar_texture_;
157 }
158
163 const color& get_bar_color() const;
164
170
175 bool is_reversed() const;
176
178 static void register_on_lua(sol::state& lua);
179
180 static constexpr const char* class_name = "StatusBar";
181
182protected:
183 void create_bar_texture_();
185
186 void parse_attributes_(const layout_node& node) override;
187 void parse_all_nodes_before_children_(const layout_node& node) override;
188
189 const std::vector<std::string>& get_type_list_() const override;
190
192 bool is_reversed_ = false;
193
194 float value_ = 0.0f;
195 float min_value_ = 0.0f;
196 float max_value_ = 1.0f;
197
200 utils::observer_ptr<texture> bar_texture_ = nullptr;
201 std::array<float, 4> initial_text_coords_ = {0.0f, 0.0f, 1.0f, 1.0f};
202};
203
204} // namespace lxgui::gui
205
206#endif
Holds a single color (float RGBA, 128 bits)
Definition gui_color.hpp:13
static const color white
Definition gui_color.hpp:44
A region that can contain other regions and react to events.
An node in a layout file.
Manages the user interface.
The base class of all elements in the GUI.
A frame representing a variable-length bar.
void set_value(float value)
Sets this status_bar's value.
void set_orientation(orientation orient)
Sets this status_bar's orientation.
std::array< float, 4 > initial_text_coords_
float get_max_value() const
Returns this status_bar's maximum value.
utils::observer_ptr< texture > bar_texture_
float get_min_value() const
Returns this status_bar's minimum value.
float get_value() const
Returns this status_bar's value.
bool is_reversed() const
Checks if this status_bar is reversed.
static constexpr const char * class_name
const std::vector< std::string > & get_type_list_() const override
orientation get_orientation() const
Returns this status_bar's orientation.
void set_min_value(float min_value)
Sets this status_bar's minimum value.
const color & get_bar_color() const
Returns this status_bar's bar color.
void copy_from(const region &obj) override
Copies a region's parameters into this status_bar (inheritance).
void set_min_max_values(float min_value, float max_value)
Sets this status_bar's value range.
void parse_all_nodes_before_children_(const layout_node &node) override
void set_bar_draw_layer(layer bar_layer)
Sets the draw layer of this status_bar's bar texture.
void set_reversed(bool reversed)
Reverses this status_bar.
const utils::observer_ptr< texture > & get_bar_texture()
Returns this status_bar's bar texture.
layer get_bar_draw_layer() const
Returns the draw layer of status_bar's bar texture.
void parse_attributes_(const layout_node &node) override
bool can_use_script(const std::string &script_name) const override
Returns 'true' if this status_bar can use a script.
static void register_on_lua(sol::state &lua)
Registers this region class to the provided Lua state.
void set_max_value(float max_value)
Sets this status_bar's maximum value.
void set_bar_texture(utils::observer_ptr< texture > bar_texture)
Sets this status_bar's bar texture.
utils::observer_ptr< const texture > get_bar_texture() const
Returns this status_bar's bar texture.
std::string serialize(const std::string &tab) const override
Prints all relevant information about this region in a string.
void set_bar_color(const color &bar_color)
Sets this status_bar's bar color.
layer
ID of a layer for rendering inside a frame.
Struct holding all the core information about a frame necessary for its creation.