This commit is contained in:
2018-02-10 18:59:45 +01:00
16 changed files with 260 additions and 78 deletions

View File

@@ -186,6 +186,16 @@ void Node::loaded()
}
void Node::added(Node* parent)
{
}
void Node::removed(Node* parent)
{
}
const Node* Node::init_template(const char* id)
{
const auto& m_template = static_cast<Node*>((*m_manager)[const_hash(id)]->m_children[0].get());
@@ -207,6 +217,7 @@ void Node::add_child(Node* n)
n->parent = this;
n->m_manager = m_manager;
YGNodeInsertChild(y_node, n->y_node, YGNodeGetChildCount(y_node));
n->added(this);
}
void Node::add_child(Node* n, int index)
@@ -215,6 +226,7 @@ void Node::add_child(Node* n, int index)
n->parent = this;
n->m_manager = m_manager;
YGNodeInsertChild(y_node, n->y_node, index);
n->added(this);
}
void Node::add_child(std::shared_ptr<Node> n)
@@ -223,6 +235,7 @@ void Node::add_child(std::shared_ptr<Node> n)
n->parent = this;
n->m_manager = m_manager;
YGNodeInsertChild(y_node, n->y_node, YGNodeGetChildCount(y_node));
n->added(this);
}
void Node::add_child(std::shared_ptr<Node> n, int index)
@@ -231,6 +244,7 @@ void Node::add_child(std::shared_ptr<Node> n, int index)
n->parent = this;
n->m_manager = m_manager;
YGNodeInsertChild(y_node, n->y_node, index);
n->added(this);
}
void Node::remove_child(Node* n)
@@ -238,6 +252,7 @@ void Node::remove_child(Node* n)
auto i = std::find_if(m_children.begin(), m_children.end(), [=](auto& ptr) { return ptr.get() == n; });
if (i != m_children.end())
{
n->removed(this);
YGNodeRemoveChild(y_node, n->y_node);
m_children.erase(i);
}
@@ -246,7 +261,10 @@ void Node::remove_child(Node* n)
void Node::remove_all_children()
{
for (auto& n : m_children)
{
n->removed(this);
YGNodeRemoveChild(y_node, n->y_node);
}
m_children.clear();
}