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:
parent
8c84f9749e
commit
6f37429f57
20 changed files with 290 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue