39 lines
1.3 KiB
C
Raw Normal View History

2025-12-03 22:00:29 +11:00
#pragma once
#include <functional>
#include <memory>
2025-12-03 22:00:29 +11:00
#include "Epub.h"
class Page;
class GfxRenderer;
2025-12-03 22:00:29 +11:00
class Section {
std::shared_ptr<Epub> epub;
2025-12-03 22:00:29 +11:00
const int spineIndex;
GfxRenderer& renderer;
2025-12-03 22:00:29 +11:00
std::string cachePath;
void writeCacheMetadata(int fontId, float lineCompression, int marginTop, int marginRight, int marginBottom,
int marginLeft, bool extraParagraphSpacing) const;
void onPageComplete(std::unique_ptr<Page> page);
2025-12-03 22:00:29 +11:00
public:
int pageCount = 0;
int currentPage = 0;
explicit Section(const std::shared_ptr<Epub>& epub, const int spineIndex, GfxRenderer& renderer)
: epub(epub),
spineIndex(spineIndex),
renderer(renderer),
cachePath(epub->getCachePath() + "/" + std::to_string(spineIndex)) {}
2025-12-03 22:00:29 +11:00
~Section() = default;
bool loadCacheMetadata(int fontId, float lineCompression, int marginTop, int marginRight, int marginBottom,
int marginLeft, bool extraParagraphSpacing);
2025-12-03 22:00:29 +11:00
void setupCacheDir() const;
bool clearCache() const;
bool persistPageDataToSD(int fontId, float lineCompression, int marginTop, int marginRight, int marginBottom,
int marginLeft, bool extraParagraphSpacing,
const std::function<void(int)>& progressFn = nullptr);
std::unique_ptr<Page> loadPageFromSD() const;
2025-12-03 22:00:29 +11:00
};