mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:18:11 +00:00
LibCore+LibGUI: Make CObject child events synchronous.
...and then make GWidget layout invalidation lazy. This way we coalesce multiple invalidations into a single relayout and we don't have to worry about child widgets not being fully constructed.
This commit is contained in:
parent
0e6b273620
commit
9e6b0ccc0e
4 changed files with 22 additions and 13 deletions
|
@ -4,8 +4,9 @@
|
|||
#include <AK/Assertions.h>
|
||||
#include <stdio.h>
|
||||
|
||||
CObject::CObject(CObject* parent)
|
||||
CObject::CObject(CObject* parent, bool is_widget)
|
||||
: m_parent(parent)
|
||||
, m_widget(is_widget)
|
||||
{
|
||||
if (m_parent)
|
||||
m_parent->add_child(*this);
|
||||
|
@ -43,7 +44,7 @@ void CObject::event(CEvent& event)
|
|||
void CObject::add_child(CObject& object)
|
||||
{
|
||||
m_children.append(&object);
|
||||
CEventLoop::current().post_event(*this, make<CChildEvent>(CEvent::ChildAdded, object));
|
||||
event(*make<CChildEvent>(CEvent::ChildAdded, object));
|
||||
}
|
||||
|
||||
void CObject::remove_child(CObject& object)
|
||||
|
@ -51,7 +52,7 @@ void CObject::remove_child(CObject& object)
|
|||
for (ssize_t i = 0; i < m_children.size(); ++i) {
|
||||
if (m_children[i] == &object) {
|
||||
m_children.remove(i);
|
||||
CEventLoop::current().post_event(*this, make<CChildEvent>(CEvent::ChildRemoved, object));
|
||||
event(*make<CChildEvent>(CEvent::ChildRemoved, object));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue