#pragma once #include #include #include #include #include #include #include #include "../ActivityWithSubactivity.h" #include "MappedInputManager.h" class EpubReaderMenuActivity final : public ActivityWithSubactivity { public: enum class MenuAction { SELECT_CHAPTER, GO_HOME, DELETE_CACHE }; explicit EpubReaderMenuActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, const std::string& title, const std::function& onBack, const std::function& onAction) : ActivityWithSubactivity("EpubReaderMenu", renderer, mappedInput), title(title), onBack(onBack), onAction(onAction) {} void onEnter() override; void onExit() override; void loop() override; private: struct MenuItem { MenuAction action; std::string label; }; const std::vector menuItems = {{MenuAction::SELECT_CHAPTER, "Go to Chapter"}, {MenuAction::GO_HOME, "Go Home"}, {MenuAction::DELETE_CACHE, "Delete Book Cache"}}; int selectedIndex = 0; bool updateRequired = false; TaskHandle_t displayTaskHandle = nullptr; SemaphoreHandle_t renderingMutex = nullptr; std::string title = "Reader Menu"; const std::function onBack; const std::function onAction; static void taskTrampoline(void* param); [[noreturn]] void displayTaskLoop(); void renderScreen(); };