#pragma once #include #include #include #include #include "activities/UiListActivity.h" #include "components/OptionPopup.h" class EpubReaderMenuActivity final : public UiListActivity { public: // Menu actions available from the reader menu. enum class MenuAction { SELECT_CHAPTER, FOOTNOTES, TEXT_SETTINGS, NIGHT_MODE, FRONTLIGHT, GO_TO_PERCENT, AUTO_PAGE_TURN, ROTATE_SCREEN, BOOKMARKS, TOGGLE_BOOKMARK, SCREENSHOT, DISPLAY_QR, GO_HOME, SYNC, DELETE_CACHE, DICTIONARY }; struct MenuItem { MenuAction action; StrId labelId; }; static void buildMenuItems(std::vector& items, bool hasFootnotes, bool hasBookmarks); explicit EpubReaderMenuActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, const std::string& title, const int currentPage, const int totalPages, const int bookProgressPercent, const uint8_t currentOrientation, const bool hasFootnotes, bool hasBookmarks); void render(RenderLock&&) override; bool handleHomeGesture() override; private: // Row storage: menuItems is at most MAX_MENU_ITEMS, so a // fixed-capacity array avoids any heap allocation for the row list. Labels // are set once in the constructor (buildMenuRowItems()); buildScreen() // only refreshes rows whose values reflect live state. static constexpr size_t MAX_MENU_ITEMS = 16; freeink::ui::ListItem menuRowItems[MAX_MENU_ITEMS]{}; void buildMenuRowItems(); int listCount() const override { return static_cast(menuItems.size()); } void buildScreen(UiScreen& screen) override; void activateIndex(int index) override; // Popup input runs before any button or touch handling. bool handleCustomInput() override; // Back closes on RELEASE and Confirm activates on RELEASE; everything else // (row navigation, page jumps) falls through to the base handler. bool handleButtons() override; // Header via GUI.drawHeader inside the safe area for the battery indicator. void drawChrome() override; void closeCancelled(); // Fixed menu layout std::vector menuItems; OptionPopup optionPopup; std::string title = "Reader Menu"; uint8_t pendingOrientation = 0; uint8_t selectedPageTurnOption = 0; const std::vector orientationLabels = {StrId::STR_PORTRAIT, StrId::STR_LANDSCAPE_CW, StrId::STR_INVERTED, StrId::STR_LANDSCAPE_CCW}; const std::vector pageTurnLabels = {I18N.get(StrId::STR_STATE_OFF), "1", "3", "6", "12"}; int currentPage = 0; int totalPages = 0; int bookProgressPercent = 0; };