1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:57:45 +00:00

Intense hacking on Widgets.

This commit is contained in:
Andreas Kling 2018-10-10 16:49:36 +02:00
parent 8c84f9749e
commit 6f37429f57
20 changed files with 290 additions and 5 deletions

View file

@ -5,10 +5,17 @@
Object::Object(Object* parent)
: m_parent(parent)
{
if (m_parent)
m_parent->addChild(*this);
}
Object::~Object()
{
if (m_parent)
m_parent->removeChild(*this);
for (auto* child : m_children) {
delete child;
}
}
void Object::event(Event& event)
@ -21,3 +28,19 @@ void Object::event(Event& event)
break;
}
}
void Object::addChild(Object& object)
{
m_children.append(&object);
}
void Object::removeChild(Object& object)
{
// Oh geez, Vector needs a remove() huh...
Vector<Object*> newList;
for (auto* child : m_children) {
if (child != &object)
newList.append(child);
}
m_children = std::move(newList);
}