mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-05 15:17:37 +03:00
Compare commits
2 Commits
8671dcda4f
...
71d4fffe79
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71d4fffe79 | ||
|
|
ef0fef1755 |
@ -474,11 +474,11 @@ void GfxRenderer::drawButtonHints(const int fontId, const char* btn1, const char
|
||||
setOrientation(Orientation::Portrait);
|
||||
|
||||
const int pageHeight = getScreenHeight();
|
||||
constexpr int buttonWidth = 106;
|
||||
constexpr int buttonWidth = 94;
|
||||
constexpr int buttonHeight = 40;
|
||||
constexpr int buttonY = 40; // Distance from bottom
|
||||
constexpr int textYOffset = 7; // Distance from top of button to text baseline
|
||||
constexpr int buttonPositions[] = {25, 130, 245, 350};
|
||||
constexpr int buttonPositions[] = {50, 143, 247, 340};
|
||||
const char* labels[] = {btn1, btn2, btn3, btn4};
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
@ -496,7 +496,10 @@ void GfxRenderer::drawButtonHints(const int fontId, const char* btn1, const char
|
||||
setOrientation(orig_orientation);
|
||||
}
|
||||
|
||||
void GfxRenderer::drawSideButtonHints(const int fontId, const char* topBtn, const char* bottomBtn) const {
|
||||
void GfxRenderer::drawSideButtonHints(const int fontId, const char* topBtn, const char* bottomBtn) {
|
||||
const Orientation orig_orientation = getOrientation();
|
||||
setOrientation(Orientation::Portrait);
|
||||
|
||||
const int screenWidth = getScreenWidth();
|
||||
constexpr int buttonWidth = 40; // Width on screen (height when rotated)
|
||||
constexpr int buttonHeight = 80; // Height on screen (width when rotated)
|
||||
@ -545,6 +548,8 @@ void GfxRenderer::drawSideButtonHints(const int fontId, const char* topBtn, cons
|
||||
drawTextRotated90CW(fontId, textX, textY, labels[i]);
|
||||
}
|
||||
}
|
||||
|
||||
setOrientation(orig_orientation);
|
||||
}
|
||||
|
||||
int GfxRenderer::getTextHeight(const int fontId) const {
|
||||
|
||||
@ -85,7 +85,7 @@ class GfxRenderer {
|
||||
|
||||
// UI Components
|
||||
void drawButtonHints(int fontId, const char* btn1, const char* btn2, const char* btn3, const char* btn4);
|
||||
void drawSideButtonHints(int fontId, const char* topBtn, const char* bottomBtn) const;
|
||||
void drawSideButtonHints(int fontId, const char* topBtn, const char* bottomBtn);
|
||||
|
||||
private:
|
||||
// Helper for drawing rotated text (90 degrees clockwise, for side buttons)
|
||||
|
||||
73
src/activities/Activity.cpp
Normal file
73
src/activities/Activity.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
#include "Activity.h"
|
||||
|
||||
#include <GfxRenderer.h>
|
||||
|
||||
#include "CrossPointSettings.h"
|
||||
|
||||
void Activity::onEnter() {
|
||||
Serial.printf("[%lu] [ACT] Entering activity: %s\n", millis(), name.c_str());
|
||||
setMargins();
|
||||
}
|
||||
|
||||
void Activity::onExit() { Serial.printf("[%lu] [ACT] Exiting activity: %s\n", millis(), name.c_str()); }
|
||||
|
||||
void Activity::setMargins() {
|
||||
switch (SETTINGS.orientation) {
|
||||
case CrossPointSettings::ORIENTATION::PORTRAIT:
|
||||
marginLeft = marginRight = marginTop = 20;
|
||||
marginBottom = 50;
|
||||
break;
|
||||
case CrossPointSettings::ORIENTATION::LANDSCAPE_CW:
|
||||
marginRight = marginTop = marginBottom = 20;
|
||||
marginLeft = 50;
|
||||
break;
|
||||
case CrossPointSettings::ORIENTATION::INVERTED:
|
||||
marginLeft = marginRight = marginBottom = 20;
|
||||
marginTop = 20;
|
||||
break;
|
||||
case CrossPointSettings::ORIENTATION::LANDSCAPE_CCW:
|
||||
marginLeft = marginTop = marginBottom = 20;
|
||||
marginRight = 50;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Activity::setRendererOrientation() {
|
||||
switch (SETTINGS.orientation) {
|
||||
case CrossPointSettings::ORIENTATION::PORTRAIT:
|
||||
renderer.setOrientation(GfxRenderer::Orientation::Portrait);
|
||||
break;
|
||||
case CrossPointSettings::ORIENTATION::LANDSCAPE_CW:
|
||||
renderer.setOrientation(GfxRenderer::Orientation::LandscapeClockwise);
|
||||
break;
|
||||
case CrossPointSettings::ORIENTATION::INVERTED:
|
||||
renderer.setOrientation(GfxRenderer::Orientation::PortraitInverted);
|
||||
break;
|
||||
case CrossPointSettings::ORIENTATION::LANDSCAPE_CCW:
|
||||
renderer.setOrientation(GfxRenderer::Orientation::LandscapeCounterClockwise);
|
||||
break;
|
||||
}
|
||||
setMargins();
|
||||
}
|
||||
|
||||
// Number of items that fit on a page, derived from logical screen height.
|
||||
// This adapts automatically when switching between portrait and landscape.
|
||||
int Activity::getPageItems() const {
|
||||
// Layout constants used in renderScreen
|
||||
constexpr int startY = CONTENT_START_Y;
|
||||
constexpr int lineHeight = LINE_HEIGHT;
|
||||
|
||||
const int screenHeight = renderer.getScreenHeight();
|
||||
const int endY = screenHeight - lineHeight;
|
||||
|
||||
const int availableHeight = endY - startY;
|
||||
int items = availableHeight / lineHeight;
|
||||
|
||||
// Ensure we always have at least one item per page to avoid division by zero
|
||||
if (items < 1) {
|
||||
items = 1;
|
||||
}
|
||||
return items;
|
||||
}
|
||||
@ -8,19 +8,31 @@
|
||||
class MappedInputManager;
|
||||
class GfxRenderer;
|
||||
|
||||
constexpr int CONTENT_START_Y = 60;
|
||||
constexpr int LINE_HEIGHT = 30;
|
||||
|
||||
class Activity {
|
||||
protected:
|
||||
std::string name;
|
||||
GfxRenderer& renderer;
|
||||
MappedInputManager& mappedInput;
|
||||
int marginLeft = 0;
|
||||
int marginRight = 0;
|
||||
int marginTop = 0;
|
||||
int marginBottom = 0;
|
||||
|
||||
public:
|
||||
explicit Activity(std::string name, GfxRenderer& renderer, MappedInputManager& mappedInput)
|
||||
: name(std::move(name)), renderer(renderer), mappedInput(mappedInput) {}
|
||||
virtual ~Activity() = default;
|
||||
virtual void onEnter() { Serial.printf("[%lu] [ACT] Entering activity: %s\n", millis(), name.c_str()); }
|
||||
virtual void onExit() { Serial.printf("[%lu] [ACT] Exiting activity: %s\n", millis(), name.c_str()); }
|
||||
virtual void onEnter();
|
||||
virtual void onExit();
|
||||
virtual void loop() {}
|
||||
virtual bool skipLoopDelay() { return false; }
|
||||
virtual bool preventAutoSleep() { return false; }
|
||||
|
||||
void setMargins();
|
||||
void setRendererOrientation();
|
||||
|
||||
int getPageItems() const;
|
||||
};
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
|
||||
void BootActivity::onEnter() {
|
||||
Activity::onEnter();
|
||||
setRendererOrientation();
|
||||
|
||||
const auto pageWidth = renderer.getScreenWidth();
|
||||
const auto pageHeight = renderer.getScreenHeight();
|
||||
|
||||
@ -138,6 +138,7 @@ void SleepActivity::renderDefaultSleepScreen() const {
|
||||
|
||||
void SleepActivity::renderBitmapSleepScreen(const Bitmap& bitmap) const {
|
||||
int x, y;
|
||||
renderer.setOrientation(GfxRenderer::Orientation::Portrait);
|
||||
const auto pageWidth = renderer.getScreenWidth();
|
||||
const auto pageHeight = renderer.getScreenHeight();
|
||||
float cropX = 0, cropY = 0;
|
||||
|
||||
@ -229,7 +229,7 @@ void OpdsBookBrowserActivity::render() const {
|
||||
}
|
||||
|
||||
const auto pageStartIndex = selectorIndex / PAGE_ITEMS * PAGE_ITEMS;
|
||||
renderer.fillRect(0, 60 + (selectorIndex % PAGE_ITEMS) * 30 - 2, pageWidth - 1, 30);
|
||||
renderer.fillRect(0, CONTENT_START_Y + (selectorIndex % PAGE_ITEMS) * LINE_HEIGHT - 2, pageWidth - 1, LINE_HEIGHT);
|
||||
|
||||
for (size_t i = pageStartIndex; i < entries.size() && i < static_cast<size_t>(pageStartIndex + PAGE_ITEMS); i++) {
|
||||
const auto& entry = entries[i];
|
||||
@ -247,7 +247,7 @@ void OpdsBookBrowserActivity::render() const {
|
||||
}
|
||||
|
||||
auto item = renderer.truncatedText(UI_10_FONT_ID, displayText.c_str(), renderer.getScreenWidth() - 40);
|
||||
renderer.drawText(UI_10_FONT_ID, 20, 60 + (i % PAGE_ITEMS) * 30, item.c_str(),
|
||||
renderer.drawText(UI_10_FONT_ID, 20, CONTENT_START_Y + (i % PAGE_ITEMS) * LINE_HEIGHT, item.c_str(),
|
||||
i != static_cast<size_t>(selectorIndex));
|
||||
}
|
||||
|
||||
|
||||
@ -216,19 +216,30 @@ void HomeActivity::render() {
|
||||
const auto pageWidth = renderer.getScreenWidth();
|
||||
const auto pageHeight = renderer.getScreenHeight();
|
||||
|
||||
constexpr int margin = 20;
|
||||
constexpr int bottomMargin = 60;
|
||||
// --- Bottom menu tiles ---
|
||||
// Build menu items dynamically
|
||||
std::vector<const char*> menuItems = {"My Library", "File Transfer", "Settings"};
|
||||
if (hasOpdsUrl) {
|
||||
// Insert Calibre Library after My Library
|
||||
menuItems.insert(menuItems.begin() + 1, "Calibre Library");
|
||||
}
|
||||
|
||||
const int menuTileWidth = pageWidth - marginLeft - marginRight;
|
||||
constexpr int menuTileHeight = 45;
|
||||
constexpr int menuSpacing = 8;
|
||||
const int totalMenuHeight =
|
||||
static_cast<int>(menuItems.size()) * menuTileHeight + (static_cast<int>(menuItems.size()) - 1) * menuSpacing;
|
||||
|
||||
// --- Top "book" card for the current title (selectorIndex == 0) ---
|
||||
const int bookWidth = pageWidth / 2;
|
||||
const int bookHeight = pageHeight / 2;
|
||||
const int bookX = (pageWidth - bookWidth) / 2;
|
||||
constexpr int bookY = 30;
|
||||
const int bookWidth = menuTileWidth;
|
||||
const int bookHeight = pageHeight - marginBottom - totalMenuHeight - menuTileHeight;
|
||||
const int bookX = marginLeft;
|
||||
constexpr int bookY = 35;
|
||||
const bool bookSelected = hasContinueReading && selectorIndex == 0;
|
||||
|
||||
// Bookmark dimensions (used in multiple places)
|
||||
const int bookmarkWidth = bookWidth / 8;
|
||||
const int bookmarkHeight = bookHeight / 5;
|
||||
// Bookmark dimensions (used in multiple places)... FIXME
|
||||
const int bookmarkWidth = pageWidth / 16;
|
||||
const int bookmarkHeight = pageHeight / 10;
|
||||
const int bookmarkX = bookX + bookWidth - bookmarkWidth - 10;
|
||||
const int bookmarkY = bookY + 5;
|
||||
|
||||
@ -439,7 +450,7 @@ void HomeActivity::render() {
|
||||
|
||||
const int boxWidth = maxTextWidth + boxPadding * 2;
|
||||
const int boxHeight = totalTextHeight + boxPadding * 2;
|
||||
const int boxX = (pageWidth - boxWidth) / 2;
|
||||
const int boxX = bookX + (bookWidth - boxWidth) / 2;
|
||||
const int boxY = titleYStart - boxPadding;
|
||||
|
||||
// Draw box (inverted when selected: black box instead of white)
|
||||
@ -449,7 +460,8 @@ void HomeActivity::render() {
|
||||
}
|
||||
|
||||
for (const auto& line : lines) {
|
||||
renderer.drawCenteredText(UI_12_FONT_ID, titleYStart, line.c_str(), !bookSelected);
|
||||
renderer.drawText(UI_12_FONT_ID, bookX + (bookWidth - renderer.getTextWidth(UI_12_FONT_ID, line.c_str())) / 2,
|
||||
titleYStart, line.c_str(), !bookSelected);
|
||||
titleYStart += renderer.getLineHeight(UI_12_FONT_ID);
|
||||
}
|
||||
|
||||
@ -470,58 +482,46 @@ void HomeActivity::render() {
|
||||
}
|
||||
trimmedAuthor.append("...");
|
||||
}
|
||||
renderer.drawCenteredText(UI_10_FONT_ID, titleYStart, trimmedAuthor.c_str(), !bookSelected);
|
||||
renderer.drawText(UI_10_FONT_ID,
|
||||
bookX + (bookWidth - renderer.getTextWidth(UI_10_FONT_ID, trimmedAuthor.c_str())) / 2,
|
||||
titleYStart, trimmedAuthor.c_str(), !bookSelected);
|
||||
}
|
||||
|
||||
// "Continue Reading" label at the bottom
|
||||
const int continueY = bookY + bookHeight - renderer.getLineHeight(UI_10_FONT_ID) * 3 / 2;
|
||||
const char* continueText = "Continue Reading";
|
||||
const int continueTextWidth = renderer.getTextWidth(UI_10_FONT_ID, continueText);
|
||||
if (coverRendered) {
|
||||
// Draw box behind "Continue Reading" text (inverted when selected: black box instead of white)
|
||||
const char* continueText = "Continue Reading";
|
||||
const int continueTextWidth = renderer.getTextWidth(UI_10_FONT_ID, continueText);
|
||||
constexpr int continuePadding = 6;
|
||||
const int continueBoxWidth = continueTextWidth + continuePadding * 2;
|
||||
const int continueBoxHeight = renderer.getLineHeight(UI_10_FONT_ID) + continuePadding;
|
||||
const int continueBoxX = (pageWidth - continueBoxWidth) / 2;
|
||||
const int continueBoxX = bookX + (bookWidth - continueBoxWidth) / 2;
|
||||
const int continueBoxY = continueY - continuePadding / 2;
|
||||
renderer.fillRect(continueBoxX, continueBoxY, continueBoxWidth, continueBoxHeight, bookSelected);
|
||||
renderer.drawRect(continueBoxX, continueBoxY, continueBoxWidth, continueBoxHeight, !bookSelected);
|
||||
renderer.drawCenteredText(UI_10_FONT_ID, continueY, continueText, !bookSelected);
|
||||
} else {
|
||||
renderer.drawCenteredText(UI_10_FONT_ID, continueY, "Continue Reading", !bookSelected);
|
||||
}
|
||||
renderer.drawText(UI_10_FONT_ID, bookX + (bookWidth - continueTextWidth) / 2, continueY, continueText,
|
||||
!bookSelected);
|
||||
} else {
|
||||
// No book to continue reading
|
||||
const int y =
|
||||
bookY + (bookHeight - renderer.getLineHeight(UI_12_FONT_ID) - renderer.getLineHeight(UI_10_FONT_ID)) / 2;
|
||||
// FIXME
|
||||
renderer.drawCenteredText(UI_12_FONT_ID, y, "No open book");
|
||||
renderer.drawCenteredText(UI_10_FONT_ID, y + renderer.getLineHeight(UI_12_FONT_ID), "Start reading below");
|
||||
}
|
||||
|
||||
// --- Bottom menu tiles ---
|
||||
// Build menu items dynamically
|
||||
std::vector<const char*> menuItems = {"My Library", "File Transfer", "Settings"};
|
||||
if (hasOpdsUrl) {
|
||||
// Insert Calibre Library after My Library
|
||||
menuItems.insert(menuItems.begin() + 1, "Calibre Library");
|
||||
}
|
||||
|
||||
const int menuTileWidth = pageWidth - 2 * margin;
|
||||
constexpr int menuTileHeight = 45;
|
||||
constexpr int menuSpacing = 8;
|
||||
const int totalMenuHeight =
|
||||
static_cast<int>(menuItems.size()) * menuTileHeight + (static_cast<int>(menuItems.size()) - 1) * menuSpacing;
|
||||
|
||||
int menuStartY = bookY + bookHeight + 15;
|
||||
int menuStartY = bookY + bookHeight + menuSpacing;
|
||||
// Ensure we don't collide with the bottom button legend
|
||||
const int maxMenuStartY = pageHeight - bottomMargin - totalMenuHeight - margin;
|
||||
const int maxMenuStartY = pageHeight - marginBottom - totalMenuHeight;
|
||||
if (menuStartY > maxMenuStartY) {
|
||||
menuStartY = maxMenuStartY;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < menuItems.size(); ++i) {
|
||||
const int overallIndex = static_cast<int>(i) + (hasContinueReading ? 1 : 0);
|
||||
constexpr int tileX = margin;
|
||||
const int tileX = marginLeft;
|
||||
const int tileY = menuStartY + static_cast<int>(i) * (menuTileHeight + menuSpacing);
|
||||
const bool selected = selectorIndex == overallIndex;
|
||||
|
||||
|
||||
@ -14,10 +14,7 @@
|
||||
namespace {
|
||||
// Layout constants
|
||||
constexpr int TAB_BAR_Y = 15;
|
||||
constexpr int CONTENT_START_Y = 60;
|
||||
constexpr int LINE_HEIGHT = 30;
|
||||
constexpr int LEFT_MARGIN = 20;
|
||||
constexpr int RIGHT_MARGIN = 40; // Extra space for scroll indicator
|
||||
constexpr int scrollIndicatorWidth = 20;
|
||||
|
||||
// Timing thresholds
|
||||
constexpr int SKIP_PAGE_MS = 700;
|
||||
@ -34,17 +31,6 @@ void sortFileList(std::vector<std::string>& strs) {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int MyLibraryActivity::getPageItems() const {
|
||||
const int screenHeight = renderer.getScreenHeight();
|
||||
const int bottomBarHeight = 60; // Space for button hints
|
||||
const int availableHeight = screenHeight - CONTENT_START_Y - bottomBarHeight;
|
||||
int items = availableHeight / LINE_HEIGHT;
|
||||
if (items < 1) {
|
||||
items = 1;
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
int MyLibraryActivity::getCurrentItemCount() const {
|
||||
if (currentTab == Tab::Recent) {
|
||||
return static_cast<int>(bookTitles.size());
|
||||
@ -315,7 +301,7 @@ void MyLibraryActivity::render() const {
|
||||
|
||||
// Draw scroll indicator
|
||||
const int screenHeight = renderer.getScreenHeight();
|
||||
const int contentHeight = screenHeight - CONTENT_START_Y - 60; // 60 for bottom bar
|
||||
const int contentHeight = screenHeight - CONTENT_START_Y - marginBottom;
|
||||
ScreenComponents::drawScrollIndicator(renderer, getCurrentPage(), getTotalPages(), CONTENT_START_Y, contentHeight);
|
||||
|
||||
// Draw side button hints (up/down navigation on right side)
|
||||
@ -335,20 +321,21 @@ void MyLibraryActivity::renderRecentTab() const {
|
||||
const int bookCount = static_cast<int>(bookTitles.size());
|
||||
|
||||
if (bookCount == 0) {
|
||||
renderer.drawText(UI_10_FONT_ID, LEFT_MARGIN, CONTENT_START_Y, "No recent books");
|
||||
renderer.drawText(UI_10_FONT_ID, marginLeft, CONTENT_START_Y, "No recent books");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto pageStartIndex = selectorIndex / pageItems * pageItems;
|
||||
|
||||
// Draw selection highlight
|
||||
renderer.fillRect(0, CONTENT_START_Y + (selectorIndex % pageItems) * LINE_HEIGHT - 2, pageWidth - RIGHT_MARGIN,
|
||||
LINE_HEIGHT);
|
||||
renderer.fillRect(0, CONTENT_START_Y + (selectorIndex % pageItems) * LINE_HEIGHT - 2,
|
||||
pageWidth - marginRight - scrollIndicatorWidth, LINE_HEIGHT);
|
||||
|
||||
// Draw items
|
||||
for (int i = pageStartIndex; i < bookCount && i < pageStartIndex + pageItems; i++) {
|
||||
auto item = renderer.truncatedText(UI_10_FONT_ID, bookTitles[i].c_str(), pageWidth - LEFT_MARGIN - RIGHT_MARGIN);
|
||||
renderer.drawText(UI_10_FONT_ID, LEFT_MARGIN, CONTENT_START_Y + (i % pageItems) * LINE_HEIGHT, item.c_str(),
|
||||
auto item = renderer.truncatedText(UI_10_FONT_ID, bookTitles[i].c_str(),
|
||||
pageWidth - marginLeft - marginRight - scrollIndicatorWidth);
|
||||
renderer.drawText(UI_10_FONT_ID, marginLeft, CONTENT_START_Y + (i % pageItems) * LINE_HEIGHT, item.c_str(),
|
||||
i != selectorIndex);
|
||||
}
|
||||
}
|
||||
@ -359,20 +346,21 @@ void MyLibraryActivity::renderFilesTab() const {
|
||||
const int fileCount = static_cast<int>(files.size());
|
||||
|
||||
if (fileCount == 0) {
|
||||
renderer.drawText(UI_10_FONT_ID, LEFT_MARGIN, CONTENT_START_Y, "No books found");
|
||||
renderer.drawText(UI_10_FONT_ID, marginLeft, CONTENT_START_Y, "No books found");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto pageStartIndex = selectorIndex / pageItems * pageItems;
|
||||
|
||||
// Draw selection highlight
|
||||
renderer.fillRect(0, CONTENT_START_Y + (selectorIndex % pageItems) * LINE_HEIGHT - 2, pageWidth - RIGHT_MARGIN,
|
||||
LINE_HEIGHT);
|
||||
renderer.fillRect(0, CONTENT_START_Y + (selectorIndex % pageItems) * LINE_HEIGHT - 2,
|
||||
pageWidth - marginRight - scrollIndicatorWidth, LINE_HEIGHT);
|
||||
|
||||
// Draw items
|
||||
for (int i = pageStartIndex; i < fileCount && i < pageStartIndex + pageItems; i++) {
|
||||
auto item = renderer.truncatedText(UI_10_FONT_ID, files[i].c_str(), pageWidth - LEFT_MARGIN - RIGHT_MARGIN);
|
||||
renderer.drawText(UI_10_FONT_ID, LEFT_MARGIN, CONTENT_START_Y + (i % pageItems) * LINE_HEIGHT, item.c_str(),
|
||||
auto item = renderer.truncatedText(UI_10_FONT_ID, files[i].c_str(),
|
||||
pageWidth - marginLeft - marginRight - scrollIndicatorWidth);
|
||||
renderer.drawText(UI_10_FONT_ID, marginLeft, CONTENT_START_Y + (i % pageItems) * LINE_HEIGHT, item.c_str(),
|
||||
i != selectorIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,7 +34,6 @@ class MyLibraryActivity final : public Activity {
|
||||
const std::function<void(const std::string& path, Tab fromTab)> onSelectBook;
|
||||
|
||||
// Number of items that fit on a page
|
||||
int getPageItems() const;
|
||||
int getCurrentItemCount() const;
|
||||
int getTotalPages() const;
|
||||
int getCurrentPage() const;
|
||||
|
||||
@ -399,6 +399,7 @@ void drawQRCode(const GfxRenderer& renderer, const int x, const int y, const std
|
||||
void CrossPointWebServerActivity::renderServerRunning() const {
|
||||
// Use consistent line spacing
|
||||
constexpr int LINE_SPACING = 28; // Space between lines
|
||||
const int screenWidth = renderer.getScreenWidth();
|
||||
|
||||
renderer.drawCenteredText(UI_12_FONT_ID, 15, "File Transfer", true, EpdFontFamily::BOLD);
|
||||
|
||||
@ -417,7 +418,7 @@ void CrossPointWebServerActivity::renderServerRunning() const {
|
||||
"or scan QR code with your phone to connect to Wifi.");
|
||||
// Show QR code for URL
|
||||
const std::string wifiConfig = std::string("WIFI:S:") + connectedSSID + ";;";
|
||||
drawQRCode(renderer, (480 - 6 * 33) / 2, startY + LINE_SPACING * 4, wifiConfig);
|
||||
drawQRCode(renderer, (screenWidth - 6 * 33) / 2, startY + LINE_SPACING * 4, wifiConfig);
|
||||
|
||||
startY += 6 * 29 + 3 * LINE_SPACING;
|
||||
// Show primary URL (hostname)
|
||||
@ -431,7 +432,7 @@ void CrossPointWebServerActivity::renderServerRunning() const {
|
||||
|
||||
// Show QR code for URL
|
||||
renderer.drawCenteredText(SMALL_FONT_ID, startY + LINE_SPACING * 6, "or scan QR code with your phone:");
|
||||
drawQRCode(renderer, (480 - 6 * 33) / 2, startY + LINE_SPACING * 7, hostnameUrl);
|
||||
drawQRCode(renderer, (screenWidth - 6 * 33) / 2, startY + LINE_SPACING * 7, hostnameUrl);
|
||||
} else {
|
||||
// STA mode display (original behavior)
|
||||
const int startY = 65;
|
||||
@ -456,7 +457,7 @@ void CrossPointWebServerActivity::renderServerRunning() const {
|
||||
renderer.drawCenteredText(SMALL_FONT_ID, startY + LINE_SPACING * 4, "Open this URL in your browser");
|
||||
|
||||
// Show QR code for URL
|
||||
drawQRCode(renderer, (480 - 6 * 33) / 2, startY + LINE_SPACING * 6, webInfo);
|
||||
drawQRCode(renderer, (screenWidth - 6 * 33) / 2, startY + LINE_SPACING * 6, webInfo);
|
||||
renderer.drawCenteredText(SMALL_FONT_ID, startY + LINE_SPACING * 5, "or scan QR code with your phone:");
|
||||
}
|
||||
|
||||
|
||||
@ -523,8 +523,8 @@ void WifiSelectionActivity::renderNetworkList() const {
|
||||
renderer.drawCenteredText(SMALL_FONT_ID, top + height + 10, "Press OK to scan again");
|
||||
} else {
|
||||
// Calculate how many networks we can display
|
||||
constexpr int startY = 60;
|
||||
constexpr int lineHeight = 25;
|
||||
constexpr int startY = CONTENT_START_Y;
|
||||
constexpr int lineHeight = 25; // tighter spacing than normal menus
|
||||
const int maxVisibleNetworks = (pageHeight - startY - 40) / lineHeight;
|
||||
|
||||
// Calculate scroll offset to keep selected item visible
|
||||
@ -549,42 +549,47 @@ void WifiSelectionActivity::renderNetworkList() const {
|
||||
if (displayName.length() > 16) {
|
||||
displayName.replace(13, displayName.length() - 13, "...");
|
||||
}
|
||||
renderer.drawText(UI_10_FONT_ID, 20, networkY, displayName.c_str());
|
||||
renderer.drawText(UI_10_FONT_ID, marginLeft, networkY, displayName.c_str());
|
||||
|
||||
// Draw signal strength indicator
|
||||
std::string signalStr = getSignalStrengthIndicator(network.rssi);
|
||||
renderer.drawText(UI_10_FONT_ID, pageWidth - 90, networkY, signalStr.c_str());
|
||||
renderer.drawText(UI_10_FONT_ID, pageWidth - marginRight - 90, networkY, signalStr.c_str());
|
||||
|
||||
// Draw saved indicator (checkmark) for networks with saved passwords
|
||||
if (network.hasSavedPassword) {
|
||||
renderer.drawText(UI_10_FONT_ID, pageWidth - 50, networkY, "+");
|
||||
renderer.drawText(UI_10_FONT_ID, pageWidth - marginRight - 50, networkY, "+");
|
||||
}
|
||||
|
||||
// Draw lock icon for encrypted networks
|
||||
if (network.isEncrypted) {
|
||||
renderer.drawText(UI_10_FONT_ID, pageWidth - 30, networkY, "*");
|
||||
renderer.drawText(UI_10_FONT_ID, pageWidth - marginRight - 30, networkY, "*");
|
||||
}
|
||||
}
|
||||
|
||||
// Draw scroll indicators if needed
|
||||
if (scrollOffset > 0) {
|
||||
renderer.drawText(SMALL_FONT_ID, pageWidth - 15, startY - 10, "^");
|
||||
renderer.drawText(SMALL_FONT_ID, pageWidth - marginRight - 15, startY - 10, "^");
|
||||
}
|
||||
if (scrollOffset + maxVisibleNetworks < static_cast<int>(networks.size())) {
|
||||
renderer.drawText(SMALL_FONT_ID, pageWidth - 15, startY + maxVisibleNetworks * lineHeight, "v");
|
||||
renderer.drawText(SMALL_FONT_ID, pageWidth - marginRight - 15, startY + maxVisibleNetworks * lineHeight, "v");
|
||||
}
|
||||
|
||||
// Show network count
|
||||
char countStr[32];
|
||||
snprintf(countStr, sizeof(countStr), "%zu networks found", networks.size());
|
||||
renderer.drawText(SMALL_FONT_ID, 20, pageHeight - 90, countStr);
|
||||
renderer.drawText(SMALL_FONT_ID, pageWidth - marginRight - renderer.getTextWidth(SMALL_FONT_ID, countStr) - 95,
|
||||
pageHeight - 90, countStr);
|
||||
}
|
||||
|
||||
// Show MAC address above the network count and legend
|
||||
renderer.drawText(SMALL_FONT_ID, 20, pageHeight - 105, cachedMacAddress.c_str());
|
||||
renderer.drawText(SMALL_FONT_ID,
|
||||
pageWidth - marginRight - renderer.getTextWidth(SMALL_FONT_ID, cachedMacAddress.c_str()) - 95,
|
||||
pageHeight - 105, cachedMacAddress.c_str());
|
||||
|
||||
// Draw help text
|
||||
renderer.drawText(SMALL_FONT_ID, 20, pageHeight - 75, "* = Encrypted | + = Saved");
|
||||
const char helpLabel[] = "* = Encrypted | + = Saved";
|
||||
renderer.drawText(SMALL_FONT_ID, pageWidth - marginRight - renderer.getTextWidth(SMALL_FONT_ID, helpLabel) - 95,
|
||||
pageHeight - 75, helpLabel);
|
||||
const auto labels = mappedInput.mapLabels("« Back", "Connect", "", "");
|
||||
renderer.drawButtonHints(UI_10_FONT_ID, labels.btn1, labels.btn2, labels.btn3, labels.btn4);
|
||||
}
|
||||
|
||||
@ -32,24 +32,6 @@ void EpubReaderActivity::onEnter() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Configure screen orientation based on settings
|
||||
switch (SETTINGS.orientation) {
|
||||
case CrossPointSettings::ORIENTATION::PORTRAIT:
|
||||
renderer.setOrientation(GfxRenderer::Orientation::Portrait);
|
||||
break;
|
||||
case CrossPointSettings::ORIENTATION::LANDSCAPE_CW:
|
||||
renderer.setOrientation(GfxRenderer::Orientation::LandscapeClockwise);
|
||||
break;
|
||||
case CrossPointSettings::ORIENTATION::INVERTED:
|
||||
renderer.setOrientation(GfxRenderer::Orientation::PortraitInverted);
|
||||
break;
|
||||
case CrossPointSettings::ORIENTATION::LANDSCAPE_CCW:
|
||||
renderer.setOrientation(GfxRenderer::Orientation::LandscapeCounterClockwise);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
renderingMutex = xSemaphoreCreateMutex();
|
||||
|
||||
epub->setupCacheDir();
|
||||
@ -94,9 +76,6 @@ void EpubReaderActivity::onEnter() {
|
||||
void EpubReaderActivity::onExit() {
|
||||
ActivityWithSubactivity::onExit();
|
||||
|
||||
// Reset orientation back to portrait for the rest of the UI
|
||||
renderer.setOrientation(GfxRenderer::Orientation::Portrait);
|
||||
|
||||
// Wait until not rendering to delete task to avoid killing mid-instruction to EPD
|
||||
xSemaphoreTake(renderingMutex, portMAX_DELAY);
|
||||
if (displayTaskHandle) {
|
||||
|
||||
@ -32,24 +32,6 @@ int EpubReaderChapterSelectionActivity::tocIndexFromItemIndex(int itemIndex) con
|
||||
return itemIndex - offset;
|
||||
}
|
||||
|
||||
int EpubReaderChapterSelectionActivity::getPageItems() const {
|
||||
// Layout constants used in renderScreen
|
||||
constexpr int startY = 60;
|
||||
constexpr int lineHeight = 30;
|
||||
|
||||
const int screenHeight = renderer.getScreenHeight();
|
||||
const int endY = screenHeight - lineHeight;
|
||||
|
||||
const int availableHeight = endY - startY;
|
||||
int items = availableHeight / lineHeight;
|
||||
|
||||
// Ensure we always have at least one item per page to avoid division by zero
|
||||
if (items < 1) {
|
||||
items = 1;
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
void EpubReaderChapterSelectionActivity::taskTrampoline(void* param) {
|
||||
auto* self = static_cast<EpubReaderChapterSelectionActivity*>(param);
|
||||
self->displayTaskLoop();
|
||||
@ -186,10 +168,10 @@ void EpubReaderChapterSelectionActivity::renderScreen() {
|
||||
renderer.drawCenteredText(UI_12_FONT_ID, 15, title.c_str(), true, EpdFontFamily::BOLD);
|
||||
|
||||
const auto pageStartIndex = selectorIndex / pageItems * pageItems;
|
||||
renderer.fillRect(0, 60 + (selectorIndex % pageItems) * 30 - 2, pageWidth - 1, 30);
|
||||
renderer.fillRect(0, CONTENT_START_Y + (selectorIndex % pageItems) * LINE_HEIGHT - 2, pageWidth - 1, LINE_HEIGHT);
|
||||
|
||||
for (int itemIndex = pageStartIndex; itemIndex < totalItems && itemIndex < pageStartIndex + pageItems; itemIndex++) {
|
||||
const int displayY = 60 + (itemIndex % pageItems) * 30;
|
||||
const int displayY = CONTENT_START_Y + (itemIndex % pageItems) * LINE_HEIGHT;
|
||||
const bool isSelected = (itemIndex == selectorIndex);
|
||||
|
||||
if (isSyncItem(itemIndex)) {
|
||||
@ -202,8 +184,8 @@ void EpubReaderChapterSelectionActivity::renderScreen() {
|
||||
const int indentSize = 20 + (item.level - 1) * 15;
|
||||
const std::string chapterName =
|
||||
renderer.truncatedText(UI_10_FONT_ID, item.title.c_str(), pageWidth - 40 - indentSize);
|
||||
renderer.drawText(UI_10_FONT_ID, indentSize, 60 + (tocIndex % pageItems) * 30, chapterName.c_str(),
|
||||
tocIndex != selectorIndex);
|
||||
renderer.drawText(UI_10_FONT_ID, indentSize, CONTENT_START_Y + (tocIndex % pageItems) * LINE_HEIGHT,
|
||||
chapterName.c_str(), tocIndex != selectorIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -22,10 +22,6 @@ class EpubReaderChapterSelectionActivity final : public ActivityWithSubactivity
|
||||
const std::function<void(int newSpineIndex)> onSelectSpineIndex;
|
||||
const std::function<void(int newSpineIndex, int newPage)> onSyncPosition;
|
||||
|
||||
// Number of items that fit on a page, derived from logical screen height.
|
||||
// This adapts automatically when switching between portrait and landscape.
|
||||
int getPageItems() const;
|
||||
|
||||
// Total items including sync options (top and bottom)
|
||||
int getTotalItems() const;
|
||||
|
||||
|
||||
@ -33,24 +33,6 @@ void TxtReaderActivity::onEnter() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Configure screen orientation based on settings
|
||||
switch (SETTINGS.orientation) {
|
||||
case CrossPointSettings::ORIENTATION::PORTRAIT:
|
||||
renderer.setOrientation(GfxRenderer::Orientation::Portrait);
|
||||
break;
|
||||
case CrossPointSettings::ORIENTATION::LANDSCAPE_CW:
|
||||
renderer.setOrientation(GfxRenderer::Orientation::LandscapeClockwise);
|
||||
break;
|
||||
case CrossPointSettings::ORIENTATION::INVERTED:
|
||||
renderer.setOrientation(GfxRenderer::Orientation::PortraitInverted);
|
||||
break;
|
||||
case CrossPointSettings::ORIENTATION::LANDSCAPE_CCW:
|
||||
renderer.setOrientation(GfxRenderer::Orientation::LandscapeCounterClockwise);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
renderingMutex = xSemaphoreCreateMutex();
|
||||
|
||||
txt->setupCacheDir();
|
||||
@ -73,9 +55,6 @@ void TxtReaderActivity::onEnter() {
|
||||
void TxtReaderActivity::onExit() {
|
||||
ActivityWithSubactivity::onExit();
|
||||
|
||||
// Reset orientation back to portrait for the rest of the UI
|
||||
renderer.setOrientation(GfxRenderer::Orientation::Portrait);
|
||||
|
||||
// Wait until not rendering to delete task
|
||||
xSemaphoreTake(renderingMutex, portMAX_DELAY);
|
||||
if (displayTaskHandle) {
|
||||
|
||||
@ -30,6 +30,7 @@ void XtcReaderActivity::taskTrampoline(void* param) {
|
||||
|
||||
void XtcReaderActivity::onEnter() {
|
||||
ActivityWithSubactivity::onEnter();
|
||||
renderer.setOrientation(GfxRenderer::Orientation::Portrait);
|
||||
|
||||
if (!xtc) {
|
||||
return;
|
||||
@ -60,6 +61,7 @@ void XtcReaderActivity::onEnter() {
|
||||
|
||||
void XtcReaderActivity::onExit() {
|
||||
ActivityWithSubactivity::onExit();
|
||||
setRendererOrientation();
|
||||
|
||||
// Wait until not rendering to delete task
|
||||
xSemaphoreTake(renderingMutex, portMAX_DELAY);
|
||||
@ -84,6 +86,7 @@ void XtcReaderActivity::loop() {
|
||||
if (xtc && xtc->hasChapters() && !xtc->getChapters().empty()) {
|
||||
xSemaphoreTake(renderingMutex, portMAX_DELAY);
|
||||
exitActivity();
|
||||
setRendererOrientation();
|
||||
enterNewActivity(new XtcReaderChapterSelectionActivity(
|
||||
this->renderer, this->mappedInput, xtc, currentPage,
|
||||
[this] {
|
||||
@ -93,6 +96,7 @@ void XtcReaderActivity::loop() {
|
||||
[this](const uint32_t newPage) {
|
||||
currentPage = newPage;
|
||||
exitActivity();
|
||||
renderer.setOrientation(GfxRenderer::Orientation::Portrait);
|
||||
updateRequired = true;
|
||||
}));
|
||||
xSemaphoreGive(renderingMutex);
|
||||
|
||||
@ -9,21 +9,6 @@ namespace {
|
||||
constexpr int SKIP_PAGE_MS = 700;
|
||||
} // namespace
|
||||
|
||||
int XtcReaderChapterSelectionActivity::getPageItems() const {
|
||||
constexpr int startY = 60;
|
||||
constexpr int lineHeight = 30;
|
||||
|
||||
const int screenHeight = renderer.getScreenHeight();
|
||||
const int endY = screenHeight - lineHeight;
|
||||
|
||||
const int availableHeight = endY - startY;
|
||||
int items = availableHeight / lineHeight;
|
||||
if (items < 1) {
|
||||
items = 1;
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
int XtcReaderChapterSelectionActivity::findChapterIndexForPage(uint32_t page) const {
|
||||
if (!xtc) {
|
||||
return 0;
|
||||
@ -142,11 +127,11 @@ void XtcReaderChapterSelectionActivity::renderScreen() {
|
||||
}
|
||||
|
||||
const auto pageStartIndex = selectorIndex / pageItems * pageItems;
|
||||
renderer.fillRect(0, 60 + (selectorIndex % pageItems) * 30 - 2, pageWidth - 1, 30);
|
||||
renderer.fillRect(0, CONTENT_START_Y + (selectorIndex % pageItems) * LINE_HEIGHT - 2, pageWidth - 1, LINE_HEIGHT);
|
||||
for (int i = pageStartIndex; i < static_cast<int>(chapters.size()) && i < pageStartIndex + pageItems; i++) {
|
||||
const auto& chapter = chapters[i];
|
||||
const char* title = chapter.name.empty() ? "Unnamed" : chapter.name.c_str();
|
||||
renderer.drawText(UI_10_FONT_ID, 20, 60 + (i % pageItems) * 30, title, i != selectorIndex);
|
||||
renderer.drawText(UI_10_FONT_ID, 20, CONTENT_START_Y + (i % pageItems) * LINE_HEIGHT, title, i != selectorIndex);
|
||||
}
|
||||
|
||||
const auto labels = mappedInput.mapLabels("« Back", "Select", "Up", "Down");
|
||||
|
||||
@ -18,7 +18,6 @@ class XtcReaderChapterSelectionActivity final : public Activity {
|
||||
const std::function<void()> onGoBack;
|
||||
const std::function<void(uint32_t newPage)> onSelectPage;
|
||||
|
||||
int getPageItems() const;
|
||||
int findChapterIndexForPage(uint32_t page) const;
|
||||
|
||||
static void taskTrampoline(void* param);
|
||||
|
||||
@ -144,20 +144,20 @@ void CalibreSettingsActivity::render() {
|
||||
renderer.drawCenteredText(UI_12_FONT_ID, 15, "Calibre", true, EpdFontFamily::BOLD);
|
||||
|
||||
// Draw selection highlight
|
||||
renderer.fillRect(0, 60 + selectedIndex * 30 - 2, pageWidth - 1, 30);
|
||||
renderer.fillRect(0, CONTENT_START_Y + selectedIndex * LINE_HEIGHT - 2, pageWidth - 1, LINE_HEIGHT);
|
||||
|
||||
// Draw menu items
|
||||
for (int i = 0; i < MENU_ITEMS; i++) {
|
||||
const int settingY = 60 + i * 30;
|
||||
const int settingY = CONTENT_START_Y + i * LINE_HEIGHT;
|
||||
const bool isSelected = (i == selectedIndex);
|
||||
|
||||
renderer.drawText(UI_10_FONT_ID, 20, settingY, menuNames[i], !isSelected);
|
||||
renderer.drawText(UI_10_FONT_ID, marginLeft, settingY, menuNames[i], !isSelected);
|
||||
|
||||
// Draw status for URL setting
|
||||
if (i == 0) {
|
||||
const char* status = (strlen(SETTINGS.opdsServerUrl) > 0) ? "[Set]" : "[Not Set]";
|
||||
const auto width = renderer.getTextWidth(UI_10_FONT_ID, status);
|
||||
renderer.drawText(UI_10_FONT_ID, pageWidth - 20 - width, settingY, status, !isSelected);
|
||||
renderer.drawText(UI_10_FONT_ID, pageWidth - marginRight - width, settingY, status, !isSelected);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -87,6 +87,9 @@ void CategorySettingsActivity::toggleCurrentSetting() {
|
||||
} else if (setting.type == SettingType::ENUM && setting.valuePtr != nullptr) {
|
||||
const uint8_t currentValue = SETTINGS.*(setting.valuePtr);
|
||||
SETTINGS.*(setting.valuePtr) = (currentValue + 1) % static_cast<uint8_t>(setting.enumValues.size());
|
||||
if (strcmp(setting.name, "Orientation") == 0) {
|
||||
setRendererOrientation();
|
||||
}
|
||||
} else if (setting.type == SettingType::VALUE && setting.valuePtr != nullptr) {
|
||||
const int8_t currentValue = SETTINGS.*(setting.valuePtr);
|
||||
if (currentValue + setting.valueRange.step > setting.valueRange.max) {
|
||||
@ -151,20 +154,22 @@ void CategorySettingsActivity::render() const {
|
||||
renderer.clearScreen();
|
||||
|
||||
const auto pageWidth = renderer.getScreenWidth();
|
||||
const auto pageHeight = renderer.getScreenHeight();
|
||||
const int pageItems = getPageItems();
|
||||
|
||||
renderer.drawCenteredText(UI_12_FONT_ID, 15, categoryName, true, EpdFontFamily::BOLD);
|
||||
|
||||
// Draw selection highlight
|
||||
renderer.fillRect(0, 60 + selectedSettingIndex * 30 - 2, pageWidth - 1, 30);
|
||||
renderer.fillRect(0, CONTENT_START_Y + (selectedSettingIndex % pageItems) * LINE_HEIGHT - 2, pageWidth - 1,
|
||||
LINE_HEIGHT);
|
||||
|
||||
// Draw all settings
|
||||
for (int i = 0; i < settingsCount; i++) {
|
||||
const int settingY = 60 + i * 30; // 30 pixels between settings
|
||||
const auto pageStartIndex = selectedSettingIndex / pageItems * pageItems;
|
||||
for (int i = pageStartIndex; i < settingsCount && i < pageStartIndex + pageItems; i++) {
|
||||
const int settingY = CONTENT_START_Y + (i % pageItems) * LINE_HEIGHT;
|
||||
const bool isSelected = (i == selectedSettingIndex);
|
||||
|
||||
// Draw setting name
|
||||
renderer.drawText(UI_10_FONT_ID, 20, settingY, settingsList[i].name, !isSelected);
|
||||
renderer.drawText(UI_10_FONT_ID, marginLeft, settingY, settingsList[i].name, !isSelected);
|
||||
|
||||
// Draw value based on setting type
|
||||
std::string valueText;
|
||||
@ -179,12 +184,12 @@ void CategorySettingsActivity::render() const {
|
||||
}
|
||||
if (!valueText.empty()) {
|
||||
const auto width = renderer.getTextWidth(UI_10_FONT_ID, valueText.c_str());
|
||||
renderer.drawText(UI_10_FONT_ID, pageWidth - 20 - width, settingY, valueText.c_str(), !isSelected);
|
||||
renderer.drawText(UI_10_FONT_ID, pageWidth - marginRight - width, settingY, valueText.c_str(), !isSelected);
|
||||
}
|
||||
}
|
||||
|
||||
renderer.drawText(SMALL_FONT_ID, pageWidth - 20 - renderer.getTextWidth(SMALL_FONT_ID, CROSSPOINT_VERSION),
|
||||
pageHeight - 60, CROSSPOINT_VERSION);
|
||||
renderer.drawText(SMALL_FONT_ID, pageWidth - marginRight - renderer.getTextWidth(SMALL_FONT_ID, CROSSPOINT_VERSION),
|
||||
20, CROSSPOINT_VERSION);
|
||||
|
||||
const auto labels = mappedInput.mapLabels("« Back", "Toggle", "", "");
|
||||
renderer.drawButtonHints(UI_10_FONT_ID, labels.btn1, labels.btn2, labels.btn3, labels.btn4);
|
||||
|
||||
@ -178,14 +178,14 @@ void KOReaderSettingsActivity::render() {
|
||||
renderer.drawCenteredText(UI_12_FONT_ID, 15, "KOReader Sync", true, EpdFontFamily::BOLD);
|
||||
|
||||
// Draw selection highlight
|
||||
renderer.fillRect(0, 60 + selectedIndex * 30 - 2, pageWidth - 1, 30);
|
||||
renderer.fillRect(0, CONTENT_START_Y + selectedIndex * LINE_HEIGHT - 2, pageWidth - 1, LINE_HEIGHT);
|
||||
|
||||
// Draw menu items
|
||||
for (int i = 0; i < MENU_ITEMS; i++) {
|
||||
const int settingY = 60 + i * 30;
|
||||
const int settingY = CONTENT_START_Y + i * LINE_HEIGHT;
|
||||
const bool isSelected = (i == selectedIndex);
|
||||
|
||||
renderer.drawText(UI_10_FONT_ID, 20, settingY, menuNames[i], !isSelected);
|
||||
renderer.drawText(UI_10_FONT_ID, marginLeft, settingY, menuNames[i], !isSelected);
|
||||
|
||||
// Draw status for each item
|
||||
const char* status = "";
|
||||
@ -202,7 +202,7 @@ void KOReaderSettingsActivity::render() {
|
||||
}
|
||||
|
||||
const auto width = renderer.getTextWidth(UI_10_FONT_ID, status);
|
||||
renderer.drawText(UI_10_FONT_ID, pageWidth - 20 - width, settingY, status, !isSelected);
|
||||
renderer.drawText(UI_10_FONT_ID, pageWidth - marginRight - width, settingY, status, !isSelected);
|
||||
}
|
||||
|
||||
// Draw button hints
|
||||
|
||||
@ -11,17 +11,19 @@
|
||||
const char* SettingsActivity::categoryNames[categoryCount] = {"Display", "Reader", "Controls", "System"};
|
||||
|
||||
namespace {
|
||||
constexpr int displaySettingsCount = 5;
|
||||
constexpr int displaySettingsCount = 6;
|
||||
const SettingInfo displaySettings[displaySettingsCount] = {
|
||||
// Should match with SLEEP_SCREEN_MODE
|
||||
SettingInfo::Enum("Sleep Screen", &CrossPointSettings::sleepScreen, {"Dark", "Light", "Custom", "Cover", "None"}),
|
||||
SettingInfo::Enum("Sleep Screen Cover Mode", &CrossPointSettings::sleepScreenCoverMode, {"Fit", "Crop"}),
|
||||
SettingInfo::Enum("Orientation", &CrossPointSettings::orientation,
|
||||
{"Portrait", "Landscape CW", "Inverted", "Landscape CCW"}),
|
||||
SettingInfo::Enum("Status Bar", &CrossPointSettings::statusBar, {"None", "No Progress", "Full"}),
|
||||
SettingInfo::Enum("Hide Battery %", &CrossPointSettings::hideBatteryPercentage, {"Never", "In Reader", "Always"}),
|
||||
SettingInfo::Enum("Refresh Frequency", &CrossPointSettings::refreshFrequency,
|
||||
{"1 page", "5 pages", "10 pages", "15 pages", "30 pages"})};
|
||||
|
||||
constexpr int readerSettingsCount = 9;
|
||||
constexpr int readerSettingsCount = 8;
|
||||
const SettingInfo readerSettings[readerSettingsCount] = {
|
||||
SettingInfo::Enum("Font Family", &CrossPointSettings::fontFamily, {"Bookerly", "Noto Sans", "Open Dyslexic"}),
|
||||
SettingInfo::Enum("Font Size", &CrossPointSettings::fontSize, {"Small", "Medium", "Large", "X Large"}),
|
||||
@ -30,8 +32,6 @@ const SettingInfo readerSettings[readerSettingsCount] = {
|
||||
SettingInfo::Enum("Paragraph Alignment", &CrossPointSettings::paragraphAlignment,
|
||||
{"Justify", "Left", "Center", "Right"}),
|
||||
SettingInfo::Toggle("Hyphenation", &CrossPointSettings::hyphenationEnabled),
|
||||
SettingInfo::Enum("Reading Orientation", &CrossPointSettings::orientation,
|
||||
{"Portrait", "Landscape CW", "Inverted", "Landscape CCW"}),
|
||||
SettingInfo::Toggle("Extra Paragraph Spacing", &CrossPointSettings::extraParagraphSpacing),
|
||||
SettingInfo::Toggle("Text Anti-Aliasing", &CrossPointSettings::textAntiAliasing)};
|
||||
|
||||
@ -174,25 +174,24 @@ void SettingsActivity::render() const {
|
||||
renderer.clearScreen();
|
||||
|
||||
const auto pageWidth = renderer.getScreenWidth();
|
||||
const auto pageHeight = renderer.getScreenHeight();
|
||||
|
||||
// Draw header
|
||||
renderer.drawCenteredText(UI_12_FONT_ID, 15, "Settings", true, EpdFontFamily::BOLD);
|
||||
|
||||
// Draw selection
|
||||
renderer.fillRect(0, 60 + selectedCategoryIndex * 30 - 2, pageWidth - 1, 30);
|
||||
renderer.fillRect(0, CONTENT_START_Y + selectedCategoryIndex * LINE_HEIGHT - 2, pageWidth - 1, LINE_HEIGHT);
|
||||
|
||||
// Draw all categories
|
||||
for (int i = 0; i < categoryCount; i++) {
|
||||
const int categoryY = 60 + i * 30; // 30 pixels between categories
|
||||
const int categoryY = CONTENT_START_Y + i * LINE_HEIGHT;
|
||||
|
||||
// Draw category name
|
||||
renderer.drawText(UI_10_FONT_ID, 20, categoryY, categoryNames[i], i != selectedCategoryIndex);
|
||||
renderer.drawText(UI_10_FONT_ID, marginLeft, categoryY, categoryNames[i], i != selectedCategoryIndex);
|
||||
}
|
||||
|
||||
// Draw version text above button hints
|
||||
renderer.drawText(SMALL_FONT_ID, pageWidth - 20 - renderer.getTextWidth(SMALL_FONT_ID, CROSSPOINT_VERSION),
|
||||
pageHeight - 60, CROSSPOINT_VERSION);
|
||||
// Draw version text in corner of header
|
||||
renderer.drawText(SMALL_FONT_ID, pageWidth - marginRight - renderer.getTextWidth(SMALL_FONT_ID, CROSSPOINT_VERSION),
|
||||
20, CROSSPOINT_VERSION);
|
||||
|
||||
// Draw help text
|
||||
const auto labels = mappedInput.mapLabels("« Back", "Select", "", "");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user