|
AeonGUI
A portable video game graphic user interface library.
|
Base class for all nodes in the DOM tree. More...
#include <aeongui/dom/Node.hpp>
Public Types | |
| enum | NodeType { ELEMENT_NODE = 1 , ATTRIBUTE_NODE = 2 , TEXT_NODE = 3 , CDATA_SECTION_NODE = 4 , ENTITY_REFERENCE_NODE = 5 , ENTITY_NODE = 6 , PROCESSING_INSTRUCTION_NODE = 7 , COMMENT_NODE = 8 , DOCUMENT_NODE = 9 , DOCUMENT_TYPE_NODE = 10 , DOCUMENT_FRAGMENT_NODE = 11 , NOTATION_NODE = 12 } |
| DOM node type constants. More... | |
Public Member Functions | |
| Node (Node *aParent=nullptr) | |
| Construct a node with an optional parent. | |
| Node * | AddNode (std::unique_ptr< Node > aNode) |
| Add a child node. | |
| std::unique_ptr< Node > | RemoveNode (const Node *aNode) |
| Remove a child node. | |
| void | TraverseDepthFirstPreOrder (const std::function< void(Node &) > &aAction) |
| Traverse the tree depth-first in pre-order. | |
| void | TraverseDepthFirstPreOrder (const std::function< void(const Node &) > &aAction) const |
| Traverse the tree depth-first in pre-order (const). | |
| void | TraverseDepthFirstPostOrder (const std::function< void(Node &) > &aAction) |
| Traverse the tree depth-first in post-order. | |
| void | TraverseDepthFirstPostOrder (const std::function< void(const Node &) > &aAction) const |
| Traverse the tree depth-first in post-order (const). | |
| void | TraverseDepthFirstPreOrder (const std::function< void(Node &) > &aPreamble, const std::function< void(Node &) > &aPostamble) |
| Traverse pre-order with separate pre and post callbacks. | |
| void | TraverseDepthFirstPreOrder (const std::function< void(const Node &) > &aPreamble, const std::function< void(const Node &) > &aPostamble) const |
| Traverse pre-order with pre/post callbacks (const). | |
| void | TraverseDepthFirstPreOrder (const std::function< void(Node &) > &aPreamble, const std::function< void(Node &) > &aPostamble, const std::function< bool(Node &) > &aUnaryPredicate) |
| Traverse pre-order with pre/post callbacks and a predicate filter. | |
| void | TraverseDepthFirstPreOrder (const std::function< void(const Node &) > &aPreamble, const std::function< void(const Node &) > &aPostamble, const std::function< bool(const Node &) > &aUnaryPredicate) const |
| Traverse pre-order with pre/post callbacks and predicate (const). | |
| virtual void | DrawStart (Canvas &aCanvas) const |
| Begin drawing this node on the canvas. | |
| virtual void | DrawFinish (Canvas &aCanvas) const |
| Finish drawing this node on the canvas. | |
| virtual void | OnLoad () |
| virtual void | OnUnload () |
| virtual bool | IsDrawEnabled () const |
| Node * | parentNode () const |
| Get the parent node. | |
| Node * | parentElement () const |
| Get the parent element (same as parentNode for elements). | |
| virtual NodeType | nodeType () const =0 |
| Get the node type. | |
| const std::vector< std::unique_ptr< Node > > & | childNodes () const |
| Get the list of child nodes. | |
| Public Member Functions inherited from AeonGUI::DOM::EventTarget | |
| virtual | ~EventTarget ()=0 |
| Virtual destructor. | |
| void | addEventListener (const DOMString &type, EventListener *callback, const std::variant< std::monostate, AddEventListenerOptions, bool > &options={}) |
| Register an event listener. | |
| void | removeEventListener (const DOMString &type, EventListener *callback, const std::variant< std::monostate, EventListenerOptions, bool > &options={}) |
| Unregister an event listener. | |
| virtual bool | dispatchEvent (Event &event) |
| Dispatch an event to this target. | |
Base class for all nodes in the DOM tree.
Implements the DOM Node interface: parent/child relationships, tree traversal, and draw hooks for rendering.
DOM node type constants.
| Enumerator | |
|---|---|
| ELEMENT_NODE | An Element node. |
| ATTRIBUTE_NODE | An Attribute node (legacy). |
| TEXT_NODE | A Text node. |
| CDATA_SECTION_NODE | A CDATASection node. |
| ENTITY_REFERENCE_NODE | An EntityReference node (legacy). |
| ENTITY_NODE | An Entity node (legacy). |
| PROCESSING_INSTRUCTION_NODE | A ProcessingInstruction node. |
| COMMENT_NODE | A Comment node. |
| DOCUMENT_NODE | A Document node. |
| DOCUMENT_TYPE_NODE | A DocumentType node. |
| DOCUMENT_FRAGMENT_NODE | A DocumentFragment node. |
| NOTATION_NODE | A Notation node (legacy). |
| AeonGUI::DOM::Node::Node | ( | Node * | aParent = nullptr | ) |
Construct a node with an optional parent.
| aParent | The parent node, or nullptr. |
Add a child node.
| aNode | The child to add (ownership transferred). |
| const std::vector< std::unique_ptr< Node > > & AeonGUI::DOM::Node::childNodes | ( | ) | const |
Get the list of child nodes.
|
virtual |
Finish drawing this node on the canvas.
| aCanvas | The target canvas. |
|
virtual |
Begin drawing this node on the canvas.
| aCanvas | The target canvas. |
Reimplemented in AeonGUI::DOM::SVGGeometryElement, AeonGUI::DOM::SVGGraphicsElement, AeonGUI::DOM::SVGImageElement, AeonGUI::DOM::SVGSVGElement, AeonGUI::DOM::SVGTextElement, and AeonGUI::DOM::SVGTSpanElement.
|
virtual |
Returns whether this node and all descendants should be skipped in a drawing operation.
Reimplemented in AeonGUI::DOM::SVGDefsElement.
|
pure virtual |
Get the node type.
Implemented in AeonGUI::DOM::Document, AeonGUI::DOM::Element, and AeonGUI::DOM::Text.
|
virtual |
Use OnLoad to implement custom loading behavior in derived classes. This method is called after all nodes are created and all children have been set. Nodes are visited in depth-first pre-order.
|
virtual |
Use OnUnload to implement custom unloading behavior in derived classes. This method is called while all nodes are still in place but before they are destroyed. Nodes are visited in depth-first post-order.
| Node * AeonGUI::DOM::Node::parentElement | ( | ) | const |
Get the parent element (same as parentNode for elements).
| Node * AeonGUI::DOM::Node::parentNode | ( | ) | const |
Get the parent node.
DOM Properties and Methods
Remove a child node.
| aNode | Raw pointer to the child to remove. |
| void AeonGUI::DOM::Node::TraverseDepthFirstPostOrder | ( | const std::function< void(const Node &) > & | aAction | ) | const |
Traverse the tree depth-first in post-order (const).
| aAction | Action invoked for each node. |
| void AeonGUI::DOM::Node::TraverseDepthFirstPostOrder | ( | const std::function< void(Node &) > & | aAction | ) |
Traverse the tree depth-first in post-order.
| aAction | Action invoked for each node. |
| void AeonGUI::DOM::Node::TraverseDepthFirstPreOrder | ( | const std::function< void(const Node &) > & | aAction | ) | const |
Traverse the tree depth-first in pre-order (const).
| aAction | Action invoked for each node. |
| void AeonGUI::DOM::Node::TraverseDepthFirstPreOrder | ( | const std::function< void(const Node &) > & | aPreamble, |
| const std::function< void(const Node &) > & | aPostamble ) const |
Traverse pre-order with pre/post callbacks (const).
| aPreamble | Called before visiting children. |
| aPostamble | Called after visiting children. |
| void AeonGUI::DOM::Node::TraverseDepthFirstPreOrder | ( | const std::function< void(const Node &) > & | aPreamble, |
| const std::function< void(const Node &) > & | aPostamble, | ||
| const std::function< bool(const Node &) > & | aUnaryPredicate ) const |
Traverse pre-order with pre/post callbacks and predicate (const).
| aPreamble | Called before visiting children. |
| aPostamble | Called after visiting children. |
| aUnaryPredicate | Only descend into children for which this returns true. |
| void AeonGUI::DOM::Node::TraverseDepthFirstPreOrder | ( | const std::function< void(Node &) > & | aAction | ) |
Traverse the tree depth-first in pre-order.
| aAction | Action invoked for each node. |
| void AeonGUI::DOM::Node::TraverseDepthFirstPreOrder | ( | const std::function< void(Node &) > & | aPreamble, |
| const std::function< void(Node &) > & | aPostamble ) |
Traverse pre-order with separate pre and post callbacks.
| aPreamble | Called before visiting children. |
| aPostamble | Called after visiting children. |
| void AeonGUI::DOM::Node::TraverseDepthFirstPreOrder | ( | const std::function< void(Node &) > & | aPreamble, |
| const std::function< void(Node &) > & | aPostamble, | ||
| const std::function< bool(Node &) > & | aUnaryPredicate ) |
Traverse pre-order with pre/post callbacks and a predicate filter.
| aPreamble | Called before visiting children. |
| aPostamble | Called after visiting children. |
| aUnaryPredicate | Only descend into children for which this returns true. |