|
|
Donner
C++20 SVG rendering library
|
Stores the tree structure for an XML element, such as the parent, children, and siblings. More...
#include "donner/base/xml/components/TreeComponent.h"
Public Member Functions | |
| TreeComponent (const xml::XMLQualifiedNameRef &tagName) | |
Construct a new tree component with the given type and tagName. | |
| void | insertBefore (Registry ®istry, Entity newNode, Entity referenceNode) |
| Insert newNode as a child, before referenceNode. | |
| void | appendChild (Registry ®istry, Entity child) |
| Append child as a child of the current node. | |
| void | replaceChild (Registry ®istry, Entity newChild, Entity oldChild) |
| Replace oldChild with newChild in the tree, removing oldChild and inserting newChild in its place. | |
| void | removeChild (Registry ®istry, Entity child) |
| Remove child from this node. | |
| void | remove (Registry ®istry) |
| Remove this node from its parent, if it has one. | |
| xml::XMLQualifiedNameRef | tagName () const |
| Get the qualified tag name of the element, e.g. "svg". | |
| Entity | parent () const |
Get the parent of this node, if it has one. Returns entt::null if this is the root. | |
| Entity | firstChild () const |
Get the first child of this node, if it has one. Returns entt::null if this has no children. | |
| Entity | lastChild () const |
Get the last child of this node, if it has one. Returns entt::null if this has no children. | |
| Entity | previousSibling () const |
Get the previous sibling of this node, if it has one. Returns entt::null if this is the first child. | |
| Entity | nextSibling () const |
Get the next sibling of this node, if it has one. Returns entt::null if this is the last child. | |
Stores the tree structure for an XML element, such as the parent, children, and siblings.
This component is added to all entities that are part of the SVG tree, and is used to navigate the tree structure.
|
inlineexplicit |
Construct a new tree component with the given type and tagName.
| tagName | The qualified tag name of the element, which may include a namespace. (e.g. "svg") |
Append child as a child of the current node.
If child is already in the tree, it is first removed from its parent. However, if inserting the child will create a cycle, the behavior is undefined.
| registry | Entity registry. |
| child | Node to append. |
| void donner::components::TreeComponent::insertBefore | ( | Registry & | registry, |
| Entity | newNode, | ||
| Entity | referenceNode ) |
Insert newNode as a child, before referenceNode.
If referenceNode is entt::null, append the child.
If newNode is already in the tree, it is first removed from its parent. However, if inserting the child will create a cycle, the behavior is undefined.
| registry | Entity registry. |
| newNode | New node to insert. |
| referenceNode | Nullable, a child of this node to insert newNode before. Must be a child of the current node. |
| void donner::components::TreeComponent::remove | ( | Registry & | registry | ) |
Remove this node from its parent, if it has one.
Has no effect if this has no parent.
| registry | Entity registry. |
Remove child from this node.
| registry | Entity registry. |
| child | Child to remove, must be a child of the current node. |
| void donner::components::TreeComponent::replaceChild | ( | Registry & | registry, |
| Entity | newChild, | ||
| Entity | oldChild ) |
Replace oldChild with newChild in the tree, removing oldChild and inserting newChild in its place.
If newChild is already in the tree, it is first removed from its parent. However, if inserting the child will create a cycle, the behavior is undefined.
| registry | Entity registry. |
| newChild | New child to insert. |
| oldChild | Old child to remove, must be a child of the current node. |