mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2025-12-18 23:27:44 +03:00
* Move to smart pointers and split out ParsedText class * Cleanup ParsedText * Fix clearCache functions and clear section cache if page load fails * Bump Page and Section file versions * Combine removeDir implementations in Epub * Adjust screen margins
36 lines
1.1 KiB
C++
36 lines
1.1 KiB
C++
#pragma once
|
|
#include <memory>
|
|
|
|
#include "Epub.h"
|
|
|
|
class Page;
|
|
class GfxRenderer;
|
|
|
|
class Section {
|
|
std::shared_ptr<Epub> epub;
|
|
const int spineIndex;
|
|
GfxRenderer& renderer;
|
|
std::string cachePath;
|
|
|
|
void writeCacheMetadata(int fontId, float lineCompression, int marginTop, int marginRight, int marginBottom,
|
|
int marginLeft) const;
|
|
void onPageComplete(std::unique_ptr<Page> page);
|
|
|
|
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);
|
|
}
|
|
~Section() = default;
|
|
bool loadCacheMetadata(int fontId, float lineCompression, int marginTop, int marginRight, int marginBottom,
|
|
int marginLeft);
|
|
void setupCacheDir() const;
|
|
bool clearCache() const;
|
|
bool persistPageDataToSD(int fontId, float lineCompression, int marginTop, int marginRight, int marginBottom,
|
|
int marginLeft);
|
|
std::unique_ptr<Page> loadPageFromSD() const;
|
|
};
|