Skip to content

Commit ac324f1

Browse files
committed
GWidget: Add move_by() and make set_relative_rect() invalidate parent.
1 parent 486ed41 commit ac324f1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

LibGUI/GWidget.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ void GWidget::set_relative_rect(const Rect& rect)
4343
{
4444
if (rect == m_relative_rect)
4545
return;
46+
47+
auto old_rect = m_relative_rect;
48+
4649
bool size_changed = m_relative_rect.size() != rect.size();
4750
m_relative_rect = rect;
4851

@@ -51,6 +54,8 @@ void GWidget::set_relative_rect(const Rect& rect)
5154
event(resize_event);
5255
}
5356

57+
if (auto* parent = parent_widget())
58+
parent->update(old_rect);
5459
update();
5560
}
5661

LibGUI/GWidget.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ class GWidget : public CObject {
112112
void resize(const Size& size) { set_relative_rect({ relative_rect().location(), size }); }
113113
void resize(int width, int height) { resize({ width, height }); }
114114

115+
void move_by(int x, int y) { move_by({ x, y }); }
116+
void move_by(const Point& delta) { set_relative_rect({ relative_position().translated(delta), size() }); }
117+
115118
Color background_color() const { return m_background_color; }
116119
Color foreground_color() const { return m_foreground_color; }
117120

0 commit comments

Comments
 (0)