mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 12:27:35 +00:00
GWidget: Add move_by() and make set_relative_rect() invalidate parent.
This commit is contained in:
parent
486ed41fd2
commit
ac324f14b8
2 changed files with 8 additions and 0 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue