Browse Source

span element

pull/1/head
gyroninja 5 years ago
parent
commit
b66a4a799e
  1. 4
      src/html/TagNode.cpp
  2. 12
      src/html/elements/SPANElement.cpp
  3. 13
      src/html/elements/SPANElement.h

4
src/html/TagNode.cpp

@ -4,13 +4,15 @@ @@ -4,13 +4,15 @@
#include "elements/H3Element.h"
#include "elements/LIElement.h"
#include "elements/PElement.h"
#include "elements/SPANElement.h"
const Element TagNode::elements[] = {
{"h1", &H1Element::render},
{"h2", &H2Element::render},
{"h3", &H3Element::render},
{"li", &LIElement::render},
{"p", &PElement::render}
{"p", &PElement::render},
{"span", &SPANElement::render}
};
TagNode::TagNode() : Node(NodeType::TAG) {

12
src/html/elements/SPANElement.cpp

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
#include "SPANElement.h"
#include "../TextNode.h"
std::unique_ptr<Component> SPANElement::render(const Node &node, int y, int windowWidth, int windowHeight) {
if (!node.children.empty()) {
TextNode *textNode = dynamic_cast<TextNode*>(node.children[0].get());
if (textNode) {
return std::make_unique<TextComponent>(textNode->text, 0, y, 12, false, windowWidth, windowHeight);
}
}
return nullptr;
}

13
src/html/elements/SPANElement.h

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
#ifndef SPANELEMENT_H
#define SPANELEMENT_H
#include "../../graphics/opengl/components/Component.h"
#include "../../graphics/opengl/components/TextComponent.h"
#include "../Node.h"
class SPANElement {
public:
static std::unique_ptr<Component> render(const Node &node, int y, int windowWidth, int windowHeight);
};
#endif
Loading…
Cancel
Save