#pragma once #include #include #include #include #include #include #include "../ActivityWithSubactivity.h" #include "util/BookmarkStore.h" #include "util/ButtonNavigator.h" class EpubReaderBookmarkSelectionActivity final : public ActivityWithSubactivity { std::shared_ptr epub; std::vector bookmarks; std::string cachePath; TaskHandle_t displayTaskHandle = nullptr; SemaphoreHandle_t renderingMutex = nullptr; ButtonNavigator buttonNavigator; int selectorIndex = 0; bool updateRequired = false; bool deleteConfirmMode = false; bool ignoreNextConfirmRelease = false; int pendingDeleteIndex = 0; const std::function onGoBack; const std::function onSelectBookmark; // Number of items that fit on a page, derived from logical screen height. int getPageItems() const; int getTotalItems() const; // Build the prefix portion of a bookmark label (chapter + snippet, without page suffix) std::string getBookmarkPrefix(const Bookmark& bookmark) const; // Build the page suffix (e.g. " - Page 5") static std::string getPageSuffix(const Bookmark& bookmark); static void taskTrampoline(void* param); [[noreturn]] void displayTaskLoop(); void renderScreen(); public: explicit EpubReaderBookmarkSelectionActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, const std::shared_ptr& epub, std::vector bookmarks, const std::string& cachePath, const std::function& onGoBack, const std::function& onSelectBookmark) : ActivityWithSubactivity("EpubReaderBookmarkSelection", renderer, mappedInput), epub(epub), bookmarks(std::move(bookmarks)), cachePath(cachePath), onGoBack(onGoBack), onSelectBookmark(onSelectBookmark) {} void onEnter() override; void onExit() override; void loop() override; };