#pragma once #include #include #include #include #include #include "../Activity.h" class EpubReaderChapterSelectionActivity final : public Activity { std::shared_ptr epub; TaskHandle_t displayTaskHandle = nullptr; SemaphoreHandle_t renderingMutex = nullptr; int currentSpineIndex = 0; int selectorIndex = 0; bool updateRequired = false; const std::function onGoBack; const std::function onSelectSpineIndex; // Number of items that fit on a page, derived from logical screen height. // This adapts automatically when switching between portrait and landscape. int getPageItems() const; static void taskTrampoline(void* param); [[noreturn]] void displayTaskLoop(); void renderScreen(); public: explicit EpubReaderChapterSelectionActivity(GfxRenderer& renderer, InputManager& inputManager, const std::shared_ptr& epub, const int currentSpineIndex, const std::function& onGoBack, const std::function& onSelectSpineIndex) : Activity("EpubReaderChapterSelection", renderer, inputManager), epub(epub), currentSpineIndex(currentSpineIndex), onGoBack(onGoBack), onSelectSpineIndex(onSelectSpineIndex) {} void onEnter() override; void onExit() override; void loop() override; };