mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 14:47:37 +03:00
Unified styling (matching settings screen).
This commit is contained in:
parent
1cbe081a59
commit
c51eb6a71f
@ -131,7 +131,7 @@ void EpubReaderActivity::loop() {
|
||||
const int totalPages = section ? section->pageCount : 0;
|
||||
exitActivity();
|
||||
enterNewActivity(new EpubReaderMenuActivity(
|
||||
this->renderer, this->mappedInput, [this]() { onReaderMenuBack(); },
|
||||
this->renderer, this->mappedInput, epub->getTitle(), [this]() { onReaderMenuBack(); },
|
||||
[this](EpubReaderMenuActivity::MenuAction action) { onReaderMenuConfirm(action); }));
|
||||
xSemaphoreGive(renderingMutex);
|
||||
}
|
||||
|
||||
@ -181,9 +181,7 @@ void EpubReaderChapterSelectionActivity::renderScreen() {
|
||||
const int pageItems = getPageItems();
|
||||
const int totalItems = getTotalItems();
|
||||
|
||||
const std::string title =
|
||||
renderer.truncatedText(UI_12_FONT_ID, epub->getTitle().c_str(), pageWidth - 40, EpdFontFamily::BOLD);
|
||||
renderer.drawCenteredText(UI_12_FONT_ID, 15, title.c_str(), true, EpdFontFamily::BOLD);
|
||||
renderer.drawCenteredText(UI_12_FONT_ID, 15, "Go to Chapter", true, EpdFontFamily::BOLD);
|
||||
|
||||
const auto pageStartIndex = selectorIndex / pageItems * pageItems;
|
||||
renderer.fillRect(0, 60 + (selectorIndex % pageItems) * 30 - 2, pageWidth - 1, 30);
|
||||
|
||||
@ -76,22 +76,23 @@ void EpubReaderMenuActivity::renderScreen() {
|
||||
const auto pageWidth = renderer.getScreenWidth();
|
||||
|
||||
// Title
|
||||
renderer.drawCenteredText(UI_12_FONT_ID, 20, "Reader Menu", true, EpdFontFamily::BOLD);
|
||||
// renderer.fillRect(0, 60 + (selectedIndex % menuItems.size()) * 30 - 2, pageWidth - 1, 30);
|
||||
const std::string truncTitle =
|
||||
renderer.truncatedText(UI_12_FONT_ID, title.c_str(), pageWidth - 40, EpdFontFamily::BOLD);
|
||||
renderer.drawCenteredText(UI_12_FONT_ID, 15, truncTitle.c_str(), true, EpdFontFamily::BOLD);
|
||||
|
||||
// Menu Items
|
||||
constexpr int startY = 80;
|
||||
constexpr int lineHeight = 40;
|
||||
constexpr int startY = 60;
|
||||
constexpr int lineHeight = 30;
|
||||
|
||||
for (size_t i = 0; i < menuItems.size(); ++i) {
|
||||
const int displayY = startY + (i * lineHeight);
|
||||
const bool isSelected = (static_cast<int>(i) == selectedIndex);
|
||||
|
||||
if (isSelected) {
|
||||
renderer.fillRect(10, displayY - 5, pageWidth - 20, lineHeight, true);
|
||||
renderer.fillRect(0, displayY, pageWidth - 1, lineHeight, true);
|
||||
}
|
||||
|
||||
renderer.drawText(UI_12_FONT_ID, 30, displayY + 5, menuItems[i].label.c_str(), !isSelected);
|
||||
renderer.drawText(UI_10_FONT_ID, 20, displayY, menuItems[i].label.c_str(), !isSelected);
|
||||
}
|
||||
|
||||
// Footer / Hints
|
||||
|
||||
@ -15,9 +15,12 @@ class EpubReaderMenuActivity final : public ActivityWithSubactivity {
|
||||
public:
|
||||
enum class MenuAction { SELECT_CHAPTER, GO_HOME, DELETE_CACHE };
|
||||
|
||||
explicit EpubReaderMenuActivity(GfxRenderer& renderer, MappedInputManager& mappedInput,
|
||||
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), onBack(onBack), onAction(onAction) {}
|
||||
: ActivityWithSubactivity("EpubReaderMenu", renderer, mappedInput),
|
||||
title(title),
|
||||
onBack(onBack),
|
||||
onAction(onAction) {}
|
||||
|
||||
void onEnter() override;
|
||||
void onExit() override;
|
||||
@ -37,6 +40,7 @@ class EpubReaderMenuActivity final : public ActivityWithSubactivity {
|
||||
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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user