#pragma once #include #include #include #include "blocks/TextBlock.h" enum PageElementTag : uint8_t { TAG_PageLine = 1, }; // represents something that has been added to a page class PageElement { public: int16_t xPos; int16_t yPos; explicit PageElement(const int16_t xPos, const int16_t yPos) : xPos(xPos), yPos(yPos) {} virtual ~PageElement() = default; virtual void render(GfxRenderer& renderer, int fontId, int xOffset, int yOffset) = 0; virtual bool serialize(FsFile& file) = 0; }; // a line from a block element class PageLine final : public PageElement { std::shared_ptr block; public: PageLine(std::shared_ptr block, const int16_t xPos, const int16_t yPos) : PageElement(xPos, yPos), block(std::move(block)) {} void render(GfxRenderer& renderer, int fontId, int xOffset, int yOffset) override; bool serialize(FsFile& file) override; static std::unique_ptr deserialize(FsFile& file); }; class Page { public: // the list of block index and line numbers on this page std::vector> elements; void render(GfxRenderer& renderer, int fontId, int xOffset, int yOffset) const; bool serialize(FsFile& file) const; static std::unique_ptr deserialize(FsFile& file); };