From ac324f14b8a088770e4a59e84f754ddea8909be6 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 16 Apr 2019 22:59:27 +0200 Subject: [PATCH] GWidget: Add move_by() and make set_relative_rect() invalidate parent. --- LibGUI/GWidget.cpp | 5 +++++ LibGUI/GWidget.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/LibGUI/GWidget.cpp b/LibGUI/GWidget.cpp index 76f94d8085..8dca7e125b 100644 --- a/LibGUI/GWidget.cpp +++ b/LibGUI/GWidget.cpp @@ -43,6 +43,9 @@ void GWidget::set_relative_rect(const Rect& rect) { if (rect == m_relative_rect) return; + + auto old_rect = m_relative_rect; + bool size_changed = m_relative_rect.size() != rect.size(); m_relative_rect = rect; @@ -51,6 +54,8 @@ void GWidget::set_relative_rect(const Rect& rect) event(resize_event); } + if (auto* parent = parent_widget()) + parent->update(old_rect); update(); } diff --git a/LibGUI/GWidget.h b/LibGUI/GWidget.h index 5c34380c35..5fc98de9f5 100644 --- a/LibGUI/GWidget.h +++ b/LibGUI/GWidget.h @@ -112,6 +112,9 @@ public: void resize(const Size& size) { set_relative_rect({ relative_rect().location(), size }); } void resize(int width, int height) { resize({ width, height }); } + void move_by(int x, int y) { move_by({ x, y }); } + void move_by(const Point& delta) { set_relative_rect({ relative_position().translated(delta), size() }); } + Color background_color() const { return m_background_color; } Color foreground_color() const { return m_foreground_color; }