summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-04-16 22:59:27 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-04-16 22:59:27 +0200
commitac324f14b8a088770e4a59e84f754ddea8909be6 (patch)
treee5cb1d94bcb95100d5b3cd741b040d91fc998fef
parent486ed41fd2f5e9220fc9d9a4bf0459d0f99db64a (diff)
downloadserenity-ac324f14b8a088770e4a59e84f754ddea8909be6.zip
GWidget: Add move_by() and make set_relative_rect() invalidate parent.
-rw-r--r--LibGUI/GWidget.cpp5
-rw-r--r--LibGUI/GWidget.h3
2 files changed, 8 insertions, 0 deletions
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; }