From 47d7faa998b933e669747824baa35c908c9c3144 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sat, 15 Aug 2020 11:44:34 +0200 Subject: [PATCH] LibGUI: Update active tooltip when source widget changes the label Application::show_tooltip() now keeps track of the application's active tooltip source widget so it can be updated while being shown when the same widget updates its tooltip label. Application::hide_tooltip() will unset the tooltip source widget, respectively. This is pretty useful for the ResourceGraph applet's tooltips! Also re-use the Application::TooltipWindow's rect position in its set_tooltip() method to avoid flickering from the window temporarily being moved to 100, 100 and the position adjusted moments later. --- Libraries/LibGUI/Application.cpp | 6 ++++-- Libraries/LibGUI/Application.h | 5 ++++- Libraries/LibGUI/Widget.cpp | 16 ++++++++++++++-- Libraries/LibGUI/Widget.h | 5 ++++- Libraries/LibWeb/PageView.cpp | 2 +- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Libraries/LibGUI/Application.cpp b/Libraries/LibGUI/Application.cpp index 042b512cd8..dd256ebdca 100644 --- a/Libraries/LibGUI/Application.cpp +++ b/Libraries/LibGUI/Application.cpp @@ -115,7 +115,7 @@ public: { // FIXME: Add some kind of GUI::Label auto-sizing feature. int text_width = m_label->font().width(tooltip); - set_rect(100, 100, text_width + 10, m_label->font().glyph_height() + 8); + set_rect(rect().x(), rect().y(), text_width + 10, m_label->font().glyph_height() + 8); m_label->set_text(tooltip); } @@ -134,8 +134,9 @@ private: RefPtr