Eunchurn Park f11d70279e
feat(ui): add progress bar for chapter indexing
- Add progressFn callback to ChapterHtmlSlimParser for file-based progress
- Update progress every 10% to avoid excessive e-ink refreshes
- Display 200px progress bar below "Indexing..." text
- Use FAST_REFRESH for responsive progress updates
2025-12-25 19:56:36 +09:00

39 lines
1.3 KiB
C++

#pragma once
#include <functional>
#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, bool extraParagraphSpacing) 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, bool extraParagraphSpacing);
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;
};