1 #include "lxgui/gui_status_bar.hpp"
3 #include "lxgui/gui_alive_checker.hpp"
4 #include "lxgui/gui_frame.hpp"
5 #include "lxgui/gui_manager.hpp"
6 #include "lxgui/gui_out.hpp"
7 #include "lxgui/gui_region_tpl.hpp"
8 #include "lxgui/gui_texture.hpp"
14 std::array<float, 4>
select_uvs(
const std::array<float, 8>& uvs) {
15 return {uvs[0], uvs[1], uvs[4], uvs[5]};
20 frame(block, mgr, attr) {
26 std::ostringstream str;
29 str << tab <<
" # Orientation: " << utils::to_string(
orientation_) <<
"\n";
31 str << tab <<
" # Value : " <<
value_ <<
"\n";
32 str << tab <<
" # Min value : " <<
min_value_ <<
"\n";
33 str << tab <<
" # Max value : " <<
max_value_ <<
"\n";
45 const status_bar* bar_obj = down_cast<status_bar>(&obj);
58 attr.
name = bar->get_raw_name();
62 this->create_layered_region<texture>(bar->get_draw_layer(), std::move(attr));
65 bar_texture->set_manually_inherited(
true);
66 bar_texture->notify_loaded();
80 const auto old_value =
value_;
101 const auto old_value =
value_;
104 if (
value_ != old_value) {
121 const auto old_value =
value_;
124 if (
value_ != old_value) {
166 std::string parent =
bar_texture_->get_parent().get() ==
this ?
"$parent" :
name_;
244 auto bar_texture = create_layered_region<texture>(
bar_layer_,
"$parentBarTexture");
248 bar_texture->set_manually_inherited(
true);
249 bar_texture->notify_loaded();
268 uvs[0] = (uvs[0] - uvs[2]) * coef + uvs[2];
270 uvs[2] = (uvs[2] - uvs[0]) * coef + uvs[0];
274 uvs[3] = (uvs[3] - uvs[1]) * coef + uvs[1];
276 uvs[1] = (uvs[1] - uvs[3]) * coef + uvs[3];
284 return get_type_list_impl_<status_bar>();
Utility class for safe checking of region validity.
bool is_alive() const
Check if the wrapped region is still alive.
Holds a single color (float RGBA, 128 bits)
A region that can contain other regions and react to events.
std::string serialize(const std::string &tab) const override
Prints all relevant information about this region in a string.
void copy_from(const region &obj) override
Copies a region's parameters into this frame (inheritance).
virtual void fire_script(const std::string &script_name, const event_data &data=event_data{})
Calls a script.
virtual bool can_use_script(const std::string &script_name) const
Returns 'true' if this frame can use a script.
Manages the user interface.
The base class of all elements in the GUI.
void initialize_(T &self, const region_core_attributes &attr)
Set up function to call in all derived class constructors.
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.
void create_bar_texture_()
float get_value() const
Returns this status_bar's value.
bool is_reversed() const
Checks if this status_bar is reversed.
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).
status_bar(utils::control_block &block, manager &mgr, const frame_core_attributes &attr)
Constructor.
void set_min_max_values(float min_value, float max_value)
Sets this status_bar's value range.
void notify_bar_texture_needs_update_()
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.
layer get_bar_draw_layer() const
Returns the draw layer of status_bar's bar texture.
bool can_use_script(const std::string &script_name) const override
Returns 'true' if this status_bar can use a script.
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.
const utils::observer_ptr< texture > & get_bar_texture()
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.
A layered_region that can draw images and colored rectangles.
layer
ID of a layer for rendering inside a frame.
vector2< float > vector2f
Holds 2D coordinates (as floats)
std::array< float, 4 > select_uvs(const std::array< float, 8 > &uvs)
Struct holding all the core information about a frame necessary for its creation.
Struct holding all the core information about a region necessary for its creation.
std::vector< utils::observer_ptr< const region > > inheritance