mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-13 06:51:51 +00:00
fix: tooltip getting out of the root container
This commit is contained in:
parent
eb10904069
commit
fa985138c4
1 changed files with 7 additions and 2 deletions
|
|
@ -68,9 +68,14 @@ void GUI::updateTooltip(float delta) {
|
||||||
const auto& text = hover->getTooltip();
|
const auto& text = hover->getTooltip();
|
||||||
if (label && !text.empty()) {
|
if (label && !text.empty()) {
|
||||||
tooltip->setVisible(true);
|
tooltip->setVisible(true);
|
||||||
tooltip->setPos(Events::cursor+glm::vec2(10.0f));
|
|
||||||
label->setText(langs::get(text));
|
label->setText(langs::get(text));
|
||||||
tooltip->setSize(label->getSize()+glm::vec2(4.0f));
|
auto size = label->getSize()+glm::vec2(4.0f);
|
||||||
|
auto pos = Events::cursor+glm::vec2(10.0f);
|
||||||
|
auto rootSize = container->getSize();
|
||||||
|
pos.x = glm::min(pos.x, rootSize.x-size.x);
|
||||||
|
pos.y = glm::min(pos.y, rootSize.y-size.y);
|
||||||
|
tooltip->setSize(size);
|
||||||
|
tooltip->setPos(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tooltipTimer += delta;
|
tooltipTimer += delta;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue