## Summary * **What is the goal of this PR?** Implements a take-screenshot feature * **What changes are included?** - Quick press Power button and Down button at the same time to take a screenshot - Screenshots are saved in `screenshots` folder ## Additional Context - Currently it does not use the device orientation. --- Example screenshots:  [screenshot-6771.bmp](https://github.com/user-attachments/files/25157071/screenshot-6771.bmp)  [screenshot-14158.bmp](https://github.com/user-attachments/files/25157073/screenshot-14158.bmp) ### AI Usage Did you use AI tools to help write this code? _** YES --------- Co-authored-by: Eliz Kilic <elizk@google.com> Co-authored-by: Xuan Son Nguyen <son@huggingface.co> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Arthur Tazhitdinov <lisnake@gmail.com>
61 lines
2.3 KiB
C++
61 lines
2.3 KiB
C++
#pragma once
|
|
#include <Epub.h>
|
|
#include <I18n.h>
|
|
|
|
#include <functional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "../ActivityWithSubactivity.h"
|
|
#include "util/ButtonNavigator.h"
|
|
|
|
class EpubReaderMenuActivity final : public ActivityWithSubactivity {
|
|
public:
|
|
// Menu actions available from the reader menu.
|
|
enum class MenuAction { SELECT_CHAPTER, GO_TO_PERCENT, ROTATE_SCREEN, SCREENSHOT, GO_HOME, SYNC, DELETE_CACHE };
|
|
|
|
explicit EpubReaderMenuActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, const std::string& title,
|
|
const int currentPage, const int totalPages, const int bookProgressPercent,
|
|
const uint8_t currentOrientation, const std::function<void(uint8_t)>& onBack,
|
|
const std::function<void(MenuAction)>& onAction)
|
|
: ActivityWithSubactivity("EpubReaderMenu", renderer, mappedInput),
|
|
title(title),
|
|
pendingOrientation(currentOrientation),
|
|
currentPage(currentPage),
|
|
totalPages(totalPages),
|
|
bookProgressPercent(bookProgressPercent),
|
|
onBack(onBack),
|
|
onAction(onAction) {}
|
|
|
|
void onEnter() override;
|
|
void onExit() override;
|
|
void loop() override;
|
|
void render(Activity::RenderLock&&) override;
|
|
|
|
private:
|
|
struct MenuItem {
|
|
MenuAction action;
|
|
StrId labelId;
|
|
};
|
|
|
|
// Fixed menu layout (order matters for up/down navigation).
|
|
const std::vector<MenuItem> menuItems = {
|
|
{MenuAction::SELECT_CHAPTER, StrId::STR_SELECT_CHAPTER}, {MenuAction::ROTATE_SCREEN, StrId::STR_ORIENTATION},
|
|
{MenuAction::GO_TO_PERCENT, StrId::STR_GO_TO_PERCENT}, {MenuAction::SCREENSHOT, StrId::STR_SCREENSHOT_BUTTON},
|
|
{MenuAction::GO_HOME, StrId::STR_GO_HOME_BUTTON}, {MenuAction::SYNC, StrId::STR_SYNC_PROGRESS},
|
|
{MenuAction::DELETE_CACHE, StrId::STR_DELETE_CACHE}};
|
|
int selectedIndex = 0;
|
|
|
|
ButtonNavigator buttonNavigator;
|
|
std::string title = "Reader Menu";
|
|
uint8_t pendingOrientation = 0;
|
|
const std::vector<StrId> orientationLabels = {StrId::STR_PORTRAIT, StrId::STR_LANDSCAPE_CW, StrId::STR_INVERTED,
|
|
StrId::STR_LANDSCAPE_CCW};
|
|
int currentPage = 0;
|
|
int totalPages = 0;
|
|
int bookProgressPercent = 0;
|
|
|
|
const std::function<void(uint8_t)> onBack;
|
|
const std::function<void(MenuAction)> onAction;
|
|
};
|