browser: graphics and dom

This commit is contained in:
SimonFJ20 2023-01-14 03:28:26 +01:00
parent 70ee584c65
commit 1223958c1f
2 changed files with 67 additions and 0 deletions

55
browser/dom.hpp Normal file
View File

@ -0,0 +1,55 @@
#pragma once
#include <memory>
#include <string>
#include <vector>
namespace dom {
enum class Elements {
Box,
Text,
};
class Element {
public:
Element() = default;
Element(const Element&) = default;
Element(Element&&) = delete;
auto operator=(const Element&) -> Element& = default;
auto operator=(Element&&) -> Element& = default;
virtual ~Element() = default;
[[nodiscard]] virtual auto element_type() const noexcept -> Elements = 0;
[[nodiscard]] virtual auto parent() noexcept -> std::shared_ptr<Element>
= 0;
};
class Box final : public Element {
public:
Box() = default;
[[nodiscard]] auto element_type() const noexcept -> Elements override
{
return Elements::Text;
};
auto add_child() noexcept { }
private:
std::vector<std::shared_ptr<Element>> children;
};
class Text final : public Element {
public:
Text(std::string value)
: value { std::move(value) }
{ }
[[nodiscard]] auto element_type() const noexcept -> Elements override
{
return Elements::Text;
};
private:
std::string value;
};
}

12
browser/graphics.hpp Normal file
View File

@ -0,0 +1,12 @@
#pragma once
class Graphics {
public:
Graphics(const Graphics&) = default;
Graphics(Graphics&&) = default;
auto operator=(const Graphics&) -> Graphics& = default;
auto operator=(Graphics&&) -> Graphics& = default;
virtual ~Graphics() = default;
private:
};