## Summary * Swap to updated SDCardManager which uses SdFat * Add exFAT support * Swap to using FsFile everywhere * Use newly exposed `SdMan` macro to get to static instance of SDCardManager * Move a bunch of FsHelpers up to SDCardManager
44 lines
1.3 KiB
C++
44 lines
1.3 KiB
C++
#pragma once
|
|
#include <SdFat.h>
|
|
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
#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<TextBlock> block;
|
|
|
|
public:
|
|
PageLine(std::shared_ptr<TextBlock> 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<PageLine> deserialize(FsFile& file);
|
|
};
|
|
|
|
class Page {
|
|
public:
|
|
// the list of block index and line numbers on this page
|
|
std::vector<std::shared_ptr<PageElement>> elements;
|
|
void render(GfxRenderer& renderer, int fontId, int xOffset, int yOffset) const;
|
|
bool serialize(FsFile& file) const;
|
|
static std::unique_ptr<Page> deserialize(FsFile& file);
|
|
};
|