1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 11:17:43 +00:00

LibGUI: Make tooltip height line count aware

Previously multiline was not handled properly thus in case of the
Network applet the tooltip would be drawn improperly.
This commit is contained in:
LuK1337 2021-07-04 10:41:51 +02:00 committed by Gunnar Beutner
parent e42484bb65
commit 62d4b4abf3

View file

@ -28,12 +28,13 @@ public:
{
m_label->set_text(Gfx::parse_ampersand_string(tooltip));
int tooltip_width = m_label->min_width() + 10;
int tooltip_height = m_label->font().glyph_height() * max(1, m_label->text().count("\n")) + 8;
Gfx::IntRect desktop_rect = Desktop::the().rect();
if (tooltip_width > desktop_rect.width())
tooltip_width = desktop_rect.width();
set_rect(rect().x(), rect().y(), tooltip_width, m_label->font().glyph_height() + 8);
set_rect(rect().x(), rect().y(), tooltip_width, tooltip_height);
}
private: