From 1223958c1f76047f64599c42f025f512adfe7572 Mon Sep 17 00:00:00 2001 From: SimonFJ20 Date: Sat, 14 Jan 2023 03:28:26 +0100 Subject: [PATCH] browser: graphics and dom --- browser/dom.hpp | 55 ++++++++++++++++++++++++++++++++++++++++++++ browser/graphics.hpp | 12 ++++++++++ 2 files changed, 67 insertions(+) create mode 100644 browser/dom.hpp create mode 100644 browser/graphics.hpp diff --git a/browser/dom.hpp b/browser/dom.hpp new file mode 100644 index 0000000..8e8dbe5 --- /dev/null +++ b/browser/dom.hpp @@ -0,0 +1,55 @@ +#pragma once + +#include +#include +#include + +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 + = 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> 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; +}; + +} diff --git a/browser/graphics.hpp b/browser/graphics.hpp new file mode 100644 index 0000000..bbd3fef --- /dev/null +++ b/browser/graphics.hpp @@ -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: +};