#pragma once #include #include #include #include #include "../Activity.h" // Enum for dictionary mode selection enum class DictionaryMode { ENTER_WORD, SELECT_FROM_SCREEN }; /** * DictionaryMenuActivity presents the user with a choice: * - "Enter a Word" - Manually type a word to look up * - "Select from Screen" - Select a word from the current page * * The onModeSelected callback is called with the user's choice. * The onCancel callback is called if the user presses back. */ class DictionaryMenuActivity final : public Activity { TaskHandle_t displayTaskHandle = nullptr; SemaphoreHandle_t renderingMutex = nullptr; int selectedIndex = 0; bool updateRequired = false; const std::function onModeSelected; const std::function onCancel; const bool wordSelectionAvailable; // True if we can select from screen (e.g., in EPUB reader) static void taskTrampoline(void* param); [[noreturn]] void displayTaskLoop(); void render() const; public: explicit DictionaryMenuActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, const std::function& onModeSelected, const std::function& onCancel, bool wordSelectionAvailable = true) : Activity("DictionaryMenu", renderer, mappedInput), onModeSelected(onModeSelected), onCancel(onCancel), wordSelectionAvailable(wordSelectionAvailable) {} void onEnter() override; void onExit() override; void loop() override; };