mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-05 07:07:38 +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;
|
const int totalPages = section ? section->pageCount : 0;
|
||||||
exitActivity();
|
exitActivity();
|
||||||
enterNewActivity(new EpubReaderMenuActivity(
|
enterNewActivity(new EpubReaderMenuActivity(
|
||||||
this->renderer, this->mappedInput, [this]() { onReaderMenuBack(); },
|
this->renderer, this->mappedInput, epub->getTitle(), [this]() { onReaderMenuBack(); },
|
||||||
[this](EpubReaderMenuActivity::MenuAction action) { onReaderMenuConfirm(action); }));
|
[this](EpubReaderMenuActivity::MenuAction action) { onReaderMenuConfirm(action); }));
|
||||||
xSemaphoreGive(renderingMutex);
|
xSemaphoreGive(renderingMutex);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -181,9 +181,7 @@ void EpubReaderChapterSelectionActivity::renderScreen() {
|
|||||||
const int pageItems = getPageItems();
|
const int pageItems = getPageItems();
|
||||||
const int totalItems = getTotalItems();
|
const int totalItems = getTotalItems();
|
||||||
|
|
||||||
const std::string title =
|
renderer.drawCenteredText(UI_12_FONT_ID, 15, "Go to Chapter", true, EpdFontFamily::BOLD);
|
||||||
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);
|
|
||||||
|
|
||||||
const auto pageStartIndex = selectorIndex / pageItems * pageItems;
|
const auto pageStartIndex = selectorIndex / pageItems * pageItems;
|
||||||
renderer.fillRect(0, 60 + (selectorIndex % pageItems) * 30 - 2, pageWidth - 1, 30);
|
renderer.fillRect(0, 60 + (selectorIndex % pageItems) * 30 - 2, pageWidth - 1, 30);
|
||||||
|
|||||||
@ -76,22 +76,23 @@ void EpubReaderMenuActivity::renderScreen() {
|
|||||||
const auto pageWidth = renderer.getScreenWidth();
|
const auto pageWidth = renderer.getScreenWidth();
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
renderer.drawCenteredText(UI_12_FONT_ID, 20, "Reader Menu", true, EpdFontFamily::BOLD);
|
const std::string truncTitle =
|
||||||
// renderer.fillRect(0, 60 + (selectedIndex % menuItems.size()) * 30 - 2, pageWidth - 1, 30);
|
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
|
// Menu Items
|
||||||
constexpr int startY = 80;
|
constexpr int startY = 60;
|
||||||
constexpr int lineHeight = 40;
|
constexpr int lineHeight = 30;
|
||||||
|
|
||||||
for (size_t i = 0; i < menuItems.size(); ++i) {
|
for (size_t i = 0; i < menuItems.size(); ++i) {
|
||||||
const int displayY = startY + (i * lineHeight);
|
const int displayY = startY + (i * lineHeight);
|
||||||
const bool isSelected = (static_cast<int>(i) == selectedIndex);
|
const bool isSelected = (static_cast<int>(i) == selectedIndex);
|
||||||
|
|
||||||
if (isSelected) {
|
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
|
// Footer / Hints
|
||||||
|
|||||||
@ -15,9 +15,12 @@ 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::string& title,
|
||||||
const std::function<void()>& onBack, const std::function<void(MenuAction)>& onAction)
|
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 onEnter() override;
|
||||||
void onExit() override;
|
void onExit() override;
|
||||||
@ -37,6 +40,7 @@ class EpubReaderMenuActivity final : public ActivityWithSubactivity {
|
|||||||
bool updateRequired = false;
|
bool updateRequired = false;
|
||||||
TaskHandle_t displayTaskHandle = nullptr;
|
TaskHandle_t displayTaskHandle = nullptr;
|
||||||
SemaphoreHandle_t renderingMutex = nullptr;
|
SemaphoreHandle_t renderingMutex = nullptr;
|
||||||
|
std::string title = "Reader Menu";
|
||||||
|
|
||||||
const std::function<void()> onBack;
|
const std::function<void()> onBack;
|
||||||
const std::function<void(MenuAction)> onAction;
|
const std::function<void(MenuAction)> onAction;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user