Compare commits

..

1 Commits

Author SHA1 Message Date
Jonas Diemer
5b4cb90420
Merge 95b7f8008c into 6d68466891 2026-01-19 21:50:44 +00:00
2 changed files with 14 additions and 13 deletions

View File

@ -1,7 +1,5 @@
#include "EpubReaderMenuActivity.h" #include "EpubReaderMenuActivity.h"
#include <GfxRenderer.h> #include <GfxRenderer.h>
#include "fontIds.h" #include "fontIds.h"
void EpubReaderMenuActivity::onEnter() { void EpubReaderMenuActivity::onEnter() {
@ -48,11 +46,11 @@ void EpubReaderMenuActivity::loop() {
// Use local variables for items we need to check after potential deletion // Use local variables for items we need to check after potential deletion
if (mappedInput.wasReleased(MappedInputManager::Button::Up) || if (mappedInput.wasReleased(MappedInputManager::Button::Up) ||
mappedInput.wasReleased(MappedInputManager::Button::Left)) { mappedInput.wasReleased(MappedInputManager::Button::Left) ) {
selectedIndex = (selectedIndex + menuItems.size() - 1) % menuItems.size(); selectedIndex = (selectedIndex + menuItems.size() - 1) % menuItems.size();
updateRequired = true; updateRequired = true;
} else if (mappedInput.wasReleased(MappedInputManager::Button::Down) || } else if (mappedInput.wasReleased(MappedInputManager::Button::Down) ||
mappedInput.wasReleased(MappedInputManager::Button::Right)) { mappedInput.wasReleased(MappedInputManager::Button::Right)) {
selectedIndex = (selectedIndex + 1) % menuItems.size(); selectedIndex = (selectedIndex + 1) % menuItems.size();
updateRequired = true; updateRequired = true;
} else if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) { } else if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) {
@ -67,7 +65,7 @@ void EpubReaderMenuActivity::loop() {
return; return;
} else if (mappedInput.wasReleased(MappedInputManager::Button::Back)) { } else if (mappedInput.wasReleased(MappedInputManager::Button::Back)) {
onBack(); onBack();
return; // Also return here just in case return; // Also return here just in case
} }
} }

View File

@ -3,21 +3,23 @@
#include <freertos/FreeRTOS.h> #include <freertos/FreeRTOS.h>
#include <freertos/semphr.h> #include <freertos/semphr.h>
#include <freertos/task.h> #include <freertos/task.h>
#include <functional> #include <functional>
#include <string>
#include <vector> #include <vector>
#include <string>
#include "../ActivityWithSubactivity.h"
#include "MappedInputManager.h" #include "MappedInputManager.h"
#include "../ActivityWithSubactivity.h"
class EpubReaderMenuActivity final : public ActivityWithSubactivity { class EpubReaderMenuActivity final : public ActivityWithSubactivity {
public: public:
enum class MenuAction { SELECT_CHAPTER, GO_HOME, DELETE_CACHE }; enum class MenuAction { SELECT_CHAPTER, GO_HOME, DELETE_CACHE };
explicit EpubReaderMenuActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, explicit EpubReaderMenuActivity(GfxRenderer& renderer, MappedInputManager& mappedInput,
const std::function<void()>& onBack, const std::function<void(MenuAction)>& onAction) const std::function<void()>& onBack,
: ActivityWithSubactivity("EpubReaderMenu", renderer, mappedInput), onBack(onBack), onAction(onAction) {} const std::function<void(MenuAction)>& onAction)
: ActivityWithSubactivity("EpubReaderMenu", renderer, mappedInput),
onBack(onBack),
onAction(onAction) {}
void onEnter() override; void onEnter() override;
void onExit() override; void onExit() override;
@ -29,9 +31,10 @@ class EpubReaderMenuActivity final : public ActivityWithSubactivity {
std::string label; std::string label;
}; };
const std::vector<MenuItem> menuItems = {{MenuAction::SELECT_CHAPTER, "Select Chapter"}, const std::vector<MenuItem> menuItems = {
{MenuAction::GO_HOME, "Go Home"}, {MenuAction::SELECT_CHAPTER, "Select Chapter"},
{MenuAction::DELETE_CACHE, "Delete Book Cache"}}; {MenuAction::GO_HOME, "Go Home"},
{MenuAction::DELETE_CACHE, "Delete Book Cache"}};
int selectedIndex = 0; int selectedIndex = 0;
bool updateRequired = false; bool updateRequired = false;