From 62d4b4abf38857c514694260abc68ed0010d7707 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Sun, 4 Jul 2021 10:41:51 +0200 Subject: [PATCH] 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. --- Userland/Libraries/LibGUI/Application.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGUI/Application.cpp b/Userland/Libraries/LibGUI/Application.cpp index 080310e5d8..a16b557106 100644 --- a/Userland/Libraries/LibGUI/Application.cpp +++ b/Userland/Libraries/LibGUI/Application.cpp @@ -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: