summaryrefslogtreecommitdiff
path: root/LibGUI/GWidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'LibGUI/GWidget.cpp')
-rw-r--r--LibGUI/GWidget.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/LibGUI/GWidget.cpp b/LibGUI/GWidget.cpp
index 764037870d..b02bf059f2 100644
--- a/LibGUI/GWidget.cpp
+++ b/LibGUI/GWidget.cpp
@@ -6,6 +6,7 @@
#include <AK/Assertions.h>
#include <SharedGraphics/GraphicsBitmap.h>
#include <LibGUI/GPainter.h>
+#include <LibGUI/GApplication.h>
#include <unistd.h>
@@ -79,9 +80,9 @@ void GWidget::event(GEvent& event)
case GEvent::MouseUp:
return handle_mouseup_event(static_cast<GMouseEvent&>(event));
case GEvent::Enter:
- return enter_event(event);
+ return handle_enter_event(event);
case GEvent::Leave:
- return leave_event(event);
+ return handle_leave_event(event);
default:
return GObject::event(event);
}
@@ -177,6 +178,19 @@ void GWidget::handle_mousedown_event(GMouseEvent& event)
mousedown_event(event);
}
+void GWidget::handle_enter_event(GEvent& event)
+{
+ if (has_tooltip())
+ GApplication::the().show_tooltip(m_tooltip, screen_relative_rect().center().translated(0, height() / 2));
+ enter_event(event);
+}
+
+void GWidget::handle_leave_event(GEvent& event)
+{
+ GApplication::the().hide_tooltip();
+ leave_event(event);
+}
+
void GWidget::click_event(GMouseEvent&)
{
}
@@ -261,6 +275,11 @@ Rect GWidget::window_relative_rect() const
return rect;
}
+Rect GWidget::screen_relative_rect() const
+{
+ return window_relative_rect().translated(window()->position());
+}
+
GWidget::HitTestResult GWidget::hit_test(int x, int y)
{
// FIXME: Care about z-order.