1 #include "lxgui/gui_button.hpp"
3 #include "lxgui/gui_alive_checker.hpp"
4 #include "lxgui/gui_font_string.hpp"
5 #include "lxgui/gui_frame.hpp"
6 #include "lxgui/gui_manager.hpp"
7 #include "lxgui/gui_out.hpp"
8 #include "lxgui/gui_region_tpl.hpp"
9 #include "lxgui/gui_texture.hpp"
14 frame(block, mgr, attr) {
28 script_name ==
"OnEnable" || script_name ==
"OnDisable";
40 if (script_name ==
"OnEnter")
43 if (script_name ==
"OnLeave") {
50 bool try_handle_click =
false;
51 if (script_name ==
"OnMouseDown" || script_name ==
"OnMouseUp" ||
52 script_name ==
"OnDoubleClick") {
54 try_handle_click =
true;
58 if (script_name ==
"OnMouseUp" && !data.
get<
bool>(5)) {
59 try_handle_click =
false;
63 if (try_handle_click) {
77 float mx = data.
get<
float>(2);
78 float my = data.
get<
float>(3);
80 click_(button_id, event_id, mx, my);
89 const button* button_obj = down_cast<button>(&obj);
97 attr.
name = other_texture->get_raw_name();
101 this->create_layered_region<texture>(other_texture->get_draw_layer(), std::move(attr));
104 tex->set_manually_inherited(
true);
105 tex->notify_loaded();
112 attr.
name = other_texture->get_raw_name();
116 this->create_layered_region<texture>(other_texture->get_draw_layer(), std::move(attr));
119 tex->set_manually_inherited(
true);
120 tex->notify_loaded();
127 attr.
name = other_texture->get_raw_name();
131 this->create_layered_region<texture>(other_texture->get_draw_layer(), std::move(attr));
134 tex->set_manually_inherited(
true);
135 tex->notify_loaded();
142 attr.
name = other_texture->get_raw_name();
146 this->create_layered_region<texture>(other_texture->get_draw_layer(), std::move(attr));
149 tex->set_manually_inherited(
true);
150 tex->notify_loaded();
157 attr.
name = other_text->get_raw_name();
161 this->create_layered_region<font_string>(other_text->get_draw_layer(), std::move(attr));
164 fstr->set_manually_inherited(
true);
165 fstr->notify_loaded();
172 attr.
name = other_text->get_raw_name();
176 this->create_layered_region<font_string>(other_text->get_draw_layer(), std::move(attr));
179 fstr->set_manually_inherited(
true);
180 fstr->notify_loaded();
187 attr.
name = other_text->get_raw_name();
191 this->create_layered_region<font_string>(other_text->get_draw_layer(), std::move(attr));
194 fstr->set_manually_inherited(
true);
195 fstr->notify_loaded();
400 if (!mouse_event_id.has_value()) {
404 click(mouse_event_id.value().first, mouse_event_id.value().second);
419 std::string event_name =
423 new_data.
add(
static_cast<std::underlying_type_t<input::mouse_button>
>(button_id));
424 new_data.
add(
static_cast<std::underlying_type_t<input::mouse_button_event>
>(button_event));
425 new_data.
add(event_name);
536 if (
click.find(button_name) == 0) {
545 return get_type_list_impl_<button>();
Utility class for safe checking of region validity.
bool is_alive() const
Check if the wrapped region is still alive.
Stores a variable number of arguments for an event.
const utils::variant & get(std::size_t index) const
Returns a parameter of this event.
void add(T &&value)
Adds a parameter to this event.
A layered_region that can draw text on the screen.
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).
void enable_mouse()
Marks this frame as able to receive mouse input (click & move).
virtual void fire_script(const std::string &script_name, const event_data &data=event_data{})
Calls a script.
void notify_renderer_need_redraw() override
Notifies the renderer of this region that it needs to be redrawn.
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.
vector2f get_center() const
Returns the position of this region's center.
A layered_region that can draw images and colored rectangles.
vector2< float > vector2f
Holds 2D coordinates (as floats)
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