summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/Application.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-08-15 11:44:34 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-15 13:45:08 +0200
commit47d7faa998b933e669747824baa35c908c9c3144 (patch)
treef17e0b29da31d6ad2a440d8c0d6b09cb2c595316 /Libraries/LibGUI/Application.cpp
parentf19b88c96518176e962b487baf7937ceacf1f235 (diff)
downloadserenity-47d7faa998b933e669747824baa35c908c9c3144.zip
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.
Diffstat (limited to 'Libraries/LibGUI/Application.cpp')
-rw-r--r--Libraries/LibGUI/Application.cpp6
1 files changed, 4 insertions, 2 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<Label> m_label;
};
-void Application::show_tooltip(const StringView& tooltip, const Gfx::IntPoint& screen_location)
+void Application::show_tooltip(const StringView& tooltip, const Gfx::IntPoint& screen_location, const Widget* tooltip_source_widget)
{
+ m_tooltip_source_widget = tooltip_source_widget;
if (!m_tooltip_window) {
m_tooltip_window = TooltipWindow::construct();
m_tooltip_window->set_double_buffering_enabled(false);
@@ -159,6 +160,7 @@ void Application::show_tooltip(const StringView& tooltip, const Gfx::IntPoint& s
void Application::hide_tooltip()
{
+ m_tooltip_source_widget = nullptr;
if (m_tooltip_window) {
m_tooltip_window->hide();
m_tooltip_window = nullptr;