فهرست منبع

LibGUI: Widget updates should invalidate their window-relative rect.

Andreas Kling 6 سال پیش
والد
کامیت
5bd363c4bb
2فایلهای تغییر یافته به همراه12 افزوده شده و 1 حذف شده
  1. 10 1
      LibGUI/GWidget.cpp
  2. 2 0
      LibGUI/GWidget.h

+ 10 - 1
LibGUI/GWidget.cpp

@@ -139,7 +139,16 @@ void GWidget::update()
     if (m_has_pending_paint_event)
         return;
     m_has_pending_paint_event = true;
-    w->update(relative_rect());
+    w->update(window_relative_rect());
+}
+
+Rect GWidget::window_relative_rect() const
+{
+    auto rect = relative_rect();
+    for (auto* parent = parent_widget(); parent; parent = parent->parent_widget()) {
+        rect.move_by(parent->relative_position());
+    }
+    return rect;
 }
 
 GWidget::HitTestResult GWidget::hit_test(int x, int y)

+ 2 - 0
LibGUI/GWidget.h

@@ -31,6 +31,8 @@ public:
     Rect relative_rect() const { return m_relative_rect; }
     Point relative_position() const { return m_relative_rect.location(); }
 
+    Rect window_relative_rect() const;
+
     int x() const { return m_relative_rect.x(); }
     int y() const { return m_relative_rect.y(); }
     int width() const { return m_relative_rect.width(); }