mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 14:47:37 +03:00
## Summary * Adds a menu in the Epub reader * The Chapter selection is moved there to pos 1 (so it can be reached by double tapping the confirm button) * A Go Home is there, too * Most significantly, a function "Delete Book Cache" is added. This returns to main (to avoid directly rebuilding cached items, eg. if this is used to debug/develop other areas - and it's also easier ;)) Probably, the Sync function could now be moved from the Chapter selection to this menu, too. --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**PARTIALLY**_
52 lines
1.5 KiB
C++
52 lines
1.5 KiB
C++
#pragma once
|
|
#include <Epub.h>
|
|
#include <freertos/FreeRTOS.h>
|
|
#include <freertos/semphr.h>
|
|
#include <freertos/task.h>
|
|
|
|
#include <functional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#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<void()>& onBack, const std::function<void(MenuAction)>& 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<MenuItem> 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<void()> onBack;
|
|
const std::function<void(MenuAction)> onAction;
|
|
|
|
static void taskTrampoline(void* param);
|
|
[[noreturn]] void displayTaskLoop();
|
|
void renderScreen();
|
|
};
|