crosspoint-reader/src/activities/util/QuickMenuActivity.h
cottongin 492cf976f5
feat(quickmenu): comprehensive quick menu enhancements
Quick Menu UI Improvements:
- Add navigation button hints (prev/next on front buttons, up/down on side buttons)
- Fix orientation-aware margins for button hint areas in landscape modes

Screen Rotation Toggle:
- Add "Rotate Screen" option to toggle between Portrait and Landscape CCW
- Force section reindex when orientation changes to properly reflow content
- Position is automatically restored via content offset after reindex

Customizable Menu Order:
- Add "Edit List Order" option (fixed at bottom of menu)
- Pick-and-place reordering: select item to move, navigate to destination, place
- Visual feedback: filled highlight for cursor, outlined box for item being moved
- Menu order persists in settings (quickMenuOrder array in CrossPointSettings)
- New default order: Bookmark, Dictionary, Rotate Screen, Settings, Clear Cache

Files changed:
- CrossPointSettings.h: Add quickMenuOrder[5] setting
- QuickMenuActivity.h/cpp: Edit mode, order rendering, pick-and-place logic
- EpubReaderActivity.cpp: Handle TOGGLE_ORIENTATION action with section reset
2026-01-29 12:57:37 -05:00

54 lines
1.9 KiB
C++

#pragma once
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>
#include <freertos/task.h>
#include <functional>
#include "../Activity.h"
// Enum for quick menu selection
enum class QuickMenuAction { DICTIONARY, ADD_BOOKMARK, CLEAR_CACHE, TOGGLE_ORIENTATION, GO_TO_SETTINGS };
/**
* QuickMenuActivity presents a quick access menu triggered by short power button press.
* Options:
* - "Dictionary" - Look up a word
* - "Add/Remove Bookmark" - Toggle bookmark on current page
*
* The onActionSelected callback is called with the user's choice.
* The onCancel callback is called if the user presses back.
*/
class QuickMenuActivity final : public Activity {
TaskHandle_t displayTaskHandle = nullptr;
SemaphoreHandle_t renderingMutex = nullptr;
int selectedIndex = 0;
bool updateRequired = false;
const std::function<void(QuickMenuAction)> onActionSelected;
const std::function<void()> onCancel;
const bool isPageBookmarked; // True if current page already has a bookmark
// Edit mode state
bool editMode = false; // True when in edit mode
int movingIndex = -1; // Index of item being moved (-1 if none)
uint8_t localOrder[5] = {0}; // Local copy of order for editing
static void taskTrampoline(void* param);
[[noreturn]] void displayTaskLoop();
void render() const;
void handleNormalMode();
void handleEditMode();
public:
explicit QuickMenuActivity(GfxRenderer& renderer, MappedInputManager& mappedInput,
const std::function<void(QuickMenuAction)>& onActionSelected,
const std::function<void()>& onCancel, bool isPageBookmarked = false)
: Activity("QuickMenu", renderer, mappedInput),
onActionSelected(onActionSelected),
onCancel(onCancel),
isPageBookmarked(isPageBookmarked) {}
void onEnter() override;
void onExit() override;
void loop() override;
};