## Summary * **What is the goal of this PR?** (e.g., Implements the new feature for file uploading.) - Implements auto page turn feature for epub reader in the reader submenu * **What changes are included?** - added auto page turn feature in epub reader in the submenu - currently there are 5 settings, `OFF, 1, 3, 6, 12` pages per minute ## Additional Context * Add any other information that might be helpful for the reviewer (e.g., performance implications, potential risks, specific areas to focus on). - Replacement PR for #723 - when auto turn is enabled, space reserved for chapter title will be used to indicate auto page turn being active - Back and Confirm button is used to disable it --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**Partially (mainly code reviews)**_
62 lines
2.3 KiB
C++
62 lines
2.3 KiB
C++
#pragma once
|
|
#include <Epub.h>
|
|
#include <Epub/FootnoteEntry.h>
|
|
#include <Epub/Section.h>
|
|
|
|
#include "EpubReaderMenuActivity.h"
|
|
#include "activities/Activity.h"
|
|
|
|
class EpubReaderActivity final : public Activity {
|
|
std::shared_ptr<Epub> epub;
|
|
std::unique_ptr<Section> section = nullptr;
|
|
int currentSpineIndex = 0;
|
|
int nextPageNumber = 0;
|
|
int pagesUntilFullRefresh = 0;
|
|
int cachedSpineIndex = 0;
|
|
int cachedChapterTotalPageCount = 0;
|
|
unsigned long lastPageTurnTime = 0UL;
|
|
unsigned long pageTurnDuration = 0UL;
|
|
// Signals that the next render should reposition within the newly loaded section
|
|
// based on a cross-book percentage jump.
|
|
bool pendingPercentJump = false;
|
|
// Normalized 0.0-1.0 progress within the target spine item, computed from book percentage.
|
|
float pendingSpineProgress = 0.0f;
|
|
bool pendingScreenshot = false;
|
|
bool skipNextButtonCheck = false; // Skip button processing for one frame after subactivity exit
|
|
bool automaticPageTurnActive = false;
|
|
|
|
// Footnote support
|
|
std::vector<FootnoteEntry> currentPageFootnotes;
|
|
struct SavedPosition {
|
|
int spineIndex;
|
|
int pageNumber;
|
|
};
|
|
static constexpr int MAX_FOOTNOTE_DEPTH = 3;
|
|
SavedPosition savedPositions[MAX_FOOTNOTE_DEPTH] = {};
|
|
int footnoteDepth = 0;
|
|
|
|
void renderContents(std::unique_ptr<Page> page, int orientedMarginTop, int orientedMarginRight,
|
|
int orientedMarginBottom, int orientedMarginLeft);
|
|
void renderStatusBar() const;
|
|
void saveProgress(int spineIndex, int currentPage, int pageCount);
|
|
// Jump to a percentage of the book (0-100), mapping it to spine and page.
|
|
void jumpToPercent(int percent);
|
|
void onReaderMenuConfirm(EpubReaderMenuActivity::MenuAction action);
|
|
void applyOrientation(uint8_t orientation);
|
|
void toggleAutoPageTurn(uint8_t selectedPageTurnOption);
|
|
void pageTurn(bool isForwardTurn);
|
|
|
|
// Footnote navigation
|
|
void navigateToHref(const std::string& href, bool savePosition = false);
|
|
void restoreSavedPosition();
|
|
|
|
public:
|
|
explicit EpubReaderActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, std::unique_ptr<Epub> epub)
|
|
: Activity("EpubReader", renderer, mappedInput), epub(std::move(epub)) {}
|
|
void onEnter() override;
|
|
void onExit() override;
|
|
void loop() override;
|
|
void render(RenderLock&& lock) override;
|
|
bool isReaderActivity() const override { return true; }
|
|
};
|