2025-12-03 22:00:29 +11:00
|
|
|
#pragma once
|
|
|
|
|
#include <Epub.h>
|
|
|
|
|
#include <Epub/Section.h>
|
|
|
|
|
#include <freertos/FreeRTOS.h>
|
|
|
|
|
#include <freertos/semphr.h>
|
|
|
|
|
#include <freertos/task.h>
|
|
|
|
|
|
|
|
|
|
#include "Screen.h"
|
|
|
|
|
|
|
|
|
|
class EpubReaderScreen final : public Screen {
|
2025-12-12 22:13:34 +11:00
|
|
|
std::shared_ptr<Epub> epub;
|
|
|
|
|
std::unique_ptr<Section> section = nullptr;
|
2025-12-03 22:00:29 +11:00
|
|
|
TaskHandle_t displayTaskHandle = nullptr;
|
2025-12-06 03:02:52 +11:00
|
|
|
SemaphoreHandle_t renderingMutex = nullptr;
|
2025-12-13 21:17:34 +11:00
|
|
|
std::unique_ptr<Screen> subScreen = nullptr;
|
2025-12-03 22:00:29 +11:00
|
|
|
int currentSpineIndex = 0;
|
|
|
|
|
int nextPageNumber = 0;
|
2025-12-05 22:19:44 +11:00
|
|
|
int pagesUntilFullRefresh = 0;
|
2025-12-03 22:00:29 +11:00
|
|
|
bool updateRequired = false;
|
2025-12-17 20:47:43 +11:00
|
|
|
const std::function<void()> onGoBack;
|
2025-12-03 22:00:29 +11:00
|
|
|
|
|
|
|
|
static void taskTrampoline(void* param);
|
|
|
|
|
[[noreturn]] void displayTaskLoop();
|
2025-12-08 19:48:49 +11:00
|
|
|
void renderScreen();
|
2025-12-12 22:13:34 +11:00
|
|
|
void renderContents(std::unique_ptr<Page> p);
|
2025-12-03 22:00:29 +11:00
|
|
|
void renderStatusBar() const;
|
|
|
|
|
|
|
|
|
|
public:
|
2025-12-12 22:13:34 +11:00
|
|
|
explicit EpubReaderScreen(GfxRenderer& renderer, InputManager& inputManager, std::unique_ptr<Epub> epub,
|
2025-12-17 20:47:43 +11:00
|
|
|
const std::function<void()>& onGoBack)
|
|
|
|
|
: Screen(renderer, inputManager), epub(std::move(epub)), onGoBack(onGoBack) {}
|
2025-12-03 22:00:29 +11:00
|
|
|
void onEnter() override;
|
|
|
|
|
void onExit() override;
|
2025-12-06 12:35:41 +11:00
|
|
|
void handleInput() override;
|
2025-12-03 22:00:29 +11:00
|
|
|
};
|