ladybird/Libraries/LibCore/CEvent.cpp
Andreas Kling d3558b6137 LibCore+LibGUI: Allow inserting a CObject/GWidget before another
When adding a widget to a parent, you don't always want to append it to
the set of existing children, but instead insert it before one of them.

This patch makes that possible by adding CObject::insert_child_before()
which also produces a ChildAdded event with an additional before_child
pointer. This pointer is then used by GWidget to make sure that any
layout present maintains the correct order. (Without doing that, newly
added children would still be appended into the layout order, despite
having a different widget sibling order.)
2019-11-05 20:41:27 +01:00

14 lines
343 B
C++

#include <LibCore/CEvent.h>
#include <LibCore/CObject.h>
CChildEvent::CChildEvent(Type type, CObject& child, CObject* insertion_before_child)
: CEvent(type)
, m_child(child.make_weak_ptr())
, m_insertion_before_child(insertion_before_child ? insertion_before_child->make_weak_ptr() : nullptr)
{
}
CChildEvent::~CChildEvent()
{
}