feat: add EndOfBookMenuActivity replacing static end-of-book text
Interactive menu shown when reaching the end of a book with options: Archive Book, Delete Book, Back to Beginning, Close Book, Close Menu. Wired into EpubReaderActivity, XtcReaderActivity, and TxtReaderActivity (TXT shows menu when user tries to advance past the last page). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
46
src/activities/reader/EndOfBookMenuActivity.h
Normal file
46
src/activities/reader/EndOfBookMenuActivity.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include <I18n.h>
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../Activity.h"
|
||||
#include "util/ButtonNavigator.h"
|
||||
|
||||
class EndOfBookMenuActivity final : public Activity {
|
||||
public:
|
||||
enum class Action {
|
||||
ARCHIVE,
|
||||
DELETE,
|
||||
BACK_TO_BEGINNING,
|
||||
CLOSE_BOOK,
|
||||
CLOSE_MENU,
|
||||
};
|
||||
|
||||
explicit EndOfBookMenuActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, const std::string& bookPath,
|
||||
const std::function<void(Action)>& onAction)
|
||||
: Activity("EndOfBookMenu", renderer, mappedInput), bookPath(bookPath), onAction(onAction) {
|
||||
buildMenuItems();
|
||||
}
|
||||
|
||||
void onEnter() override;
|
||||
void onExit() override;
|
||||
void loop() override;
|
||||
void render(Activity::RenderLock&&) override;
|
||||
|
||||
private:
|
||||
struct MenuItem {
|
||||
Action action;
|
||||
StrId labelId;
|
||||
};
|
||||
|
||||
std::string bookPath;
|
||||
std::vector<MenuItem> menuItems;
|
||||
int selectedIndex = 0;
|
||||
ButtonNavigator buttonNavigator;
|
||||
const std::function<void(Action)> onAction;
|
||||
|
||||
void buildMenuItems();
|
||||
};
|
||||
Reference in New Issue
Block a user