25 #include "eng3d/ui/tooltip.hpp"
26 #include "eng3d/ui/widget.hpp"
27 #include "eng3d/ui/text.hpp"
28 #include "eng3d/ui/ui.hpp"
29 #include "eng3d/state.hpp"
30 #include "eng3d/texture.hpp"
37 init(_parent, 600, 600);
43 size_t w = glm::min(text.size() * 12, (
size_t)512);
44 size_t h = ((text.size() * 12) / 512) * 24 + 24;
55 void UI::Tooltip::init(
UI::Widget* _parent,
size_t w,
size_t h) {
56 this->parent = _parent;
60 this->have_shadow =
true;
67 const glm::ivec2 size{ 4, 4 };
68 const glm::ivec2 texture_size{ 10, 10 };
74 int extra_below = screen_h - _y - _height;
75 if(extra_above > extra_below) {
83 int right_side = this->x + this->width;
84 if(right_side > screen_w)
85 this->x = screen_w - this->width;
90 this->kill_children();
91 if(text.empty())
return;
94 this->width = s.width - this->x;
95 this->height = s.height - this->x;
97 auto& text_txt = this->make_widget<UI::Text>(0, 0, text);
98 this->width = text_txt.width;
99 this->height = text_txt.height;
static State & get_instance()
Border class that defines the texture and size of borders of the widgets.
std::shared_ptr< Eng3D::Texture > tooltip_tex
std::shared_ptr< Eng3D::Texture > border_tex
Primitive color type used through the engine.