25 #include "eng3d/ui/window.hpp"
26 #include "eng3d/ui/image.hpp"
27 #include "eng3d/ui/div.hpp"
28 #include "eng3d/ui/ui.hpp"
29 #include "eng3d/state.hpp"
30 #include "eng3d/texture.hpp"
39 this->
padding = glm::ivec2(8, 24 + 8);
40 this->
current_texture = s.tex_man.load(s.package_man.get_unique(
"gfx/window_background.png"));
44 glm::ivec2 size(4, 4);
45 glm::ivec2 texture_size(10, 10);
46 glm::ivec2 offset(0, 24);
49 this->
set_on_drag([
this](glm::ivec2 start_pos, glm::ivec2 current_pos) {
50 if (start_pos == current_pos) {
51 this->start_drag_position = glm::ivec2{this->
x, this->
y};
54 const auto move_offset = current_pos - start_pos;
55 this->
x = this->start_drag_position.x + move_offset.x;
56 this->
y = this->start_drag_position.y + move_offset.y;
67 if(!this->close_btn) {
69 auto& btn_wrapper = this->make_widget<UI::Div>(-size -
padding.x, -
padding.y, size, size);
72 btn_wrapper.make_widget<
UI::Image>(0, 0, size, size,
"gfx/ui/button/exit_btn_shadow.png",
true);
73 const int btn_size = (int)(size * 0.75f);
74 const int offset = (size - btn_size) / 2;
75 auto* btn =
Image::make_transparent(offset, offset, btn_size, btn_size,
"gfx/ui/button/exit_btn.png",
true, &btn_wrapper);
76 btn->set_on_click(_on_click);
77 this->close_btn = &btn_wrapper;
81 this->close_btn->
kill();
82 this->close_btn =
nullptr;
static State & get_instance()
Border class that defines the texture and size of borders of the widgets.
std::shared_ptr< Eng3D::Texture > border_tex
Image widget, can display pictures or effects on the screen.
static Image * make_transparent(int x, int y, unsigned w, unsigned h, const std::string &tex_path, Widget *parent=nullptr)
void set_close_btn_function(std::function< void(Widget &)> on_click)
Window(int x, int y, unsigned w, unsigned h, Widget *parent=nullptr)
WidgetType
The type of the widget, some widgets share types between them to keep simplicity.
Primitive color type used through the engine.